From 149b885e35d9d80d4b329eae8262f65212200052 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 08:02:05 +0900 Subject: [PATCH 1/3] 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". --- .../scan-platform-sensitive-source.sh | 76 +++++++++++++------ .../test-scan-platform-sensitive-source.sh | 33 ++++++++ 2 files changed, 84 insertions(+), 25 deletions(-) diff --git a/scripts/validate/scan-platform-sensitive-source.sh b/scripts/validate/scan-platform-sensitive-source.sh index ca433fd..63e65d4 100644 --- a/scripts/validate/scan-platform-sensitive-source.sh +++ b/scripts/validate/scan-platform-sensitive-source.sh @@ -2,9 +2,13 @@ set -o pipefail -readonly PLATFORM_SENSITIVE_SOURCE_EXACT_PLATFORM_ROOT=/home/donghyeon/workspace/platform -readonly PLATFORM_SENSITIVE_SOURCE_EXACT_DOCS_ROOT=/home/donghyeon/workspace/docs/platform -readonly PLATFORM_SENSITIVE_SOURCE_EXACT_SCANNER="$PLATFORM_SENSITIVE_SOURCE_EXACT_PLATFORM_ROOT/scripts/validate/scan-platform-sensitive-source.sh" +# The platform root is the checkout this scanner lives in, so a temporary copy +# or a CI runner scans itself. The central documentation root stays on the +# desktop host unless --docs-root or --platform-only says otherwise. +PLATFORM_SENSITIVE_SOURCE_SELF_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd -P)" +readonly PLATFORM_SENSITIVE_SOURCE_SELF_ROOT +readonly PLATFORM_SENSITIVE_SOURCE_SELF="$PLATFORM_SENSITIVE_SOURCE_SELF_ROOT/scripts/validate/scan-platform-sensitive-source.sh" +readonly PLATFORM_SENSITIVE_SOURCE_DEFAULT_DOCS_ROOT=/home/donghyeon/workspace/docs/platform _sensitive_source_fail() { printf 'ERROR: %s\n' "$*" >&2 @@ -14,12 +18,15 @@ _sensitive_source_fail() { _sensitive_source_usage() { cat <<'USAGE' Usage: - bash scripts/validate/scan-platform-sensitive-source.sh + bash scripts/validate/scan-platform-sensitive-source.sh [--docs-root DIR | --platform-only] -Scans the complete platform source and central platform documentation trees. -Only .git and .helm directory contents, plus the exact platform-root -.superpowers/sdd scratch subtree, are excluded. Diagnostics contain file names -and finding classes only; matched values and lines are never printed. +Scans the platform checkout that contains this script and the central platform +documentation tree (default /home/donghyeon/workspace/docs/platform, or +--docs-root DIR). --platform-only skips the documentation tree, for a +temporary copy or a CI runner that has none. Only .git and .helm directory +contents, plus the platform-root .superpowers/sdd scratch subtree, are +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 @@ -43,7 +50,7 @@ _sensitive_source_report_path() { local path=$1 platform_root=$2 docs_root=$3 relative if [[ "$path" == "$platform_root"/* ]]; then relative="platform/${path#"$platform_root"/}" - elif [[ "$path" == "$docs_root"/* ]]; then + elif [[ -n "$docs_root" && "$path" == "$docs_root"/* ]]; then relative="docs/${path#"$docs_root"/}" else relative="$(basename -- "$path")" @@ -82,13 +89,19 @@ structured_source = suffix in (".yaml", ".yml", ".json") python_source = suffix == ".py" shell_source = suffix in (".sh", ".bash", ".zsh") or not suffix prose_source = suffix in (".md", ".markdown", ".txt", ".rst") -embedded_python_source = path in ( - "/home/donghyeon/workspace/platform/scripts/validate/observability-smoke.sh", - "/home/donghyeon/workspace/platform/scripts/validate/test-scan-platform-sensitive-source.sh", - "/home/donghyeon/workspace/platform/scripts/validate/test-configure-keycloak-grafana-oidc.sh", - "/home/donghyeon/workspace/platform/scripts/bootstrap/create-observability-secrets.sh", - "/home/donghyeon/workspace/platform/scripts/bootstrap/configure-keycloak-grafana-oidc.sh", -) +# Shell files with embedded Python, relative to the checkout that holds this +# scanner (scanner_source is /scripts/validate/). +scanner_root = Path(scanner_source).parents[2] +embedded_python_source = path in { + str(scanner_root / relative) + for relative in ( + "scripts/validate/observability-smoke.sh", + "scripts/validate/test-scan-platform-sensitive-source.sh", + "scripts/validate/test-configure-keycloak-grafana-oidc.sh", + "scripts/bootstrap/create-observability-secrets.sh", + "scripts/bootstrap/configure-keycloak-grafana-oidc.sh", + ) +} try: raw = open(path, "rb").read() @@ -1382,9 +1395,13 @@ scan_platform_sensitive_roots() ( return 1 } done - [[ "$platform_root" == /* && "$docs_root" == /* && "$platform_root" != "$docs_root" ]] || + # An empty docs root means a platform-only scan. + local -a scan_roots=("$platform_root") + [[ -z "$docs_root" ]] || scan_roots+=("$docs_root") + [[ "$platform_root" == /* ]] && { [[ -z "$docs_root" ]] || + [[ "$docs_root" == /* && "$platform_root" != "$docs_root" ]]; } || _sensitive_source_fail 'scan roots must be distinct absolute paths' || return - for argument in "$platform_root" "$docs_root"; do + for argument in "${scan_roots[@]}"; do [[ -d "$argument" && ! -L "$argument" && "$(cd -- "$argument" && pwd -P)" == "$argument" ]] || _sensitive_source_fail "scan root is not a physical directory: $argument" || return done @@ -1397,7 +1414,7 @@ scan_platform_sensitive_roots() ( printf 'SCANNER_ERROR: file inventory hardening failed\n' >&2 return 1 } - if ! find "$platform_root" "$docs_root" \ + if ! find "${scan_roots[@]}" \ \( -type d -path "$platform_root/.superpowers/sdd" -prune \) -o \ \( -type d \( -name .git -o -name .helm \) -prune \) -o \ \( -type f -o -type l \) -print0 >"$list_file"; then @@ -1432,7 +1449,7 @@ scan_platform_sensitive_roots() ( fi finding="$(_sensitive_source_python_scan \ - "$file" "$test_file" "$PLATFORM_SENSITIVE_SOURCE_EXACT_SCANNER")" || { + "$file" "$test_file" "$PLATFORM_SENSITIVE_SOURCE_SELF")" || { printf 'SCANNER_ERROR: content scan failed for FILE=%s\n' "$report" >&2 return 1 } @@ -1706,14 +1723,23 @@ scan_platform_renderer_secrets() ( ) scan_platform_sensitive_source_main() { - (( $# == 0 )) || { + local docs_root=$PLATFORM_SENSITIVE_SOURCE_DEFAULT_DOCS_ROOT + if (( $# == 1 )) && [[ "$1" == --platform-only ]]; then + docs_root='' + elif (( $# == 2 )) && [[ "$1" == --docs-root && "$2" == /* ]]; then + docs_root=$2 + elif (( $# != 0 )); then _sensitive_source_usage >&2 return 2 - } + fi + if [[ -n "$docs_root" && ! -d "$docs_root" ]]; then + printf 'ERROR: documentation root %s does not exist; pass --docs-root DIR or --platform-only\n' \ + "$docs_root" >&2 + return 2 + fi scan_platform_sensitive_roots \ - "$PLATFORM_SENSITIVE_SOURCE_EXACT_PLATFORM_ROOT" \ - "$PLATFORM_SENSITIVE_SOURCE_EXACT_DOCS_ROOT" >/dev/null || return - scan_platform_renderer_secrets "$PLATFORM_SENSITIVE_SOURCE_EXACT_PLATFORM_ROOT" || return + "$PLATFORM_SENSITIVE_SOURCE_SELF_ROOT" "$docs_root" >/dev/null || return + scan_platform_renderer_secrets "$PLATFORM_SENSITIVE_SOURCE_SELF_ROOT" || return printf 'PLATFORM SENSITIVE SOURCE SCAN PASS\n' } diff --git a/scripts/validate/test-scan-platform-sensitive-source.sh b/scripts/validate/test-scan-platform-sensitive-source.sh index 6a61395..0f5ad6c 100644 --- a/scripts/validate/test-scan-platform-sensitive-source.sh +++ b/scripts/validate/test-scan-platform-sensitive-source.sh @@ -1468,6 +1468,39 @@ output="$(run_scanner 2>&1)" || scanner_error_rc=$? fail 'scanner error did not fail closed' } pass 'rg errors fail closed' +PLATFORM_SENSITIVE_SOURCE_TEST_PATH='' + +[[ "$PLATFORM_SENSITIVE_SOURCE_SELF_ROOT" == "$ROOT" ]] || \ + fail 'the scanner does not scan the checkout it lives in' +pass 'the scanner scans the checkout it lives in, not a fixed path' +main_rc=0 +main_output="$(scan_platform_sensitive_source_main --unknown 2>&1)" || main_rc=$? +(( main_rc == 2 )) || fail 'an unknown entrypoint argument was accepted' +main_rc=0 +main_output="$(scan_platform_sensitive_source_main --docs-root relative/docs 2>&1)" || main_rc=$? +(( main_rc == 2 )) || fail 'a relative docs root was accepted' +new_fixture +main_rc=0 +main_output="$(scan_platform_sensitive_source_main --docs-root "$WORK/missing-docs" 2>&1)" || main_rc=$? +(( main_rc == 2 )) || fail 'a missing docs root was accepted' +[[ "$main_output" == *'--platform-only'* ]] || \ + fail 'a missing docs root did not name --platform-only' +pass 'the entrypoint rejects unknown, relative and missing docs roots before scanning' +printf 'ordinary input\n' >"$WORK/platform/bootstrap/ordinary.md" +platform_only_output="$(scan_platform_sensitive_roots "$WORK/platform" '' 2>&1)" || { + printf '%s\n' "$platform_only_output" >&2 + fail 'a platform-only root scan failed' +} +[[ "$platform_only_output" == *'PLATFORM SENSITIVE SOURCE SCAN PASS'* ]] || \ + fail 'a platform-only root scan did not emit the PASS marker' +printf 'Slack: https://hooks.%s/services/T1/B2/C3\n' 'slack.com' \ + >"$WORK/platform/bootstrap/live.env" +platform_only_rc=0 +platform_only_output="$(scan_platform_sensitive_roots "$WORK/platform" '' 2>&1)" || platform_only_rc=$? +(( platform_only_rc != 0 )) || fail 'a platform-only root scan accepted a Slack webhook' +[[ "$platform_only_output" == *'platform/bootstrap/live.env'* ]] || \ + fail 'a platform-only root scan did not report the filename' +pass 'a platform-only root scan still scans the platform root' cleanup_before="$( find /tmp -maxdepth 1 -type d -name 'platform-sensitive-source-test.??????' \ -- 2.54.0 From 27eb8c1799e4bd3d130ada89a0fab3166d43ffda Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 08:36:38 +0900 Subject: [PATCH 2/3] 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. --- .../scan-platform-sensitive-source.sh | 64 +++++++++++++++++-- .../test-scan-platform-sensitive-source.sh | 45 +++++++++++++ 2 files changed, 104 insertions(+), 5 deletions(-) diff --git a/scripts/validate/scan-platform-sensitive-source.sh b/scripts/validate/scan-platform-sensitive-source.sh index 63e65d4..1f84765 100644 --- a/scripts/validate/scan-platform-sensitive-source.sh +++ b/scripts/validate/scan-platform-sensitive-source.sh @@ -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 diff --git a/scripts/validate/test-scan-platform-sensitive-source.sh b/scripts/validate/test-scan-platform-sensitive-source.sh index 0f5ad6c..3b382ef 100644 --- a/scripts/validate/test-scan-platform-sensitive-source.sh +++ b/scripts/validate/test-scan-platform-sensitive-source.sh @@ -967,6 +967,16 @@ label="$(basename -- "$0")" handoff=no [[ -z "$out" ]] || handoff=yes printf '%s\n' "$label${component:+:$component}:handoff=$handoff" >>"$PLATFORM_SENSITIVE_SOURCE_RENDER_LOG" +root="$(cd -- "$(dirname -- "$0")/../.." && pwd -P)" +if [[ "${PLATFORM_SENSITIVE_SOURCE_FAKE_REJECT_CACHE:-0}" != 0 ]] && \ + [[ -n "$(find "$root" -name .helm -type d -print -quit)" ]]; then + printf 'REJECT: exact chart cache already exists\n' >&2 + exit 23 +fi +if [[ -n "${PLATFORM_SENSITIVE_SOURCE_FAKE_REQUIRE_INPUT:-}" && \ + ! -f "$root/$PLATFORM_SENSITIVE_SOURCE_FAKE_REQUIRE_INPUT" ]]; then + exit 42 +fi emit_phase1_log() { local publish=$1 name @@ -1438,6 +1448,41 @@ for injected_renderer in \ fail "$injected_renderer unexpected stdout leaked content" pass "$injected_renderer stdout is restricted to its bounded grammar" done + +# A git checkout renders from a private copy of its tracked and not-ignored files, +# so an ignored chart cache left in the checkout cannot stop the renderers (the +# real renderers refuse a pre-existing exact cache with RC=23). +command -v git >/dev/null 2>&1 || fail 'git is required for the clean render copy test' +printf '.helm/\n' >"$WORK/platform/.gitignore" +git -C "$WORK/platform" init -q +git -C "$WORK/platform" add -A +git -C "$WORK/platform" -c user.name=fixture -c user.email=fixture@example.invalid \ + commit -q -m fixture +mkdir -p "$WORK/platform/services/observability/.helm/charts/stale-1.0.0" +printf 'untracked\n' >"$WORK/platform/services/observability/untracked-input.yaml" +: >"$WORK/renderer.log" +renderer_rc=0 +renderer_output="$(PLATFORM_SENSITIVE_SOURCE_FAKE_REJECT_CACHE=1 \ + PLATFORM_SENSITIVE_SOURCE_FAKE_REQUIRE_INPUT=services/observability/untracked-input.yaml \ + scan_platform_renderer_secrets "$WORK/platform" 2>&1)" || renderer_rc=$? +(( renderer_rc == 0 )) || { + printf '%s\n' "$renderer_output" >&2 + fail 'an ignored chart cache in a git checkout blocked the renderers' +} +[[ -d "$WORK/platform/services/observability/.helm/charts/stale-1.0.0" ]] || \ + fail 'the renderer scan changed the ignored cache in the scanned checkout' +pass 'a git checkout renders from a clean copy, so an ignored chart cache cannot block it' +pass 'the clean render copy keeps untracked files that git does not ignore' +rm -f -- "$WORK/platform/services/observability/untracked-input.yaml" +rm -f -- "$WORK/platform/scripts/validate/render-phase2.sh" +renderer_rc=0 +renderer_output="$(scan_platform_renderer_secrets "$WORK/platform" 2>&1)" || renderer_rc=$? +(( renderer_rc != 0 )) || fail 'a renderer deleted from the working tree was still run' +[[ "$renderer_output" == *'required renderer is unsafe: phase2'* ]] || { + printf '%s\n' "$renderer_output" >&2 + fail 'a renderer deleted from the working tree did not fail at the renderer check' +} +pass 'the clean render copy leaves out files deleted from the working tree' unset PLATFORM_SENSITIVE_SOURCE_RENDER_LOG new_fixture -- 2.54.0 From ae4e256c9553abace9f44ce1ffb458abf7f7e9e0 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 08:36:38 +0900 Subject: [PATCH 3/3] 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. --- .../scan-platform-sensitive-source.sh | 15 ++++++++ .../test-scan-platform-sensitive-source.sh | 38 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/scripts/validate/scan-platform-sensitive-source.sh b/scripts/validate/scan-platform-sensitive-source.sh index 1f84765..18fe2c8 100644 --- a/scripts/validate/scan-platform-sensitive-source.sh +++ b/scripts/validate/scan-platform-sensitive-source.sh @@ -732,6 +732,19 @@ def permitted_reference_container(key, value): ) +def permitted_s3_credentials_reference(path, key, value): + # CloudNativePG barmanObjectStore.s3Credentials: each entry is a + # SecretKeySelector (name and key only), never the value itself. + return ( + len(path) >= 1 + and path[-1] == "s3Credentials" + and key in ("accessKeyId", "secretAccessKey") + and isinstance(value, dict) + and set(value) == {"name", "key"} + and all(isinstance(value[field], str) and value[field] for field in value) + ) + + def permitted_webhook_feature(path, key, value): return ( tuple(str(part) for part in path) == ("operators", "object-store") @@ -767,6 +780,8 @@ def walk(value, path=()): pass elif permitted_reference_container(key, child): pass + elif permitted_s3_credentials_reference(path, key, child): + pass elif not isinstance(child, str) or unsafe_scalar(child): return True if walk(child, path + (key,)): diff --git a/scripts/validate/test-scan-platform-sensitive-source.sh b/scripts/validate/test-scan-platform-sensitive-source.sh index 3b382ef..d9bf67c 100644 --- a/scripts/validate/test-scan-platform-sensitive-source.sh +++ b/scripts/validate/test-scan-platform-sensitive-source.sh @@ -378,6 +378,44 @@ envValueFrom: YAML expect_reject 'a secretKeyRef container with a literal child fails closed' \ 'platform/bootstrap/reference-container.yaml' +rm -f -- "$WORK/platform/bootstrap/reference-container.yaml" + +cat >"$WORK/platform/bootstrap/s3-credentials.yaml" <<'YAML' +spec: + backup: + barmanObjectStore: + s3Credentials: + accessKeyId: + name: platform-postgres-backup-s3 + key: ACCESS_KEY_ID + secretAccessKey: + name: platform-postgres-backup-s3 + key: ACCESS_SECRET_KEY +YAML +expect_clean 'a CloudNativePG s3Credentials Secret reference remains a reference' +cat >"$WORK/platform/bootstrap/s3-credentials.yaml" <<'YAML' +spec: + s3Credentials: + secretAccessKey: + name: platform-postgres-backup-s3 + key: ACCESS_SECRET_KEY + value: should-never-be-printed-s3-reference +YAML +expect_reject 'an s3Credentials reference with an extra literal child fails closed' \ + 'platform/bootstrap/s3-credentials.yaml' +cat >"$WORK/platform/bootstrap/s3-credentials.yaml" <<'YAML' +spec: + storage: + secretAccessKey: + name: platform-postgres-backup-s3 + key: ACCESS_SECRET_KEY +YAML +expect_reject 'a name and key container outside s3Credentials still fails closed' \ + 'platform/bootstrap/s3-credentials.yaml' +printf 'spec:\n s3Credentials:\n secretAccess%sKey: Actual%s\n' '' 'ProductionSecretValue9283' \ + >"$WORK/platform/bootstrap/s3-credentials.yaml" +expect_reject 'a literal s3Credentials secret access key is rejected' \ + 'platform/bootstrap/s3-credentials.yaml' new_fixture cat >"$WORK/platform/bootstrap/webhook-feature.yaml" <<'YAML' -- 2.54.0