Skip to content

Commit 01b9ca8

Browse files
committed
NVSHAS-9525/scanner: Resolve existing Go linter issues in the NeuVector repository
1 parent cb2fff3 commit 01b9ca8

18 files changed

+246
-229
lines changed

common/common.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"path/filepath"
66
"time"
77

8+
log "github.com/sirupsen/logrus"
9+
810
"github.com/google/uuid"
911
)
1012

@@ -91,7 +93,7 @@ type AppModuleVul struct {
9193
Severity string `json:"SE"`
9294
AffectedVer []AppModuleVersion `json:"AV"`
9395
FixedVer []AppModuleVersion `json:"FV"`
94-
UnaffectedVer []AppModuleVersion `json:"UV",omitempty`
96+
UnaffectedVer []AppModuleVersion `json:"UV,omitempty"`
9597
IssuedDate time.Time `json:"Issue"`
9698
LastModDate time.Time `json:"LastMod"`
9799
CVEs []string `json:"-"`
@@ -181,6 +183,8 @@ func CreateImagePath(uid string) string {
181183
}
182184

183185
///
184-
os.MkdirAll(imgPath, 0755)
186+
if err := os.MkdirAll(imgPath, 0755); err != nil {
187+
log.WithFields(log.Fields{"error": err}).Error()
188+
}
185189
return imgPath
186190
}

common/crypto.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ package common
33
import (
44
"crypto/aes"
55
"crypto/cipher"
6-
"crypto/rand"
76
"errors"
8-
"io"
97
)
108

9+
/* removed by golint
1110
func encrypt(plaintext []byte, key []byte) ([]byte, error) {
1211
c, err := aes.NewCipher(key)
1312
if err != nil {
@@ -26,6 +25,7 @@ func encrypt(plaintext []byte, key []byte) ([]byte, error) {
2625
2726
return gcm.Seal(nonce, nonce, plaintext, nil), nil
2827
}
28+
*/
2929

3030
func decrypt(ciphertext []byte, key []byte) ([]byte, error) {
3131
c, err := aes.NewCipher(key)

common/db.go

+20-22
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"io/ioutil"
11+
"io"
1212
"os"
1313
"sort"
1414
"strconv"
@@ -202,7 +202,7 @@ func readCveDbMeta(path, osname string, fullDb map[string]*share.ScanVulnerabili
202202
}
203203
defer fvul.Close()
204204

205-
data, err := ioutil.ReadAll(fvul)
205+
data, err := io.ReadAll(fvul)
206206
if err != nil {
207207
log.WithFields(log.Fields{"error": err}).Error("Read file error")
208208
return nil, err
@@ -289,16 +289,15 @@ func readCveDbMeta(path, osname string, fullDb map[string]*share.ScanVulnerabili
289289
func readAppDbMeta(path string, fullDb map[string]*share.ScanVulnerability, output bool) (map[string]*OutputCVEVul, error) {
290290
var outCVEs map[string]*OutputCVEVul
291291

292-
var filename string
293-
filename = fmt.Sprintf("%s/apps.tb", path)
292+
filename := fmt.Sprintf("%s/apps.tb", path)
294293
fvul, err := os.Open(filename)
295294
if err != nil {
296295
log.WithFields(log.Fields{"error": err}).Error("open file error")
297296
return nil, err
298297
}
299298
defer fvul.Close()
300299

301-
data, err := ioutil.ReadAll(fvul)
300+
data, err := io.ReadAll(fvul)
302301
if err != nil {
303302
log.WithFields(log.Fields{"error": err}).Error("Read file error")
304303
return nil, err
@@ -376,16 +375,15 @@ func readAppDbMeta(path string, fullDb map[string]*share.ScanVulnerability, outp
376375
}
377376

378377
func LoadVulnerabilityIndex(path, osname string) ([]VulShort, error) {
379-
var filename string
380-
filename = fmt.Sprintf("%s/%s_index.tb", path, osname)
378+
filename := fmt.Sprintf("%s/%s_index.tb", path, osname)
381379
fvul, err := os.Open(filename)
382380
if err != nil {
383381
log.WithFields(log.Fields{"error": err}).Error("Open file error")
384382
return nil, err
385383
}
386384
defer fvul.Close()
387385

388-
data, err := ioutil.ReadAll(fvul)
386+
data, err := io.ReadAll(fvul)
389387
if err != nil {
390388
log.WithFields(log.Fields{"error": err}).Error("Read file error")
391389
return nil, err
@@ -419,7 +417,7 @@ func LoadFullVulnerabilities(path, osname string) (map[string]VulFull, error) {
419417
}
420418
defer fvul.Close()
421419

422-
data, err := ioutil.ReadAll(fvul)
420+
data, err := io.ReadAll(fvul)
423421
if err != nil {
424422
log.WithFields(log.Fields{"error": err}).Error("Read file error")
425423
return nil, err
@@ -455,16 +453,15 @@ func uniqueVulDb(vuls []AppModuleVul) []AppModuleVul {
455453
}
456454

457455
func LoadAppVulsTb(path string) (map[string][]AppModuleVul, error) {
458-
var filename string
459-
filename = fmt.Sprintf("%s/apps.tb", path)
456+
filename := fmt.Sprintf("%s/apps.tb", path)
460457
fvul, err := os.Open(filename)
461458
if err != nil {
462459
log.WithFields(log.Fields{"filename": filename, "error": err}).Error("open file error")
463460
return nil, err
464461
}
465462
defer fvul.Close()
466463

467-
data, err := ioutil.ReadAll(fvul)
464+
data, err := io.ReadAll(fvul)
468465
if err != nil {
469466
log.WithFields(log.Fields{"filename": filename, "error": err}).Error("Read file error")
470467
return nil, err
@@ -504,7 +501,7 @@ func LoadAppVulsTb(path string) (map[string][]AppModuleVul, error) {
504501
for _, mn := range mns {
505502
colon := strings.LastIndex(mn, ":")
506503
m := strings.ReplaceAll(mn, ":", ".")
507-
vf, _ := vul[mn]
504+
vf := vul[mn]
508505

509506
if _, ok := vul[m]; ok {
510507
vul[m] = uniqueVulDb(append(vul[m], vf...))
@@ -524,16 +521,15 @@ func LoadAppVulsTb(path string) (map[string][]AppModuleVul, error) {
524521
}
525522

526523
func LoadRawFile(path, name string) ([]byte, error) {
527-
var filename string
528-
filename = fmt.Sprintf("%s/%s", path, name)
524+
filename := fmt.Sprintf("%s/%s", path, name)
529525
fp, err := os.Open(filename)
530526
if err != nil {
531527
log.WithFields(log.Fields{"filename": filename, "error": err}).Error("open file error")
532528
return nil, err
533529
}
534530
defer fp.Close()
535531

536-
data, err := ioutil.ReadAll(fp)
532+
data, err := io.ReadAll(fp)
537533
if err != nil {
538534
log.WithFields(log.Fields{"filename": filename, "error": err}).Error("Read file error")
539535
return nil, err
@@ -590,7 +586,7 @@ func LoadCveDb(path, desPath string, encryptKey []byte) (string, string, error)
590586
log.WithFields(log.Fields{"version": newVer}).Info("Expand new DB")
591587

592588
// new database is newer then the expanded database, untar the new database
593-
tmpDir, err := ioutil.TempDir(os.TempDir(), "cvedb")
589+
tmpDir, err := os.MkdirTemp(os.TempDir(), "cvedb")
594590
if err != nil {
595591
log.Errorf("could not create temporary folder for RPM detection: %s", err)
596592
return "", "", err
@@ -675,7 +671,9 @@ func unzipDb(path, desPath string, encryptKey []byte) error {
675671
}
676672
defer f.Close()
677673

678-
f.Seek(0, 0)
674+
if _, err := f.Seek(0, 0); err != nil {
675+
log.WithFields(log.Fields{"error": err}).Error()
676+
}
679677

680678
// read keys len
681679
bhead := make([]byte, 4)
@@ -702,14 +700,14 @@ func unzipDb(path, desPath string, encryptKey []byte) error {
702700
log.WithFields(log.Fields{"error": err}).Error("Read db file error")
703701
return err
704702
}
705-
err = ioutil.WriteFile(desPath+"keys", bhead, 0400)
703+
err = os.WriteFile(desPath+"keys", bhead, 0400)
706704
if err != nil {
707705
log.WithFields(log.Fields{"error": err}).Error("Write keys file error")
708706
return err
709707
}
710708

711709
// Read the rest of DB
712-
cipherData, err := ioutil.ReadAll(f)
710+
cipherData, err := io.ReadAll(f)
713711
if err != nil {
714712
log.WithFields(log.Fields{"error": err}).Error("Read db file tar part error")
715713
return err
@@ -733,7 +731,7 @@ func unzipDb(path, desPath string, encryptKey []byte) error {
733731
}
734732

735733
func checkDbHash(filename, hash string) bool {
736-
data, err := ioutil.ReadFile(filename)
734+
data, err := os.ReadFile(filename)
737735
if err != nil {
738736
log.WithFields(log.Fields{"file": filename, "error": err}).Info("Read file error")
739737
return false
@@ -793,7 +791,7 @@ func moveDb(path, desPath string) error {
793791
}
794792

795793
func CheckExpandedDb(path string, checkHash bool) (float64, string, error) {
796-
data, err := ioutil.ReadFile(path + "keys")
794+
data, err := os.ReadFile(path + "keys")
797795
if err != nil {
798796
return 0, "", err
799797
}

cvetools/apps.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const log4jModName = "org.apache.logging.log4j.log4j"
2222
var log4jComponents = utils.NewSet("org.apache.logging.log4j:log4j-core")
2323

2424
func (cv *ScanTools) DetectAppVul(path string, apps []detectors.AppFeatureVersion, namespace string) []vulFullReport {
25-
if apps == nil || len(apps) == 0 {
25+
if len(apps) == 0 {
2626
return nil
2727
}
2828
modVuls, err := common.LoadAppVulsTb(path)

cvetools/apps_test.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ func TestAffectedVersion(t *testing.T) {
1919
versionTestCase{result: true, version: "1.2.3", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}}},
2020
versionTestCase{result: false, version: "1.2.4", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}}},
2121
versionTestCase{result: true, version: "4.0.1", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "", Version: "4.0.1"}}},
22-
versionTestCase{result: true, version: "1.2.3", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"gt", "1.2.0"}}},
23-
versionTestCase{result: true, version: "1.3.4", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"gt", "1.2.0"}, {"orlt", "1.3.5"}}},
24-
versionTestCase{result: true, version: "1.3.4", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"gt", "1.2.0"}, {"lt", "1.3.5"}}},
25-
versionTestCase{result: false, version: "1.3.4", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"lt", "1.3.5"}}},
26-
versionTestCase{result: true, version: "1.3.4", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"orlt", "1.3.5"}}},
27-
versionTestCase{result: true, version: "1.3.4", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"orlt", "1.3.5"}, {"gteq", "1.3.4"}}},
28-
versionTestCase{result: false, version: "1.3.3", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"orlt", "1.3.5"}, {"gteq", "1.3.4"}}},
29-
versionTestCase{result: true, version: "1.1.1", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}}},
30-
versionTestCase{result: false, version: "1.1.1", dbVer: []common.AppModuleVersion{{"lt", "1.2.4,1.2"}}},
31-
versionTestCase{result: true, version: "1.3.6", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"lt", "1.3.7"}, {"gt", "1.3.5"}}},
32-
versionTestCase{result: true, version: "1.3.6", dbVer: []common.AppModuleVersion{{"lt", "1.2.4"}, {"orlt", "1.3.7"}, {"gt", "1.3.5"}}},
33-
versionTestCase{result: false, version: "2.9.1-6.el7.4", dbVer: []common.AppModuleVersion{{"lt", "2.9.1-6.el7_2.2"}}},
34-
versionTestCase{result: false, version: "4.18.0-193.19.1.el8_2", dbVer: []common.AppModuleVersion{{"lt", "4.18.0-193.19.1.el8"}}},
35-
versionTestCase{result: false, version: "4.18.0-193.19.1.el8_2", dbVer: []common.AppModuleVersion{{"lt", "4.18.0-193.el8"}}},
36-
versionTestCase{result: true, version: "4.18.0-193.19.1.el8", dbVer: []common.AppModuleVersion{{"lt", "4.18.0-193.19.1.el8_2"}}},
37-
versionTestCase{result: false, version: "4.18.0.el8_2", dbVer: []common.AppModuleVersion{{"lt", "4.18.0.el8"}}},
38-
versionTestCase{result: false, version: "5.2.4.5", dbVer: []common.AppModuleVersion{{"lt", "5.2.4.3,5.2"}, {"orlt", "6.0.3.1"}}},
39-
versionTestCase{result: true, version: "5.2.4.5", dbVer: []common.AppModuleVersion{{"gteq", "5.2.4.3,5.2"}, {"orgteq", "6.0.3.1"}}},
40-
versionTestCase{result: false, version: "5.0.11", dbVer: []common.AppModuleVersion{{"gteq", "5.0"}, {"lteq", "5.0.8"}, {"orgteq", "2.1"}, {"lteq", "2.1.28"}, {"orgteq", "3.1"}, {"lteq", "3.1.17"}, {"orgteq", "7.0"}, {"lt", "7.0.7"}, {"orgteq", "7.1"}, {"lt", "7.1.4"}}},
22+
versionTestCase{result: true, version: "1.2.3", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "gt", Version: "1.2.0"}}},
23+
versionTestCase{result: true, version: "1.3.4", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "gt", Version: "1.2.0"}, {OpCode: "orlt", Version: "1.3.5"}}},
24+
versionTestCase{result: true, version: "1.3.4", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "gt", Version: "1.2.0"}, {OpCode: "lt", Version: "1.3.5"}}},
25+
versionTestCase{result: false, version: "1.3.4", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "lt", Version: "1.3.5"}}},
26+
versionTestCase{result: true, version: "1.3.4", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "orlt", Version: "1.3.5"}}},
27+
versionTestCase{result: true, version: "1.3.4", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "orlt", Version: "1.3.5"}, {OpCode: "gteq", Version: "1.3.4"}}},
28+
versionTestCase{result: false, version: "1.3.3", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "orlt", Version: "1.3.5"}, {OpCode: "gteq", Version: "1.3.4"}}},
29+
versionTestCase{result: true, version: "1.1.1", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}}},
30+
versionTestCase{result: false, version: "1.1.1", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4,1.2"}}},
31+
versionTestCase{result: true, version: "1.3.6", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "lt", Version: "1.3.7"}, {OpCode: "gt", Version: "1.3.5"}}},
32+
versionTestCase{result: true, version: "1.3.6", dbVer: []common.AppModuleVersion{common.AppModuleVersion{OpCode: "lt", Version: "1.2.4"}, {OpCode: "orlt", Version: "1.3.7"}, {OpCode: "gt", Version: "1.3.5"}}},
33+
versionTestCase{result: false, version: "2.9.1-6.el7.4", dbVer: []common.AppModuleVersion{{OpCode: "lt", Version: "2.9.1-6.el7_2.2"}}},
34+
versionTestCase{result: false, version: "4.18.0-193.19.1.el8_2", dbVer: []common.AppModuleVersion{{OpCode: "lt", Version: "4.18.0-193.19.1.el8"}}},
35+
versionTestCase{result: false, version: "4.18.0-193.19.1.el8_2", dbVer: []common.AppModuleVersion{{OpCode: "lt", Version: "4.18.0-193.el8"}}},
36+
versionTestCase{result: true, version: "4.18.0-193.19.1.el8", dbVer: []common.AppModuleVersion{{OpCode: "lt", Version: "4.18.0-193.19.1.el8_2"}}},
37+
versionTestCase{result: false, version: "4.18.0.el8_2", dbVer: []common.AppModuleVersion{{OpCode: "lt", Version: "4.18.0.el8"}}},
38+
versionTestCase{result: false, version: "5.2.4.5", dbVer: []common.AppModuleVersion{{OpCode: "lt", Version: "5.2.4.3,5.2"}, {OpCode: "orlt", Version: "6.0.3.1"}}},
39+
versionTestCase{result: true, version: "5.2.4.5", dbVer: []common.AppModuleVersion{{OpCode: "gteq", Version: "5.2.4.3,5.2"}, {OpCode: "orgteq", Version: "6.0.3.1"}}},
40+
versionTestCase{result: false, version: "5.0.11", dbVer: []common.AppModuleVersion{{OpCode: "gteq", Version: "5.0"}, {OpCode: "lteq", Version: "5.0.8"}, {OpCode: "orgteq", Version: "2.1"}, {OpCode: "lteq", Version: "2.1.28"}, {OpCode: "orgteq", Version: "3.1"}, {OpCode: "lteq", Version: "3.1.17"}, {OpCode: "orgteq", Version: "7.0"}, {OpCode: "lt", Version: "7.0.7"}, {OpCode: "orgteq", Version: "7.1"}, {OpCode: "lt", Version: "7.1.4"}}},
4141
}
4242

4343
for _, c := range cases {
@@ -54,7 +54,7 @@ func TestAffectedVersion(t *testing.T) {
5454

5555
func TestFixedVersion(t *testing.T) {
5656
cases := []versionTestCase{
57-
versionTestCase{result: true, version: "4.0.2", dbVer: []common.AppModuleVersion{{"gteq", "2.12.5"}, {"lt", "3.0.0"}, {"orgteq", "3.7.2"}, {"lt", "4.0.0"}, {"orgteq", "4.0.0.beta8"}}},
57+
versionTestCase{result: true, version: "4.0.2", dbVer: []common.AppModuleVersion{{OpCode: "gteq", Version: "2.12.5"}, {OpCode: "lt", Version: "3.0.0"}, {OpCode: "orgteq", Version: "3.7.2"}, {OpCode: "lt", Version: "4.0.0"}, {OpCode: "orgteq", Version: "4.0.0.beta8"}}},
5858
}
5959
for _, c := range cases {
6060
v, _ := utils.NewVersion(c.version)

cvetools/cvesearch.go

+19-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"os"
1010
"path/filepath"
1111
"regexp"
@@ -32,6 +32,7 @@ const (
3232
contentManifest = "root/buildinfo/content_manifests"
3333
)
3434

35+
/* removed by golint
3536
var redhat_db []common.VulShort = nil
3637
var debian_db []common.VulShort = nil
3738
var ubuntu_db []common.VulShort = nil
@@ -51,6 +52,7 @@ var oracle_fdb map[string]common.VulFull
5152
var mariner_fdb map[string]common.VulFull
5253
var photon_fdb map[string]common.VulFull
5354
var suse_fdb map[string]common.VulFull
55+
*/
5456

5557
///////
5658

@@ -64,8 +66,8 @@ type featureVulnWindow struct {
6466
}
6567

6668
///////
69+
// var cveTools *ScanTools
6770

68-
var cveTools *ScanTools
6971
var overrideMap map[string][]featureVulnWindow = map[string][]featureVulnWindow{
7072
"CVE-2019-13509": {
7173
{
@@ -213,7 +215,9 @@ func (cv *ScanTools) writeModuleFile(apps []scan.AppPackage) {
213215
return (apps[i].FileName < apps[j].FileName)
214216
})
215217
data, _ := json.Marshal(apps)
216-
ioutil.WriteFile(cv.modulesFile, data, 0644)
218+
if err := os.WriteFile(cv.modulesFile, data, 0644); err != nil {
219+
log.WithFields(log.Fields{"error": err}).Error()
220+
}
217221
}
218222
}
219223

@@ -238,7 +242,7 @@ func (cv *ScanTools) ScanImage(ctx context.Context, req *share.ScanImageRequest,
238242
Signature: false,
239243
}
240244

241-
if req.RootsOfTrust != nil && len(req.RootsOfTrust) > 0 {
245+
if len(req.RootsOfTrust) > 0 {
242246
log.Info("Sigstore root of trust information in request, adding signature scan")
243247
req.ScanTypesRequested.Signature = true
244248
}
@@ -272,7 +276,7 @@ func (cv *ScanTools) ScanImage(ctx context.Context, req *share.ScanImageRequest,
272276
// var layeredSecret []*share.ScanSecretResult
273277
var setidPerm []*share.ScanSetIdPermLog
274278
var layerRecords map[string]*LayerRecord
275-
layers := make([]string, 0)
279+
var layers []string
276280
layerFiles := make(map[string]*LayerFiles)
277281
secretLogs := make(map[string][]share.CLUSSecretLog)
278282
setidPermLogs := make(map[string][]share.CLUSSetIdPermLog)
@@ -430,6 +434,11 @@ func (cv *ScanTools) ScanImage(ctx context.Context, req *share.ScanImageRequest,
430434
// echo -e "GET /images/docker.io/nvlab/iperf/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
431435
}
432436

437+
if len(layers) == 0 {
438+
log.Error("no layer data")
439+
return nil, nil
440+
}
441+
433442
// For those package manager files, they can exist in multiple layers, the upper layer has the superset (if no deletion).
434443
// Scan the file in the upper layer is enough for image scan, but if we want to identify if the package is installed in
435444
// the base layer, we will mark all packages as "not in base". This is why we need scan layers again if BaseImage variable
@@ -489,7 +498,7 @@ func (cv *ScanTools) ScanImage(ctx context.Context, req *share.ScanImageRequest,
489498
go func() {
490499
log.Debug("Scanning secrets ....")
491500
var err error
492-
logs := make([]share.CLUSSecretLog, 0)
501+
var logs []share.CLUSSecretLog
493502
perms := make([]share.CLUSSetIdPermLog, 0)
494503

495504
config := secrets.Config{
@@ -501,7 +510,7 @@ func (cv *ScanTools) ScanImage(ctx context.Context, req *share.ScanImageRequest,
501510
buffers.WriteString(s)
502511
buffers.WriteByte('\n')
503512
}
504-
envVars, _ := ioutil.ReadAll(buffers)
513+
envVars, _ := io.ReadAll(buffers)
505514

506515
if bFromRawData {
507516
logs, perms, err = secrets.FindSecretsByFilePathMap(fileMap, envVars, config)
@@ -1086,7 +1095,7 @@ func searchAffectedFeature(mv map[string][]common.VulShort, namespace string, ft
10861095
name = val
10871096
}
10881097
featName := fmt.Sprintf("%s:%s", namespace, name)
1089-
vs, _ := mv[featName]
1098+
vs := mv[featName]
10901099

10911100
matchMap := make(map[string]share.ScanVulStatus)
10921101
moduleVuls := make([]detectors.ModuleVul, 0)
@@ -1284,7 +1293,7 @@ func makeFeatureMap(vss []common.VulShort, namespace string) map[string][]common
12841293
CPEs: v.CPEs,
12851294
}
12861295
s := fmt.Sprintf("%s:%s", vns, ft.Name)
1287-
vs, _ := mv[s]
1296+
vs := mv[s]
12881297
vs = append(vs, short)
12891298
mv[s] = vs
12901299
}
@@ -1416,7 +1425,7 @@ func getVulItemList(vuls []vulFullReport, dbPrefix string) []*share.ScanVulnerab
14161425
Score: float32(v.CVSSv2.Score),
14171426
ScoreV3: float32(v.CVSSv3.Score),
14181427
Name: v.Name,
1419-
Severity: fmt.Sprintf("%s", severity),
1428+
Severity: string(severity),
14201429
PackageNameDeprecated: featver.Package,
14211430
PackageName: featver.Package,
14221431
PackageVersion: packVer,

0 commit comments

Comments
 (0)