Skip to content

Commit 232dfa6

Browse files
committed
refactor: use slices.Concat
1 parent a0cd9cd commit 232dfa6

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

pkg/osvscanner/osvscanner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func DoContainerScan(actions ScannerActions) (models.VulnerabilityResults, error
316316
scanner := scalibr.New()
317317
scalibrSR, err := scanner.ScanContainer(context.Background(), img, &scalibr.ScanConfig{
318318
FilesystemExtractors: getExtractors(
319-
[][]string{scalibrextract.ExtractorsArtifacts},
319+
scalibrextract.ExtractorsArtifacts,
320320
accessors,
321321
actions,
322322
),

pkg/osvscanner/scan.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log/slog"
77
"path/filepath"
8+
"slices"
89

910
"github.com/google/osv-scalibr/extractor"
1011
"github.com/google/osv-scalibr/extractor/filesystem"
@@ -44,13 +45,11 @@ func configureExtractors(extractors []filesystem.Extractor, accessors ExternalAc
4445
}
4546
}
4647

47-
func getExtractors(defaultExtractorNames [][]string, accessors ExternalAccessors, actions ScannerActions) []filesystem.Extractor {
48+
func getExtractors(defaultExtractorNames []string, accessors ExternalAccessors, actions ScannerActions) []filesystem.Extractor {
4849
names := actions.ExtractorNames
4950

5051
if len(names) == 0 {
51-
for _, preset := range defaultExtractorNames {
52-
names = append(names, preset...)
53-
}
52+
names = defaultExtractorNames
5453
}
5554

5655
extractors := scanners.BuildAll(names)
@@ -66,7 +65,7 @@ func scan(accessors ExternalAccessors, actions ScannerActions) ([]imodels.Packag
6665
var scannedInventories []*extractor.Package
6766

6867
// --- Lockfiles ---
69-
lockfileExtractors := getExtractors([][]string{scalibrextract.ExtractorsLockfiles}, accessors, actions)
68+
lockfileExtractors := getExtractors(scalibrextract.ExtractorsLockfiles, accessors, actions)
7069
for _, lockfileElem := range actions.LockfilePaths {
7170
invs, err := scanners.ScanSingleFileWithMapping(lockfileElem, lockfileExtractors)
7271
if err != nil {
@@ -102,11 +101,11 @@ func scan(accessors ExternalAccessors, actions ScannerActions) ([]imodels.Packag
102101

103102
// --- Directories ---
104103
dirExtractors := getExtractors(
105-
[][]string{
104+
slices.Concat(
106105
scalibrextract.ExtractorsLockfiles,
107106
scalibrextract.ExtractorsSBOMs,
108107
scalibrextract.ExtractorsDirectories,
109-
},
108+
),
110109
accessors,
111110
actions,
112111
)

0 commit comments

Comments
 (0)