@@ -635,6 +635,86 @@ func TestDistroMatchBySourceIndirection(t *testing.T) {
635
635
assertMatches (t , expected , actual )
636
636
}
637
637
638
+ func TestSecDBMatchesStillCountedWithCpeErrors (t * testing.T ) {
639
+ // this should match the test package
640
+ // the test package will have no CPE causing an error,
641
+ // but the error should not cause the secDB matches to fail
642
+ secDbVuln := grypeDB.Vulnerability {
643
+ ID : "CVE-2020-2" ,
644
+ VersionConstraint : "<= 1.3.3-r0" ,
645
+ VersionFormat : "apk" ,
646
+ Namespace : "secdb:distro:alpine:3.12" ,
647
+ }
648
+
649
+ store := mockStore {
650
+ backend : map [string ]map [string ][]grypeDB.Vulnerability {
651
+ "secdb:distro:alpine:3.12" : {
652
+ "musl" : []grypeDB.Vulnerability {secDbVuln },
653
+ },
654
+ },
655
+ }
656
+
657
+ provider , err := db .NewVulnerabilityProvider (& store )
658
+ require .NoError (t , err )
659
+
660
+ m := Matcher {}
661
+ d , err := distro .New (distro .Alpine , "3.12.0" , "" )
662
+ if err != nil {
663
+ t .Fatalf ("failed to create a new distro: %+v" , err )
664
+ }
665
+
666
+ p := pkg.Package {
667
+ ID : pkg .ID (uuid .NewString ()),
668
+ Name : "musl-utils" ,
669
+ Version : "1.3.2-r0" ,
670
+ Type : syftPkg .ApkPkg ,
671
+ Upstreams : []pkg.UpstreamPackage {
672
+ {
673
+ Name : "musl" ,
674
+ },
675
+ },
676
+ CPEs : []cpe.CPE {},
677
+ }
678
+
679
+ vulnFound , err := vulnerability .NewVulnerability (secDbVuln )
680
+ assert .NoError (t , err )
681
+
682
+ expected := []match.Match {
683
+ {
684
+
685
+ Vulnerability : * vulnFound ,
686
+ Package : p ,
687
+ Details : []match.Detail {
688
+ {
689
+ Type : match .ExactIndirectMatch ,
690
+ Confidence : 1.0 ,
691
+ SearchedBy : map [string ]interface {}{
692
+ "distro" : map [string ]string {
693
+ "type" : d .Type .String (),
694
+ "version" : d .RawVersion ,
695
+ },
696
+ "package" : map [string ]string {
697
+ "name" : "musl" ,
698
+ "version" : p .Version ,
699
+ },
700
+ "namespace" : "secdb:distro:alpine:3.12" ,
701
+ },
702
+ Found : map [string ]interface {}{
703
+ "versionConstraint" : vulnFound .Constraint .String (),
704
+ "vulnerabilityID" : "CVE-2020-2" ,
705
+ },
706
+ Matcher : match .ApkMatcher ,
707
+ },
708
+ },
709
+ },
710
+ }
711
+
712
+ actual , err := m .Match (provider , d , p )
713
+ assert .NoError (t , err )
714
+
715
+ assertMatches (t , expected , actual )
716
+ }
717
+
638
718
func TestNVDMatchBySourceIndirection (t * testing.T ) {
639
719
nvdVuln := grypeDB.Vulnerability {
640
720
ID : "CVE-2020-1" ,
0 commit comments