Compare commits

...
Author SHA1 Message Date
Will Murphy ee70b5d714 temp: use stereoscope from pr to test ci
Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com>
2026-11-03 09:19:34 -05:00
Juan 5ec416cb24 fix: do not generate CPEs for msrc-kb packages (#5510)
A msrc-kb package's name is an MSRC product ID and its version a KB
number, so the generic generator produced CPEs such as
cpe:2.3:a:12437:12437:935509:*:*:*:*:*:*:*. A KB is a patch rather than
a product and has no CPE representation; these packages are matched
against MSRC data by name and version. Skip generation for them, as is
already done for ML model packages. The dictionary lookup already
returns nothing for this type.

Signed-off-by: juanjsebgarcia <github@juangarcia.co.uk>
2026-11-02 15:52:38 -05:00
4 changed files with 23 additions and 6 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ require (
github.com/anchore/go-sync v0.1.2
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b
github.com/anchore/packageurl-go v0.2.0
github.com/anchore/stereoscope v0.4.0
github.com/anchore/stereoscope v0.4.1-0.20261103134938-3923a1d71f2e
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be
github.com/aquasecurity/go-pep440-version v0.0.1
github.com/bitnami/go-version v0.0.0-20250131085805-b1f57a8634ef
+2 -2
View File
@@ -150,8 +150,8 @@ github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b h1:e1bmaoJfZV
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b/go.mod h1:Bkc+JYWjMCF8OyZ340IMSIi2Ebf3uwByOk6ho4wne1E=
github.com/anchore/packageurl-go v0.2.0 h1:CkrM4RMUwrEGAiE1OVlxaZNzWj0TuHRey7o4T/EAErk=
github.com/anchore/packageurl-go v0.2.0/go.mod h1:2JCgOQMIsqZ7TmliXG4PnUthPJAKE3mWQbsW2XHjAOE=
github.com/anchore/stereoscope v0.4.0 h1:MDL7YFRDaGzhCdjm/s+em1D/X9HwnZMYupfgg+mvqPI=
github.com/anchore/stereoscope v0.4.0/go.mod h1:hYJsi3M8a8N1O66u+rMQSgv5TREGM7QIjKBjPPnwiD8=
github.com/anchore/stereoscope v0.4.1-0.20261103134938-3923a1d71f2e h1:5I/3QbnhqciUj2NOAMJTfzyyqR/e/JPtdNdhrPu5gEs=
github.com/anchore/stereoscope v0.4.1-0.20261103134938-3923a1d71f2e/go.mod h1:hYJsi3M8a8N1O66u+rMQSgv5TREGM7QIjKBjPPnwiD8=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
@@ -141,9 +141,16 @@ func FromDictionaryFind(p pkg.Package) ([]cpe.CPE, bool) {
// generate the minimal set of representative CPEs, which implies that optional fields should not be included
// (such as target SW).
func FromPackageAttributes(p pkg.Package) []cpe.CPE {
// ML models should not have CPEs as they are not traditional software packages
// and don't fit the vulnerability model used for software packages.
if p.Type == pkg.ModelPkg {
switch p.Type {
case pkg.KbPkg:
// Microsoft KB packages are patches, not products: the name is an MSRC product ID and the
// version a KB number, neither of which maps onto a CPE vendor, product or version. They are
// matched against MSRC data by name and version, so a generated CPE is only noise, and one
// that NVD-based matching could misread.
return nil
case pkg.ModelPkg:
// ML models should not have CPEs as they are not traditional software packages
// and don't fit the vulnerability model used for software packages.
return nil
}
@@ -892,6 +892,16 @@ func TestGeneratePackageCPEs(t *testing.T) {
},
expected: []string{},
},
{
name: "Microsoft KB package should generate no CPEs",
p: pkg.Package{
Name: "12437",
Version: "935509",
Type: pkg.KbPkg,
Metadata: pkg.MicrosoftKbPatch{ProductID: "12437", Kb: "935509"},
},
expected: []string{},
},
{
name: "rust package",
p: pkg.Package{