-
Notifications
You must be signed in to change notification settings - Fork 27
write CWEs into database #705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* 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]>
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 == "" { |
There was a problem hiding this comment.
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]>
This is a rebase / fixup of #660.