Skip to content

Commit

Permalink
vex: update some minor parsing logic
Browse files Browse the repository at this point in the history
In non-debug environments (and always for known-affected
vulnerabilities) we carry on parsing when we don't find a relationship.
This means we error at the next block and continue then but it makes the
logs more confusing.

Signed-off-by: crozzy <[email protected]>
  • Loading branch information
crozzy committed Sep 4, 2024
1 parent 0e59253 commit da9a4a0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions rhel/vex/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,13 @@ func (c *creator) knownAffectedVulnerabilities(ctx context.Context, v csaf.Vulne
out := []*claircore.Vulnerability{}
for _, pc := range v.ProductStatus["known_affected"] {
pkgName, repoName, err := walkRelationships(pc, c.c)
if err != nil && debugEnabled {
unrelatedProductIDs = append(unrelatedProductIDs, pc)
if err != nil {
// It's possible to get here due to middleware not having a defined component:package
// relationship.
if debugEnabled {
unrelatedProductIDs = append(unrelatedProductIDs, pc)

Check warning on line 225 in rhel/vex/parser.go

View check run for this annotation

Codecov / codecov/patch

rhel/vex/parser.go#L224-L225

Added lines #L224 - L225 were not covered by tests
}
continue

Check warning on line 227 in rhel/vex/parser.go

View check run for this annotation

Codecov / codecov/patch

rhel/vex/parser.go#L227

Added line #L227 was not covered by tests
}
if strings.HasPrefix(pkgName, "kernel") {
// We don't want to ingest kernel advisories as
Expand Down Expand Up @@ -335,10 +338,12 @@ func (c *creator) fixedVulnerabilities(ctx context.Context, v csaf.Vulnerability
debugEnabled := zlog.Debug(ctx).Enabled()
for _, pc := range v.ProductStatus["fixed"] {
pkgName, repoName, err := walkRelationships(pc, c.c)
if err != nil && debugEnabled {
unrelatedProductIDs = append(unrelatedProductIDs, pc)
if err != nil {
// It's possible to get here due to middleware not having a defined component:package
// relationship.
if debugEnabled {
unrelatedProductIDs = append(unrelatedProductIDs, pc)
}
continue
}

Expand Down

0 comments on commit da9a4a0

Please sign in to comment.