github-security-scanner-hook
Skill1 starsChanged 4 days agoMITView on GitHub
Use when the user asks to "scan for security vulnerabilities", "check for secrets in code", "set up a pre-commit security hook", "install security scanning", "scan staged files for secrets", "check for hardcoded credentials", "run a security scan before commit", "detect leaked API keys", "add a git commit hook for security", "security check before push", "scan for SQL injection", "check for XSS vulnerabilities", "detect injection flaws", "check for command injection", "audit subprocess security", or wants to prevent committing security issues to git.
- Installs packages
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-orchestratorSkill
- algorithmic-complexity-analyzerSkill
- api-securitySkill
- architectural-planningSkill
- caching-queues-reviewerSkill
- code-reviewerSkill
- csharp-developerSkill
- design-pattern-detectorSkill
- detect-overengineeringSkill
- java-developerSkill
- legacy-code-modernizationSkill
- llm-as-judgeSkill
- load-memorySkill
- nodejs-executorSkill
- playwright-bdd-testerSkill
- powershell-writerSkill
- python-api-writerSkill
- python-developerSkill
- python-linterSkill
- react-developerSkill
- remote-pod-log-analyzerSkill
- save-memorySkill
- scan-halucinated-testsSkill
- scan-repo-readmeSkill
- skill-creatorSkill
- sql-connectorSkill
- sql-executorSkill
- sync-github-forksSkill
- trace-code-contextSkill
- troubleshoot-and-fixSkill
- typescript-developerSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Write access to .git/hooks/ (for hook installation only)
- Very specific: line 25
Always use .venv — create it if it does not exist, then install detect-secrets and semgrep:
- Very specific: line 47
Run scan-staged.py to check all currently staged files:
- Distinctive: line 75
If the scan is clean (exit code 0), confirm clearly: "No security issues found in staged files."
- Distinctive: line 79
Ask the user: "Would you like to install this as a git pre-commit hook so every future commit is scanned automatically?"
- Distinctive: line 93
After installation, remind the user:
- Very specific: line 104
For private keys: Remove the key, revoke it immediately (assume it is compromised), generate a new one, and add the key file pattern to …
- Very specific: line 106
For false positives: Add to the .secrets.baseline allowlist using python -m detect_secrets audit .secrets.baseline
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitHub Security Scanner Hook
Scan staged files for secrets and code-level security vulnerabilities before every git commit.
Works with any language or file type — detect-secrets finds hardcoded credentials and API keys; semgrep finds injection flaws, command injection, shell execution risks, XSS, path traversal, destructive filesystem operations, and OWASP Top 10 patterns across Python, JavaScript/TypeScript, Go, Ruby, Java, C#, and more.
Can run as a one-off manual scan or install as an automated git pre-commit hook.
Prerequisites
- Python 3.8+ available on PATH (to create the
.venv) - Git repository (any language — Python, JS/TS, Go, Ruby, Java, C#, etc.)
- Staged files to scan, or
--full-repoto scan everything - Internet access on first run only (to pip-install
detect-secretsandsemgrep) - Write access to
.git/hooks/(for hook installation only)
Workflow
Step 1 — Set Up .venv and Install Tools
Always use .venv — create it if it does not exist, then install detect-secrets and semgrep:
Windows (PowerShell):
if (-not (Test-Path .venv)) { python -m venv .venv }
$PYTHON = if (Test-Path .venv\Scripts\python.exe) { ".venv\Scripts\python.exe" } else { "python" }
& $PYTHON -m pip show detect-secrets *> $null; if ($LASTEXITCODE -ne 0) { & $PYTHON -m pip install detect-secrets }
& $PYTHON -m pip show semgrep *> $null; if ($LASTEXITCODE -ne 0) { & $PYTHON -m pip install semgrep }Unix / macOS (Bash):
[ -d .venv ] || python -m venv .venv
PYTHON=$(if [ -f .venv/Scripts/python ]; then echo .venv/Scripts/python; else echo .venv/bin/python; fi)
$PYTHON -m pip show detect-secrets > /dev/null 2>&1 || $PYTHON -m pip install detect-secrets
$PYTHON -m pip show semgrep > /dev/null 2>&1 || $PYTHON -m pip install semgrepBoth tools are optional independently — if semgrep is not installed the scan still runs with detect-secrets only. Semgrep uses the bundled rules in rules/security.yml (no login or network access required).
Step 2 — Run Security Scan on Staged Files
Run scan-staged.py to check all currently staged files:
$PYTHON .github/skills/github-security-scanner-hook/scripts/scan-staged.pyTo scan the entire repository instead of only staged files:
$PYTHON .github/skills/github-security-scanner-hook/scripts/scan-staged.py --full-repoThe script prints a JSON summary to stdout and exits with:
- Exit code 0 — no findings (clean)
- Exit code 1 — one or more HIGH severity findings (would block the commit)
- Exit code 2 — only MEDIUM or LOW severity findings (warnings, no block)
Step 3 — Review and Present Findings
Parse the JSON output and present findings grouped by severity:
- HIGH — Must be fixed before committing. Identify the flagged file and line, explain what was found (e.g., "AWS secret key on line 14 of
config.py"), why it is dangerous, and the specific remediation steps. - MEDIUM — Warn the user with a clear explanation and ask whether they want to fix it first or proceed.
- LOW — Mention briefly and move on unless the user asks for detail.
For each finding include: file path, line number, finding type, severity, and a plain-English explanation.
Consult references/github-security-scanner-hook-reference.md for the full severity table, finding types, and remediation guidance.
If the scan is clean (exit code 0), confirm clearly: "No security issues found in staged files."
Step 4 — Install Pre-Commit Hook (Optional)
Ask the user: "Would you like to install this as a git pre-commit hook so every future commit is scanned automatically?"
If yes:
$PYTHON .github/skills/github-security-scanner-hook/scripts/install-hook.pyThe installer:
- Detects whether
.git/hooks/pre-commitalready exists — if it does, it offers to Append (default), Overwrite, or Skip rather than silently destroying existing hooks - Creates or extends the hook to call
scan-staged.pybefore every commit - Makes the hook executable
- Prints the hook path and a confirmation message
After installation, remind the user:
- The hook lives in
.git/hooks/pre-commit— this directory is not tracked by git, so each contributor must runinstall-hook.pythemselves to opt in - HIGH severity findings block the commit; MEDIUM/LOW prompt a confirmation
- Emergency bypass:
git commit --no-verify— see the reference for important caveats
Step 5 — Remediate Issues
For each HIGH or MEDIUM finding the user wants to fix:
- Open the flagged file at the reported line number
- For hardcoded credentials: Replace with an environment variable (
os.environ["KEY_NAME"]) or a secrets manager call - For private keys: Remove the key, revoke it immediately (assume it is compromised), generate a new one, and add the key file pattern to
.gitignore - For code vulnerabilities & weak cryptography (semgrep): Fix injection vectors (use parameterized queries,
subprocess.run([...], shell=False)) and replace insecure hashes (hashlib.md5→hashlib.sha256,random→secrets) - For false positives: Add to the
.secrets.baselineallowlist usingpython -m detect_secrets audit .secrets.baseline - Re-stage the fixed files and re-run Step 2 to confirm all HIGH findings are resolved
Additional Resources
references/github-security-scanner-hook-reference.md— Full severity classification table, detect-secrets plugin mapping, semgrep vulnerability types with remediation examples,.secrets.baselineworkflow, false-positive handling, CI/CD integration YAML,--no-verifywarning, and secret rotation checklistrules/security.yml— Bundled semgrep rules covering SQL injection, command injection, path traversal, XSS, eval/exec, and open redirects across Python, JavaScript/TypeScript, and Goscripts/scan-staged.py— Scans staged (or all tracked) files using detect-secrets and semgrep; outputs structured JSON with findings and severity summaryscripts/install-hook.py— Installs or extends the git pre-commit hook to automate scanning on every future commit
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

