Add offline vs online parity harness; fix sdk.GetCpe query accumulation - #317
Merged
Conversation
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
force-pushed
the
2630-offline-online-parity
branch
from
July 23, 2026 10:36
5a0aaf4 to
e18d7dd
Compare
tcampbPPU
approved these changes
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 defaultgo test ./...; needsVC_TOKENand locally synced indices, and skips gracefully when either is missing. Invoke withmake test-parity.sdk.GetCpe:Client.Queryappends viaurl.Values.Add, so on a reusedClientthe secondGetCpecall 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 byGetPurl/GetPdns/GetRules/GetTags, and covered byTestGetCpeResetsQueryBetweenCalls.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.GetCpebug is the first drift the harness found while it was being written.Test plan
go test ./pkg/sdk/...passes (includesTestGetCpeResetsQueryBetweenCalls)go build ./...cleango test ./...(no tag) does not pick up the parity packageVC_TOKENset andcpecve+ at least one*-purlsindex synced:make test-parityruns the seeded cases and passes