Skip to content

SC4: OSV query batches are never packed across query_batch() calls, so later dependency files lose all advisory coverage #1174

Open

Description

@Skare69

Affected versions: v2.13.0 through v2.13.6 and current main (head f9bb13dd on 2026-11-23, MAX_OSV_QUERY_BATCHES = 4 unchanged).

Summary

OsvQueryBudget is created once per scan and shared by every query_batch() call of that scan
(static_patterns_supply_chain.py creates one budget and passes it to each per-manifest call).
query_batch() consumes one batch of MAX_OSV_QUERIES_PER_BATCH = 64 queries per 64-query chunk
and increments budget.batches_sent. When batches_sent >= MAX_OSV_QUERY_BATCHES = 4, it notes an
output_limit limitation and breaks. Capacity left in the last batch is never reused by a later
call: a scan with a large lockfile plus a second manifest loses the whole advisory coverage of the
second manifest.

Reproduction

Any skill folder with:

  1. package.json with a few npm dependencies (its lookups hit the cache of the lockfile pass),
  2. package-lock.json that pins about 220 npm packages (4 batches: 64/64/64/28),
  3. requirements.txt with exact PyPI pins (any pins work; zero-advisory pins isolate the effect).

Run a static scan (--no-llm). Observed on v2.13.0 with an instrumented
query_batch and OsvQueryBudget.note:

  • QUERY PyPI n=4 immediately followed by NOTE reason=output_limit obs=5 limit=4.
  • The report marks requirements.txt partial with
    static_patterns_supply_chain_dependencies_output_limit.
  • The 4 PyPI pins receive zero OSV advisory lookups. Downstream consumers that fail closed on
    incomplete coverage must reject the skill.

Expected behavior

The 4 PyPI queries fit in the 36 free slots of batch 4 (28/64 used). The scan should pack queries
across query_batch() calls so the total request count stays at 4.

Suggested fixes (either one)

  1. Pack queries across calls: aggregate each call's uncached queries into the shared budget's
    pending pool, or let query_batch() fill the current batch's free slots before it opens a new
    batch. Request count and rate stay identical.
  2. Raise MAX_OSV_QUERY_BATCHES or make it configurable, as v2.13.3 did for TP4 with
    SKILLSPECTOR_TP4_MAX_BATCHES (and as fix(dependency-sources): make the analysis ceiling configurable #706 did for the dependency-sources ceiling), for example
    SKILLSPECTOR_OSV_MAX_BATCHES. This raises the request count, so option 1 is the smaller fix.

Impact

Every skill with one dependency file above 192 uncached queries plus any further dependency file
silently loses coverage for all later files. The findings stay complete, but the advisory coverage
the scan vouches for is missing, and fail-closed consumers reject the skill.

Related


AI-assisted: an AI coding agent on the Ottr board found and analyzed this issue, and wrote this report. A human reviewed it before filing. The instrumented reproduction above ran on real scanner output.

Activity

  1. Skare69 commented on Nov 23, 2026

    @Skare69
    Author

    Proposed fix: #1177

  2. added 2 commits that reference this issue on Nov 25, 2026
    4a3f0d4
    19f967f
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions