Skip to content

Commit b560052

Browse files
committed
feat(detector/vuls2): SUSE by vuls2
1 parent e790ec5 commit b560052

File tree

5 files changed

+53
-20
lines changed

5 files changed

+53
-20
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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ require (
169169
github.com/go-errors/errors v1.4.2 // indirect
170170
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
171171
github.com/go-git/go-billy/v5 v5.6.2 // indirect
172-
github.com/go-git/go-git/v5 v5.16.2 // indirect
172+
github.com/go-git/go-git/v5 v5.16.3 // indirect
173173
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
174174
github.com/go-ini/ini v1.67.0 // indirect
175175
github.com/go-jose/go-jose/v4 v4.1.1 // indirect
@@ -292,7 +292,7 @@ require (
292292
github.com/prometheus/common v0.65.0 // indirect
293293
github.com/prometheus/procfs v0.16.1 // indirect
294294
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
295-
github.com/redis/rueidis v1.0.62 // indirect
295+
github.com/redis/rueidis v1.0.66 // indirect
296296
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
297297
github.com/rivo/uniseg v0.4.7 // indirect
298298
github.com/rubenv/sql-migrate v1.8.0 // indirect
@@ -367,7 +367,7 @@ require (
367367
gopkg.in/yaml.v3 v3.0.1 // indirect
368368
gorm.io/driver/mysql v1.6.0 // indirect
369369
gorm.io/driver/postgres v1.6.0 // indirect
370-
gorm.io/gorm v1.30.2 // indirect
370+
gorm.io/gorm v1.31.0 // indirect
371371
gotest.tools/v3 v3.5.0 // indirect
372372
helm.sh/helm/v3 v3.19.0 // indirect
373373
k8s.io/api v0.34.0 // indirect
@@ -394,3 +394,7 @@ require (
394394
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
395395
sigs.k8s.io/yaml v1.6.0 // indirect
396396
)
397+
398+
replace github.com/MaineK00n/vuls-data-update => ../vuls-data-update
399+
400+
replace github.com/MaineK00n/vuls2 => ../vuls2

go.sum

Lines changed: 6 additions & 10 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-20250906134441-3ba8b985542e h1:5OPMpGLCmRAIqTuhGXcLqjpcJhfoA7h8U4EmIdIjJ9A=
71-
github.com/MaineK00n/vuls-data-update v0.0.0-20250906134441-3ba8b985542e/go.mod h1:DqPD3jC7ZpsW9/c7KLJBrmtJASUdn9ZiclCp6mtMSpQ=
72-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20250728115051-467f2c79767c h1:LAZoB5s1cPwXHoZeZf9eHPcKw7kAeE3i2jwyb1zTvFw=
73-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20250728115051-467f2c79767c/go.mod h1:LeCkNcW1BC3jH3NYNM5HXq04Tsds60tiVuhmBTwuW0o=
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=
@@ -336,8 +332,8 @@ github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UN
336332
github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
337333
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
338334
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
339-
github.com/go-git/go-git/v5 v5.16.2 h1:fT6ZIOjE5iEnkzKyxTHK1W4HGAsPhqEqiSAssSO77hM=
340-
github.com/go-git/go-git/v5 v5.16.2/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
335+
github.com/go-git/go-git/v5 v5.16.3 h1:Z8BtvxZ09bYm/yYNgPKCzgWtaRqDTgIKRgIRHBfU6Z8=
336+
github.com/go-git/go-git/v5 v5.16.3/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
341337
github.com/go-gorp/gorp/v3 v3.1.0 h1:ItKF/Vbuj31dmV4jxA1qblpSwkl9g1typ24xoe70IGs=
342338
github.com/go-gorp/gorp/v3 v3.1.0/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw=
343339
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
@@ -752,8 +748,8 @@ github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 h1:EfpWLLCyXw8PSM2/XNJLjI3Pb
752748
github.com/redis/go-redis/extra/redisotel/v9 v9.0.5/go.mod h1:WZjPDy7VNzn77AAfnAfVjZNvfJTYfPetfZk5yoSTLaQ=
753749
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
754750
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
755-
github.com/redis/rueidis v1.0.62 h1:9yNCxsYtg9eMEzHhDq9tlRnDBFJyWTWn6YLQ5EWDE5I=
756-
github.com/redis/rueidis v1.0.62/go.mod h1:Lkhr2QTgcoYBhxARU7kJRO8SyVlgUuEkcJO1Y8MCluA=
751+
github.com/redis/rueidis v1.0.66 h1:7rvyrl0vL/cAEkE97+L5v3MJ3Vg8IKz+KIxUTfT+yJk=
752+
github.com/redis/rueidis v1.0.66/go.mod h1:Lkhr2QTgcoYBhxARU7kJRO8SyVlgUuEkcJO1Y8MCluA=
757753
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
758754
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
759755
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo=
@@ -1145,8 +1141,8 @@ gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
11451141
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
11461142
gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4=
11471143
gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo=
1148-
gorm.io/gorm v1.30.2 h1:f7bevlVoVe4Byu3pmbWPVHnPsLoWaMjEb7/clyr9Ivs=
1149-
gorm.io/gorm v1.30.2/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
1144+
gorm.io/gorm v1.31.0 h1:0VlycGreVhK7RF/Bwt51Fk8v0xLiiiFdbGDPIZQ7mJY=
1145+
gorm.io/gorm v1.31.0/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
11501146
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
11511147
gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
11521148
helm.sh/helm/v3 v3.19.0 h1:krVyCGa8fa/wzTZgqw0DUiXuRT5BPdeqE/sQXujQ22k=

0 commit comments

Comments
 (0)