Skip to content

Commit 344a3e1

Browse files
committed
feat(detector/vuls2): SUSE by vuls2
1 parent 1c2a238 commit 344a3e1

File tree

5 files changed

+44
-11
lines changed

5 files changed

+44
-11
lines changed

detector/detector.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,12 @@ func Detect(rs []models.ScanResult, dir string) ([]models.ScanResult, error) {
322322
func DetectPkgCves(r *models.ScanResult, ovalCnf config.GovalDictConf, gostCnf config.GostConf, vuls2Conf config.Vuls2Conf, logOpts logging.LogOpts, noProgress bool) error {
323323
if isPkgCvesDetactable(r) {
324324
switch r.Family {
325-
case constant.RedHat, constant.CentOS, constant.Fedora, constant.Alma, constant.Rocky, constant.Oracle, constant.Alpine, constant.Ubuntu:
325+
case constant.RedHat, constant.CentOS, constant.Fedora, constant.Alma, constant.Rocky, constant.Oracle, constant.Alpine, constant.Ubuntu,
326+
constant.OpenSUSE, constant.OpenSUSELeap, constant.SUSEEnterpriseServer, constant.SUSEEnterpriseDesktop:
326327
if err := vuls2.Detect(r, vuls2Conf, noProgress); err != nil {
327328
return xerrors.Errorf("Failed to detect CVE with Vuls2: %w", err)
328329
}
329-
case constant.Amazon, constant.OpenSUSE, constant.OpenSUSELeap, constant.SUSEEnterpriseServer, constant.SUSEEnterpriseDesktop:
330+
case constant.Amazon:
330331
if err := detectPkgsCvesWithOval(ovalCnf, r, logOpts); err != nil {
331332
return xerrors.Errorf("Failed to detect CVE with OVAL: %w", err)
332333
}

detector/vuls2/vendor.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,13 @@ func advisoryReference(e ecosystemTypes.Ecosystem, s sourceTypes.SourceID, da mo
462462
Source: "UBUNTU",
463463
RefID: da.AdvisoryID,
464464
}, nil
465+
case ecosystemTypes.EcosystemTypeOpenSUSE, ecosystemTypes.EcosystemTypeOpenSUSELeap, ecosystemTypes.EcosystemTypeOpenSUSELeapMicro, ecosystemTypes.EcosystemTypeOpenSUSETumbleweed,
466+
ecosystemTypes.EcosystemTypeSUSEEnterpriseServer, ecosystemTypes.EcosystemTypeSUSEEnterpriseDesktop, ecosystemTypes.EcosystemTypeSUSEEnterpriseMicro:
467+
return models.Reference{
468+
Link: fmt.Sprintf("https://www.suse.com/security/cve/%s.html", da.AdvisoryID),
469+
Source: "SUSE",
470+
RefID: da.AdvisoryID,
471+
}, nil
465472
default:
466473
return models.Reference{}, xerrors.Errorf("unsupported family: %s", et)
467474
}

detector/vuls2/vuls2.go

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,7 @@ require (
398398
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
399399
sigs.k8s.io/yaml v1.6.0 // indirect
400400
)
401+
402+
replace github.com/MaineK00n/vuls-data-update => ../vuls-data-update
403+
404+
replace github.com/MaineK00n/vuls2 => ../vuls2

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ github.com/MaineK00n/go-cisco-version v0.0.0-20250826032808-615a945b63f4 h1:2eG8
6767
github.com/MaineK00n/go-cisco-version v0.0.0-20250826032808-615a945b63f4/go.mod h1:x/MwTByToVra1edsHGAGR+t1NsIiY1/PBa6B3hz3nDA=
6868
github.com/MaineK00n/go-paloalto-version v0.0.0-20250826032740-c5203b6ee7d0 h1:qJq5Xlidm16U9EWjuQun7ZeDhj+W6gHBZyE5iX4BcQE=
6969
github.com/MaineK00n/go-paloalto-version v0.0.0-20250826032740-c5203b6ee7d0/go.mod h1:ELOxzfAd4oAe4niMmoZlSiJwzf1DF+DjNdjsUcuqAR8=
70-
github.com/MaineK00n/vuls-data-update v0.0.0-20251119040922-d7602a3c6123 h1:X6m8W8HN7ROj7/Il6+OoNtf2bB3o2mbRX5NL50rHiJ4=
71-
github.com/MaineK00n/vuls-data-update v0.0.0-20251119040922-d7602a3c6123/go.mod h1:PPnHKRINm9EpZ/HRwKD366yMeEcZGhTfuWxS96BMWcc=
72-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20251120024419-59d504def6ec h1:7PdphOIerzLLOWKm1cB8DsTKW9v/u/NJ6kN4L9Af4Uo=
73-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20251120024419-59d504def6ec/go.mod h1:thvg/lSv2QqzxI1ipYY1qZEjZsZ6cFU49aczHWX8LK4=
7470
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
7571
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
7672
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=

0 commit comments

Comments
 (0)