Skip to content

Commit

Permalink
vex: add non-vuln advisories to the deleted slice
Browse files Browse the repository at this point in the history
There is a corner-case where an advisory can initially show products as
known_affected then as known_not_affected. Because this updated advisory
doesn't result in vulnerabilities the previous vulnerabilities
associated with this advisory are carried forward. This change adds any
advisories that don't lead to created vulnerabilities to the deleted
slice in-order to ensure no existing vulnerabilities that could be
related to this advisory are carried forward. In essence, it is as-if
the advisory has been parsed from the deletions.csv file.

Signed-off-by: crozzy <[email protected]>
  • Loading branch information
crozzy committed Nov 8, 2024
1 parent 5c68e27 commit 420823a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion rhel/vex/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ func (u *Updater) DeltaParse(ctx context.Context, contents io.ReadCloser) ([]*cl
}
}
vulns := []*claircore.Vulnerability{}
for _, vs := range out {
for n, vs := range out {
if len(vs) == 0 {
// If there are no vulns for this CVE make sure we signal that
// it is deleted in case it once had vulns.
deleted = append(deleted, n)
continue
}
vulns = append(vulns, vs...)
}

Expand Down
4 changes: 2 additions & 2 deletions rhel/vex/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ func TestParse(t *testing.T) {
expectedDeleted int
}{
{
name: "six_advisories_two_deletions",
name: "six_advisories_four_deletions",
filename: "testdata/example_vex.jsonl",
expectedVulns: 546,
expectedDeleted: 2,
expectedDeleted: 4,
},
{
name: "cve-2022-1705",
Expand Down
2 changes: 1 addition & 1 deletion rhel/vex/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
deletionsFile = "deletions.csv"
lookBackToYear = 2014
repoKey = "rhel-cpe-repository"
updaterVersion = "2"
updaterVersion = "3"
)

// Factory creates an Updater to process all of the Red Hat VEX data.
Expand Down

0 comments on commit 420823a

Please sign in to comment.