@@ -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,45 @@ 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 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
+ // If there's at least one ksplice CPE and not all the affected CPEs
85
+ // are ksplice related, this will cause false positives we can catch.
86
+ // This should (almost) never happen.
87
+ atLeastOneKsplice := false
88
+ for _ , affected := range def .Advisory .AffectedCPEList {
89
+ wfn , err := cpe .Unbind (affected )
90
+ if err != nil {
91
+ // Found a CPE but could not parse it. Assume it's not a
92
+ // userspace_ksplice package.
93
+ zlog .Warn (ctx ).Str ("cpe" , affected ).Msg ("could not parse CPE" )
94
+ isOnlyKsplice = false
95
+ atLeastOneKsplice = true
96
+ break
97
+ }
98
+ if wfn .Attr [cpe .Edition ].V == "userspace_ksplice" {
99
+ atLeastOneKsplice = true
100
+ } else {
101
+ isOnlyKsplice = false
102
+ }
103
+ }
104
+
105
+ if ! isOnlyKsplice {
106
+ // This should (almost) never happen.
107
+ if atLeastOneKsplice {
108
+ zlog .Warn (ctx ).Str ("def.Title" , def .Title ).Msg ("potential false positives: vulnerability has at least one unskippable ksplice match" )
109
+ }
110
+ } else {
111
+ return nil , fmt .Errorf ("skippable ksplice vulnerabilities" )
112
+ }
113
+
74
114
return vs , nil
75
115
}
76
116
vulns , err := ovalutil .RPMDefsToVulns (ctx , & root , protoVulns )
0 commit comments