@@ -12,6 +12,7 @@ import (
12
12
"github.com/quay/claircore"
13
13
"github.com/quay/claircore/internal/xmlutil"
14
14
"github.com/quay/claircore/libvuln/driver"
15
+ "github.com/quay/claircore/pkg/cpe"
15
16
"github.com/quay/claircore/pkg/ovalutil"
16
17
)
17
18
@@ -71,6 +72,46 @@ func (u *Updater) Parse(ctx context.Context, r io.ReadCloser) ([]*claircore.Vuln
71
72
if len (vs ) == 0 {
72
73
return nil , fmt .Errorf ("could not determine dist" )
73
74
}
75
+
76
+ // Check if the vulnerability only affects a userspace_ksplice package.
77
+ // These errata should never be applied to a container since ksplice
78
+ // userspace packages are not supported to be run within a container.
79
+ // If there's at least one ksplice CPE and not all the affected CPEs
80
+ // are ksplice related, this will cause false positives we can catch.
81
+ // This should rarely happen; the most common case for this is if one
82
+ // of the CPEs wasn't parseable.
83
+ kspliceCPEs := 0
84
+ cpes := len (def .Advisory .AffectedCPEList )
85
+ for _ , affected := range def .Advisory .AffectedCPEList {
86
+ wfn , err := cpe .Unbind (affected )
87
+ if err != nil {
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
95
+ }
96
+ if wfn .Attr [cpe .Edition ].V == "userspace_ksplice" {
97
+ kspliceCPEs ++
98
+ }
99
+ }
100
+
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" )
106
+ return nil , nil
107
+ case diff > 0 :
108
+ zlog .Warn (ctx ).
109
+ Str ("def_title" , def .Title ).
110
+ Msg ("potential false positives: OVAL may have a userspace_ksplice CPE which could not be skipped" )
111
+ default :
112
+ panic ("programmer error" )
113
+ }
114
+
74
115
return vs , nil
75
116
}
76
117
vulns , err := ovalutil .RPMDefsToVulns (ctx , & root , protoVulns )
0 commit comments