Skip to content

feat(review): dependency advisories and the package inventory come from osv-scanner over the lockfiles, offline, with each advisory's own severity #1146

Closed

Description

@dan-petty

Problem

  • Every OSV batch hit is labelled HIGH, because the parser defaults to it [code: security/vulnerability_lookup.py:58-68].
  • Results go missing: there is no pagination, and zip(strict=False) drops results [code: :123].
  • Only exact pins are queried [code: ai/review/pipeline.py:2238-2241].
  • Regex extraction is slow and reads the wrong tree. It costs 47.3/100.6/123.3 s per loop run [measured: loop §7] and probes Path.cwd().
  • The inventory can describe devops-cli itself: security/sbom.py falls back to the running interpreter's distributions [code: security/sbom.py:66-83].
  • Hostnames leave the machine: Shodan and Radar send reviewed hostnames to third parties [code: pipeline.py:2210-2268].

Acceptance criteria

  • osv-scanner 2.6.0 runs over the commit's lockfiles with an offline database fetched separately (24 h TTL). The snapshot digest is recorded as a review input.
  • An AdvisoryAnchor carries purl@locked-version and the snapshot. Severity comes from the advisory, with no HIGH default.
  • The CycloneDX inventory is saved as environment facts. A missing lock is a coverage gap.
  • Removed from the review: the OSV client and extract_references. Shodan and Radar become opt-in, and sbom.py's runtime fallback is removed.
  • (person-run) On the S11 subject, results agree with uv audit.
  • Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each test under 1 s.
  • changelog.d/<n>.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
  • uv run devops ci passes.

Key questions

Strategic alignment

Update 2026-10-08: refinement

The defects stand. sbom.py is not part of the review; #1439 deletes its runtime fallback, so drop that criterion here (#1137's R6 sbom.py part goes to #1439). Lines: ai/review/pipeline.py:2807-2839, security/vulnerability_lookup.py:66, :123. #1429 fixes the Radar lookup itself.

Proposed design

Problem statement

The current OSV advisory lookup process has multiple defects: it defaults to HIGH severity for all advisories, lacks pagination support leading to missing results, only queries exact package pins, uses slow regex extraction that probes the wrong tree, and includes devops-cli's own runtime distributions in the inventory. Additionally, Shodan and Radar lookups send hostnames to third parties.

Acceptance criteria

  • Criterion 1: osv-scanner 2.6.0 runs over commit lockfiles with offline database fetched separately (24 h TTL) and records snapshot digest as review input
    Verification: Run devops review with osv-scanner 2.6.0 against a commit's lockfiles, verify it uses offline database and records snapshot digest in review input
  • Criterion 2: AdvisoryAnchor carries purl@locked-version and snapshot with severity from advisory instead of defaulting to HIGH
    Verification: Create an AdvisoryAnchor with different severity levels from advisories and verify the severity comes directly from the advisory, not defaulted to HIGH
  • Criterion 3: CycloneDX inventory is saved as environment facts with missing lock treated as coverage gap
    Verification: Run review on repository with missing lockfiles and verify it records missing locks as coverage gaps in environment facts
  • Criterion 4: OSV client and extract_references are removed from review, Shodan and Radar become opt-in, and sbom.py's runtime fallback is removed
    Verification: Verify that OSV client and extract_references are no longer called in review pipeline, and Shodan/Radar are disabled by default
  • Criterion 5: Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each test under 1 s
    Verification: Run all related tests in offline mode with fake tools and verify they complete under 1 second each

Key questions

Open questions

  • Why osv-scanner? (missing verified source)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#1143

Activity

  1. added
    type/feature
    scope/security
    scope/review
    priority/p1-high
    on Oct 3, 2026
  2. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #1353 and #1302 fix the advisory admission path (ai/review/pipeline.py:2881-2959) this item replaces; each fix survives the replacement, or this item carries it. Found by the 2026-10-08 backlog review.

  3. modified the milestone: v0.2.36 on Oct 11, 2026
  4. 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)

  5. added this to the v0.2.38 milestone on Oct 17, 2026
  6. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Amendment (2026-10-18): folded here by intake as a duplicate

    devops roadmap intake judged the candidate below a duplicate of this item and filed nothing, so its findings are recorded here for whoever plans or delivers this item. Candidate title: "fix(security): OSV lookups report each advisory's own severity and read every result page".

    Friction

    OSVClient labels every advisory HIGH, or CRITICAL when the advisory carries any CVSS v3 vector, whatever the score. A LOW advisory is reported as HIGH by devops commands that use the client outside the review: the dependency remediator and the scan_osv agent tool. The single-package query also reads only the first page of results. #1146 removes the client from the review, and #1137 Q13 decided that its other callers get a separate fix, which this item is.

    Evidence

    • src/devops_cli/security/vulnerability_lookup.py:58-63: is_critical = any("CVSS:3" in s.get("score", "") ...), then severity="CRITICAL" if is_critical else "HIGH". A CVSS vector string says nothing about the score.
    • src/devops_cli/security/vulnerability_lookup.py:139-147: the /v1/query reply is read as data.get("vulns", []), and its next_page_token is never followed.
    • Callers outside the review: src/devops_cli/security/dependency_remediator.py:212 (scan_and_plan, which filters by min_severity) and src/devops_cli/ai/tools/builtin_tools.py:437 (scan_osv).
    • AGENTS.md, "Zero Hardcoded Scoring": a score must come from the tool or the source, otherwise the field stays unset.

    Remedy

    • Take severity from the advisory itself: database_specific.severity when the source gives one (GitHub advisories give LOW, MODERATE, HIGH or CRITICAL), mapped through the existing severity normalisation, and UNKNOWN otherwise. Never infer it from a vector's presence.
    • Follow next_page_token on /v1/query until the reply has none, within the existing request timeout.
    • Tests: a recorded OSV reply with a LOW advisory that carries a CVSS v3 vector yields LOW, and one with no severity yields UNKNOWN. A two-page recorded reply yields every advisory, and dependency_remediator's min_severity filter drops the LOW one. All tests run offline through a fake transport, under 1 s each.
  7. self-assigned this
    on Oct 20, 2026
  8. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1747, merged into release/v0.2.38 as ea2ad78.

    Description

    Implements #1146 for release/v0.2.38:

    • Integrates osv-scanner 2.6.0 declarative adapter (OsvScanner) into the review pipeline and security scanner registry targeting lockfiles offline.
    • Caches offline database snapshot digest with 24-hour TTL (CONST_OSV_OFFLINE_DB_TTL_SECONDS = 86400.0) and records snapshot digest as a review profile input.
    • Findings carry AdvisoryAnchor models with purl@locked-version, snapshot digest, advisory id, and database origin.
    • Exact advisory severity is preserved from advisory records (database_specific or ecosystem_specific) without defaulting to HIGH; unspecified values map to UNKNOWN.
    • CycloneDX 1.5 SBOM inventory is saved in EnvironmentFacts and finding properties; missing lockfiles for recognized package manifests report coverage gaps.
    • Removed live OSV client queries and regex package extraction from the review pipeline.
    • Network threat intelligence lookups (Shodan InternetDB and Cloudflare Radar) are guarded behind an opt-in threat_intel flag (defaulting to False).
    • osv-scanner v2.6.0 is registered in recorded scanner runs and scanner_fake test harness.
    • All unit and integration tests run offline with fakes in <1s per test without network, real scanners, or live models.

    Fail-to-pass: not applicable: base lacks osv-scanner adapter and offline review scanner wiring.

    Closes #1146

    20 file(s) changed.

    How it was verified

    Check runs at a958286:

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

    Acceptance Criteria of docs/agent/tasks/task-1146-osv-scanner-offline-advisories.md:

    No Acceptance Criteria section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority/p1-highscope/reviewscope/securitytype/feature

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions