Repository navigation
Keep sensitive configuration and child output out of diagnostics - #1875
sameerforge wants to merge 1 commit into
Conversation
Redact URL queries, fragments and error fields before status presentation. Keep original rendered manifests separate from diagnostic copies. Suppress opaque ytt diagnostics for Secret-backed values, while retaining corrective guidance. Replace kctrl configuration dumps with identity summaries and stop teeing raw child output into debug logs. Add focused regression tests. Signed-off-by: Sameer Khan <sameer.khan@broadcom.com>
joaopapereira
left a comment
There was a problem hiding this comment.
Issues
Critical (must fix)
-
urlQuery regex misses git+ssh and bare SSH schemes —
pkg/exec/cmd_run_result.go:121— The regex([a-zA-Z][a-zA-Z0-9+.-]*://[^\s?\#]+[?\#])[^\s"'<>]+requires://so it does not matchssh://user@host/path?query=secret(matches userinfo viaurlUserinfobut not query),git+ssh://host/path?token=secret, orssh://host/path#frag=secret. TheurlUserinforegex at line 122 handlesssh://[^\s/@]+@for userinfo but there is no corresponding query/fragment pattern forssh://orgit+ssh://schemes. A URL likessh://git@example.com/repo.git?token=abcwould have userinfo redacted but?token=abcleft intact. Fix: extendurlQueryto also matchssh://andgit+ssh://schemes, or add a separate regex for them. -
Secret-backed ytt path drops Stderr entirely even on success —
pkg/template/ytt.go:94-98— Whensource.SecretRef != nilandresult.Stderr != "", the code unconditionally replaces Stderr with the guidance message, losing any legitimate warnings (e.g., deprecation notices) that are not secret-related. The PR description says "Omit opaque ytt diagnostics when Secret-backed values are supplied" but the implementation omits all stderr. Fix: only redact/replace stderr when it actually contains secret material, or preserve non-secret lines. At minimum, document the trade-off in a comment. -
DetailedCmdRunner drops command args from debug log —
cli/pkg/kctrl/local/detailed_cmd_runner.go:33,48— Changed fromfmt.Fprintf(r.log, "==> Executing %s %v\n", cmd.Path, cmd.Args)tofmt.Fprintf(r.log, "==> Executing %s\n", cmd.Path). Args can contain non-secret context (e.g.,sync -f vendir.yml) useful for debugging. The PR description says "stop teeing raw child output into debug logs" but this also removes args. Fix: log args with any sensitive values redacted, or log a redacted args summary.
Important (should fix)
-
urlQuery regex may over-redact / under-redact in complex URLs —
pkg/exec/cmd_run_result.go:121,132-134— The pattern([a-zA-Z][a-zA-Z0-9+.-]*://[^\s?\#]+[?\#])[^\s"'<>]+captures from the first?or#to the next whitespace/quote/angle-bracket. This works for simple cases but: (a) inhttps://host/path?token=abc&other=defit redactstoken=abc&other=def(correct); (b) inhttps://host/path?token=abc https://other.comit redactstoken=abc(correct); (c) inhttps://host/path?token=abc#fragit redactstoken=abc#frag(correct); (d) but it does not handle multiple query params where only some are sensitive — it redacts the entire query string. This is a reasonable safe default but worth noting. No code change required, but consider adding a test for multi-param queries. -
Vendir sync error wraps original error but loses stderr context —
cli/pkg/kctrl/local/sources/vendir_runner.go:52— Changed fromreturn fmt.Errorf("Running vendir sync: %s", stderrBs.String())toreturn fmt.Errorf("running vendir sync failed; check the source configuration and authentication: %w", err). The original stderr (which could contain non-secret error details like network errors) is dropped. The wrappederrfromcmd.Run()only contains the exit status, not stderr. Fix: include a redacted stderr in the error message, or log it separately at a non-debug level. -
Test coverage gap: fetch result redaction in pkgrepository —
pkg/pkgrepository/app_reconcile.go:148usesfetchResult.WithRedactedSecrets()but there is no test verifying fetch diagnostics (which can contain URLs with credentials from vendir/httpproxy sources) are redacted. The existing test failures in pkg/pkgrepository are pre-existing (missing vendir binary). Add a test in pkg/pkgrepository or pkg/exec covering fetch redaction.
Minor (nice to have)
-
RedactSecrets idempotence comment could be explicit about query redaction —
pkg/exec/cmd_run_result.go:127— The comment says "RedactSecrets is idempotent: calling it multiple times produces the same result." This is true but the query/fragment redaction uses${1}[REDACTED]which removes the original query/fragment entirely; a second pass has nothing to match, so it is idempotent. Consider adding a test case for double-redaction with query params. -
Inconsistent truncation: pkgrepository fetch lacks WithTruncatedStrings —
pkg/pkgrepository/app_reconcile.go:148vspkg/app/app_reconcile.go:148— The App controller truncates fetch output with.WithTruncatedStrings(a.maxOutputBytes())but PackageRepository does not. This is a pre-existing inconsistency, not introduced by the PR, but the PR touches both files. Consider aligning in a follow-up.
What this PR does / why we need it:
Sanitize URL queries/fragments and error fields before presenting command results. Keep the original rendered manifest separate from its diagnostic copy. Omit opaque ytt diagnostics when Secret-backed values are supplied and provide corrective guidance. In kctrl, display resource identities instead of complete App/PackageInstall objects, omit vendir configuration-file printing and stop teeing raw child output into debug logs.
Validation
go test ./pkg/exec ./pkg/template ./pkg/app ./pkg/pkgrepositorywith the baseline ytt/vendir tools on PATH.cd cli && go test ./pkg/....golangci-lint runpasses.golangci-lint runreports 25 existing findings, reproduced on unchangeddevelop;golangci-lint run --new-from-rev upstream/developpasses.go test ./pkg/...has two existing failures inpkg/configandpkg/fetch, also reproduced on unchangeddevelop.Does this PR introduce a user-facing change?