Skip to content

fix(review): the scanned-clean check invalidates only claims about a dependency's own advisories #1044

Closed

Description

@dan-petty

Problem

_check_scanned_clean_dependency (src/devops_cli/ai/review/verification.py:678-719) invalidates a finding when two things hold:

  • its title and description contain "vulnerab", "cve", "advisory", "outdated" or "unpatched" (:694-696);
  • they name, as a word, a dependency the session scanned CLEAN with no advisory record (:698-708).

It writes INVALIDATED deterministic:scanned_clean_dependency with the reason "This run's own advisory scan reports CLEAN" (:710-719). It runs among the early checks (_check_early_hallucinations, :1345-1366, call at :1361), before any file-level check.

It was written for one case. Session 20260922-034125 reported "Outdated FastAPI and Uvicorn versions" at pyproject.toml:33 while its own scan listed both CLEAN (tests/test_review_verification.py:1064-1084). The predicate does not check that the claim is about the package. "Vulnerability" is in almost every security finding. The scanned names include common words: kubernetes, docker, keyring, pytest, bandit.

How #948 armed it. Before #948 (b6847e9), _verify_single_file_payload built ReviewResult(findings=findings_to_verify) with no dependencies (pipeline.py:2861-2869 at b6847e9). _validate_segment_findings passes result.external_dependencies to pre-verification (verification.py:2262-2264), so the check returned at its first line (:691-692) on every orchestrator review. At b6847e9 it could fire only on the runner's page path (runner.py:1014-1020 at b6847e9), whose result carries only the dependencies a model wrote in its reply. #948 listed "The session's dependencies reach _verify_single_file_payload" as an acceptance criterion and wired them (lines at da50329):

  • _session_dependencies (pipeline.py:1702-1709) collects every dependency the session scanned. _scanner_advisories (:1718) adds the advisories Trivy looked up.
  • Stage 4 builds dependencies = [*_session_dependencies(file_payloads), *self.scanner_advisories] (:3194) and passes them through _safe_verify_file_payload (:2969-2990) to _verify_single_file_payload (:3018-3034).
  • That puts them on the result: ReviewResult(findings=..., external_dependencies=list(dependencies)) (:3060-3062).

The wiring is right. Advisory stripping (_strip_unbacked_advisories, verification.py:644-675) and the placeholder check (:722-753) need it: without the session's dependencies, every CVE a finding cites would be stripped as unbacked. But the predicate was left as written, so the check now sees all of the session's scanned dependencies (58 in S8) on every file.

Golden cases. At da50329, with S8's 58 CLEAN dependencies, the check invalidates all four:

  • tests/test_security_bandit.py:107 LOW, "Potential Path Traversal in Bandit Mock" (S8, 20261003-012555). A path-traversal claim about a test helper. S8 INVALIDATED it as "bandit CLEAN". Right outcome, wrong reason.
  • src/devops_cli/commands/k8s/networking.py:561 HIGH, "Command Injection Vulnerability in Kubernetes Process Execution" (20260928-040906). A re-verify of that session invalidated it as "kubernetes CLEAN" at 06:29:55 UTC on 2026-09-28, with 3 other findings in the same findings.json.
  • src/devops_cli/ai/spend/pricing.py:455-473 HIGH, "Unvalidated SSRF in _fetch_raw_pricing_payload" (fix(review): the devsecops persona reports misconfiguration and error-handling defects again, scored against a fixed recall set #1015's recall baseline run 20261002-232955, under .data/measurements/recall/baseline/reviews/). An SSRF claim that names httpx2. Its own run INVALIDATED it through the localhost rule.
  • k8s/gpu-feature-discovery/daemonset.yaml:57 MEDIUM, Semgrep yaml.kubernetes.security.allow-privilege-escalation (20260930-053418, saved with an absolute path, VERIFIED by llm there). The rule's own text names Kubernetes and says the fix makes containers "less vulnerable to privilege escalation attacks".

Replay over saved candidates. At da50329, with S8's 58 CLEAN dependencies, over 5,904 candidates in 36 sessions:

  • The check fires on 111 (83 distinct by location and title). 26 were VERIFIED in their own runs, 75 were reportable, and 27 were reportable at CRITICAL or HIGH.
  • By name: kubernetes 52, httpx2 25, keyring 10, pytest 6, docker 5, bandit 5.
  • 34 of the 111 (14 distinct) are Semgrep yaml.kubernetes.security.* findings. All 34 were reportable and 10 were VERIFIED. A word in the rule's text discards the scanner's own misconfiguration finding.
  • S9 (20261003-021501, 49 candidates) has no hit, so the 5,855 candidates before it give the same 111 the evaluation reports (.data/review-evaluation-20261003-s7-s8.md, section 4).

The hits come with the files a review covers. Replayed the same way, the four release/v0.2.24 branch reviews of 2026-09-30, which covered k8s/ manifests, give 5, 5, 8 and 9 hits a run, and the whole-repository path review 20261001-224227 gives 25. The nine release/v0.2.25 branch reviews since 2026-10-02 give 0 or 1 a run. #1015 restores Kubernetes network findings in this release, but its recall runs raised 10 NetworkPolicy candidates and none names a scanned package, so the check leaves them alone.

A CLEAN scan refutes one claim: that a dependency, at the version the project pins, carries a known advisory. It says nothing about how the project's code uses the package, about a Kubernetes manifest, or about whether a version written in a doc is current. A predicate that needs advisory wording fires on 9 of the 111 (7 distinct). The wording is the word "CVE" or "CVEs" (with or without an id), a GHSA id, "advisory", "unpatched", "known vulnerability" or "vulnerable version", and bare "vulnerab" and "outdated" are dropped. With a CVE id required instead of the word, it fires on 5 (4 distinct). All 9 were INVALIDATED in their own runs for other reasons, and none was VERIFIED. Both existing positive cases still fire: "Older releases may contain unpatched security vulnerabilities" (test_review_verification.py:1076-1077) and "The pinned requests version has an unpatched CVE" (tests/test_review_advisory_backing.py:182-185).

Acceptance criteria

  • _check_scanned_clean_dependency fires only when the finding names a CLEAN dependency with no advisory record and speaks of that dependency's advisories: the word "CVE" or "CVEs" (an id such as CVE-2024-24762 included), a GHSA id, "advisory" or "advisories", "unpatched", "known vulnerability" or "known vulnerabilities", or "vulnerable version". Bare "vulnerab" and "outdated" no longer trigger it. Its docstring says what a CLEAN scan refutes.
  • A parametrised test feeds the four golden findings, trimmed to fixtures, with a dependency list that holds bandit, kubernetes and httpx2 CLEAN: tests/test_security_bandit.py:107 (S8), commands/k8s/networking.py:561 (20260928-040906), ai/spend/pricing.py:455-473 (20261002-232955) and the Semgrep daemonset.yaml:57 finding (20260930-053418). The check returns None for each. The test fails on the current code, which invalidates all four.
  • A claim that "kubernetes 29.0.0 carries known vulnerabilities", against kubernetes CLEAN, is still INVALIDATED deterministic:scanned_clean_dependency. A claim about the package itself stays covered.
  • The existing cases keep their outcomes: tests/test_review_verification.py:1064-1129 and tests/test_review_advisory_backing.py:158-201.
  • The PR records a replay over saved candidates with S8's 58 dependencies: hits fall from 111 (83 distinct, 26 VERIFIED) to at most 9 (7 distinct, 0 VERIFIED). The replay reads .data once, by hand. No test reads it.
  • The tests run offline, call no model, and each runs in under 1 s.
  • changelog.d/1044.md records the fix under ### Fixed. CHANGELOG.md is not edited.
  • uv run devops ci passes.
  • (person-run) On the homelab gateway, run a branch review of release/v0.2.25 at the fix commit, with verification. Record the check's hits. No hit is a Semgrep, kube-linter or Bandit finding, and each hit's text speaks of the named package's advisories.

Key questions

Depends on: none.
Order: lands before the v0.2.25 cut. #1015's network-recall re-run uses --no-verification (.data/measurements/recall/analysis.md, section 3, "What a re-run must show", step 2), which skips this check, so it does not wait for this item. #1015's precision guard (step 7) runs with verification, so it runs after this item lands or reports this check's hits separately. This item touches only _check_scanned_clean_dependency (verification.py:678-719) and its tests. #845 edits verdict application in the same file, in other functions, so whichever lands second rebases.
Related: #948 (wired the dependencies). #1015 (recall of misconfiguration findings). #1024 (drops scanner rules that never produced a valid finding here). #770 (one rulebook for deterministic checks). The criteria-verdict fix filed with this item.

Activity

  1. added
    type/bug
    scope/review
    priority/p1-high
    on Oct 3, 2026
  2. added this to the v0.2.25 milestone on Oct 3, 2026
  3. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Closed by #1058, merged into release/v0.2.25.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

  4. added a commit that references this issue on Oct 3, 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/reviewtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions