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.
This commit is contained in:
@@ -29,9 +29,11 @@ excluded. Diagnostics contain file names and finding classes only; matched
|
||||
values and lines are never printed.
|
||||
|
||||
The production run invokes all five renderer entrypoints in private temporary
|
||||
contexts. Four output-producing renderers publish private handoffs. The access
|
||||
renderer uses its output-free Grafana verifier because it does not require
|
||||
historical metric inventories; its exact two-line success contract is checked.
|
||||
contexts. In a git checkout they run from a private copy of the tracked and
|
||||
not-ignored files, so an ignored chart cache cannot stop them. Four
|
||||
output-producing renderers publish private handoffs. The access renderer uses
|
||||
its output-free Grafana verifier because it does not require historical metric
|
||||
inventories; its exact two-line success contract is checked.
|
||||
It still traverses the pinned core renderer, whose separately published handoff
|
||||
contains the only allowlisted credential-free Secret and is decoded here.
|
||||
USAGE
|
||||
@@ -1522,7 +1524,7 @@ scan_platform_sensitive_roots() (
|
||||
scan_platform_renderer_secrets() (
|
||||
set -o pipefail
|
||||
local platform_root=$1 renderer label output_prefix publishes log file results line rc entry artifact
|
||||
local helm_bin list_file=''
|
||||
local helm_bin list_file='' render_root source_copy=''
|
||||
local failed=false
|
||||
local -a renderers=(
|
||||
'phase1|render-phase1.sh|platform-phase1-apply|yes'
|
||||
@@ -1563,6 +1565,11 @@ scan_platform_renderer_secrets() (
|
||||
rm -f -- "$list_file"
|
||||
;;
|
||||
esac
|
||||
case "$source_copy" in
|
||||
/tmp/platform-sensitive-source-render-src.??????)
|
||||
rm -rf -- "$source_copy"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
trap cleanup_renderer_scan EXIT HUP INT TERM
|
||||
|
||||
@@ -1587,9 +1594,56 @@ scan_platform_renderer_secrets() (
|
||||
return 1
|
||||
}
|
||||
|
||||
# In a git checkout, render from a private copy of the tracked and not-ignored
|
||||
# files (minus files deleted from the working tree). Ignored state such as a
|
||||
# leftover .helm chart cache would otherwise make the renderers refuse to run.
|
||||
render_root=$platform_root
|
||||
if [[ -e "$platform_root/.git" ]]; then
|
||||
for label in git tar; do
|
||||
command -v "$label" >/dev/null 2>&1 || {
|
||||
printf 'SCANNER_ERROR: renderer command unavailable: %s\n' "$label" >&2
|
||||
return 1
|
||||
}
|
||||
done
|
||||
[[ "$(git -C "$platform_root" rev-parse --show-toplevel 2>/dev/null)" == "$platform_root" ]] || {
|
||||
printf 'SCANNER_ERROR: renderer root is not the top of its git checkout\n' >&2
|
||||
return 1
|
||||
}
|
||||
source_copy="$(mktemp -d /tmp/platform-sensitive-source-render-src.XXXXXX)" || {
|
||||
printf 'SCANNER_ERROR: renderer source copy allocation failed\n' >&2
|
||||
return 1
|
||||
}
|
||||
chmod 0700 "$source_copy" || return 1
|
||||
if ! python3 -I - "$platform_root" <<'PY' |
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
root = sys.argv[1]
|
||||
|
||||
|
||||
def listed(*options):
|
||||
result = subprocess.run(
|
||||
["git", "-C", root, "ls-files", "-z", *options],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
)
|
||||
return [entry for entry in result.stdout.split(b"\0") if entry]
|
||||
|
||||
|
||||
keep = set(listed("--cached", "--others", "--exclude-standard")) - set(listed("--deleted"))
|
||||
for entry in sorted(keep):
|
||||
sys.stdout.buffer.write(entry + b"\0")
|
||||
PY
|
||||
tar -C "$platform_root" --null -T - -cf - | tar -x -C "$source_copy"; then
|
||||
printf 'SCANNER_ERROR: renderer source copy failed\n' >&2
|
||||
return 1
|
||||
fi
|
||||
render_root=$source_copy
|
||||
fi
|
||||
|
||||
for renderer in "${renderers[@]}"; do
|
||||
IFS='|' read -r label renderer output_prefix publishes <<<"$renderer"
|
||||
renderer="$platform_root/scripts/validate/$renderer"
|
||||
renderer="$render_root/scripts/validate/$renderer"
|
||||
[[ -f "$renderer" && ! -L "$renderer" ]] || {
|
||||
printf 'SCANNER_ERROR: required renderer is unsafe: %s\n' "$label" >&2
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user