Skip to content

Add offline vs online parity harness; fix sdk.GetCpe query accumulation - #317

Merged
alex-vulncheck merged 2 commits into
mainfrom
2630-offline-online-parity
Jul 24, 2026
Merged

Add offline vs online parity harness; fix sdk.GetCpe query accumulation#317
alex-vulncheck merged 2 commits into
mainfrom
2630-offline-online-parity

Conversation

@alex-vulncheck

@alex-vulncheck alex-vulncheck commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add pkg/parity, an opt-in integration suite that runs the same PURLs and CPEs through both the offline sqlite path and the live API, and diffs the CVE sets. Build-tag-gated (//go:build parity) so it stays out of the default go test ./...; needs VC_TOKEN and locally synced indices, and skips gracefully when either is missing. Invoke with make test-parity.
  • Fix sdk.GetCpe: Client.Query appends via url.Values.Add, so on a reused Client the second GetCpe call sent ?cpe=<prev>&cpe=<current> and the API keyed off the first param — every call after the first silently returned the previous CPE's CVE set. Now matches the reset-query pattern already used by GetPurl / GetPdns / GetRules / GetTags, and covered by TestGetCpeResetsQueryBetweenCalls.

Why

Offline mode is meant to emulate the API for users, but nothing in the tree today asserts that the two paths actually agree on the same input — past drift between them has surfaced only via customer reports. The parity harness closes that loop with a small, seeded fixture set so regressions get caught at PR time instead of in the field. The sdk.GetCpe bug is the first drift the harness found while it was being written.

Test plan

  • go test ./pkg/sdk/... passes (includes TestGetCpeResetsQueryBetweenCalls)
  • go build ./... clean
  • go test ./... (no tag) does not pick up the parity package
  • With VC_TOKEN set and cpecve + at least one *-purls index synced: make test-parity runs the seeded cases and passes

Adds pkg/parity, an opt-in integration suite that runs the same PURLs
and CPEs through the offline sqlite path and the live API, and diffs
the CVE sets. Fixture seeds cover previously reported drift shapes
(alpine SBOM returning zero vulns offline while online returns many;
a linux_kernel CPE returning zero in an offline SBOM scan while the
online CPE endpoint returns thousands) so they become permanent
regression cases.

Build-tag-gated (//go:build parity) so it never runs in the default
`go test ./...`; needs VC_TOKEN and locally synced indices, and skips
gracefully when either is missing. Invoke via `make test-parity`.
Client.Query appends via url.Values.Add, so on a reused Client a second
GetCpe call sent ?cpe=<prev>&cpe=<current> and the API keyed off the
first param — every call after the first silently returned the previous
CPE's CVE set. Matches the reset-query pattern already used by
sdk.GetPurl / GetPdns / GetRules / GetTags.

Adds TestGetCpeResetsQueryBetweenCalls: uses one Client to call GetCpe
twice against an httptest server and asserts each request carries
exactly one cpe param.
@alex-vulncheck
alex-vulncheck force-pushed the 2630-offline-online-parity branch from 5a0aaf4 to e18d7dd Compare July 23, 2026 10:36
@alex-vulncheck alex-vulncheck self-assigned this Jul 23, 2026
@alex-vulncheck
alex-vulncheck merged commit 32a310b into main Jul 24, 2026
12 checks passed
@alex-vulncheck
alex-vulncheck deleted the 2630-offline-online-parity branch July 24, 2026 08:48
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.

2 participants