Static Analysis Integration (SARIF-first)
Maintenance policies for adapters and rulesets live in maintenance.md — those are out-of-runtime concerns.
Constraints
- Collect and report only — read source and tool output; make no code edits.
- Graceful degradation: if no tools are installed, return
status: skip; absence is never a pipeline failure. - Deduplicate across tools: the same issue reported by multiple tools appears once, attributed to the higher-priority source.
Tool tiers
Tier 1 — required baseline (SARIF native)
| Tool | SARIF invocation | Capability |
|---|---|---|
| semgrep | semgrep scan --sarif --config auto | SAST |
| gitleaks | gitleaks detect --report-format sarif --report-path - --no-verify | secrets |
| trivy | trivy config --format sarif --skip-update --offline-scan <path> + trivy fs --format sarif --skip-update --offline-scan <path> | IaC + supply-chain |
| hadolint | hadolint --format sarif <Dockerfile> | IaC (Dockerfile) |
| actionlint | binary emits JSON; thin adapter maps to SARIF result (see references/tool-configs.md) | CI/CD |
| pmd | pmd check -d . -R <resolved-ruleset> -f sarif --no-progress — language-conditional: dispatched (and hinted when missing) only when .java files are in the target set; detection probes the repo-local .pmd/ bin before PATH; ruleset resolution in references/tool-configs.md | Java code quality |
| ruff | ruff check --output-format sarif . (ruff ≥ 0.3.1) | Python lint + autofix (language-conditional — see step 1) |
Tier 2 — optional SARIF adapters
Shipped in P2 Step 3b. Not part of the baseline.
Tier 3 — bespoke JSON adapters
Shipped in P2 Step 3b for tools without upstream SARIF. Each adapter ≤ 40 LOC. A thin adapter normalizes security-review agent output into the unified envelope (see adapters/security-review-adapter.py). Rule_id lookup is driven by plugins/dev-team/knowledge/security-review-rule-map.yaml; malformed categories hard-fail, well-formed-but-unmapped categories fall back to security-review.* with a WARN.
mypy (≥ 1.11, mypy --output json) normalizes via adapters/mypy-adapter.py — rule ids mypy.python.<error-code>; on older mypy (no --output json) the adapter degrades to a skip-with-warning. Language-conditional like ruff (see step 1). Invocation and field mapping in references/tool-configs.md.
Convention, accessibility, and performance probes (#1979)
Two additional invocations of tools already in the tiers above — no new binaries, no new adapters, no network. Each exists to hand review agents a deterministic finding where a lens would otherwise re-derive one by inference, and each is separate from its tool's main lane so the main lane keeps reflecting the project's own gating configuration:
| Probe | Invocation | Displaces |
|---|---|---|
| ruff convention | ruff check --select N,PLR2004 --output-format sarif . | the mechanical half of naming-review (PEP 8 naming, magic values in comparisons) |
| oxlint frontend | npx oxlint --jsx-a11y-plugin --react-plugin --react-perf-plugin -D perf --format sarif . | the mechanical half of a11y-review; feeds performance-review on the JS/TS side (no-await-in-loop is the N+1 shape) |
Both are language-conditional, never [REQUIRED], and never gate — they are context, exactly like the rest of the pre-pass. Invocation details, the measured calibration behind them, and the JS/TS magic-number opt-in are in references/tool-configs.md.
Cross-language performance context. When the Repowise MCP tools are available, the caller injects get_health's static I/O-in-loop / N+1 findings into the pre-pass context alongside these, rather than having performance-review fetch them per dispatch. Semgrep's registry performance rulesets (p/performance) are deliberately NOT used: resolving a registry pack requires an outbound call to semgrep.dev, which would break the offline posture § 1b establishes for this pre-pass — and the pack the spike named does not resolve at all (--config p/performance returns HTTP 404, verified on semgrep 1.174.0). Shipping our own performance rules is possible but is a separate piece of work: every rule this repo ships needs passing/failing fixtures under the semgrep rule fixtures CI gate. The oxlint perf lane covers the JS/TS side offline; anything beyond it stays with the agent.
lizard (complexity metrics) normalizes via adapters/lizard-adapter.py — rule ids lizard.complexity.<metric>; jscpd (copy-paste duplication) via adapters/jscpd-adapter.py — rule id jscpd.duplication.clone. Both are Tier 3 by this file's own taxonomy (bespoke adapter, not SARIF-native), but both are baseline capabilities rather than optional extras: they are the deterministic source for the two metric families the review panel would otherwise re-derive by inference on every run — function complexity/size/parameter count, and duplicated blocks (#1974). Neither is language-conditional; lizard covers ~15 languages and jscpd ~150, so both are probed on every target set. Invocation, thresholds, and field mapping in references/tool-configs.md.
Tier 4 — legacy (pre-SARIF)
ESLint / tsc remain callable via native JSON for older flows. Not part of the Step 3a baseline; migrate to SARIF when upstream lands. (The legacy Python entry is retired — ruff replaces it outright as the Tier 1 Python source.)
Execution flow
1. Detect available tools
For each Tier 1 tool, run command -v <tool>. Record presence in a tool-map. Missing Tier 1 tools surface as a warning group via the install-hint format below — never a pipeline failure.
Language-conditional tools (ruff, mypy) are probed and dispatched — and their missing-tool hints surfaced — only when .py files are in the target set. A non-Python repo never sees a "ruff missing" or "mypy missing" warning, and language-conditional tools never carry the [REQUIRED] prefix.
If no Tier 1 tools are present, return:
{ "status": "skip", "tools": [], "findings": [], "summary": "No static analysis tools detected." }
1b. Offline enforcement (gitleaks, trivy)
These tools default to making network calls; in restricted-egress environments those calls hang or fail and take the pre-pass down with them. Both are pinned to local-only operation so the pre-pass never depends on outbound network access.
gitleaks runs with --no-verify. Verification (confirming a detected secret is a live credential) is the only outbound call gitleaks makes; disabling it keeps detection fully pattern-based and offline. No preflight needed — the flag is always on.
trivy runs with --skip-update --offline-scan on both trivy config and trivy fs. Before dispatching trivy, run the offline DB preflight against the local cache (${TRIVY_CACHE_DIR:-$HOME/.cache/trivy}/db/trivy.db):
| Local DB state | Action | Warning |
|---|---|---|
| absent | skip trivy | trivy local DB missing — run: trivy image --download-db-only |
| mtime age ≤ 7 days | run (fresh) | none |
| mtime age > 7 days | run anyway | trivy DB is N days old — consider refreshing with: trivy image --download-db-only |
N is the integer day count. The 7-day boundary is inclusive (exactly 7 days = fresh; strictly greater than 7 days = stale). A missing or stale DB is never a hard pipeline failure — it degrades to a skip or a warning, consistent with the graceful-degradation constraint.
2. Run available tools in parallel
Dispatch each available tool's invocation. Each returns SARIF on stdout (or via its adapter). Collect SARIF documents keyed by tool name.
Target walk MUST include CI/CD workflow files even when they live outside the walked tree (monorepo case — walk up to the repo root to find them). Glob list: