Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IgnoredVulns also ignore aliases #300

Merged
merged 16 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ id = "GO-2022-1059"
# ignoreUntil = 2022-11-09 # Optional exception expiry date
reason = "No external http servers are written in Go lang."
```

Ignoring a vulnerability will also ignore vulnerabilities that are considered aliases of that vulnerability.
2 changes: 1 addition & 1 deletion internal/testutility/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func AssertMatchFixtureJSON[V any](t *testing.T, path string, val V) {
// can be used with AssertMatchFixtureJSON to compare against future values.
func CreateJSONFixture[V any](t *testing.T, path string, val V) {
t.Helper()
file, err := os.Open(path)
file, err := os.Create(path)
if err != nil {
t.Fatalf("Failed to open file to write: %s", err)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/osvscanner/fixtures/filter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out.json
21 changes: 21 additions & 0 deletions pkg/osvscanner/fixtures/filter/all/configs/a/osv-scanner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# An entry for every vulnerability (including aliases)

[[IgnoredVulns]]
id = "GHSA-mc8h-8q98-g5hr"
reason = "Ignore 1"
# Alias of RUSTSEC-2023-0018

[[IgnoredVulns]]
michaelkedar marked this conversation as resolved.
Show resolved Hide resolved
id = "RUSTSEC-2023-0018"
reason = "Redundant Ignore 1"
# Redundant ignore statement - Alias of GHSA-mc8h-8q98-g5hr

[[IgnoredVulns]]
id = "GHSA-wcg3-cvx6-7396"
reason = "Ignore 2"
# Alias of RUSTSEC-2020-0071

[[IgnoredVulns]]
id = "RUSTSEC-2020-0071"
reason = "Redundant Ignore 2"
# Redundant ignore statement - Alias of GHSA-wcg3-cvx6-7396
16 changes: 16 additions & 0 deletions pkg/osvscanner/fixtures/filter/all/configs/b/osv-scanner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One entry for each vulnerability group

[[IgnoredVulns]]
id = "GHSA-fxg5-wq6x-vr4w"
reason = "Ignore 1"
# Alias of GO-2023-1495

[[IgnoredVulns]]
id = "GO-2022-1144"
reason = "Ignore 2"
# Alias of GHSA-xrjj-mj9h-534m

[[IgnoredVulns]]
id = "GO-2023-1571"
reason = "Ignore 3"
# Alias of GHSA-vvpx-j8f3-3w6h
21 changes: 21 additions & 0 deletions pkg/osvscanner/fixtures/filter/all/configs/c/osv-scanner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# One entry for each vulnerability group

[[IgnoredVulns]]
id = "GHSA-mc8h-8q98-g5hr"
reason = "Ignore 1"
# Alias of RUSTSEC-2023-0018

[[IgnoredVulns]]
id = "RUSTSEC-2020-0071"
reason = "Ignore 2"
# Alias of GHSA-wcg3-cvx6-7396

[[IgnoredVulns]]
id = "RUSTSEC-2023-0015"
reason = "Ignore 3"
# No aliases

[[IgnoredVulns]]
id = "GHSA-mrrw-grhq-86gf"
reason = "Ignore 4"
# No aliases
1,427 changes: 1,427 additions & 0 deletions pkg/osvscanner/fixtures/filter/all/input.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions pkg/osvscanner/fixtures/filter/all/want.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"results": []
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# An empty config file
13 changes: 13 additions & 0 deletions pkg/osvscanner/fixtures/filter/none/configs/c/osv-scanner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These vulnerabilities do not appear in this 'source'

[[IgnoredVulns]]
id = "GHSA-fxg5-wq6x-vr4w"
reason = "Ignore 1"

[[IgnoredVulns]]
id = "GO-2022-1144"
reason = "Ignore 2"

[[IgnoredVulns]]
id = "GO-2023-1571"
reason = "Ignore 3"
1,427 changes: 1,427 additions & 0 deletions pkg/osvscanner/fixtures/filter/none/input.json

Large diffs are not rendered by default.

1,427 changes: 1,427 additions & 0 deletions pkg/osvscanner/fixtures/filter/none/want.json

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions pkg/osvscanner/fixtures/filter/some/configs/a/osv-scanner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Every vulnerability in this source is ignored. Should not show up at all after filtering.

[[IgnoredVulns]]
id = "GHSA-mc8h-8q98-g5hr"
reason = "Ignore 1"
# Alias of RUSTSEC-2023-0018

[[IgnoredVulns]]
id = "RUSTSEC-2020-0071"
reason = "Ignore 2"
# Alias of GHSA-wcg3-cvx6-7396
14 changes: 14 additions & 0 deletions pkg/osvscanner/fixtures/filter/some/configs/b/osv-scanner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# golang.org/x/net is the only vulnerable package, but has multiple unique vulnerabilities.
# Ignore some vulnerabilities while keeping others. Package should remain in filtered output.

[[IgnoredVulns]]
id = "GHSA-fxg5-wq6x-vr4w"
reason = "Ignore 1"
# Alias of GO-2023-1495

[[IgnoredVulns]]
id = "GO-2022-1144"
reason = "Ignore 2"
# No aliases

# GHSA-vvpx-j8f3-3w6h (and alias GO-2023-1571) should remain unfiltered.
18 changes: 18 additions & 0 deletions pkg/osvscanner/fixtures/filter/some/configs/c/osv-scanner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ignore all vulnerabilities from one package (remove_dir_all), one from one package (ascii), none from other (time).
# remove_dir_all should be removed from filtered output, other two packages should remain with filtered vulns.

# remove_dir_all:
[[IgnoredVulns]]
id = "GHSA-mc8h-8q98-g5hr"
reason = "Ignore 1"
# Alias of RUSTSEC-2023-0018

# ascii:
[[IgnoredVulns]]
id = "RUSTSEC-2023-0015"
reason = "Ignore 2"
# No Aliases

# Remaining packages/vulns:
# ascii - GHSA-mrrw-grhq-86gf (no aliases)
# time - GHSA-wcg3-cvx6-7396 (& alias RUSTSEC-2020-0071)
Loading