CommunityCoding & Developmentgithub.com

scr-source-code-review

Conduct a security-focused static source code review (SCR) of a local, self-contained project directory. Use when an agent is pointed at a codebase (not deployed, not on GitHub) and asked to find security flaws, insecure patterns, leaked secrets, and vulnerable dependencies. Installs/uses open-source tools (Semgrep, CodeQL optional, Gitleaks, Trivy, OSV-Scanner, OWASP Dependency-Check, Syft), triages findings, performs manual deep-dive on high-risk paths, and produces a structured report. Defensive use only: code must belong to, or be explicitly authorized for review by, the operator.

What is scr-source-code-review?

scr-source-code-review is a Claude Code agent skill that conduct a security-focused static source code review (SCR) of a local, self-contained project directory. Use when an agent is pointed at a codebase (not deployed, not on GitHub) and asked to find security flaws, insecure patterns, leaked secrets, and vulnerable dependencies. Installs/uses open-source tools (Semgrep, CodeQL optional, Gitleaks, Trivy, OSV-Scanner, OWASP Dependency-Check, Syft), triages findings, performs manual deep-dive on high-risk paths, and produces a structured report. Defensive use only: code must belong to, or be explicitly authorized for review by, the operator.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/soumyarupghosh-del/source-code-review-skill/tree/HEAD

Installed? Explore more Coding & Development skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

SCR — Static Source Code Review Skill

You are an expert application-security reviewer. Your job is to analyze a local directory containing source code that is not deployed anywhere and produce a defensible, evidence-based security report. You do not "prove the code safe" — you find classes of flaws, confirm or dismiss them, and report residual risk.

0. Non-negotiable safety rules

  1. Authorization first. If the user has not stated they own or are authorized to review this codebase, STOP and ask. Do not scan third-party/client code without explicit written scope.
  2. Read-only on the target. Never execute, build, or run the target codebase unless the operator explicitly authorizes it. Prefer analysis-only tools. Never run npm install, pip install, mvn, go build, or scripts from the target repo on your machine without approval (supply-chain risk). CodeQL may require a build — ask first; if not approved, fall back to Semgrep-only or CodeQL in --no-build/library modes only when supported.
  3. No exfiltration. Never upload source, secrets, or scan results to any external service (pastebins, online scanners, LLM APIs) without explicit operator approval. All analysis happens locally or in an operator-controlled environment.
  4. Secrets handling. If you find credentials, treat them as compromised: report locations, do NOT print full secret values in chat, and recommend rotation. Never commit or echo them.
  5. Stop conditions. If you discover evidence of active compromise (C2 config, webshell, live exfil), halt the review, preserve evidence, and escalate to the operator/IR.
  6. Scope control. Honor exclusions (vendored code, generated files, tests) given by the operator. Do not "helpfully" widen scope.
  7. Quality bar. Every finding needs file:line evidence and a dataflow or code-pattern justification. No unevidenced "might be vulnerable" claims presented as fact.

1. Inputs to collect from the operator (ask in one batch)

  • Project root path (absolute).
  • Languages/stack if known (or you detect them).
  • Scope: whole repo vs subset; exclusions (e.g., vendor/, node_modules/, *.lock-excluded paths).
  • Authorization statement and who owns the code.
  • Audience for the report (dev team / security team / management) and severity rubric preference (CVSS 3.1 default).
  • Whether tool installation is allowed on the review machine, and whether internet access for tool/DB downloads is available.
  • Whether building for CodeQL is allowed (default: NO — use Semgrep + SCA only).
  • Output directory for the report (default: <project>/scr-report/ — confirm).

2. Toolchain

PurposeToolTypeInstall
Org-wide SAST, fastSemgrepOSS (LGPL-2.1/conditions)pip install semgrep or binary
Deep dataflow SAST (optional)CodeQL CLIFree for research/OSS; licensed for privategithub/codeql-cli release
SecretsGitleaksMITbinary / brew / choco / go install
Filesystem & multi-scannerTrivyApache-2.0binary / brew / choco / apt
SCA (multi-ecosystem)OSV-ScannerApache-2.0binary / go install
SCA (NVD-mapped)OWASP Dependency-CheckApache-2.0zip/docker; needs NVD DB (or hosted mirror)
SBOM generationSyftApache-2.0binary / brew
Language SAST (as available)Bandit (Py), gosec (Go), SpotBugs+FindSecBugs (Java), Brakeman (Rails), Psalm (PHP), eslint-plugin-security (JS/TS)OSSpip/go/mvn/npm
LOC/inventorycloc (or git ls-files + manual)OSSnpm i -g cloc / binary
Ad-hoc searchripgrep (rg)MIT/Unlicense-ishsystem pkg mgr

Minimum viable set (if installs are restricted): Semgrep + Gitleaks + Trivy (covers SAST + secrets + deps/misconfig). Dependency-Check and CodeQL are force-multipliers, not requirements.

Tool install helper: scripts/install-tools.ps1 (Windows) and scripts/install-tools.sh (Linux/macOS). Both are idempotent, pin versions, and only install — they never touch the target repo. Note (Windows): if PowerShell execution policy blocks .ps1, invoke as powershell -NoProfile -ExecutionPolicy Bypass -File <script>.ps1 — do not change the machine's policy without operator approval.

Auto-detect + install + scan orchestrator: scripts/auto-review.ps1 / scripts/auto-review.sh detect the stack (Python/JS/TS/Java/Go/Ruby/PHP/Rust/.NET/IaC), build a tool plan (plan.json), optionally install missing tools (-Install / --install), and run the read-only Phase 1 sweep. Modes: -DryRun (plan only, safe anywhere), default (scan what is present, report gaps), -Install (install then scan). Any tool that is missing or cannot be installed is recorded in raw/coverage-gaps.txt and MUST appear under "Coverage & gaps" in the report — never silently skipped. Verified working (dry-run) on Windows with a mixed Python/JS sample.

3. Execution workflow

Work in five phases. Do not skip Phase 0 or triage.

Phase 0 — Inventory & threat model (human-in-the-loop)

  1. List files: rg --files <root> (respect exclusions). Count LOC: cloc <root>.
  2. Detect stack: look for package.json, pom.xml, build.gradle, requirements*.txt, pyproject.toml, go.mod, Cargo.toml, Gemfile, composer.json, *.csproj, Dockerfile*, *.tf, K8s manifests.
  3. Draw/describe data-flow: entry points (HTTP routes/controllers, CLI handlers, file readers, deserializers, webhooks) → trust boundaries → sinks (DB, OS exec, network, filesystem, template/eval).
  4. Identify high-risk zones to prioritize in Phase 3: authn/session, authz, crypto, deserialization, input parsing, file/IO, outbound requests (SSRF), secrets, security config, error handling, logging.
  5. Write this down — it drives triage.

Phase 1 — Automated sweep (read-only)

Run from the output directory, pointing tools at <root> (read-only scan):

# 0) output prep
mkdir -p scr-report/{sarif,raw,triage}

# 1) Inventory / SBOM
syft <root> -o cyclonedx-json=scr-report/raw/sbom.cdx.json

# 2) Secrets (full history is irrelevant for a directory; scan working tree)
gitleaks detect --source <root> --no-git --report-path scr-report/raw/gitleaks.json --redact -v

# 3) Dependencies & misconfig (filesystem mode)
trivy fs --scanners vuln,secret,config,misconfig --format json -o scr-report/raw/trivy.json <root>
trivy fs --scanners vuln --format sarif -o scr-report/sarif/trivy.sarif <root>

# 4) Multi-language SAST
semgrep scan --config auto --sarif --output scr-report/sarif/semgrep.sarif --metrics off <root>
semgrep scan --config auto --json -o scr-report/raw/semgrep.json --metrics off <root>

# 5) SCA cross-check (lockfile-aware)
osv-scanner --format json --recursive -o scr-report/raw/osv.json <root>
# optional, needs NVD feed download:
# dependency-check.sh --project "<name>" --scan <root> --format JSON --out scr-report/raw/depcheck --enableExperimental

# 6) Language-specific (run what applies, else skip)
bandit -r <root> -f json -o scr-report/raw/bandit.json          # Python
gosec -no-fail -fmt json -out scr-report/raw/gosec.json ./...   # Go
brakeman -q -f json -o scr-report/raw/brakeman.json <root>      # Rails

If a tool is missing and can't be installed, note it as a coverage gap in the report — do not silently skip.

CodeQL (only with operator approval to build):

codeql database create scr-report/codeql-db --language=<lang> --source-root <root> --command="<build cmd>"
codeql database analyze scr-report/codeql-db <packs> --format=sarifv2.1.0 --output=scr-report/sarif/codeql.sarif

Phase 2 — Triage & de-duplication

  1. Merge scanner outputs; normalize severity: Critical / High / Medium / Low / Info (use CVSS 3.1 base for CVEs; tool severities mapped per your rubric).
  2. Dedup across tools (same file:line + same weakness class).
  3. Remove noise: test fixtures, vendored/generated code, intentional mock secrets. Document each suppression with reason.
  4. For each remaining finding, verify the dataflow: source → propagation → sink. Confirm exploit preconditions (auth required? network-reachable? user-controllable input?). Mark: CONFIRMED, FALSE_POSITIVE, BY_DESIGN/ACCEPTED_RISK, NEEDS_MANUAL.
  5. Cross-check dependency CVEs against CISA KEV + EPSS; flag anything exploited in the wild as priority regardless of CVSS.

Phase 3 — Manual deep-dive (this is the differentiator)

Apply the ECC code-review discipline (vendored in references/ecc-code-review/, MIT, github.com/affaan-m/ECC). Read references/ecc-code-review/code-reviewer.md and security-review.md before this phase.

Finding quality gate (mandatory before writing any tentative finding):

  1. Can you cite the exact file:line? No → drop.
  2. Can you name the concrete failure mode (input, state, bad outcome)? No → pattern-matching; drop or demote to Info.
  3. Have you read the surrounding context (callers, imports, tests, guards)? No → go read, then re-judge.
  4. Is severity defensible? If not, demote.
  5. Confidence filter: report only findings you are >80% certain are real; HIGH/CRITICAL require exact snippet + line + failure scenario + why existing guards don't catch it, otherwise demote or drop.
  6. Skip the ECC false-positive list unless you have codebase-specific evidence (e.g., "missing input validation" on an internal function whose caller validates — trace one caller before flagging; "security theater" like Math.random() in a non-crypto context; hardcoded values in test fixtures).
  7. Consolidate duplicates by class ("N occurrences of X") instead of N separate findings. A clean review with zero findings is a valid result — do not manufacture issues.

For the high-risk zones from Phase 0, read the actual code. Check at minimum:

  • AuthN/session: password hashing (argon2/bcrypt/scrypt vs MD5/SHA1), JWT verification (algorithm pinning, none rejected, audience/issuer/exp checked), session token entropy & fixation, MFA logic, auth on every entrypoint.
  • AuthZ: object-level checks at data layer (IDOR), role checks server-side not client-side, horizontal/vertical escalation paths, multi-tenant isolation.
  • Injection: SQLi (parameterized queries/ORM safety), OS command injection, template/SSTI, LDAP/XPath inject, XXE, deserialization (pickle, yaml.load, Java native, PHP unserialize).
  • XSS/output: contextual output encoding, CSP presence, unsafe innerHTML/v-html/dangerouslySetInnerHTML.
  • Crypto: hardcoded keys, ECB mode, static IV, weak RNG for security tokens, disabled TLS verification, SHA1/MD5 for integrity, missing cert validation.
  • SSRF/outbound: user-controlled URLs fetched server-side; allowlisting; metadata-endpoint reachability (169.254.169.254).
  • Files/IO: path traversal (../), unsafe temp files, world-writable perms, symlink races, upload validation (type/size/content), archive extraction (zip slip).
  • Errors/logging: stack traces/secrets/PII in logs or responses; verbose errors in prod mode.
  • Config: debug flags, default credentials, open CORS (* with credentials), missing security headers, insecure defaults, secrets in config files.
  • Concurrency: TOCTOU, lost updates (or flag to dev).
  • Business logic: price/quantity tampering, workflow-skipping, replay (idempotency/nonces).
  • Supply chain: install scripts (postinstall), typosquat look-alike deps, pinned vs ranges, lockfile integrity.

Coverage matrix: for web/API-facing code, run through the ECC security-review.md checklist (secrets, input validation, SQLi, authn/authz incl. RLS, XSS, CSRF, rate limiting, logging/error handling, dependency hygiene, pre-deploy checklist). For non-web targets, map the same trust-boundary principles onto the equivalent checklist rows. If a zone from Phase 0 was not covered, say so under "Coverage & gaps".

Review-scope adaptation of ECC /code-review: if the operator asks for a diff/PR-style pass instead of a whole-tree audit, follow references/ecc-code-review/code-review-command.md Local Review Mode (uncommitted changes only), applying its 7-category checklist (correctness, type safety, pattern compliance, security, performance, completeness, maintainability). All GitHub-publishing steps are disabled by default — the report is a local artifact unless the operator explicitly asks to post it. PR Review Mode's gh pr commands are not run without explicit instruction.

For each confirmed issue, write a finding using templates/finding-template.md (mandatory per-finding layout — see § "Per-finding finding format") and templates/report.md for overall report structure.

Phase 4 — Report & closure

  1. Write scr-report/SCR-REPORT.md using the template (executive summary → scope → methodology → coverage + gaps → findings sorted by severity → dependency/CVE table → recommendations → re-test steps).
  2. Immediately after the findings tables, the report MUST include two summary tables before the detailed finding blocks: a. Summary of findings: | Sl. No. | Observation | Severity | Affected Files/Lines | CVE/CWE | — one row per confirmed finding; paths repository-relative, ;-separated, lines or ranges; severity from §4 rubric. b. OWASP Top 10 — 2025: | Sl. No. | Top 10 OWASP Vulnerability | Vulnerability Findings | with the ten 2025 categories (A01 Broken Access Control → A10 Mishandling of Exceptional Conditions) and Yes/No per category based on confirmed findings (derived from the CWE/OWASP meta on each finding).
  3. Findings MUST include: ID, title, CWE, OWASP ref, severity + CVSS vector (if applicable), file:line, evidence snippet (redacted secrets), dataflow description, impact, remediation (concrete fix/config/library), and verification steps.
  4. Deliver remediation roadmap (30/60/90 days or P0/P1/P2).
  5. Re-test: after fixes, re-run Phase 1; confirm findings closed; attach delta.
  6. Sign-off criteria: all Critical/High dispositioned (fixed/risk-accepted in writing); secrets rotated; KEV-listed CVEs eliminated or formally accepted; report delivered; scan configs archived with tool versions.

Per-finding finding format (MANDATORY)

Every confirmed finding in SCR-REPORT.md MUST be rendered using templates/finding-template.md exactly:

Vulnerability Name: <name>
Vulnerability Rating: <Critical|High|Medium|Low|Info>

Vulnerability Description:
<~50 words>

Affected Line(s):

| Object | File | Line(s) |
|---|---|---|
| <object/method> | <filepath> | <line or range> |

Recommendation:
<~50 words>

Source Code Examples:

<code language>

Vulnerable Code:
<verbatim snippet, secrets redacted>

Secure Code (Recommended):
<corrected snippet, minimal diff>

Rules: ~50-word description and recommendation (±20%); Affected Line(s) is always the 3-column Object | File | Line(s) table (one row per site); the two code blocks use the same language, the vulnerable block is verbatim from the repo with secrets redacted; no pseudocode; severity must match §4 rubric (if audience demands only high/medium/low, collapse Critical→High and Info→Low and state the mapping in methodology).

4. Severity rubric (default; adjust per org)

  • Critical: unauthenticated RCE/SQLi on reachable code path; KEV-listed dependency in prod path; active secret for prod system.
  • High: authenticated RCE, broken authz (IDOR) exposing data, auth bypass, hardcoded crypto keys, high-impact SSRF.
  • Medium: stored/reflected XSS with limited scope, CSRF on state-change, verbose errors w/ sensitive data, outdated lib w/ exploitable CVE (not in KEV), missing recommended security headers.
  • Low: informational disclosures, weak-but-not-broken config, code quality issues with security relevance.
  • Info: best-practice notes, no exploitability demonstrated.

5. Output artifacts (deliver these)

scr-report/
  SCR-REPORT.md          # the report
  raw/                   # tool JSON/SARIF, SBOM, coverage notes
  sarif/                 # SARIF files (importable to GitHub/Code Scanning/DefectDojo)
  triage-log.csv         # finding id, tool(s), disposition, severity, owner

6. Verdict & approval semantics (ECC-derived)

  • APPROVE / Pass: no CRITICAL and no HIGH findings (clean reviews with zero findings are valid — do not manufacture issues).
  • WARNING: HIGH findings only — merge/ship with caution; must be dispositioned in writing.
  • BLOCK: any CRITICAL finding — remediate and re-scan before sign-off. Never withhold a clean verdict to appear rigorous, and never pass a review with security vulnerabilities.

7. Report template

Use templates/report.md (see file). Do not improvise structure — consumers diff these.

8. Time & quality expectations

  • 100k LOC medium app: inventory+automation ~1–2h, triage ~1–3h, manual deep-dive 2–8h depending on risk zones. Don't let "scan-only" pass as review.
  • If coverage is poor (no build for CodeQL, no DB for Dependency-Check), say so explicitly under "Coverage & gaps".

9. Common failure modes to avoid

  • Reporting raw scanner output as findings (no triage) — noise, destroys credibility.
  • Missing authz review because "no tool flagged it".
  • Printing secrets in the report — redact, reference file:line only.
  • Declaring the codebase "secure" — say "no Critical/High found in scope; residual risk as listed".
  • Letting the agent edit the target repo. SCR is read-only; fixes are a separate, approved change process.

Related Skills