diff --git a/.github/workflows/secret-scanner.yml b/.github/workflows/secret-scanner.yml index 2e9830b..f8f8cef 100644 --- a/.github/workflows/secret-scanner.yml +++ b/.github/workflows/secret-scanner.yml @@ -305,13 +305,15 @@ jobs: old_scope="$(printf '%s\n' "$hits" | grep -E '^\./src/' || [ $? -eq 1 ])" new_scope="$(printf '%s\n' "$hits" | grep -vE '^\./src/' || [ $? -eq 1 ])" + # Print file:line only. The matched source text is the credential + # itself; echoing it would publish it to the Actions log. if [ -n "$old_scope" ]; then - printf '%s\n' "$old_scope" + printf '%s\n' "$old_scope" | cut -d: -f1,2 | sed 's/$/: hardcoded-secret pattern match (line text withheld)/' echo "WARNING: Potential hardcoded secret found matching: $pattern" blocking=1 fi if [ -n "$new_scope" ]; then - printf '%s\n' "$new_scope" + printf '%s\n' "$new_scope" | cut -d: -f1,2 | sed 's/$/: hardcoded-secret pattern match (line text withheld)/' if [[ "$TODAY" < "$ENFORCE_RUST_WIDE_SCAN_FROM" ]]; then echo "::warning::Potential hardcoded secret outside ./src matching:" \ "$pattern — becomes BLOCKING on $ENFORCE_RUST_WIDE_SCAN_FROM (today is $TODAY)." @@ -350,7 +352,16 @@ jobs: run: | set -euo pipefail rc=0 - git grep -IlE '(ghp_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9_]{82}|glpat-[A-Za-z0-9_-]{20,}|AKIA[0-9A-Z]{16}|-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----)' > "$RUNNER_TEMP/hits.txt" || rc=$? + # Provider-specific patterns, plus assignment of a quoted literal to a + # *_TOKEN / *_KEY / *_SECRET / password name (as in the estate canonical + # reusable, metadatastician/standards@f0b3cd4 + # .github/workflows/secret-scanner-reusable.yml). The value classes + # exclude '$', so ="${VAR}" and ="$VAR" never match. Only file names + # are listed, never the matched text. + SQ="'" + ASSIGN="[A-Z_]*(TOKEN|API_KEY|SECRET)[A-Z_]*=[\"${SQ}][A-Za-z0-9_./+=-]{16,}[\"${SQ}]|PASS[W]ORD=[\"${SQ}][^\"${SQ}\$]{6,}[\"${SQ}]" + PROVIDER='ghp_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9_]{82}|glpat-[A-Za-z0-9_-]{20,}|AKIA[0-9A-Z]{16}|-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----' + git grep -IlE "(${PROVIDER}|${ASSIGN})" > "$RUNNER_TEMP/hits.txt" || rc=$? # git grep exits 1 when nothing matches; above 1 is an error. if [ "$rc" -gt 1 ]; then echo "::error::Secret pattern scan failed with exit ${rc}"