@@ -76,43 +76,40 @@ func (u *Updater) Parse(ctx context.Context, r io.ReadCloser) ([]*claircore.Vuln
76
76
// Check if the vulnerability only affects a userspace_ksplice package.
77
77
// These errata should never be applied to a container since ksplice
78
78
// 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
84
79
// If there's at least one ksplice CPE and not all the affected CPEs
85
80
// 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
87
82
// of the CPEs wasn't parseable.
88
- atLeastOneKsplice := false
83
+ kspliceCPEs := 0
84
+ cpes := len (def .Advisory .AffectedCPEList )
89
85
for _ , affected := range def .Advisory .AffectedCPEList {
90
86
wfn , err := cpe .Unbind (affected )
91
87
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
99
95
}
100
96
if wfn .Attr [cpe .Edition ].V == "userspace_ksplice" {
101
- atLeastOneKsplice = true
102
- } else {
103
- isOnlyKsplice = false
97
+ kspliceCPEs ++
104
98
}
105
99
}
106
100
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" )
109
106
return nil , nil
110
- }
111
-
112
- if atLeastOneKsplice {
107
+ case diff > 0 :
113
108
zlog .Warn (ctx ).
114
109
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" )
116
113
}
117
114
118
115
return vs , nil
0 commit comments