Skip to content

Commit 37acf17

Browse files
author
James Campbell
committed
Fix secret scanning workflow to exclude f-strings with variables
1 parent 7c88141 commit 37acf17

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/secret-scanning.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@ jobs:
2525
run: |
2626
echo "Checking for common secret patterns..."
2727
# Check for hardcoded API keys, passwords, tokens
28-
if grep -rE "(api[_-]?key|apikey|secret|password|token|auth|credential|private[_-]?key)\s*=\s*['\"][^'\"]{10,}" --include="*.py" python-examples/ | grep -v "configs.py" | grep -v "from configs import" | grep -v "os.getenv" | grep -v "input(" | grep -v "#.*example" | grep -v "yoursecretkey" | grep -v "your.*token"; then
28+
# Exclude: configs.py, imports, os.getenv, input(), examples, f-strings with variables
29+
if grep -rE "(api[_-]?key|apikey|secret|password|token|auth|credential|private[_-]?key)\s*=\s*['\"][^'\"]{10,}" --include="*.py" python-examples/ | \
30+
grep -v "configs.py" | \
31+
grep -v "from configs import" | \
32+
grep -v "os.getenv" | \
33+
grep -v "input(" | \
34+
grep -v "#.*example" | \
35+
grep -v "yoursecretkey" | \
36+
grep -v "your.*token" | \
37+
grep -vE "f[\"'].*\{.*(password|api|secret|token|auth|credential)" | \
38+
grep -vE "['\"].*\{.*\}.*['\"]"; then
2939
echo "::error::Found potential hardcoded secrets in code!"
3040
exit 1
3141
fi

0 commit comments

Comments
 (0)