Skip to content

Commit f487af5

Browse files
committed
fixup! oracle: omit ksplice-related vulnerabilities
Signed-off-by: Brad Lugo <[email protected]>
1 parent 98f717a commit f487af5

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

oracle/parser.go

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,43 +76,40 @@ func (u *Updater) Parse(ctx context.Context, r io.ReadCloser) ([]*claircore.Vuln
7676
// Check if the vulnerability only affects a userspace_ksplice package.
7777
// These errata should never be applied to a container since ksplice
7878
// userspace packages are not supported to be run within a container.
79-
// If we couldn't find a CPE list, make sure to include the
80-
// vulnerability. We'd rather have false positives for
81-
// userspace_ksplice packages than have false negatives for
82-
// *everything*.
83-
isOnlyKsplice := len(def.Advisory.AffectedCPEList) > 0
8479
// If there's at least one ksplice CPE and not all the affected CPEs
8580
// are ksplice related, this will cause false positives we can catch.
86-
// This should rarely happen. The most common case for this is if one
81+
// This should rarely happen; the most common case for this is if one
8782
// of the CPEs wasn't parseable.
88-
atLeastOneKsplice := false
83+
kspliceCPEs := 0
84+
cpes := len(def.Advisory.AffectedCPEList)
8985
for _, affected := range def.Advisory.AffectedCPEList {
9086
wfn, err := cpe.Unbind(affected)
9187
if err != nil {
92-
// Found a CPE but could not parse it. Let's break out of these
93-
// checks and signal that these vulnerabilities should be
94-
// added to the list, but that there may be false positives.
95-
zlog.Warn(ctx).Str("cpe", affected).Msg("could not parse CPE")
96-
isOnlyKsplice = false
97-
atLeastOneKsplice = true
98-
break
88+
// Found a CPE but could not parse it. Log a warning and return
89+
// successfully.
90+
zlog.Warn(ctx).
91+
Str("def_title", def.Title).
92+
Str("cpe", affected).
93+
Msg("could not parse CPE: there may be a false positive match with a userspace_ksplice package")
94+
return vs, nil
9995
}
10096
if wfn.Attr[cpe.Edition].V == "userspace_ksplice" {
101-
atLeastOneKsplice = true
102-
} else {
103-
isOnlyKsplice = false
97+
kspliceCPEs++
10498
}
10599
}
106100

107-
if isOnlyKsplice {
108-
zlog.Debug(ctx).Msg("skipping ksplice vulnerabilities")
101+
switch diff := cpes - kspliceCPEs; {
102+
case cpes == 0:
103+
// Continue if there are no CPEs.
104+
case diff == 0:
105+
zlog.Debug(ctx).Msg("skipping userspace_ksplice vulnerabilities")
109106
return nil, nil
110-
}
111-
112-
if atLeastOneKsplice {
107+
case diff > 0:
113108
zlog.Warn(ctx).
114109
Str("def_title", def.Title).
115-
Msg("potential false positives: vulnerability has at least one unskippable ksplice match")
110+
Msg("potential false positives: OVAL may have a userspace_ksplice CPE which could not be skipped")
111+
default:
112+
panic("programmer error")
116113
}
117114

118115
return vs, nil

0 commit comments

Comments
 (0)