Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/secret-scanner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
Expand Down Expand Up @@ -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}]"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*P2 Badge Match generic _KEY assignments

When a credential is stored under a common name such as AUTH_KEY="abcdefghijklmnop" or ENCRYPTION_KEY="abcdefghijklmnop", this expression does not match it: the alternation accepts only the literal API_KEY, despite the surrounding comment and commit contract claiming support for *_KEY. Such values also need not match any provider-specific prefix, so the shell-secrets pass can report clean; include a generic KEY alternative (with the intended naming boundaries).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gap is real: the expression matches API_KEY but not AUTH_KEY or ENCRYPTION_KEY. I traced it to the template (rsr-template-repo secret-scanner.yml, ASSIGN), and the canonical secret-scanner-reusable.yml in standards has the same restriction ([A-Z_]*API_KEY[A-Z_]*) despite its comment saying *_KEY. I'm not widening the regex only in this copy: it would diverge from the template and show up as drift on the next sync. The fix belongs at source (standards reusable first, then the template mirrors it), so I'm taking it to the owner as a separate change. This thread stays open until that is decided.


Generated by Claude Code

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}"
Expand Down
Loading