Code scanning
proposed checked A convention of ontrack-engineering 0.6.0. How ontrack ruled on it.
traits: code_scanning: tool: fail_on:Status
Proposed
What is this file? A question governance asks your repository, with the answer it recommends. While it says
status: proposed, you may edit it freely.revision:dates the question, not the file: you do not fill it, and it only moves when the question changes. rejected is a full answer: when the question does not apply here, rule rejected, remove the wholetraits:block, and say what stands in for it. ADR-0001 explains the mechanics.
Context
ADR-0019 scans what the repository depends on. Nothing reads the code the repository writes: an HTTP route that builds SQL from a parameter, a path taken from user input, a command assembled with a string.
While these keys are empty, an agent writing such code does not know whether a tool will analyse it. Facing an alert, it does not know whether the alert blocks, nor whether it may dismiss it or exclude the file.
Static analysis reads the code without running it. CodeQL, GitHub’s engine, supports Python and JavaScript/TypeScript among other languages, and is free on public repositories. Private repositories need GitHub Code Security. Semgrep is a rule-based scanner that runs anywhere.
Narrowing a scan silences it without saying so. A dismissed alert
stays in the Security tab, with who dismissed it and why. A path in
paths-ignore, or a query removed by query-filters, leaves nothing to
see: the alert never exists.
A scan of small code finds little. Measured on governance itself, a TypeScript CLI that validates its inputs: CodeQL’s 87 default queries reported one alert, a false positive in a test helper. The question is asked for the repositories where routes, queries and paths do come from outside.
Not concerned: the workflows themselves
(ADR-0011’s forge.audit), secrets
(ADR-0015), dependencies (ADR-0019).
Decision
What governance recommends, and why.
| Key | Recommended value | Reason |
|---|---|---|
code_scanning.tool |
codeql |
free on public repositories, supports both languages ADR-0004 recommends, and its results carry the severity GitHub’s merge protection reads. semgrep for a private repository without GitHub Code Security |
code_scanning.fail_on |
high |
the finding is in code this repository wrote, and the agent that wrote it can fix it in the same change. ADR-0019 stops at critical because a dependency’s fix waits on someone else’s release; this one waits on nobody |
none is an answer for tool, for a repository with no code that handles
outside input. Any tool that writes SARIF answers it too.
What governance fixes, whatever you rule:
- No blocking scan without
forge.gate: blocking(ADR-0011). Withinformativeornone, a required check does not exist. - The scan runs in a workflow, pinned, on every change.
- It runs in a workflow (for CodeQL, the advanced setup), on every pull request and every push to the default branch, with its actions pinned by SHA (ADR-0011 rule 3).
- For CodeQL, set
tools: linked. A SHA pin alone does not freeze the queries: on github.com the action uses the bundle GitHub recommends at run time. Withlinked, the bundle and its queries change only when Dependabot updates the action, in a pull request that is scanned. A scheduled scan then adds nothing. - The results go to GitHub code scanning as SARIF, where ADR-0019’s scanner already sends its own. Where the plan does not allow the upload, the SARIF stays a job artifact.
- Default setup alone does not answer this ADR: it is a setting no file records, and it runs the version GitHub picks.
- How a finding blocks. CodeQL blocks through the ruleset rule
“Require code scanning results”, with its security-alerts threshold at
fail_on(high_or_higherforhigh). Any other tool blocks through its own exit code atfail_on, for examplesemgrep scan --error --severity ERRORforhigh. Its SARIF is not documented to carry thesecurity-severitythat threshold reads. - All code is scanned, tests included. governance cannot tell what counts as test code in another repository, and a fixture that shells out is still a command built from a string.
- Narrowing the scan is a person’s call. Dismissing an alert,
excluding a path (
paths-ignore,paths, a tool’s ignore file) and removing a query or rule (query-filters, a narrower suite) all silence a finding. The agent fixes the code, or proposes one of these with its reason, and a person dismisses it, or approves or merges it as ADR-0022’sreview.bysays, as ADR-0019 rule 4 has for an ignore rule.
What codeql looks like in practice:
on: pull_request: push: branches: [main]permissions: contents: readjobs: analyze: runs-on: ubuntu-latest permissions: contents: read security-events: write strategy: matrix: language: [javascript-typescript] # or python steps: - uses: actions/checkout@<sha> # vX.Y.Z with: persist-credentials: false - uses: github/codeql-action/init@<sha> # vX.Y.Z with: languages: ${{ matrix.language }} tools: linked - uses: github/codeql-action/analyze@<sha> # vX.Y.ZWith semgrep, the job runs semgrep scan --sarif --output semgrep.sarif
then github/codeql-action/upload-sarif (or actions/upload-artifact),
and a separate semgrep scan --error --severity ERROR step that fails the
job.
Everything below disappears when you rule, from this sentence up to the Consequences heading, which stays.
How to rule: five steps, all in this file. Read all of them before doing any, because the last one deletes the other four, and do them in one commit.
- Write the value of each key under
traits:in the frontmatter, or, if you rule rejected, remove the wholetraits:block. - Change
status:from proposed to accepted or rejected. - Fill
date:andauthors::date:asYYYY-MM-DD, the day you rule;authors:, the names of the people who decided, without email addresses. - Rewrite the Positive, Negative and Neutral lists under Consequences for your verdict: what it makes easier, and what it costs.
- Last, delete this block, from its first sentence up to the Consequences heading, which stays. In its place, write the reason for your decision wherever you depart from the recommendation, or, if you adopt it as is, one line that says so.
The first step is the one people forget: a decision written only in prose leaves an agent guessing. This is what the frontmatter looks like once filled, and it is the one part of the file an agent reads without interpreting it:
---adr: ADR-0024slug: code-scanningtitle: Code scanningstatus: acceptedrevision: 1date: 2026-11-15authors: [Your Name]supersedes: []check: npx --no-install ontrack-engineering-check ADR-0024traits: code_scanning: tool: codeql fail_on: high---The check: line stays. Once this ADR is accepted, ontrack check
runs it from your repository’s root. It reads the keys you ruled and checks
only that the files they imply are committed, not what those files say:
code_scanning.tool: withcodeql, a workflow holdsgithub/codeql-action/analyze. With another tool, one workflow holds the tool’s name and eithergithub/codeql-action/upload-sariforactions/upload-artifact, so ADR-0019’s SARIF upload alone does not count.nonehas nothing to check.code_scanning.fail_onmust be written, and nothing more: the threshold lives in the ruleset and in the workflow’s flags, which the check reads neither of. Neither does it readtools: linked, or default setup in your repository’s settings.
The Alternatives Considered below were weighed by governance without knowing your context. Weighing them against yours is still to do, and it is what makes a decision different from an accepted default.
Consequences
Positive
- An agent writing a route or a query knows a tool reads it, and what to do when it objects.
- Every alert, from this scan and from ADR-0019’s, is in one place, and every way to silence one goes through a person.
- The scan’s version moves only in a pull request.
Negative
- At
high, a false positive blocks the merge until a person dismisses it. - The scan adds minutes to every pull request.
- A private repository pays for GitHub Code Security, or blocks on a tool’s exit code and loses the common view.
Neutral
- The ruleset that makes CodeQL’s alerts block is a GitHub setting, outside the repository, and nothing here checks it.
Alternatives Considered
Default setup
One click in the repository’s settings, and GitHub picks the languages, the queries and their version. Nothing in the repository records it, the check cannot see it, and the version moves without a pull request. It is fine to try, as governance did, before writing the workflow.
fail_on: critical
ADR-0019’s threshold. Fewer blocked merges, and high findings that only report. It suits code whose fix the agent cannot make, which is not the case for a repository’s own code.
semgrep as the default
It runs anywhere, with no plan condition, and its rules are easy to read and write. Its results do not carry the severity GitHub’s merge protection reads, so blocking goes through each workflow’s flags instead of one ruleset.
The exit code everywhere, no SARIF
Simpler: the job fails or passes. Alerts then live in CI logs, and a finding is silenced by changing a flag instead of dismissing an alert with its reason.
Excluding tests by default
Less noise, as with governance’s false positive. It needs a list of test paths per language that governance would guess for every repository, and it is an exclusion nobody decided.
A key in ADR-0019
ADR-0019 asks what a release contains. This question is about the code the repository writes. One ADR for both would be the catch-all the supply-chain ADRs were split to avoid.
References
- Original to governance; no surdesrails SDR asks this question.
- ADR-0001: how governance ADRs are ruled on.
- ADR-0011: the gate, the pinning rule, and
forge.auditfor workflows. - ADR-0019: the dependency scan, its SARIF upload and its rule 4.
- ADR-0022: who reviews and merges.
- GitHub:
- about code scanning with CodeQL;
- customizing advanced setup;
- uploading a SARIF file;
- SARIF support;
- merge protection;
- GitHub Advanced Security;
github/codeql-action’sinitinputs (tools: linked).
- Semgrep: CLI reference, rule syntax, JSON and SARIF fields.
- Read on 2026-11-15.
The keys.
| Key | What it holds | Allowed values |
|---|---|---|
code_scanning.tool |
what analyses the repository’s own code | codeql, another SARIF-writing tool, or none |
code_scanning.fail_on |
the lowest severity that blocks a merge | critical, high, medium, low, none |
An empty key is not an answer. The value is written in this file and nowhere else; whoever needs it links here. See ADR-0001 for the check command.
