Skip to content

Commit 9124b27

Browse files
author
Maceo Thompson
committed
internal/vulncheck: pass SBOM to handlers
Passes the SBOM message to the handlers when in source and binary mode. Change-Id: Id3ef03eb4294f731a18739477e710edd85ab755e Reviewed-on: https://go-review.googlesource.com/c/vuln/+/616935 Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent db75d0a commit 9124b27

File tree

15 files changed

+406
-3
lines changed

15 files changed

+406
-3
lines changed

cmd/govulncheck/testdata/common/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
{
4040
"pattern": "\"timestamp\": (.*),",
4141
"replace": "\"timestamp\": \"2024-01-01T00:00:00\","
42+
},
43+
{
44+
"pattern": "path\": \"stdlib\",\n *\"version\": \"[^\\s]*\"",
45+
"replace": "path\": \"stdlib\",\n \"version\": \"v1.18.0\""
4246
}
4347
]
4448
}

cmd/govulncheck/testdata/common/testfiles/binary-call/binary_call_json.ct

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,40 @@ $ govulncheck -format json -mode binary ${common_vuln_binary}
2727
"message": "Checking the binary against the vulnerabilities..."
2828
}
2929
}
30+
{
31+
"SBOM": {
32+
"go_version": "go1.18",
33+
"modules": [
34+
{
35+
"path": "golang.org/vuln",
36+
"version": "(devel)"
37+
},
38+
{
39+
"path": "github.com/tidwall/gjson",
40+
"version": "v1.6.5"
41+
},
42+
{
43+
"path": "github.com/tidwall/match",
44+
"version": "v1.1.0"
45+
},
46+
{
47+
"path": "github.com/tidwall/pretty",
48+
"version": "v1.2.0"
49+
},
50+
{
51+
"path": "golang.org/x/text",
52+
"version": "v0.3.0"
53+
},
54+
{
55+
"path": "stdlib",
56+
"version": "v1.18.0"
57+
}
58+
],
59+
"roots": [
60+
"golang.org/vuln"
61+
]
62+
}
63+
}
3064
{
3165
"osv": {
3266
"schema_version": "1.3.1",

cmd/govulncheck/testdata/common/testfiles/binary-call/binary_vendored_json.ct

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,36 @@ $ govulncheck -format json -mode binary ${common_vendored_binary}
2727
"message": "Checking the binary against the vulnerabilities..."
2828
}
2929
}
30+
{
31+
"SBOM": {
32+
"go_version": "go1.18",
33+
"modules": [
34+
{
35+
"path": "golang.org/vendored",
36+
"version": "(devel)"
37+
},
38+
{
39+
"path": "github.com/tidwall/gjson",
40+
"version": "v1.6.5"
41+
},
42+
{
43+
"path": "golang.org/x/text",
44+
"version": "v0.3.0"
45+
},
46+
{
47+
"path": "private.com/privateuser/fakemod",
48+
"version": "v1.0.0"
49+
},
50+
{
51+
"path": "stdlib",
52+
"version": "v1.18.0"
53+
}
54+
],
55+
"roots": [
56+
"golang.org/vendored"
57+
]
58+
}
59+
}
3060
{
3161
"osv": {
3262
"schema_version": "1.3.1",

cmd/govulncheck/testdata/common/testfiles/binary-module/binary_module_json.ct

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,40 @@ $ govulncheck -format json -mode binary -scan module ${common_vuln_binary}
2727
"message": "Checking the binary against the vulnerabilities..."
2828
}
2929
}
30+
{
31+
"SBOM": {
32+
"go_version": "go1.18",
33+
"modules": [
34+
{
35+
"path": "golang.org/vuln",
36+
"version": "(devel)"
37+
},
38+
{
39+
"path": "github.com/tidwall/gjson",
40+
"version": "v1.6.5"
41+
},
42+
{
43+
"path": "github.com/tidwall/match",
44+
"version": "v1.1.0"
45+
},
46+
{
47+
"path": "github.com/tidwall/pretty",
48+
"version": "v1.2.0"
49+
},
50+
{
51+
"path": "golang.org/x/text",
52+
"version": "v0.3.0"
53+
},
54+
{
55+
"path": "stdlib",
56+
"version": "v1.18.0"
57+
}
58+
],
59+
"roots": [
60+
"golang.org/vuln"
61+
]
62+
}
63+
}
3064
{
3165
"osv": {
3266
"schema_version": "1.3.1",

cmd/govulncheck/testdata/common/testfiles/binary-package/binary_package_json.ct

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,40 @@ $ govulncheck -format json -mode binary -scan package ${common_vuln_binary}
2727
"message": "Checking the binary against the vulnerabilities..."
2828
}
2929
}
30+
{
31+
"SBOM": {
32+
"go_version": "go1.18",
33+
"modules": [
34+
{
35+
"path": "golang.org/vuln",
36+
"version": "(devel)"
37+
},
38+
{
39+
"path": "github.com/tidwall/gjson",
40+
"version": "v1.6.5"
41+
},
42+
{
43+
"path": "github.com/tidwall/match",
44+
"version": "v1.1.0"
45+
},
46+
{
47+
"path": "github.com/tidwall/pretty",
48+
"version": "v1.2.0"
49+
},
50+
{
51+
"path": "golang.org/x/text",
52+
"version": "v0.3.0"
53+
},
54+
{
55+
"path": "stdlib",
56+
"version": "v1.18.0"
57+
}
58+
],
59+
"roots": [
60+
"golang.org/vuln"
61+
]
62+
}
63+
}
3064
{
3165
"osv": {
3266
"schema_version": "1.3.1",

cmd/govulncheck/testdata/common/testfiles/source-call/source_call_json.ct

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,40 @@ $ govulncheck -C ${moddir}/vuln -format json ./...
2727
"message": "Checking the code against the vulnerabilities..."
2828
}
2929
}
30+
{
31+
"SBOM": {
32+
"go_version": "go1.18",
33+
"modules": [
34+
{
35+
"path": "golang.org/vuln"
36+
},
37+
{
38+
"path": "github.com/tidwall/gjson",
39+
"version": "v1.6.5"
40+
},
41+
{
42+
"path": "github.com/tidwall/match",
43+
"version": "v1.1.0"
44+
},
45+
{
46+
"path": "github.com/tidwall/pretty",
47+
"version": "v1.2.0"
48+
},
49+
{
50+
"path": "golang.org/x/text",
51+
"version": "v0.3.0"
52+
},
53+
{
54+
"path": "stdlib",
55+
"version": "v1.18.0"
56+
}
57+
],
58+
"roots": [
59+
"golang.org/vuln",
60+
"golang.org/vuln/subdir"
61+
]
62+
}
63+
}
3064
{
3165
"osv": {
3266
"schema_version": "1.3.1",

cmd/govulncheck/testdata/common/testfiles/source-call/source_multientry_json.ct

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ $ govulncheck -format json -C ${moddir}/multientry .
2828
"message": "Checking the code against the vulnerabilities..."
2929
}
3030
}
31+
{
32+
"SBOM": {
33+
"go_version": "go1.18",
34+
"modules": [
35+
{
36+
"path": "golang.org/multientry"
37+
},
38+
{
39+
"path": "golang.org/x/text",
40+
"version": "v0.3.5"
41+
},
42+
{
43+
"path": "stdlib",
44+
"version": "v1.18.0"
45+
}
46+
],
47+
"roots": [
48+
"golang.org/multientry"
49+
]
50+
}
51+
}
3152
{
3253
"osv": {
3354
"schema_version": "1.3.1",

cmd/govulncheck/testdata/common/testfiles/source-call/source_replace_json.ct

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ $ govulncheck -C ${moddir}/replace -format json ./...
2828
"message": "Checking the code against the vulnerabilities..."
2929
}
3030
}
31+
{
32+
"SBOM": {
33+
"go_version": "go1.18",
34+
"modules": [
35+
{
36+
"path": "golang.org/replace"
37+
},
38+
{
39+
"path": "golang.org/x/text",
40+
"version": "v0.3.0"
41+
},
42+
{
43+
"path": "stdlib",
44+
"version": "v1.18.0"
45+
}
46+
],
47+
"roots": [
48+
"golang.org/replace"
49+
]
50+
}
51+
}
3152
{
3253
"osv": {
3354
"schema_version": "1.3.1",

cmd/govulncheck/testdata/common/testfiles/source-call/source_vendored_json.ct

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,36 @@ $ govulncheck -C ${moddir}/vendored -format json ./...
2828
"message": "Checking the code against the vulnerabilities..."
2929
}
3030
}
31+
{
32+
"SBOM": {
33+
"go_version": "go1.18",
34+
"modules": [
35+
{
36+
"path": "golang.org/vendored"
37+
},
38+
{
39+
"path": "github.com/tidwall/gjson",
40+
"version": "v1.6.5"
41+
},
42+
{
43+
"path": "golang.org/x/text",
44+
"version": "v0.3.0"
45+
},
46+
{
47+
"path": "private.com/privateuser/fakemod",
48+
"version": "v1.0.0"
49+
},
50+
{
51+
"path": "stdlib",
52+
"version": "v1.18.0"
53+
}
54+
],
55+
"roots": [
56+
"golang.org/vendored",
57+
"golang.org/vendored/subdir"
58+
]
59+
}
60+
}
3161
{
3262
"osv": {
3363
"schema_version": "1.3.1",

cmd/govulncheck/testdata/common/testfiles/source-module/source_module_json.ct

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ $ govulncheck -format json -scan module -C ${moddir}/multientry
2828
"message": "Checking the code against the vulnerabilities..."
2929
}
3030
}
31+
{
32+
"SBOM": {
33+
"go_version": "go1.18",
34+
"modules": [
35+
{
36+
"path": "golang.org/multientry"
37+
},
38+
{
39+
"path": "golang.org/x/text",
40+
"version": "v0.3.5"
41+
},
42+
{
43+
"path": "stdlib",
44+
"version": "v1.18.0"
45+
}
46+
],
47+
"roots": [
48+
"golang.org/multientry"
49+
]
50+
}
51+
}
3152
{
3253
"osv": {
3354
"schema_version": "1.3.1",

0 commit comments

Comments
 (0)