@@ -19,6 +19,7 @@ import (
1919 criteriaTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/data/detection/condition/criteria"
2020 criterionTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/data/detection/condition/criteria/criterion"
2121 vcAffectedRangeTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/data/detection/condition/criteria/criterion/versioncriterion/affected/range"
22+ "github.com/MaineK00n/vuls-data-update/pkg/extract/types/data/detection/condition/criteria/criterion/versioncriterion/fixstatus"
2223 vcPackageTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/data/detection/condition/criteria/criterion/versioncriterion/package"
2324 segmentTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/data/detection/segment"
2425 ecosystemTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/data/detection/segment/ecosystem"
@@ -34,6 +35,7 @@ import (
3435 "github.com/MaineK00n/vuls2/pkg/version"
3536
3637 "github.com/future-architect/vuls/config"
38+ "github.com/future-architect/vuls/constant"
3739 "github.com/future-architect/vuls/logging"
3840 "github.com/future-architect/vuls/models"
3941)
@@ -121,10 +123,18 @@ func preConvert(sr *models.ScanResult) scanTypes.ScanResult {
121123 pkgs [p .Name ] = base
122124 }
123125
126+ family := func () string {
127+ switch sr .Family {
128+ case constant .OpenSUSE , constant .OpenSUSELeap , constant .SUSEEnterpriseServer , constant .SUSEEnterpriseDesktop :
129+ return strings .ReplaceAll (sr .Family , "." , "-" )
130+ default :
131+ return sr .Family
132+ }
133+ }()
124134 return scanTypes.ScanResult {
125135 JSONVersion : 0 ,
126136 ServerName : sr .ServerName ,
127- Family : ecosystemTypes .Ecosystem (sr . Family ),
137+ Family : ecosystemTypes .Ecosystem (family ),
128138 Release : sr .Release ,
129139
130140 Kernel : scanTypes.Kernel {
@@ -159,7 +169,7 @@ func detect(dbc db.DB, sr scanTypes.ScanResult) (detectTypes.DetectResult, error
159169 }
160170
161171 for rootID , base := range detected {
162- for d , err := range dbc .GetVulnerabilityData (dbTypes .SearchRoot , string (rootID )) {
172+ for d , err := range dbc .GetVulnerabilityData (dbTypes .SearchRoot , dbTypes. Predicate { RootID : & rootID }, string (rootID )) {
163173 if err != nil {
164174 return detectTypes.DetectResult {}, xerrors .Errorf ("Failed to get vulnerability data. RootID: %s, err: %w" , rootID , err )
165175 }
@@ -475,6 +485,10 @@ func walkCriteria(e ecosystemTypes.Ecosystem, sourceID sourceTypes.SourceID, ca
475485
476486 switch fcn .Criterion .Version .Package .Type {
477487 case vcPackageTypes .PackageTypeBinary , vcPackageTypes .PackageTypeSource :
488+ if ! cn .Criterion .Version .Vulnerable {
489+ continue
490+ }
491+
478492 rangeType , fixedIn := func () (vcAffectedRangeTypes.RangeType , string ) {
479493 if fcn .Criterion .Version .Affected == nil {
480494 return vcAffectedRangeTypes .RangeTypeUnknown , ""
@@ -494,10 +508,21 @@ func walkCriteria(e ecosystemTypes.Ecosystem, sourceID sourceTypes.SourceID, ca
494508 if fcn .Criterion .Version .FixStatus == nil {
495509 return ""
496510 }
497- return fixState (e , sourceID , fcn .Criterion .Version .FixStatus .Vendor )
511+ if s := fixState (e , sourceID , fcn .Criterion .Version .FixStatus .Vendor ); s != "" {
512+ return s
513+ }
514+ if fcn .Criterion .Version .FixStatus .Class == fixstatus .ClassUnknown {
515+ return "Unknown"
516+ }
517+ return ""
518+ }(),
519+ FixedIn : fixedIn ,
520+ NotFixedYet : func () bool {
521+ if cn .Criterion .Version .FixStatus == nil {
522+ return true
523+ }
524+ return cn .Criterion .Version .FixStatus .Class != fixstatus .ClassFixed
498525 }(),
499- FixedIn : fixedIn ,
500- NotFixedYet : fixedIn == "" ,
501526 },
502527 })
503528 }
0 commit comments