Skip to content

Commit 760eadf

Browse files
committed
feat: remove deprecated sbom flag
1 parent 4dfa15e commit 760eadf

5 files changed

Lines changed: 8 additions & 141 deletions

File tree

cmd/osv-scanner/scan/source/__snapshots__/command_test.snap

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,6 @@ DESCRIPTION:
11331133

11341134
OPTIONS:
11351135
--lockfile string, -L string [ --lockfile string, -L string ] scan package lockfile on this path
1136-
--sbom string, -S string [ --sbom string, -S string ] [DEPRECATED] scan sbom file on this path, the sbom file name must follow the relevant spec
11371136
--recursive, -r check subdirectories
11381137
--no-ignore also scan files that would be ignored by .gitignore
11391138
--include-git-root include scanning git root (non-submoduled) repositories
@@ -1298,22 +1297,10 @@ No package sources found, --help for usage information.
12981297
---
12991298

13001299
[TestCommand/one_file_that_does_not_match_the_supported_sbom_file_names - 1]
1301-
Warning: --sbom has been deprecated in favor of -L
13021300

13031301
---
13041302

13051303
[TestCommand/one_file_that_does_not_match_the_supported_sbom_file_names - 2]
1306-
Failed to parse SBOM "./testdata/locks-many/composer.lock": Invalid SBOM filename.
1307-
If you believe this is a valid SBOM, make sure the filename follows format per your SBOMs specification.
1308-
invalid SBOM filename: ./testdata/locks-many/composer.lock
1309-
1310-
---
1311-
1312-
[TestCommand/one_file_that_does_not_match_the_supported_sbom_file_names_using_-L_flag - 1]
1313-
1314-
---
1315-
1316-
[TestCommand/one_file_that_does_not_match_the_supported_sbom_file_names_using_-L_flag - 2]
13171304
could not determine extractor, requested spdx
13181305

13191306
---
@@ -1356,8 +1343,7 @@ No issues found
13561343

13571344
---
13581345

1359-
[TestCommand/one_specific_supported_sbom_with_duplicate_PURLs - 1]
1360-
Warning: --sbom has been deprecated in favor of -L
1346+
[TestCommand/one_specific_supported_sbom_with_duplicate_purls - 1]
13611347
Scanned <rootdir>/testdata/sbom-insecure/with-duplicates.cdx.xml file and found 17 packages
13621348
Filtered 1 local/unscannable package/s from the scan.
13631349
Total 2 packages affected by 3 known vulnerabilities (1 Critical, 2 High, 0 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
@@ -1374,73 +1360,18 @@ Total 2 packages affected by 3 known vulnerabilities (1 Critical, 2 High, 0 Medi
13741360

13751361
---
13761362

1377-
[TestCommand/one_specific_supported_sbom_with_duplicate_PURLs - 2]
1363+
[TestCommand/one_specific_supported_sbom_with_duplicate_purls - 2]
13781364

13791365
---
13801366

1381-
[TestCommand/one_specific_supported_sbom_with_duplicate_PURLs_using_-L_flag - 1]
1382-
Scanned <rootdir>/testdata/sbom-insecure/with-duplicates.cdx.xml file and found 17 packages
1383-
Filtered 1 local/unscannable package/s from the scan.
1384-
Total 2 packages affected by 3 known vulnerabilities (1 Critical, 2 High, 0 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
1385-
0 vulnerabilities can be fixed.
1386-
1387-
1388-
+---------------------------------------+------+-----------+---------+-----------+---------------+------------------------------------------------+
1389-
| OSV URL | CVSS | ECOSYSTEM | PACKAGE | VERSION | FIXED VERSION | SOURCE |
1390-
+---------------------------------------+------+-----------+---------+-----------+---------------+------------------------------------------------+
1391-
| https://osv.dev/ALPINE-CVE-2025-26519 | 7.0 | Alpine | musl | 1.2.3-r4 | -- | testdata/sbom-insecure/with-duplicates.cdx.xml |
1392-
| https://osv.dev/ALPINE-CVE-2018-25032 | 7.5 | Alpine | zlib | 1.2.10-r0 | -- | testdata/sbom-insecure/with-duplicates.cdx.xml |
1393-
| https://osv.dev/ALPINE-CVE-2022-37434 | 9.8 | Alpine | zlib | 1.2.10-r0 | -- | testdata/sbom-insecure/with-duplicates.cdx.xml |
1394-
+---------------------------------------+------+-----------+---------+-----------+---------------+------------------------------------------------+
1395-
1396-
---
1397-
1398-
[TestCommand/one_specific_supported_sbom_with_duplicate_PURLs_using_-L_flag - 2]
1399-
1400-
---
1401-
1402-
[TestCommand/one_specific_supported_sbom_with_invalid_PURLs - 1]
1403-
Warning: --sbom has been deprecated in favor of -L
1367+
[TestCommand/one_specific_supported_sbom_with_invalid_purls - 1]
14041368
Scanned <rootdir>/testdata/sbom-insecure/bad-purls.cdx.xml file and found 15 packages
14051369
Filtered 7 local/unscannable package/s from the scan.
14061370
No issues found
14071371

14081372
---
14091373

1410-
[TestCommand/one_specific_supported_sbom_with_invalid_PURLs - 2]
1411-
1412-
---
1413-
1414-
[TestCommand/one_specific_supported_sbom_with_invalid_PURLs_using_-L_flag - 1]
1415-
Scanned <rootdir>/testdata/sbom-insecure/bad-purls.cdx.xml file and found 15 packages
1416-
Filtered 7 local/unscannable package/s from the scan.
1417-
No issues found
1418-
1419-
---
1420-
1421-
[TestCommand/one_specific_supported_sbom_with_invalid_PURLs_using_-L_flag - 2]
1422-
1423-
---
1424-
1425-
[TestCommand/one_specific_supported_sbom_with_vulns - 1]
1426-
Warning: --sbom has been deprecated in favor of -L
1427-
Scanned <rootdir>/testdata/sbom-insecure/alpine.cdx.xml file and found 15 packages
1428-
Filtered 1 local/unscannable package/s from the scan.
1429-
Total 2 packages affected by 3 known vulnerabilities (1 Critical, 2 High, 0 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
1430-
0 vulnerabilities can be fixed.
1431-
1432-
1433-
+---------------------------------------+------+-----------+---------+-----------+---------------+---------------------------------------+
1434-
| OSV URL | CVSS | ECOSYSTEM | PACKAGE | VERSION | FIXED VERSION | SOURCE |
1435-
+---------------------------------------+------+-----------+---------+-----------+---------------+---------------------------------------+
1436-
| https://osv.dev/ALPINE-CVE-2025-26519 | 7.0 | Alpine | musl | 1.2.3-r4 | -- | testdata/sbom-insecure/alpine.cdx.xml |
1437-
| https://osv.dev/ALPINE-CVE-2018-25032 | 7.5 | Alpine | zlib | 1.2.10-r0 | -- | testdata/sbom-insecure/alpine.cdx.xml |
1438-
| https://osv.dev/ALPINE-CVE-2022-37434 | 9.8 | Alpine | zlib | 1.2.10-r0 | -- | testdata/sbom-insecure/alpine.cdx.xml |
1439-
+---------------------------------------+------+-----------+---------+-----------+---------------+---------------------------------------+
1440-
1441-
---
1442-
1443-
[TestCommand/one_specific_supported_sbom_with_vulns - 2]
1374+
[TestCommand/one_specific_supported_sbom_with_invalid_purls - 2]
14441375

14451376
---
14461377

cmd/osv-scanner/scan/source/command.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ func Command(stdout, stderr io.Writer, client *http.Client) *cli.Command {
3030
Usage: "scan package lockfile on this path",
3131
TakesFile: true,
3232
},
33-
&cli.StringSliceFlag{
34-
Name: "sbom",
35-
Aliases: []string{"S"},
36-
Usage: "[DEPRECATED] scan sbom file on this path, the sbom file name must follow the relevant spec",
37-
Action: func(_ context.Context, _ *cli.Command, _ []string) error {
38-
cmdlogger.Warnf("Warning: --sbom has been deprecated in favor of -L")
39-
40-
return nil
41-
},
42-
TakesFile: true,
43-
},
4433
&cli.BoolFlag{
4534
Name: "recursive",
4635
Aliases: []string{"r"},
@@ -124,8 +113,6 @@ func action(_ context.Context, cmd *cli.Command, stdout, stderr io.Writer, clien
124113
scannerAction := helper.GetCommonScannerActions(cmd, scanLicensesAllowlist)
125114

126115
scannerAction.LockfilePaths = cmd.StringSlice("lockfile")
127-
//nolint:staticcheck // ignore our own deprecated field
128-
scannerAction.SBOMPaths = cmd.StringSlice("sbom")
129116
scannerAction.Recursive = cmd.Bool("recursive")
130117
scannerAction.NoIgnore = cmd.Bool("no-ignore")
131118
scannerAction.DirectoryPaths = cmd.Args().Slice()

cmd/osv-scanner/scan/source/command_test.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,47 +47,26 @@ func TestCommand(t *testing.T) {
4747
Args: []string{"", "source", "--all-vulns", "./testdata/sbom-insecure/only-unimportant.spdx.json"},
4848
Exit: 1,
4949
},
50-
// one specific supported sbom with vulns
51-
{
52-
Name: "one specific supported sbom with vulns",
53-
Args: []string{"", "source", "--sbom", "./testdata/sbom-insecure/alpine.cdx.xml"},
54-
Exit: 1,
55-
},
5650
{
5751
Name: "one specific supported sbom with vulns using -L flag",
5852
Args: []string{"", "source", "-L", "./testdata/sbom-insecure/alpine.cdx.xml"},
5953
Exit: 1,
6054
},
6155
// one specific supported sbom with vulns and invalid PURLs
6256
{
63-
Name: "one specific supported sbom with invalid PURLs",
64-
Args: []string{"", "source", "--sbom", "./testdata/sbom-insecure/bad-purls.cdx.xml"},
65-
Exit: 0,
66-
},
67-
{
68-
Name: "one specific supported sbom with invalid PURLs using -L flag",
57+
Name: "one_specific_supported_sbom_with_invalid_purls",
6958
Args: []string{"", "source", "-L", "./testdata/sbom-insecure/bad-purls.cdx.xml"},
7059
Exit: 0,
7160
},
7261
// one specific supported sbom with duplicate PURLs
7362
{
74-
Name: "one specific supported sbom with duplicate PURLs",
75-
Args: []string{"", "source", "--sbom", "./testdata/sbom-insecure/with-duplicates.cdx.xml"},
76-
Exit: 1,
77-
},
78-
{
79-
Name: "one specific supported sbom with duplicate PURLs using -L flag",
63+
Name: "one_specific_supported_sbom_with_duplicate_purls",
8064
Args: []string{"", "source", "-L", "./testdata/sbom-insecure/with-duplicates.cdx.xml"},
8165
Exit: 1,
8266
},
8367
// one file that does not match the supported sbom file names
8468
{
85-
Name: "one file that does not match the supported sbom file names",
86-
Args: []string{"", "source", "--sbom", "./testdata/locks-many/composer.lock"},
87-
Exit: 127,
88-
},
89-
{
90-
Name: "one file that does not match the supported sbom file names using -L flag",
69+
Name: "one_file_that_does_not_match_the_supported_sbom_file_names",
9170
Args: []string{"", "source", "-L", "spdx:./testdata/locks-many/composer.lock"},
9271
Exit: 127,
9372
},

pkg/osvscanner/osvscanner.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ type ScannerActions struct {
6464
// license scanning
6565
ScanLicensesSummary bool
6666
ScanLicensesAllowlist []string
67-
68-
// Deprecated: in favor of LockfilePaths
69-
SBOMPaths []string
7067
}
7168

7269
type ExperimentalScannerActions struct {

pkg/osvscanner/scan.go

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
transitivedependencyrequirements "github.com/google/osv-scalibr/enricher/transitivedependency/requirements"
2020
"github.com/google/osv-scalibr/extractor"
2121
"github.com/google/osv-scalibr/extractor/filesystem"
22-
"github.com/google/osv-scalibr/extractor/filesystem/simplefileapi"
2322
"github.com/google/osv-scalibr/fs"
2423
"github.com/google/osv-scalibr/inventory"
2524
"github.com/google/osv-scalibr/log"
@@ -169,7 +168,7 @@ func scan(accessors ExternalAccessors, actions ScannerActions) (*inventory.Inven
169168
// map[path]parseAs
170169
overrideMap := map[string]filesystem.Extractor{}
171170
// List of specific paths the user passes in so that we can check that they all get processed.
172-
specificPaths := make([]string, 0, len(actions.LockfilePaths)+len(actions.SBOMPaths))
171+
specificPaths := make([]string, 0, len(actions.LockfilePaths))
173172

174173
statsCollector := fileOpenedPrinter{
175174
filesExtracted: make(map[string]struct{}),
@@ -202,32 +201,6 @@ func scan(accessors ExternalAccessors, actions ScannerActions) (*inventory.Inven
202201
}
203202
}
204203

205-
// --- SBOMs (Deprecated) ---
206-
// none of the SBOM extractors need configuring
207-
sbomExtractors := scalibrplugin.Resolve([]string{"sbom"}, []string{}, &cpb.PluginConfig{})
208-
209-
SBOMLoop:
210-
for _, sbomPath := range actions.SBOMPaths {
211-
absPath, err := pathToRootMap(rootMap, sbomPath, actions.Recursive)
212-
if err != nil {
213-
return nil, err
214-
}
215-
specificPaths = append(specificPaths, absPath)
216-
217-
for _, se := range sbomExtractors {
218-
// All sbom extractors are filesystem extractors
219-
sbomExtractor := se.(filesystem.Extractor)
220-
if sbomExtractor.FileRequired(simplefileapi.New(absPath, nil)) {
221-
overrideMap[absPath] = sbomExtractor
222-
continue SBOMLoop
223-
}
224-
}
225-
cmdlogger.Errorf("Failed to parse SBOM %q: Invalid SBOM filename.", sbomPath)
226-
cmdlogger.Errorf("If you believe this is a valid SBOM, make sure the filename follows format per your SBOMs specification.")
227-
228-
return nil, fmt.Errorf("invalid SBOM filename: %s", sbomPath)
229-
}
230-
231204
// --- Add git commits directly ---
232205
gitDirectPlugin := gitcommitdirect.New(actions.GitCommits)
233206

0 commit comments

Comments
 (0)