fix: mark NVD records as disputed status based on cveTags - #3633
Open
pujitha24 wants to merge 1 commit into
Open
fix: mark NVD records as disputed status based on cveTags#3633pujitha24 wants to merge 1 commit into
pujitha24 wants to merge 1 commit into
Conversation
Motivation: NVD API records can be labeled "disputed" via the cveTags field (https://csrc.nist.gov/schema/nvd/api/2.0/cve_api_json_2.0.schema) independently of the vulnStatus field. Grype's NVD unmarshaller never captured cveTags, and the v6 transformer only derived vulnerability handle status from vulnStatus, so these records ended up with an incorrect status (e.g. unknown) instead of disputed. For example, CVE-2001-1517 has vulnStatus "Deferred" (not a status grype maps to anything) but cveTags contains a "disputed" tag, so its grype db status should be disputed. Approach: - Add a CveTags field (and CveTag struct) to CveItem in grype/db/internal/provider/unmarshal/nvd/cve.go, matching the NVD API schema shape, plus an IsDisputed() helper that does a case-insensitive scan for a "disputed" tag. - In grype/db/v6/build/transformers/nvd/transform.go, getVulnStatus now checks IsDisputed() before falling back to the vulnStatus-based switch, since a record can carry a disputed cveTag while vulnStatus is any other value (e.g. "Analyzed" or an unrecognized one like "Deferred"). This means a disputed tag takes precedence over any other vulnStatus mapping, including "rejected" - this is an intentional choice since disputed and rejected are independent, non-mutually-exclusive signals in the NVD data and disputed is the more actionable/specific one to surface. Validation: Ran `go build ./...` (passes) and `go test ./grype/db/...` (all packages pass), including the new grype/db/v6/build/transformers/nvd TestGetVulnStatus table test, which reproduces the exact scenario from the issue (vulnStatus "Deferred" + a disputed cveTag -> db.VulnerabilityDisputed), matching CVE-2001-1517's real NVD data. Also fed the exact JSON payload from the issue through the updated CveItem JSON decoding (in a local scratch test, not included in this commit) and confirmed CveTags populates correctly and IsDisputed() returns true. This change affects the shared unmarshal/transform packages used to build the grype v6 vulnerability database; it does not alter grype's own scan-time behavior in this repo, only the derived status of disputed NVD records once a database is rebuilt with this logic. Report: anchore#3248 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Author
|
Just checking in on this — it'''s rebased and green, happy to make any changes that would help review go smoother. |
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.
Motivation:
NVD API records can be labeled "disputed" via the cveTags field
(https://csrc.nist.gov/schema/nvd/api/2.0/cve_api_json_2.0.schema)
independently of the vulnStatus field. Grype's NVD unmarshaller never
captured cveTags, and the v6 transformer only derived vulnerability
handle status from vulnStatus, so these records ended up with an
incorrect status (e.g. unknown) instead of disputed. For example,
CVE-2001-1517 has vulnStatus "Deferred" (not a status grype maps to
anything) but cveTags contains a "disputed" tag, so its grype db
status should be disputed.
Approach:
grype/db/internal/provider/unmarshal/nvd/cve.go, matching the NVD
API schema shape, plus an IsDisputed() helper that does a
case-insensitive scan for a "disputed" tag.
now checks IsDisputed() before falling back to the vulnStatus-based
switch, since a record can carry a disputed cveTag while vulnStatus
is any other value (e.g. "Analyzed" or an unrecognized one like
"Deferred"). This means a disputed tag takes precedence over any
other vulnStatus mapping, including "rejected" - this is an
intentional choice since disputed and rejected are independent,
non-mutually-exclusive signals in the NVD data and disputed is the
more actionable/specific one to surface.
Validation:
Ran
go build ./...(passes) andgo test ./grype/db/...(allpackages pass), including the new grype/db/v6/build/transformers/nvd
TestGetVulnStatus table test, which reproduces the exact scenario
from the issue (vulnStatus "Deferred" + a disputed cveTag ->
db.VulnerabilityDisputed), matching CVE-2001-1517's real NVD data.
Also fed the exact JSON payload from the issue through the updated
CveItem JSON decoding (in a local scratch test, not included in this
commit) and confirmed CveTags populates correctly and IsDisputed()
returns true.
This change affects the shared unmarshal/transform packages used to
build the grype v6 vulnerability database; it does not alter grype's
own scan-time behavior in this repo, only the derived status of
disputed NVD records once a database is rebuilt with this logic.
Report: #3248
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com
Fixes #3248