Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Secrets Scanner hook intended to detect hardcoded secrets in files modified during a Copilot coding agent session, with optional blocking behavior and structured logging.
Changes:
- Introduces a bash-based secrets scanning hook (
scan-secrets.sh) with pattern matching, allowlisting, and JSONL logging. - Adds hook documentation and configuration (
README.md,hooks.json) for installation and usage. - Registers the new hook in the hooks catalog (
docs/README.hooks.md).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| hooks/secrets-scanner/scan-secrets.sh | Implements the secrets scanning logic, file selection by scope, and JSONL logging of findings. |
| hooks/secrets-scanner/README.md | Documents purpose, installation, configuration, patterns, and example output. |
| hooks/secrets-scanner/hooks.json | Provides default sessionEnd hook configuration for the secrets scanner. |
| docs/README.hooks.md | Adds the Secrets Scanner entry to the repository’s hooks index. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Adds a new Secrets Scanner hook to the repository’s hooks collection, intended to scan modified (or staged) files at Copilot session end for common secret/token patterns and optionally block the session on findings.
Changes:
- Introduces a new
secrets-scannerhook (script + hooks.json) that scans changed files for secret-like regex matches and logs JSONL output. - Adds hook documentation (README with configuration, usage, and examples).
- Registers the new hook in
docs/README.hooks.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| hooks/secrets-scanner/scan-secrets.sh | Implements the secrets scanning logic, allowlist handling, and JSONL logging. |
| hooks/secrets-scanner/README.md | Documents installation, configuration, detected patterns, and log format. |
| hooks/secrets-scanner/hooks.json | Hook configuration to run the scanner on sessionEnd. |
| docs/README.hooks.md | Adds the Secrets Scanner entry to the hooks index table. |
You can also share your feedback on Copilot code review. Take the survey.
f7322b2 to
63f18ae
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new Secrets Scanner hook to help prevent accidental credential/secrets leaks during GitHub Copilot coding agent sessions by scanning modified files at sessionEnd.
Changes:
- Introduces a bash-based secrets scanning hook with configurable scan mode/scope and JSONL logging.
- Adds hook documentation and an example
hooks.jsonconfiguration. - Registers the new hook in the hooks index documentation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| hooks/secrets-scanner/scan-secrets.sh | Implements the secrets scanning logic, filtering, and structured logging. |
| hooks/secrets-scanner/README.md | Documents installation, configuration, detected patterns, and output/log formats. |
| hooks/secrets-scanner/hooks.json | Provides the hook configuration for running at sessionEnd. |
| docs/README.hooks.md | Adds Secrets Scanner to the hooks catalog table. |
You can also share your feedback on Copilot code review. Take the survey.
63f18ae to
a5d5215
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new Secrets Scanner Copilot hook that scans modified/staged files at sessionEnd for common credential/secret patterns and optionally blocks the session when findings are detected, plus documentation and index listing updates.
Changes:
- Introduces
scan-secrets.shhook script with pattern-based detection, allowlisting, redacted output, and JSONL logging. - Adds hook documentation (
README.md) and sample hook configuration (hooks.json). - Registers the new hook in
docs/README.hooks.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| hooks/secrets-scanner/scan-secrets.sh | Implements the secrets scanning logic, logging, and block/warn behavior. |
| hooks/secrets-scanner/README.md | Documents installation, configuration, patterns, and log format for the hook. |
| hooks/secrets-scanner/hooks.json | Provides hook configuration to run the scanner at sessionEnd. |
| docs/README.hooks.md | Adds the Secrets Scanner entry to the hooks index. |
You can also share your feedback on Copilot code review. Take the survey.
a5d5215 to
20f7435
Compare
Add a secrets-scanner hook that scans files modified during a Copilot coding agent session for leaked secrets, credentials, and sensitive data. The hook runs on sessionEnd and inspects files in one of three scopes: - diff: only files changed in the current session (default) - staged: only files currently staged in the git index - all: every tracked file in the repository Detected pattern categories: - AWS access keys and secret keys - GCP service account credentials - Azure client secrets and storage connection strings - GitHub personal access tokens - Slack tokens (bot, user, webhook) - Private key headers (RSA, EC, DSA, OpenSSH, PEM) - Generic high-entropy bearer tokens - Internal IP:port strings Configurable via environment variables (SCAN_MODE, SCAN_SCOPE, SECRETS_ALLOWLIST) so teams can tune for their workflow without editing the script. Patterns are POSIX ERE (grep -E) compatible, with no PCRE metacharacters, for portability across macOS and Linux. Files: hooks.json, scan-secrets.sh, README.md
20f7435 to
7318b1c
Compare
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.Description
Adds a new secrets-scanner hook that scans files modified during a Copilot coding agent session for accidentally leaked credentials, API keys, and sensitive data. The hook runs at
sessionEndand can operate inwarnmode (log and continue) orblockmode (exit non-zero to prevent auto-commit).AI coding agents generate and modify code rapidly, which increases the risk of hardcoded secrets slipping into a codebase. This hook acts as a last-resort safety net at the end of each session.
What it does
The scanner checks all modified text files against 20+ regex patterns for known secret formats before the session closes:
AKIA...), GCP service account JSON, Azure client secretsghp_,gho_,ghs_,ghr_,github_pat_), npm tokens, Stripe live keys, Slack tokens, SendGrid API keys, Discord tokens, Twilio API keysapi_key =,password =,client_secret =, etc.eyJ...), bearer tokens10.x,172.16-31.x,192.168.x)Key capabilities
SCAN_MODE=warn(log findings, exit 0) orSCAN_MODE=block(exit non-zero, stops auto-commit)SCAN_SCOPE=diff(uncommitted changes vs HEAD) orSCAN_SCOPE=staged(git-staged files only)package-lock.json,yarn.lock,go.sum, etc.), and placeholder values (your_password_here,changeme,example)SECRETS_ALLOWLIST=pattern1,pattern2suppresses known false positivesfirst4...last4of each match to JSONL; secrets are never fully re-exposed in logsbash,git,grep, andfile; no external tools neededFiles
hooks/secrets-scanner/README.md: Full documentation with installation guide, configuration reference, pattern table, example output, and log formathooks/secrets-scanner/hooks.json: Hook configuration (sessionEnd, defaults toSCAN_MODE=warn,SCAN_SCOPE=diff, 30s timeout)hooks/secrets-scanner/scan-secrets.sh: Scanner script (~270 lines of bash)docs/README.hooks.md: Updated automatically bynpm run build(hook count: 3 to 4)Validation
npm run buildpasses;docs/README.hooks.mdupdated with the new hook entrynpm run skill:validatepasses (all 222 skills valid)your_password_here,changeme)SCAN_MODE=warn: lists findings, exits 0SCAN_MODE=block: lists findings, exits 1 with "Session blocked" messageType of Contribution
hooks/secrets-scanner)Additional Notes
This hook pairs well with the existing Session Auto-Commit hook. When both are installed, the secrets scanner runs first at
sessionEndand blocks the auto-commit if secrets are detected (whenSCAN_MODE=block).All patterns use POSIX ERE (
grep -E) syntax with no PCRE metacharacters, ensuring portability across macOS and Linux.By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.