Skip to content

Handle pagination of the Docker Scout vulnerability API#197

Merged
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-169-xmpb2k
Jul 22, 2026
Merged

Handle pagination of the Docker Scout vulnerability API#197
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-169-xmpb2k

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

DockerScoutVulnerabilityProvider.FetchVulnerabilitiesAsync now walks the full Docker Scout vulnerability result set instead of reading only the first response. It follows a next-page marker on the response body, aggregates the advisories from every page into a single list, and maps them once. ScoutVulnerabilityResponse gains a next property ([JsonPropertyName("next")]) holding the absolute URL of the following page, or null on the last page. A hard cap of 50 pages guards against runaway loops: when it is hit, a new warning (DockerScoutPageCapReached, EventId 3419) is logged and the collected partial data is returned as Succeeded so the truncation is visible in the logs rather than silent. Each page reuses the cached JWT and the existing single 401 refresh-and-retry behavior from #164; the retry now restarts the whole fetch instead of an individual page, so at most one refresh happens per fetch.

Why

If the endpoint paginates (common for images with hundreds of CVEs), everything after the first page was silently dropped, making the stored finding count wrong without any error. Closes #169.

Linked issues

Closes #169

Review notes

The live response shape could not be verified against the real API in this environment: https://api.scout.docker.com/v1/repositories/{ns}/{repo}/tags/{tag}/vulnerabilities requires an authenticated Docker Hub JWT (returns HTTP 403 unauthenticated) and no Docker Hub credentials were available here. The pagination field is modeled on Docker's standard DRF-style next full-URL convention (the same shape Docker Hub's own v2 API uses). The change is backward compatible: a response without a next field yields exactly one page, identical to the previous behavior — all pre-existing tests still pass unchanged. If the live API turns out to expose pagination differently (a different body field name or RFC 5988 Link headers), only the marker read in FetchVulnerabilitiesAsync and the Next property would need adjusting; the loop, cap, and retry logic stay the same. New tests cover multi-page merge, the page-cap warning path, and a 401 on a later page refreshing the token once and restarting the whole paginated fetch.

Follow-up work

Confirm the next marker name against a live many-CVE response and adjust the JSON property if it differs.

Fetch every vulnerability page instead of only the first one, following the
response next-page marker and aggregating advisories before mapping. A hard
page cap of 50 guards against infinite loops; when it is hit, a warning
(EventId 3419) is logged and the collected partial data is returned as
Succeeded. Each page reuses the cached JWT and the existing single 401
refresh-and-retry, which now restarts the whole fetch rather than a single
page. Closes #169.
@sonarqubecloud

Copy link
Copy Markdown

@LarsLaskowski
LarsLaskowski merged commit 842da5c into main Jul 22, 2026
4 checks passed
@LarsLaskowski
LarsLaskowski deleted the claude/issue-169-xmpb2k branch July 22, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle pagination of the Docker Scout vulnerability API

2 participants