Skip to content

fix(review): Semgrep runs pinned and offline with metrics off, from a cached registry ruleset plus devops-cli's tested rule pack #1144

Closed

Description

@dan-petty

Ready: implementation plan (refined 2026-10-17 at 3dd7fa6)

This section supersedes any text below that conflicts with it.

Decisions

  • Keep --disable-nosem: yes. An inline nosemgrep must not silence a finding without review. Admission already honours the marker only where it exists at the base revision (review/suppression.py:129-160, config/constants.py:671), so Semgrep has to report every result.
  • Metrics and the version check: every semgrep scan command carries --metrics off and --disable-version-check. Semgrep 1.179.0's --disable-version-check does what SEMGREP_ENABLE_VERSION_CHECK=0 does and shows in the argv, so no environment is passed (checked with semgrep scan --help at 1.179.0). There is no --dataflow-traces.
  • Output: findings come from --sarif-output <workdir>/semgrep.sarif, read with security/sarif.py's read_sarif, so severity comes from the rule's security-severity and level (sarif.py:323-348). The JSON on stdout is read only for paths.scanned, paths.skipped and errors. Checked at 1.179.0: one offline run writes both, with paths.scanned in the JSON.
  • One command builder: build_semgrep_cmd (config/commands.py:214-225) builds every semgrep scan. That covers the review (security/semgrep.py:124-133), devops scan sast (commands/scan.py:364-394), the canary (review/canary.py:415-424) and the agent tool (ai/tools/builtin_tools.py:350-357). The pack's semgrep --test (review/rules_pack.py:231-238) keeps its own command.
  • The MCP tool's default config: auto (ai/mcp/server.py:2053) becomes DEFAULT_SEMGREP_CONFIG. Semgrep refuses --config auto with metrics off (checked at 1.179.0: "Cannot create auto config when metrics are off").
  • The pack always runs: its --config is added to every review scan and every devops scan sast run, whatever --config names. Today it is added only with the default config (semgrep.py:130-132).
  • Registry rules on by default: yes. The review runs the cached p/default plus the pack. S11's Semgrep pair, which the person-run check expects back, came from p/default, and the pack holds only the recall set's rules.
  • The fetch step: devops review rules fetch [--ruleset p/default], beside review rules test (commands/review.py:2569-2573).
    • It downloads CONST_SEMGREP_REGISTRY_URL_TEMPLATE = "https://semgrep.dev/c/{ruleset}" through the HTTP client factory (http/client.py:142).
    • It writes <user data root>/semgrep/<ruleset slug>.yaml (core/repo.py:294-297), and beside it a .json with the URL, sha256, retrieved_at, every rule id, the skipped interfile ids and each rule's metadata.license. Both files are written atomically.
    • --dry-run makes no request and prints the URL and the two paths.
    • The cache code lives in a new src/devops_cli/security/semgrep_registry.py.
  • Digest pinning: before use, the review and devops scan sast check the cached file's sha256 against its metadata, and a mismatch counts as a missing cache. The digest is recorded in profile.json as semgrep_registry_digest, beside tools_lock_digest (ai/review/profile.py:125), and review score compares it like its other input digests (commands/review.py:1655-1661).
  • A missing cache: the review runs the pack alone. Semgrep's outcome is coverage_gap with the reason registry rules p/default not cached: run devops review rules fetch, which review.md and profile.json show. devops scan sast with a registry ruleset and no cache exits 1 with the same message. Nothing fetches during a scan: tools run offline, and the fetch is its own step, outside feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772's network-less sandbox.
  • The TTL: DEFAULT_SEMGREP_REGISTRY_TTL_SECONDS = 86_400 in config/defaults.py. An older cache is still used, since its digest keeps the run reproducible, and the review prints a warning naming its age and the fetch command. Failing on age would block every review until someone refetched.
  • Interfile rules: a rule whose options.interfile is true is skipped with --exclude-rule <id>, so the cached file stays byte-identical to the download and keeps its digest. --exclude-rule is the only tuning mechanism, and fix(review): the review's scanner config drops the rules that never produced a valid finding on this repository #1024's exclusions use it too.
  • Rule ids: Semgrep prefixes a local config's rule ids with its directory path. Checked at 1.179.0: a rule demo in /tmp/x/rules/r.yaml came back as tmp.x.rules.demo. Returned ids are mapped back to the ruleset's own ids by suffix against the id list in the metadata, as normalize_pack_check_id does for the pack (review/rules_pack.py:74-77), so .devops/review.toml suppressions keep matching.
  • Licences: recorded per rule id in the metadata. AGPL rules are not skipped, because the cache is for the user's own internal use, and none of it is committed. Tests build synthetic rules in tmp_path, and recorded tool output keeps rule ids only.
  • Batching: files are sorted by (suffix, path), and a batch holds files of one suffix, so files of one language share a batch without a list of languages. A batch closes when the suffix changes, at DEFAULT_SEMGREP_REVIEW_BATCH_FILES (100) files or DEFAULT_SEMGREP_REVIEW_BATCH_BYTES = 1_500_000 bytes, whichever comes first. 100 files at this repository's mean Python file size (13.9 KB over the 569 files under src/) is about 1.4 MB, so a batch of large files takes no longer than the measured 100-file batch.
  • The total budget: DEFAULT_SEMGREP_REVIEW_BUDGET_SECONDS = 300.0 in config/defaults.py, the old single-run timeout.
    • Each batch's timeout is the smaller of DEFAULT_SECURITY_SCANNER_TIMEOUT_SECONDS and the time left.
    • Batches not started when the budget runs out are not run, and their files are listed as not scanned.
    • At the measured 0.87 s a file (defaults.py:242-245), 300 s covers the loop input's 328 files and keeps Semgrep inside P1a's 600 s review target.
  • paths.scanned: a target missing from it is listed as not scanned, with the reason from paths.skipped when Semgrep gives one, and the outcome becomes coverage_gap. ScanOutcome gains unscanned: dict[str, str] (path to reason), which merge_outcomes merges and the coverage matrix shows per file. fix(review): a branch review leaves the files it deletes out of persona pages and scanners, and a file a scanner cannot read does not mark the scanner failed #1140 reuses it for failed manifests.
  • Scope: the flags, the pack and the cache apply to devops scan sast, the agent tool and the MCP tool as well, because the telemetry opt-out covers every Semgrep run. Batching and the budget apply to the review only.
  • Does feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772 gate this item? No. Offline comes from the flags and the local ruleset, and feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772 later wraps the same command in its sandbox.
  • Opengrep: not now. That waits until opengrep#846 (PEP 758) merges and its taint recall is measured.

Delivery

  1. PR 1 (S): one builder, the flags, SARIF output, the pack always on, and the MCP default. Tests first:

    • each of the review, scan sast, the canary and the agent tool builds an argv with --metrics off, --disable-version-check and no --dataflow-traces;
    • review argv also has --disable-nosem and --sarif-output;
    • devops scan sast --config ./local-rules still adds the pack's --config;
    • the MCP default is not auto;
    • a fake subprocess that returns recorded JSON and writes a recorded SARIF gives findings whose ids and severities come from the SARIF.

    Files: src/devops_cli/config/commands.py, src/devops_cli/security/semgrep.py, src/devops_cli/review/canary.py, src/devops_cli/ai/tools/builtin_tools.py, src/devops_cli/ai/mcp/server.py, tests/test_security_semgrep.py. Refs fix(review): Semgrep runs pinned and offline with metrics off, from a cached registry ruleset plus devops-cli's tested rule pack #1144.

  2. PR 2 (M): the registry cache. Tests first:

    • devops review rules fetch, with a fake transport serving a synthetic two-rule YAML (one options.interfile: true), writes the YAML and metadata with sha256, retrieved_at, both ids, the interfile id and the licences;
    • --dry-run makes no request;
    • the review argv for p/default names the cached file and --exclude-rule for the interfile id;
    • with no cache, the argv names the pack alone and the outcome is coverage_gap with a reason naming devops review rules fetch;
    • an edited cache file is treated the same way;
    • a 25-hour-old cache is used and warns;
    • devops scan sast with no cache exits 1;
    • a prefixed check id maps back to the registry id;
    • profile.json carries semgrep_registry_digest, and review score lists it.

    Files: src/devops_cli/security/semgrep_registry.py (new), src/devops_cli/security/semgrep.py, src/devops_cli/commands/review.py, src/devops_cli/commands/scan.py, src/devops_cli/ai/review/profile.py, src/devops_cli/config/defaults.py, src/devops_cli/config/constants.py, src/devops_cli/lang/en/help.py, tests/test_semgrep_registry.py (new), generated CLI docs. Refs fix(review): Semgrep runs pinned and offline with metrics off, from a cached registry ruleset plus devops-cli's tested rule pack #1144.

  3. PR 3 (M): batches, the budget and paths.scanned. Tests first:

    • files b.yaml, a.py and c.py give the batches [a.py, c.py] and [b.yaml], and with a byte cap below one file's size each file is its own batch;
    • with a fake clock where the first batch spends the budget, the second batch never runs, its files are listed with a budget reason, and the outcome is coverage_gap;
    • a recorded JSON whose paths.scanned lacks one target marks that file not scanned in the coverage matrix;
    • merge_outcomes keeps every batch's unscanned.

    Files: src/devops_cli/security/semgrep.py, src/devops_cli/security/base.py, src/devops_cli/ai/review/pipeline.py, src/devops_cli/config/defaults.py, tests/test_security_semgrep.py. Closes fix(review): Semgrep runs pinned and offline with metrics off, from a cached registry ruleset plus devops-cli's tested rule pack #1144.

Acceptance criteria

  • Every semgrep scan command devops-cli builds carries --metrics off and --disable-version-check, and none carries --dataflow-traces. Review scans keep --disable-nosem.
  • Review findings come from Semgrep's SARIF, with severity from the rule's metadata; paths.scanned comes from its JSON.
  • devops-cli's pack runs on every review and every devops scan sast run.
  • devops review rules fetch caches the ruleset with its URL, sha256, retrieval time, rule ids, interfile ids and licences. Reviews and scan sast use the cache offline, check its digest, and record the digest in profile.json.
  • A missing or altered cache leaves the review on the pack alone, with a coverage_gap reason naming devops review rules fetch. A cache older than 24 h is used, with a warning.
  • Interfile rules are skipped with --exclude-rule and listed in the metadata. No registry rule text is committed, and tests use synthetic rules and recorded ids.
  • Review batches hold files of one suffix and close at 100 files or 1.5 MB. The stage stops starting batches after 300 s in total and lists the files it did not scan.
  • A target missing from paths.scanned shows as not scanned in the coverage matrix, with Semgrep's reason when it gives one.
  • (person-run) On the loop input, Semgrep completes in 5/5 runs, and S11's Semgrep pair and config.py:514 reappear.
  • Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each test under 1 s.
  • changelog.d/1144.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
  • uv run devops ci passes.

Current references

  • Review command: src/devops_cli/security/semgrep.py:124-133; other targets :136-158; result parser :60-105; batches :259-275; entry :278-298; pack added only with the default config :130-132.
  • Shared builder: src/devops_cli/config/commands.py:214-225.
  • Defaults: DEFAULT_SEMGREP_CONFIG src/devops_cli/config/defaults.py:127; timeouts and batch size :240-246.
  • Scanner subprocess: src/devops_cli/security/base.py:480-486, :521-522; ScanOutcome :80-112; merge_outcomes :115-130; statuses src/devops_cli/config/constants.py:387-396.
  • Inline markers: src/devops_cli/config/constants.py:669-674; src/devops_cli/review/suppression.py:129-160.
  • SARIF reader: src/devops_cli/security/sarif.py:323-348, :484, :518.
  • Pack: normalize_pack_check_id src/devops_cli/review/rules_pack.py:74-77; pack tests :231-238.
  • Other Semgrep callers: src/devops_cli/review/canary.py:415-424; src/devops_cli/commands/scan.py:364-394; src/devops_cli/ai/tools/builtin_tools.py:350-357; src/devops_cli/ai/mcp/server.py:2052-2060.
  • Fetch command home: src/devops_cli/commands/review.py:2569-2573; HTTP client factory src/devops_cli/http/client.py:142; user data root src/devops_cli/core/repo.py:294-297.
  • Review inputs: src/devops_cli/ai/review/profile.py:125, :347; review score inputs src/devops_cli/commands/review.py:1655-1661.
  • Pipeline: _scan_semgrep src/devops_cli/ai/review/pipeline.py:1551-1565; analyzer state :1334-1351; coverage matrix :1432-1472.

Dependencies and order


Problem

  • The review pulls rules on every run. It runs semgrep scan --json --config p/default --quiet <every file> [code: security/semgrep.py:93-114], which sends metrics by default [sourced: https://docs.semgrep.dev/metrics].
  • Semgrep returned nothing in 12/12 reviews at the current code (D17). That loses runAsNonRoot, allowPrivilegeEscalation and config.py:514 [measured: loop §7].
  • Registry rules are for internal use only: no redistribution and no service [sourced: https://semgrep.dev/legal/rules-license]. This repository is public.
  • The registry ruleset: https://semgrep.dev/c/p/default returns 200 without login, with 1,074 rules. 56 of them need the paid cross-file engine (interfile: true), and 18 are AGPL-3.0 [measured: c-feasibility GET].
  • CE output has no dataflow: under CE, --dataflow-traces yields null traces and no codeFlows [measured: c-feasibility].

Acceptance criteria

Key questions

Strategic alignment

Proposed design

Problem statement

The review process currently runs Semgrep on every run with default settings that send metrics and use registry rules, which are not redistributable. This leads to no findings in 12/12 reviews and loss of important checks like runAsNonRoot and allowPrivilegeEscalation. The solution requires pinning Semgrep to a specific version, running it offline with cached rulesets, and using only devops-cli's tested rule pack.

Acceptance criteria

  • Criterion 1: Semgrep 1.179.0 runs with --metrics off, SEMGREP_ENABLE_VERSION_CHECK=0, and --sarif without --dataflow-traces
    Verification: Run 'semgrep scan --json --config p/default --quiet ' with the specified flags and verify no metrics are sent
  • Criterion 2: devops-cli's pack always runs alongside cached registry rules
    Verification: Execute a review and confirm devops-cli's tested rules are applied in addition to cached rules
  • Criterion 3: Registry rules are fetched into user data root with digest, retrieval time, and 24 h TTL
    Verification: Check that the registry ruleset is downloaded to user data root with metadata including digest, timestamp, and TTL
  • Criterion 4: Rules with interfile: true are skipped and listed with their license recorded
    Verification: Run a review and verify that rules with interfile: true are excluded from scanning and their licenses are documented in the output
  • Criterion 5: Tuning is done only by rule-id exclusion and suppressions, never by modifying registry rule text
    Verification: Confirm that fixture files contain only rule IDs and no actual rule text modifications
  • Criterion 6: Targets are explicit files under the scan's working directory in bounded batches
    Verification: Run a review with specified targets and verify paths.scanned matches the explicit file list
  • Criterion 7: Semgrep completes in 5/5 runs on loop input with S11's Semgrep pair and config.py:514 reappearing
    Verification: Execute multiple review runs and confirm consistent completion with expected findings
  • Criterion 8: Tests run offline with fakes and recorded tool output without network access
    Verification: Run tests in an environment with no network connectivity and verify they complete within 1 second

Key questions

None.

Open questions

  • Registry rules on by default? (missing verified source)
  • Opengrep? (missing verified source)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#1079, #1143, #1145

Activity

  1. added
    type/bug
    scope/security
    scope/review
    priority/p1-high
    on Oct 3, 2026
  2. modified the milestone: v0.2.36 on Oct 11, 2026
  3. dan-petty commented on Oct 14, 2026

    @dan-petty
    OwnerAuthor

    Moved to the backlog: it was New, not Ready, when v0.2.36 started. (devops roadmap reprioritize)

  4. added this to the v0.2.37 milestone on Oct 17, 2026
  5. dan-petty commented on Oct 17, 2026

    @dan-petty
    OwnerAuthor

    Readiness check for v0.2.37, against release/v0.2.36 at 22d8748. Line numbers are at that commit.

    Status: needs a split. Its dependencies have landed. It is a tool-layer fix, so the #1137 freeze doesn't apply.

    Today

    • src/devops_cli/security/semgrep.py:124-133 runs scan --json --config p/default … --disable-nosem --quiet, without --metrics off or --sarif.
    • build_semgrep_cmd (src/devops_cli/config/commands.py:214-225) builds the same command.
    • The scanner subprocess gets no environment (src/devops_cli/security/base.py:521-522).
    • p/default is pulled live (defaults.py:127).
    • Batches are split by file count only (defaults.py:246, semgrep.py:259-275), at 300 s each, with no total budget.
    • paths.scanned is read nowhere.

    Done

    • 1.179.0 is pinned (tools_lock/semgrep.in, tools.lock:381-387).
    • The rule pack is used only with the default config (semgrep.py:128-132).
    • Targets are materialised under the workdir (:202-213).
    • SEMGREP_ENABLE_VERSION_CHECK=0 is set, but only for the pack tests (src/devops_cli/review/rules_pack.py:231).

    References that moved

    • semgrep.py:93-114 → :124-158 and :259-298.
    • config.py:514 is a loop-input site.

    Dependencies

    Gaps in the body

    • paths.scanned is only in the JSON output, so the run needs both --sarif and JSON, plus the SARIF parser (src/devops_cli/security/sarif.py:484).
    • There is no CLI surface for the fetch step, and no behaviour for a missing or stale cache.
    • "Recorded as a review input" names no location (run_store.review_setup, src/devops_cli/ai/run_store.py:150).
    • There is no value for the total budget, and no rule for splitting batches by language or size.
    • Are devops scan semgrep (scan.py:394) and builtin_tools.py:350 in scope?
    • Keep --disable-nosem?
    • "Registry on by default" is only proposed.

    Slices (M–L overall)

    Tests use a fake subprocess with recorded JSON and SARIF, and check rule ids only.

    1. (S/M) The flags, the environment, SARIF, and the pack always on.
    2. (M) A registry cache in user_data_root() (src/devops_cli/core/repo.py:294): digest, TTL, skipped interfile rules and licences.
    3. (M) Batching by language and size, a total budget, and the paths.scanned check.
  6. removed this from the v0.2.37 milestone on Oct 17, 2026
  7. dan-petty commented on Oct 17, 2026

    @dan-petty
    OwnerAuthor

    Moved to the backlog: it was New, not Ready, when v0.2.37 started. (devops roadmap reprioritize)

  8. added this to the v0.2.39 milestone on Oct 20, 2026
  9. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1930, merged into release/v0.2.39 as 9d6d204.

    Cause

    A review names files to Semgrep. Semgrep scans a named file only when a loaded rule covers its language, and it lists the files that it scanned in paths.scanned. The review did not read that list. A file that Semgrep left out therefore looked scanned, and a scan that found nothing looked clean for every file.

    Change

    ScanOutcome.unscanned maps each file that a scan left out to the reason. merge_outcomes keeps the files of every batch. SemgrepScanner.unscanned_files compares the staged files of a review with paths.scanned. A scan that leaves files out has the status coverage_gap.

    The coverage matrix shows each such file as not scanned(<reason>), and the other files of the scan stay scanned. The Static Analyzers table and static_analyzer_reasons in profile.json show the count of such files. The executive summary line and the console summary name an analyzer with a coverage gap, for example Coverage gap: Semgrep.

    Batches by suffix and a time budget are not built. Offline, one run of 300 files took 81 to 93 s against a scanner timeout of 300 s. The batches of 100 files stay. The comment on DEFAULT_SEMGREP_REVIEW_BATCH_FILES carries the new figures.

    Existing tool considered

    Semgrep gives the list in its own JSON (paths.scanned), and the code uses it as it is. The code maps that one key into ScanOutcome and nothing more. It is about 25 lines in security/semgrep.py, 25 in security/base.py and 75 in ai/review/pipeline.py. It took about 35…

    13 file(s) changed.

    How it was verified

    Check runs at a1ba552:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Rule Pack Tests: pass
    • Fail-to-Pass Self-Check: pass
    • Tests & Coverage: pass
    • Fail-to-Pass Check: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • Changed-Test Independence: pass
    • Analyze (python): pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1144-semgrep-pinned-offline.md:

    • Every semgrep scan command devops-cli builds carries --metrics off and --disable-version-check, and none carries --dataflow-traces. Every scan keeps --disable-nosem. Red first: the builder, the review with a local config, devops scan sast --config ./local-rules, the agent tool and the canary each failed on the argv they built, which named neither flag and, for all but the canary, left out the pack. Now test_command_builders, test_a_review_runs_the_rule_pack_whatever_config_it_names, test_scan_sast_runs_the_rule_pack_next_to_the_config_it_names, test_the_agent_semgrep_tool_sends_no_metrics_and_runs_the_rule_pack and test_the_semgrep_canary_sends_no_metrics_and_checks_no_version pass, and tests/test_scanner_contract.py holds the review's command to the recording.
    • devops-cli's pack runs on every review and every devops scan sast run, whatever --config names.
    • Findings from SARIF: dropped, for the reasons in the description. Findings come from the JSON on stdout.
    • devops review rules fetch caches the ruleset with its ETag. It writes both files atomically, the ruleset first. It asks the registry whether the cached ruleset changed before it downloads it again. Red first: the module and the command did not exist. Now tests/test_semgrep_registry.py serves two synthetic rulesets in the shape of the registry's own through the shared web stub. No registry rule text is committed. The tests check the cached bytes and ETag, the read timeout and the files left in the directory. They check the ETag sent on a refetch, a 304 that rewrites neither file, and a changed ruleset that replaces both. They check that no ETag is sent without a ruleset to keep. They check that an answer without an ETag removes the old one. They check that the ruleset is written before its ETag. Each refusal writes nothing and leaves the earlier cache as it was. The refusals are a bad status, a 304 to a fetch that held nothing, a redirect and a transport failure. The others are an oversize answer and a body that is not a ruleset.
    • --dry-run makes no request and prints the URL and the two paths. The test checks the whole output and that the stub received nothing and no directory was created.
    • A ruleset name outside the registry grammar (p/.., p/a/b, p/default?x=1, a name needing percent-encoding, no kind) is refused before any request and writes nothing.
    • A review, devops scan sast, devops scan report and the agent tool read the cached registry ruleset offline. Red first: no consumer read the cache, so each scan passed --config p/default and Semgrep downloaded it. Now tests/test_security_semgrep.py and tests/test_builtin_tools.py check the argv of each scan over a synthetic cached ruleset. They also check the working directory of each scan when Semgrep starts. A scan outside a review runs from the cache directory and names ./p-default.yaml. A review holds the bytes of the ruleset under the digest name.
    • A file of the reviewed tree with the name of the ruleset file does not replace the ruleset (test_a_reviewed_file_named_like_the_written_ruleset_does_not_replace_it in tests/test_security_semgrep.py). The planted .semgrep.yml, .semgrep/ rule and .semgrepignore of a hostile tree stay out (tests/test_review_untrusted_tree.py).
    • A cache that a fetch replaces during a review changes no batch. Each batch scans with the bytes that were hashed (test_every_batch_of_a_review_scans_with_the_bytes_that_were_read_when_the_cache_is_replaced).
    • A scan outside a review returns plain rule ids. The scan runs from the cache directory with --config ./<file> and absolute targets, for a directory and for a file (tests/test_security_semgrep.py, tests/test_builtin_tools.py). The scanner fake cannot run Semgrep. The plain ids come from the real runs in the feasibility notes.
    • The digest of the cached file is recorded in profile.json as semgrep_registry_digest, and it is empty without a cache. devops review score lists it (tests/test_review_profile.py, tests/test_review_static_analyzers.py, tests/test_review_score.py).
    • A missing cache, or a file edited until it is no ruleset, leaves the review on the rule pack alone. The outcome is coverage_gap and its reason names devops review rules fetch. Review.md and profile.json show it. devops scan sast with a registry id and no cache prints the reason and exits 1, with no report and no Semgrep run. The agent tool returns the reason. A dry run, a local config and a scan that did not run keep their own outcomes.
    • A cache older than DEFAULT_SEMGREP_REGISTRY_TTL_SECONDS is used with a warning. This holds for the review, devops scan sast, devops scan report and the agent tool. The warning names the age, taken from the modification time of the file, and the fetch command. A current cache gives no warning. A fetch that finds the ruleset current makes the cache new again (tests/test_semgrep_registry.py, with the clock frozen).
    • A target missing from paths.scanned is in ScanOutcome.unscanned, and the status is coverage_gap. Before the change, ScanOutcome had no unscanned, and merge_outcomes kept no such files. tests/test_security_semgrep.py runs the adapter of the review over the scanner fake. The recorded run lists app.py only, so a style.css named with it is in unscanned. A review whose files are all listed is ran.
    • Four tests guard the edges of the list. Every batch adds its files to the merged outcome. A missing ruleset keeps its own reason and the files. A scan of a directory leaves no file out. A report without a list under paths.scanned leaves no file out.
    • A review through the orchestrator shows the files in the Coverage section and the count in the Static Analyzers section. In tests/test_security_semgrep.py, Semgrep leaves out two of four files. The test checks the matrix, the two sections of review.md and static_analyzer_reasons in profile.json. tests/test_review_worktree_regression.py has unit tests of the matrix and the tool state, and tests/test_scan_outcomes_and_gating.py tests the outcome and the merge.
    • The executive summary line and the console summary name an analyzer with a coverage gap, such as Coverage gap: Semgrep (tests/test_review_report_summary.py, tests/test_review_static_analyzers.py). Before, a Semgrep scan that left files out was missing from both.
    • Batches and a budget were measured and are not needed. One run of 300 files took 81 to 93 s against a timeout of 300 s (see Feasibility). The comment on DEFAULT_SEMGREP_REVIEW_BATCH_FILES carries the new figures.
    • Not done: batches of one suffix that close at 100 files or 1.5 MB, under one budget of 300 s. The measurement shows that they are not needed.
    • Pending a person: decide whether interfile rules are skipped with --exclude-rule (28 rules; the OSS engine ran them without error). The skip needs an exclude-rules parameter in build_semgrep_cmd and the interfile ids from the cached file.
    • Pending a person: decide whether devops review rules fetch also stores the digest of the file it wrote. Then a cache edited into another valid ruleset counts as edited. Today only a file that is no longer a ruleset does, and the digest in profile.json shows the change.
    • devops review rules fetch ran against the live registry into the real user data root on 2026-10-22. It cached the 1,074 rules of p/default and their ETag.
    • Pending a person: on the loop input, Semgrep completes in 5/5 reviews and S11's Semgrep pair and config.py:514 reappear.
    • Pending a person: file an issue for the files that devops-cli drops before Semgrep sees them (see A limit). The issue asks for a status of those files in the matrix.
  10. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1930, merged into release/v0.2.39 as 9d6d204.

    Cause

    A review names files to Semgrep. Semgrep scans a named file only when a loaded rule covers its language, and it lists the files that it scanned in paths.scanned. The review did not read that list. A file that Semgrep left out therefore looked scanned, and a scan that found nothing looked clean for every file.

    Change

    ScanOutcome.unscanned maps each file that a scan left out to the reason. merge_outcomes keeps the files of every batch. SemgrepScanner.unscanned_files compares the staged files of a review with paths.scanned. A scan that leaves files out has the status coverage_gap.

    The coverage matrix shows each such file as not scanned(<reason>), and the other files of the scan stay scanned. The Static Analyzers table and static_analyzer_reasons in profile.json show the count of such files. The executive summary line and the console summary name an analyzer with a coverage gap, for example Coverage gap: Semgrep.

    Batches by suffix and a time budget are not built. Offline, one run of 300 files took 81 to 93 s against a scanner timeout of 300 s. The batches of 100 files stay. The comment on DEFAULT_SEMGREP_REVIEW_BATCH_FILES carries the new figures.

    Existing tool considered

    Semgrep gives the list in its own JSON (paths.scanned), and the code uses it as it is. The code maps that one key into ScanOutcome and nothing more. It is about 25 lines in security/semgrep.py, 25 in security/base.py and 75 in ai/review/pipeline.py. It took about 35…

    13 file(s) changed.

    How it was verified

    Check runs at a1ba552:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Rule Pack Tests: pass
    • Fail-to-Pass Self-Check: pass
    • Tests & Coverage: pass
    • Fail-to-Pass Check: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • Changed-Test Independence: pass
    • Analyze (python): pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1144-semgrep-pinned-offline.md:

    • Every semgrep scan command devops-cli builds carries --metrics off and --disable-version-check, and none carries --dataflow-traces. Every scan keeps --disable-nosem. Red first: the builder, the review with a local config, devops scan sast --config ./local-rules, the agent tool and the canary each failed on the argv they built, which named neither flag and, for all but the canary, left out the pack. Now test_command_builders, test_a_review_runs_the_rule_pack_whatever_config_it_names, test_scan_sast_runs_the_rule_pack_next_to_the_config_it_names, test_the_agent_semgrep_tool_sends_no_metrics_and_runs_the_rule_pack and test_the_semgrep_canary_sends_no_metrics_and_checks_no_version pass, and tests/test_scanner_contract.py holds the review's command to the recording.
    • devops-cli's pack runs on every review and every devops scan sast run, whatever --config names.
    • Findings from SARIF: dropped, for the reasons in the description. Findings come from the JSON on stdout.
    • devops review rules fetch caches the ruleset with its ETag. It writes both files atomically, the ruleset first. It asks the registry whether the cached ruleset changed before it downloads it again. Red first: the module and the command did not exist. Now tests/test_semgrep_registry.py serves two synthetic rulesets in the shape of the registry's own through the shared web stub. No registry rule text is committed. The tests check the cached bytes and ETag, the read timeout and the files left in the directory. They check the ETag sent on a refetch, a 304 that rewrites neither file, and a changed ruleset that replaces both. They check that no ETag is sent without a ruleset to keep. They check that an answer without an ETag removes the old one. They check that the ruleset is written before its ETag. Each refusal writes nothing and leaves the earlier cache as it was. The refusals are a bad status, a 304 to a fetch that held nothing, a redirect and a transport failure. The others are an oversize answer and a body that is not a ruleset.
    • --dry-run makes no request and prints the URL and the two paths. The test checks the whole output and that the stub received nothing and no directory was created.
    • A ruleset name outside the registry grammar (p/.., p/a/b, p/default?x=1, a name needing percent-encoding, no kind) is refused before any request and writes nothing.
    • A review, devops scan sast, devops scan report and the agent tool read the cached registry ruleset offline. Red first: no consumer read the cache, so each scan passed --config p/default and Semgrep downloaded it. Now tests/test_security_semgrep.py and tests/test_builtin_tools.py check the argv of each scan over a synthetic cached ruleset. They also check the working directory of each scan when Semgrep starts. A scan outside a review runs from the cache directory and names ./p-default.yaml. A review holds the bytes of the ruleset under the digest name.
    • A file of the reviewed tree with the name of the ruleset file does not replace the ruleset (test_a_reviewed_file_named_like_the_written_ruleset_does_not_replace_it in tests/test_security_semgrep.py). The planted .semgrep.yml, .semgrep/ rule and .semgrepignore of a hostile tree stay out (tests/test_review_untrusted_tree.py).
    • A cache that a fetch replaces during a review changes no batch. Each batch scans with the bytes that were hashed (test_every_batch_of_a_review_scans_with_the_bytes_that_were_read_when_the_cache_is_replaced).
    • A scan outside a review returns plain rule ids. The scan runs from the cache directory with --config ./<file> and absolute targets, for a directory and for a file (tests/test_security_semgrep.py, tests/test_builtin_tools.py). The scanner fake cannot run Semgrep. The plain ids come from the real runs in the feasibility notes.
    • The digest of the cached file is recorded in profile.json as semgrep_registry_digest, and it is empty without a cache. devops review score lists it (tests/test_review_profile.py, tests/test_review_static_analyzers.py, tests/test_review_score.py).
    • A missing cache, or a file edited until it is no ruleset, leaves the review on the rule pack alone. The outcome is coverage_gap and its reason names devops review rules fetch. Review.md and profile.json show it. devops scan sast with a registry id and no cache prints the reason and exits 1, with no report and no Semgrep run. The agent tool returns the reason. A dry run, a local config and a scan that did not run keep their own outcomes.
    • A cache older than DEFAULT_SEMGREP_REGISTRY_TTL_SECONDS is used with a warning. This holds for the review, devops scan sast, devops scan report and the agent tool. The warning names the age, taken from the modification time of the file, and the fetch command. A current cache gives no warning. A fetch that finds the ruleset current makes the cache new again (tests/test_semgrep_registry.py, with the clock frozen).
    • A target missing from paths.scanned is in ScanOutcome.unscanned, and the status is coverage_gap. Before the change, ScanOutcome had no unscanned, and merge_outcomes kept no such files. tests/test_security_semgrep.py runs the adapter of the review over the scanner fake. The recorded run lists app.py only, so a style.css named with it is in unscanned. A review whose files are all listed is ran.
    • Four tests guard the edges of the list. Every batch adds its files to the merged outcome. A missing ruleset keeps its own reason and the files. A scan of a directory leaves no file out. A report without a list under paths.scanned leaves no file out.
    • A review through the orchestrator shows the files in the Coverage section and the count in the Static Analyzers section. In tests/test_security_semgrep.py, Semgrep leaves out two of four files. The test checks the matrix, the two sections of review.md and static_analyzer_reasons in profile.json. tests/test_review_worktree_regression.py has unit tests of the matrix and the tool state, and tests/test_scan_outcomes_and_gating.py tests the outcome and the merge.
    • The executive summary line and the console summary name an analyzer with a coverage gap, such as Coverage gap: Semgrep (tests/test_review_report_summary.py, tests/test_review_static_analyzers.py). Before, a Semgrep scan that left files out was missing from both.
    • Batches and a budget were measured and are not needed. One run of 300 files took 81 to 93 s against a timeout of 300 s (see Feasibility). The comment on DEFAULT_SEMGREP_REVIEW_BATCH_FILES carries the new figures.
    • Not done: batches of one suffix that close at 100 files or 1.5 MB, under one budget of 300 s. The measurement shows that they are not needed.
    • Pending a person: decide whether interfile rules are skipped with --exclude-rule (28 rules; the OSS engine ran them without error). The skip needs an exclude-rules parameter in build_semgrep_cmd and the interfile ids from the cached file.
    • Pending a person: decide whether devops review rules fetch also stores the digest of the file it wrote. Then a cache edited into another valid ruleset counts as edited. Today only a file that is no longer a ruleset does, and the digest in profile.json shows the change.
    • devops review rules fetch ran against the live registry into the real user data root on 2026-10-22. It cached the 1,074 rules of p/default and their ETag.
    • Pending a person: on the loop input, Semgrep completes in 5/5 reviews and S11's Semgrep pair and config.py:514 reappear.
    • Pending a person: file an issue for the files that devops-cli drops before Semgrep sees them (see A limit). The issue asks for a status of those files in the matrix.
  11. added a commit that references this issue on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/reviewscope/securitytype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions