Thanks for considering a contribution to PAT Scanner. Two areas have the highest leverage:
- New patterns — append a regex + clearly-fake test fixture
- POSIX ERE portability — test on macOS/BSD grep (Linux GNU grep is current target)
POSIX ERE only (grep -E). Three silent-failure traps to avoid:
- No
(?:...)non-capturing groups — use(...)capturing groups instead - No
\s/\d/\w— use[[:space:]]/[0-9]/[A-Za-z0-9_] - No
[[:space:]]inside bracket expressions — the inner]closes the bracket early. Use separate alternation:([\'";]|[[:space:]]|...)not[`'"[[:space:]];]`
Append to patterns/secret-patterns.local:
myorg_[a-z]{8}_[a-f0-9]{32} # MyOrg internal API key
Format: <regex> + spaces + # <name>. The name shows in stderr when blocked.
echo "myorg_abcdefgh_0123456789abcdef0123456789abcdef" | grep -E "myorg_[a-z]{8}_[a-f0-9]{32}"
# exit 0 = match, exit 1 = no match, exit 2 = regex syntax errorIn tests/test-scan-secrets.sh, construct a clearly-fake fixture and add a check_blocks call:
# At the top with the other fixtures
MYORG_FAKE="myorg_$(repeat 'ab' 4)_$(repeat '0' 32)"
# In the block cases section
check_blocks "MyOrg API key" \
"{\"prompt\":\"$MYORG_FAKE\"}" \
"MyOrg"Critical: Use the repeat helper to construct fixtures. Do NOT paste real-shaped tokens directly into the file — GitHub's secret scanning will reject the push. Construct from clearly-fake parts: FAKE, 0, X, DEADBEEF.
bash tests/test-scan-secrets.shMust show Pass: N Fail: 0.
git checkout -b add-myorg-pattern
git add patterns/secret-patterns.local tests/test-scan-secrets.sh
git commit -m "add MyOrg API key pattern"
git push -u origin add-myorg-pattern
gh pr creategit clone https://github.com/JordanNewell/pat-scanner.git
cd pat-scanner
bash tests/test-scan-secrets.sh # must pass on cloneDependencies: bash, jq, grep -E (POSIX ERE). All standard on Linux + macOS. Windows users typically have these via Git Bash.
Fixtures must be constructed programmatically from clearly-fake parts. Static strings in the test file must NOT match real provider patterns. This is what allows the repo to push through GitHub's secret scanning without .gitleaksignore brittleness.
Wrong:
check_blocks "Anthropic key" \
'{"prompt":"sk-ant-api03-aaaa...AA"}' \
"Anthropic"Right:
ANTHROPIC_MIDDLE="$(repeat 'FAKE' 23)X" # 93 chars
ANTHROPIC_FAKE="sk-ant-api03-${ANTHROPIC_MIDDLE}AA"
check_blocks "Anthropic key" \
"{\"prompt\":\"$ANTHROPIC_FAKE\"}" \
"Anthropic"The fixture still exercises the full pattern at test time. The static file shows only repeat 'FAKE' 23 — no real-shaped tokens visible to scanners.
- Linux GNU grep — primary target, all tests pass
- macOS BSD grep — untested. PRs welcome if any patterns need adjustment
- Windows Git Bash — works (production environment for the original ship)
- Bash scripts:
set -u, noset -e(scanner needs graceful fallback),#!/usr/bin/env bash - Comments only for non-obvious logic (why, not what)
- No emojis in code or commit messages
- Subject ≤72 chars, imperative mood
- Body wraps at 80, explains "why" when non-obvious
- No
Co-Authored-By: Claudeor AI-attribution trailers (per maintainer convention) - Conventional commits not required but appreciated:
feat:,fix:,docs:,test:
By contributing, you agree your contributions are licensed MIT alongside the rest of the project.