Skip to content

Conversation

willmurphyscode
Copy link
Contributor

This is a rebase / fixup of #660.

hasnatbashir and others added 5 commits October 6, 2025 06:14
* add cwe ids from nvd weaknesses data

Signed-off-by: Hasnat Bashir <[email protected]>

* replaced MustCompile as it can cause program to crash

Signed-off-by: Hasnat Bashir <[email protected]>

* added cwe handle and updated nvd transformer to include cwe information

Signed-off-by: Hasnat Bashir <[email protected]>

* Update entry.go

Signed-off-by: Hasnat Bashir <[email protected]>

---------

Signed-off-by: Hasnat Bashir <[email protected]>
Signed-off-by: Hasnat Bashir <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
}

func (w *writer) writeEntry(entry transformers.RelatedEntries) error { // nolint:gocognit
func (w *writer) writeEntry(entry transformers.RelatedEntries) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split this up rather than have a nolint for cognitive load and line count.

github.com/adrg/xdg v0.5.3
github.com/anchore/go-logger v0.0.0-20250318195838-07ae343dd722
github.com/anchore/grype v0.100.0
github.com/anchore/grype v0.100.1-0.20251003151438-d56b008a071c
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The models are not yet released, so we had to bump grype.

var cwes []grypeDB.CWEHandle
for _, w := range vulnerability.Weaknesses {
for _, d := range w.Description {
if d.Value == "NVD-CWE-noinfo" || d.Value == "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was formerly some more complex validation here, checking against a regex like CWE-\d+ or have the exact value NVD-CWE-Other. Since this is an uninterpreted string value in our data model, I don't see the need for further validation. Put another way: I don't want to change a regex if NVD comes up with another special CWE value besides NVD-CWE-noinfo and NVD-CWE-Other.

Here's a query:

❯ sqlite3 ./build/vulnerability.db "SELECT cwe, COUNT(*) AS occurrences FROM cwe_handles WHERE cwe NOT REGEXP '^CWE-\d+$' GROUP BY cwe ORDER BY occurrences DESC;"
NVD-CWE-Other|29673

Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode merged commit 95eb62a into main Oct 6, 2025
11 checks passed
@willmurphyscode willmurphyscode deleted the temp-pr-660 branch October 6, 2025 18:06
@spiffcs spiffcs added the enhancement New feature or request label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants