fix(core): harden config, path, and output trust boundaries#976
Conversation
Memory BenchmarksThresholds: bytes/op <= +15.0%, allocs/op <= +10.0%
Result: memory benchmark gate passed. Approval: not required. |
There was a problem hiding this comment.
Pull request overview
Security-hardening sweep that tightens multiple trust boundaries across config/policy-pack loading, runtime hook discovery, git path parsing, notification redaction/escaping, CLI table output sanitization, and cache path safety.
Changes:
- Disable remote policy packs (no fetching) and adjust policy-pack trust handling/error messaging + tests.
- Anchor runtime hook lookup to fixed, non-ancestor-walk roots and add targeted tests.
- Normalize/sanitize repo-controlled strings at output boundaries (git quoted paths decoding, Slack fallback escaping, webhook redaction expansion, table-output terminal control scrubbing, cache symlink escape rejection).
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/workspace/workspace_changed_files_test.go | Adds regression coverage for decoding git-quoted non-ASCII paths from diff/status. |
| internal/workspace/changed_files.go | Decodes git C-quoted paths (defense-in-depth) in diff/status parsing. |
| internal/thresholds/config.go | Updates policy resolver trust initialization signature for hardened pack resolution. |
| internal/thresholds/config_test.go | Updates/reshapes tests to assert remote policy packs are rejected without fetching. |
| internal/thresholds/config_packs.go | Removes “explicit config implies remote trust” and hard-disables remote packs; adjusts local-root trust. |
| internal/thresholds/config_cov_more_http_test.go | Updates coverage test setup after packTrust changes. |
| internal/runtime/capture_env.go | Reworks runtime hook search roots to anchored locations; adds injectable providers for tests. |
| internal/runtime/capture_env_test.go | Adds anchored-root test and utilities for overriding executable/caller providers. |
| internal/report/terminal.go | Introduces terminal control-character sanitizer for report/table output. |
| internal/report/format_test.go | Adds regression test ensuring table output escapes control characters. |
| internal/report/format_table.go | Sanitizes string args emitted through table formatter helpers; sanitizes key row fields. |
| internal/report/format_table_values.go | Sanitizes table value renderers that may include repo-controlled strings. |
| internal/report/format_table_sections.go | Sanitizes additional table sections (scope, policy sources, comparison keys, codemod, warnings). |
| internal/notify/slack.go | Escapes Slack top-level fallback text to prevent mrkdwn injection from repo names. |
| internal/notify/slack_test.go | Adds tests covering fallback escaping for common mrkdwn/HTML-sensitive characters. |
| internal/notify/dispatcher.go | Expands webhook URL redaction candidates to cover more real-world error-message variants. |
| internal/notify/dispatcher_test.go | Adds tests for redacting path-escaped fragments, bare host+path, and bare token leakage. |
| internal/gitexec/gitexec.go | Forces core.quotePath=false to reduce quoted-path surface area in git outputs. |
| internal/analysis/cache.go | Treats symlinked cache roots as escape attempts (including broken symlinks) via Lstat precheck. |
| internal/analysis/cache_extra_test.go | Adds regression test ensuring broken symlink cache paths are rejected and don’t create dirs outside repo. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Lopper (Delta)
No dependency-surface deltas detected. |
SonarQube (PR)Open issues: 0 Duplication
IssuesOpen Sonar issues (0)
Source: SonarCloud PR view |
|



Summary
Security hardening bundle for #839, #865, #866, #867, #868, #869, and #870.
Changes
--confighandling and reject remote policy packs without fetchingValidation
Commands run locally by the worker:
Follow-up validation will rerun after the lint fix is pushed.
Risk and compatibility
Closes #839
Closes #865
Closes #866
Closes #867
Closes #868
Closes #869
Closes #870
Checklist
memory-approvedrequested/applied if intentional memory benchmark regressions exceed CI thresholds