Skip to content

Commit a99c857

Browse files
committed
feat: don't filter when ignoring all vulns
1 parent 8185df6 commit a99c857

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
@@ -5786,17 +5786,9 @@ Filtered 2 ignored package/s from the scan.
57865786
<tempdir>/nested-2/osv-scanner-test.toml has been updated to ignore 3 vulnerabilities
57875787
<tempdir>/nested-3/osv-scanner-test.toml has been updated to ignore 1 vulnerability
57885788
<tempdir>/osv-scanner-test.toml has been updated to ignore 2 vulnerabilities
5789-
CVE-2021-23424 and 1 alias have been filtered out because: Test manifest file (package-lock.json)
5790-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
5791-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
5792-
Filtered 3 vulnerabilities from output
5793-
<tempdir>/nested-2/osv-scanner-test.toml has unused ignores:
5794-
- GHSA-2g4f-4pwh-qvx6
5795-
<tempdir>/nested-3/osv-scanner-test.toml has unused ignores:
5796-
- GHSA-2g4f-4pwh-qvx6
57975789

5798-
Total 7 packages affected by 8 known vulnerabilities (0 Critical, 3 High, 5 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
5799-
8 vulnerabilities can be fixed.
5790+
Total 9 packages affected by 11 known vulnerabilities (0 Critical, 4 High, 7 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
5791+
11 vulnerabilities can be fixed.
58005792

58015793
RubyGems
58025794

@@ -5810,7 +5802,7 @@ lockfile:<tempdir>/Gemfile.lock: found 1 package with issues
58105802

58115803
npm
58125804

5813-
lockfile:<tempdir>/nested-1/package-lock.json: found 2 packages with issues
5805+
lockfile:<tempdir>/nested-1/package-lock.json: found 3 packages with issues
58145806

58155807
ajv@6.0.0 has the following known vulnerabilities:
58165808
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
@@ -5820,19 +5812,27 @@ lockfile:<tempdir>/nested-1/package-lock.json: found 2 packages with issues
58205812
ajv@8.0.0 has the following known vulnerabilities:
58215813
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
58225814
Severity: '5.5'; Minimal Fix Version: '8.18.0';
5815+
ansi-html@0.0.1 has the following known vulnerabilities:
5816+
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
5817+
Severity: '7.5'; Minimal Fix Version: '0.0.8';
58235818

5824-
3 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
5819+
4 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
58255820

5826-
lockfile:<tempdir>/nested-2/package-lock.json: found 2 packages with issues
5821+
lockfile:<tempdir>/nested-2/package-lock.json: found 3 packages with issues
58275822

58285823
ajv@6.0.0 has the following known vulnerabilities:
5824+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
5825+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
58295826
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
58305827
Severity: '5.6'; Minimal Fix Version: '6.12.3';
5828+
ajv@8.0.0 has the following known vulnerabilities:
5829+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
5830+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
58315831
ansi-html@0.0.1 has the following known vulnerabilities:
58325832
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
58335833
Severity: '7.5'; Minimal Fix Version: '0.0.8';
58345834

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

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

@@ -5961,8 +5961,6 @@ Package npm/ajv/6.0.0 has been filtered out because: (no reason given)
59615961
Package npm/ajv/8.0.0 has been filtered out because: (no reason given)
59625962
Filtered 2 ignored package/s from the scan.
59635963
<tempdir>/nested-3/osv-scanner-test.toml has been updated to ignore 1 vulnerability
5964-
<tempdir>/nested-3/osv-scanner-test.toml has unused ignores:
5965-
- GHSA-2g4f-4pwh-qvx6
59665964

59675965
Total 9 packages affected by 11 known vulnerabilities (0 Critical, 4 High, 7 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
59685966
11 vulnerabilities can be fixed.
@@ -6164,16 +6162,9 @@ Filtered 2 ignored package/s from the scan.
61646162
<tempdir>/nested-2/osv-scanner-test.toml has been updated to ignore 3 vulnerabilities
61656163
<tempdir>/nested-3/osv-scanner-test.toml has been updated to ignore 1 vulnerability
61666164
<tempdir>/osv-scanner-test.toml has been updated to ignore 2 vulnerabilities
6167-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6168-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6169-
Filtered 2 vulnerabilities from output
6170-
<tempdir>/nested-2/osv-scanner-test.toml has unused ignores:
6171-
- GHSA-2g4f-4pwh-qvx6
6172-
<tempdir>/nested-3/osv-scanner-test.toml has unused ignores:
6173-
- GHSA-2g4f-4pwh-qvx6
61746165

6175-
Total 8 packages affected by 9 known vulnerabilities (0 Critical, 4 High, 5 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
6176-
9 vulnerabilities can be fixed.
6166+
Total 9 packages affected by 11 known vulnerabilities (0 Critical, 4 High, 7 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
6167+
11 vulnerabilities can be fixed.
61776168

61786169
RubyGems
61796170

@@ -6203,16 +6194,21 @@ lockfile:<tempdir>/nested-1/package-lock.json: found 3 packages with issues
62036194

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

6206-
lockfile:<tempdir>/nested-2/package-lock.json: found 2 packages with issues
6197+
lockfile:<tempdir>/nested-2/package-lock.json: found 3 packages with issues
62076198

62086199
ajv@6.0.0 has the following known vulnerabilities:
6200+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6201+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
62096202
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
62106203
Severity: '5.6'; Minimal Fix Version: '6.12.3';
6204+
ajv@8.0.0 has the following known vulnerabilities:
6205+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6206+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
62116207
ansi-html@0.0.1 has the following known vulnerabilities:
62126208
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
62136209
Severity: '7.5'; Minimal Fix Version: '0.0.8';
62146210

6215-
2 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
6211+
4 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
62166212

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

@@ -6345,18 +6341,9 @@ Scanned <tempdir>/nested-2/package-lock.json file and found 3 packages
63456341
Scanned <tempdir>/nested-3/package-lock.json file and found 3 packages
63466342
Scanned <tempdir>/package-lock.json file and found 1 package
63476343
<tempdir>/custom-config.toml has been updated to ignore 4 vulnerabilities
6348-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6349-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6350-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6351-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6352-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6353-
GHSA-2g4f-4pwh-qvx6 and 1 alias have been filtered out because: (no reason given)
6354-
Filtered 6 vulnerabilities from output
6355-
<tempdir>/custom-config.toml has unused ignores:
6356-
- CVE-123-456-789
63576344

6358-
Total 8 packages affected by 8 known vulnerabilities (0 Critical, 4 High, 4 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
6359-
8 vulnerabilities can be fixed.
6345+
Total 11 packages affected by 14 known vulnerabilities (0 Critical, 4 High, 10 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
6346+
14 vulnerabilities can be fixed.
63606347

63616348
RubyGems
63626349

@@ -6370,38 +6357,53 @@ lockfile:<tempdir>/Gemfile.lock: found 1 package with issues
63706357

63716358
npm
63726359

6373-
lockfile:<tempdir>/nested-1/package-lock.json: found 2 packages with issues
6360+
lockfile:<tempdir>/nested-1/package-lock.json: found 3 packages with issues
63746361

63756362
ajv@6.0.0 has the following known vulnerabilities:
6363+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6364+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
63766365
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
63776366
Severity: '5.6'; Minimal Fix Version: '6.12.3';
6367+
ajv@8.0.0 has the following known vulnerabilities:
6368+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6369+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
63786370
ansi-html@0.0.1 has the following known vulnerabilities:
63796371
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
63806372
Severity: '7.5'; Minimal Fix Version: '0.0.8';
63816373

6382-
2 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
6374+
4 known vulnerabilities found in lockfile:<tempdir>/nested-1/package-lock.json
63836375

6384-
lockfile:<tempdir>/nested-2/package-lock.json: found 2 packages with issues
6376+
lockfile:<tempdir>/nested-2/package-lock.json: found 3 packages with issues
63856377

63866378
ajv@6.0.0 has the following known vulnerabilities:
6379+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6380+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
63876381
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
63886382
Severity: '5.6'; Minimal Fix Version: '6.12.3';
6383+
ajv@8.0.0 has the following known vulnerabilities:
6384+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6385+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
63896386
ansi-html@0.0.1 has the following known vulnerabilities:
63906387
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
63916388
Severity: '7.5'; Minimal Fix Version: '0.0.8';
63926389

6393-
2 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
6390+
4 known vulnerabilities found in lockfile:<tempdir>/nested-2/package-lock.json
63946391

6395-
lockfile:<tempdir>/nested-3/package-lock.json: found 2 packages with issues
6392+
lockfile:<tempdir>/nested-3/package-lock.json: found 3 packages with issues
63966393

63976394
ajv@6.0.0 has the following known vulnerabilities:
6395+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6396+
Severity: '5.5'; Minimal Fix Version: '6.14.0';
63986397
GHSA-v88g-cgmw-v5xw: Prototype Pollution in Ajv
63996398
Severity: '5.6'; Minimal Fix Version: '6.12.3';
6399+
ajv@8.0.0 has the following known vulnerabilities:
6400+
GHSA-2g4f-4pwh-qvx6: ajv has ReDoS when using `$data` option
6401+
Severity: '5.5'; Minimal Fix Version: '8.18.0';
64006402
ansi-html@0.0.1 has the following known vulnerabilities:
64016403
GHSA-whgm-jr23-g3j9: Uncontrolled Resource Consumption in ansi-html
64026404
Severity: '7.5'; Minimal Fix Version: '0.0.8';
64036405

6404-
2 known vulnerabilities found in lockfile:<tempdir>/nested-3/package-lock.json
6406+
4 known vulnerabilities found in lockfile:<tempdir>/nested-3/package-lock.json
64056407

64066408
lockfile:<tempdir>/package-lock.json: found 1 package with issues
64076409

@@ -6502,9 +6504,6 @@ Scanned <tempdir>/Gemfile.lock file and found 1 package
65026504
Scanned <tempdir>/composer.lock file and found 0 packages
65036505
Scanned <tempdir>/package-lock.json file and found 1 package
65046506
<tempdir>/custom-config.toml has been updated to ignore 2 vulnerabilities
6505-
<tempdir>/custom-config.toml has unused ignores:
6506-
- CVE-123-456-789
6507-
- GHSA-2g4f-4pwh-qvx6
65086507

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

pkg/osvscanner/osvscanner.go

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

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

@@ -410,21 +408,21 @@ func finalizeScanResult(scanResult results.ScanResults, actions ScannerActions)
410408
if err != nil {
411409
return models.VulnerabilityResults{}, err
412410
}
413-
}
414-
415-
filtered := filterResults(&vulnerabilityResults, &scanResult.ConfigManager, actions.ShowAllPackages)
416-
if filtered > 0 {
417-
cmdlogger.Infof(
418-
"Filtered %d %s from output",
419-
filtered,
420-
output.Form(filtered, "vulnerability", "vulnerabilities"),
421-
)
422-
}
411+
} else {
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+
}
423420

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

426-
if err != nil {
427-
return models.VulnerabilityResults{}, err
423+
if err != nil {
424+
return models.VulnerabilityResults{}, err
425+
}
428426
}
429427

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

0 commit comments

Comments
 (0)