fix(validate): run the sensitive-source scan from any checkout #11

Merged
donghyeon.kang merged 3 commits from donghyeon.kang/w6-scanner-fix AGit into main 2026-11-11 23:46:20 +00:00
3 Commits
Author SHA1 Message Date
DongHyeonka ae4e256c95 fix(validate): accept CloudNativePG s3Credentials Secret references
PR #10 added the platform-postgres backup patch and its restore-drill
Cluster. Both hold barmanObjectStore.s3Credentials, where accessKeyId
and secretAccessKey are SecretKeySelectors (name and key). The
structured scan treats any non-string value under a key ending in
"access key" as a credential literal, so the source scan reported
CREDENTIAL_LITERAL for both files on main.

An entry directly under s3Credentials, named accessKeyId or
secretAccessKey, whose value is a mapping of exactly name and key
with non-empty strings, is now a reference. This mirrors the existing
exact rule for the Grafana client-secret secretKeyRef.

Rejected: a general "name and key is always a reference" rule. It
would also pass a literal hidden under some other credential key that
happens to have those two fields.

Risk: none beyond the two key names under that one parent. A literal
string, an extra child, or the same mapping under another parent is
still rejected (new test cases).

Verification: on desktop, the source scan of main 205927f reported the
two files before this change and passes after it. The unit test
passes in a non-canonical clone.
2026-11-12 08:36:38 +09:00
DongHyeonka 27eb8c1799 fix(validate): render the sensitive-source scan from a clean copy
The scanner ran the five renderers inside the scanned checkout. The
desktop checkout holds eight .helm chart caches left on 2026-08-11
(ignored by git), and render-observability-core.sh refuses an existing
exact chart cache. The scan stopped with "renderer failed:
observability-core RC=23" before it checked any rendered Secret, on
main and on every branch.

In a git checkout the renderers now run from a private 0700 copy in
/tmp of the tracked and not-ignored files, minus files deleted from
the working tree (git ls-files, then tar). The copy is removed with
the other renderer temp paths. A tree that is not a git checkout, such
as the test fixtures, still renders in place.

Rejected: deleting the stale caches only. That fixes one host until a
cache is left again, and the scanner is not the place to delete files
in the tree it scans. The renderer's refusal of an existing cache
stays; it guards the chart digest checks.

Risk: an ignored file is not in the copy. No renderer reads one today
(no renderer references .env, local-recovery.env, .superpowers or
secrets/). If one ever does, its render fails closed rather than
scanning less.

Verification: on desktop, real renderers against a clone of main
205927f with the eight stale caches copied in. Before: phase1, phase2
and admin pass, then "renderer failed: observability-core RC=23".
With this branch: all five renderers pass, "PLATFORM RENDERED SECRET
SCAN PASS", the eight caches in the scanned clone are untouched and no
render copy is left in /tmp. The new test cases fail before this
change and pass after it.
2026-11-12 08:36:38 +09:00
DongHyeonka 149b885e35 fix(validate): scan the checkout that holds the sensitive-source scanner
scan-platform-sensitive-source.sh always scanned the fixed path
/home/donghyeon/workspace/platform, and its list of shell files with
embedded Python held the same fixed paths. Run from a temporary copy
or a CI runner, it scanned the desktop checkout instead of itself, or
nothing at all. Its own test failed at the first assertion in any
other checkout: the test file lost its embedded-Python context there
and was reported as a credential literal.

The platform root is now the checkout that contains the scanner
(dirname of BASH_SOURCE, physical path), and the embedded-Python list
is resolved under that root. The central documentation root stays the
desktop default. --docs-root DIR replaces it and --platform-only skips
it, for a copy or runner that has no central docs. A missing docs root
stops with exit 2 and names both options instead of scanning less.

Rejected: a --platform-root option. Scanning a tree with a scanner
from another tree would let a scanned tree differ from the rules that
scan it.

Risk: on the desktop host the default run is unchanged. A caller that
passed arguments before got usage and exit 2. It now gets the new
options.

Verification: on desktop, a non-canonical clone of main 205927f with
this change: test-scan-platform-sensitive-source.sh passes. Before the
change the same test in a worktree copy failed with "canonical scanner
test content leaf found a credential literal".
2026-11-12 08:02:05 +09:00