Skip to content

Commit 72b86d8

Browse files
committed
feat: don't filter when ignoring all vulns
1 parent 6b09f5a commit 72b86d8

2 files changed

Lines changed: 61 additions & 64 deletions

File tree

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

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5894,17 +5894,9 @@ Filtered 2 ignored package/s from the scan.
58945894
<tempdir>/nested-2/osv-scanner-test.toml has been updated to ignore 3 vulnerabilities
58955895
<tempdir>/nested-3/osv-scanner-test.toml has been updated to ignore 1 vulnerability
58965896
<tempdir>/osv-scanner-test.toml has been updated to ignore 2 vulnerabilities
5897-
CVE-2021-23424 and 1 alias have been filtered out because: Test manifest file (package-lock.json)
5898-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
5899-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
5900-
Filtered 3 vulnerabilities from output
5901-
<tempdir>/nested-2/osv-scanner-test.toml has unused ignores:
5902-
- GHSA-2g4f-4pwh-qvx6
5903-
<tempdir>/nested-3/osv-scanner-test.toml has unused ignores:
5904-
- GHSA-2g4f-4pwh-qvx6
59055897

5906-
Total 7 packages affected by 8 known vulnerabilities (0 Critical, 3 High, 5 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
5907-
8 vulnerabilities can be fixed.
5898+
Total 9 packages affected by 11 known vulnerabilities (0 Critical, 4 High, 7 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
5899+
11 vulnerabilities can be fixed.
59085900

59095901
RubyGems
59105902

@@ -5918,7 +5910,7 @@ lockfile:<tempdir>/Gemfile.lock: found 1 package with issues
59185910

59195911
npm
59205912

5921-
lockfile:<tempdir>/nested-1/package-lock.json: found 2 packages with issues
5913+
lockfile:<tempdir>/nested-1/package-lock.json: found 3 packages with issues
59225914

59235915
ajv@6.0.0 has the following known vulnerabilities:
59245916
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
@@ -5928,19 +5920,27 @@ lockfile:<tempdir>/nested-1/package-lock.json: found 2 packages with issues
59285920
ajv@8.0.0 has the following known vulnerabilities:
59295921
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
59305922
Severity: '5.5'; Minimal Fix Version: '8.18.0';
5923+
ansi-html@0.0.1 has the following known vulnerabilities:
5924+
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
5925+
Severity: '7.5'; Minimal Fix Version: '0.0.8';
59315926

5932-
3 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
5927+
4 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
59335928

5934-
lockfile:<tempdir>/nested-2/package-lock.json: found 2 packages with issues
5929+
lockfile:<tempdir>/nested-2/package-lock.json: found 3 packages with issues
59355930

59365931
ajv@6.0.0 has the following known vulnerabilities:
5932+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
5933+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
59375934
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
59385935
Severity: '5.6'; Minimal Fix Version: '6.12.3';
5936+
ajv@8.0.0 has the following known vulnerabilities:
5937+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
5938+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
59395939
ansi-html@0.0.1 has the following known vulnerabilities:
59405940
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
59415941
Severity: '7.5'; Minimal Fix Version: '0.0.8';
59425942

5943-
2 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
5943+
4 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
59445944

59455945
lockfile:<tempdir>/nested-3/package-lock.json: found 1 package with issues
59465946

@@ -6069,8 +6069,6 @@ Package npm/ajv/6.0.0 has been filtered out because: (no reason given)
60696069
Package npm/ajv/8.0.0 has been filtered out because: (no reason given)
60706070
Filtered 2 ignored package/s from the scan.
60716071
<tempdir>/nested-3/osv-scanner-test.toml has been updated to ignore 1 vulnerability
6072-
<tempdir>/nested-3/osv-scanner-test.toml has unused ignores:
6073-
- GHSA-2g4f-4pwh-qvx6
60746072

60756073
Total 9 packages affected by 11 known vulnerabilities (0 Critical, 4 High, 7 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
60766074
11 vulnerabilities can be fixed.
@@ -6272,16 +6270,9 @@ Filtered 2 ignored package/s from the scan.
62726270
<tempdir>/nested-2/osv-scanner-test.toml has been updated to ignore 3 vulnerabilities
62736271
<tempdir>/nested-3/osv-scanner-test.toml has been updated to ignore 1 vulnerability
62746272
<tempdir>/osv-scanner-test.toml has been updated to ignore 2 vulnerabilities
6275-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6276-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6277-
Filtered 2 vulnerabilities from output
6278-
<tempdir>/nested-2/osv-scanner-test.toml has unused ignores:
6279-
- GHSA-2g4f-4pwh-qvx6
6280-
<tempdir>/nested-3/osv-scanner-test.toml has unused ignores:
6281-
- GHSA-2g4f-4pwh-qvx6
62826273

6283-
Total 8 packages affected by 9 known vulnerabilities (0 Critical, 4 High, 5 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
6284-
9 vulnerabilities can be fixed.
6274+
Total 9 packages affected by 11 known vulnerabilities (0 Critical, 4 High, 7 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
6275+
11 vulnerabilities can be fixed.
62856276

62866277
RubyGems
62876278

@@ -6311,16 +6302,21 @@ lockfile:<tempdir>/nested-1/package-lock.json: found 3 packages with issues
63116302

63126303
4 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
63136304

6314-
lockfile:<tempdir>/nested-2/package-lock.json: found 2 packages with issues
6305+
lockfile:<tempdir>/nested-2/package-lock.json: found 3 packages with issues
63156306

63166307
ajv@6.0.0 has the following known vulnerabilities:
6308+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6309+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
63176310
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
63186311
Severity: '5.6'; Minimal Fix Version: '6.12.3';
6312+
ajv@8.0.0 has the following known vulnerabilities:
6313+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6314+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
63196315
ansi-html@0.0.1 has the following known vulnerabilities:
63206316
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
63216317
Severity: '7.5'; Minimal Fix Version: '0.0.8';
63226318

6323-
2 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
6319+
4 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
63246320

63256321
lockfile:<tempdir>/nested-3/package-lock.json: found 1 package with issues
63266322

@@ -6453,18 +6449,9 @@ Scanned <tempdir>/nested-2/package-lock.json file and found 3 packages
64536449
Scanned <tempdir>/nested-3/package-lock.json file and found 3 packages
64546450
Scanned <tempdir>/package-lock.json file and found 1 package
64556451
<tempdir>/custom-config.toml has been updated to ignore 4 vulnerabilities
6456-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6457-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6458-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6459-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6460-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6461-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6462-
Filtered 6 vulnerabilities from output
6463-
<tempdir>/custom-config.toml has unused ignores:
6464-
- CVE-123-456-789
64656452

6466-
Total 8 packages affected by 8 known vulnerabilities (0 Critical, 4 High, 4 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
6467-
8 vulnerabilities can be fixed.
6453+
Total 11 packages affected by 14 known vulnerabilities (0 Critical, 4 High, 10 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
6454+
14 vulnerabilities can be fixed.
64686455

64696456
RubyGems
64706457

@@ -6478,38 +6465,53 @@ lockfile:<tempdir>/Gemfile.lock: found 1 package with issues
64786465

64796466
npm
64806467

6481-
lockfile:<tempdir>/nested-1/package-lock.json: found 2 packages with issues
6468+
lockfile:<tempdir>/nested-1/package-lock.json: found 3 packages with issues
64826469

64836470
ajv@6.0.0 has the following known vulnerabilities:
6471+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6472+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
64846473
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
64856474
Severity: '5.6'; Minimal Fix Version: '6.12.3';
6475+
ajv@8.0.0 has the following known vulnerabilities:
6476+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6477+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
64866478
ansi-html@0.0.1 has the following known vulnerabilities:
64876479
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
64886480
Severity: '7.5'; Minimal Fix Version: '0.0.8';
64896481

6490-
2 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
6482+
4 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
64916483

6492-
lockfile:<tempdir>/nested-2/package-lock.json: found 2 packages with issues
6484+
lockfile:<tempdir>/nested-2/package-lock.json: found 3 packages with issues
64936485

64946486
ajv@6.0.0 has the following known vulnerabilities:
6487+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6488+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
64956489
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
64966490
Severity: '5.6'; Minimal Fix Version: '6.12.3';
6491+
ajv@8.0.0 has the following known vulnerabilities:
6492+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6493+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
64976494
ansi-html@0.0.1 has the following known vulnerabilities:
64986495
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
64996496
Severity: '7.5'; Minimal Fix Version: '0.0.8';
65006497

6501-
2 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
6498+
4 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
65026499

6503-
lockfile:<tempdir>/nested-3/package-lock.json: found 2 packages with issues
6500+
lockfile:<tempdir>/nested-3/package-lock.json: found 3 packages with issues
65046501

65056502
ajv@6.0.0 has the following known vulnerabilities:
6503+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6504+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
65066505
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
65076506
Severity: '5.6'; Minimal Fix Version: '6.12.3';
6507+
ajv@8.0.0 has the following known vulnerabilities:
6508+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6509+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
65086510
ansi-html@0.0.1 has the following known vulnerabilities:
65096511
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
65106512
Severity: '7.5'; Minimal Fix Version: '0.0.8';
65116513

6512-
2 known vulnerabilities found in lockfile:<tempdir>/nested-3/package-lock.json
6514+
4 known vulnerabilities found in lockfile:<tempdir>/nested-3/package-lock.json
65136515

65146516
lockfile:<tempdir>/package-lock.json: found 1 package with issues
65156517

@@ -6610,9 +6612,6 @@ Scanned <tempdir>/Gemfile.lock file and found 1 package
66106612
Scanned <tempdir>/composer.lock file and found 0 packages
66116613
Scanned <tempdir>/package-lock.json file and found 1 package
66126614
<tempdir>/custom-config.toml has been updated to ignore 2 vulnerabilities
6613-
<tempdir>/custom-config.toml has unused ignores:
6614-
- CVE-123-456-789
6615-
- GHSA-2g4f-4pwh-qvx6
66166615

66176616
Total 2 packages affected by 2 known vulnerabilities (0 Critical, 1 High, 1 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
66186617
2 vulnerabilities can be fixed.

pkg/osvscanner/osvscanner.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,8 @@ func finalizeScanResult(scanResult results.ScanResults, actions ScannerActions)
391391
vulnerabilityResults.LicenseSummary = buildLicenseSummary(&scanResult)
392392
}
393393

394-
// todo: consider moving this after filtering
395-
// - p: should allow deduplicating some logic
396-
// - p: might be a better UX to present the vulns we're ignoring
397-
// - c: filtering removes vulns from results, so need to account for that
394+
// we skip filtering vulns if we're going to ignore everything,
395+
// as the output will serve as a list of what actually got ignored
398396
if actions.UpdateConfigIgnores == "all" {
399397
ignoreEntries, err := addVulnConfigIgnoresAndSave(&vulnerabilityResults, &scanResult.ConfigManager)
400398

@@ -407,21 +405,21 @@ func finalizeScanResult(scanResult results.ScanResults, actions ScannerActions)
407405
if err != nil {
408406
return models.VulnerabilityResults{}, err
409407
}
410-
}
411-
412-
filtered := filterResults(&vulnerabilityResults, &scanResult.ConfigManager, actions.ShowAllPackages)
413-
if filtered > 0 {
414-
cmdlogger.Infof(
415-
"Filtered %d %s from output",
416-
filtered,
417-
output.Form(filtered, "vulnerability", "vulnerabilities"),
418-
)
419-
}
408+
} else {
409+
filtered := filterResults(&vulnerabilityResults, &scanResult.ConfigManager, actions.ShowAllPackages)
410+
if filtered > 0 {
411+
cmdlogger.Infof(
412+
"Filtered %d %s from output",
413+
filtered,
414+
output.Form(filtered, "vulnerability", "vulnerabilities"),
415+
)
416+
}
420417

421-
err := handleUnusedIgnoreEntries(&scanResult.ConfigManager, actions.UpdateConfigIgnores == "unused")
418+
err := handleUnusedIgnoreEntries(&scanResult.ConfigManager, actions.UpdateConfigIgnores == "unused")
422419

423-
if err != nil {
424-
return models.VulnerabilityResults{}, err
420+
if err != nil {
421+
return models.VulnerabilityResults{}, err
422+
}
425423
}
426424

427425
return vulnerabilityResults, determineReturnErr(vulnerabilityResults, actions.ShowAllVulns)

0 commit comments

Comments
 (0)