Skip to content

Commit 461a68a

Browse files
authoredNov 21, 2024··
fix(sbom): Fixes for Programming Language Vulnerabilities and SBOM Package Maintainer Details (#7871)
1 parent 45d3b40 commit 461a68a

File tree

9 files changed

+563
-113
lines changed

9 files changed

+563
-113
lines changed
 

‎integration/testdata/fluentd-multiple-lockfiles.cdx.json.golden

+421-106
Large diffs are not rendered by default.

‎pkg/detector/library/driver.go

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func (d *Driver) DetectVulnerabilities(pkgID, pkgName, pkgVer string) ([]types.D
133133
InstalledVersion: pkgVer,
134134
FixedVersion: createFixedVersions(adv),
135135
DataSource: adv.DataSource,
136+
Custom: adv.Custom,
136137
}
137138
vulns = append(vulns, vuln)
138139
}

‎pkg/detector/library/driver_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,32 @@ func TestDriver_Detect(t *testing.T) {
182182
},
183183
},
184184
},
185+
{
186+
name: "Custom data for vulnerability",
187+
fixtures: []string{
188+
"testdata/fixtures/go-custom-data.yaml",
189+
"testdata/fixtures/data-source.yaml",
190+
},
191+
libType: ftypes.GoBinary,
192+
args: args{
193+
pkgName: "github.com/docker/docker",
194+
pkgVer: "23.0.14",
195+
},
196+
want: []types.DetectedVulnerability{
197+
{
198+
VulnerabilityID: "GHSA-v23v-6jw2-98fq",
199+
PkgName: "github.com/docker/docker",
200+
InstalledVersion: "23.0.14",
201+
FixedVersion: "23.0.15, 26.1.5, 27.1.1, 25.0.6",
202+
DataSource: &dbTypes.DataSource{
203+
ID: vulnerability.GHSA,
204+
Name: "GitHub Security Advisory Go",
205+
URL: "https://github.com/advisories?query=type%3Areviewed+ecosystem%3Ago",
206+
},
207+
Custom: map[string]any{"Severity": 2.0},
208+
},
209+
},
210+
},
185211
}
186212
for _, tt := range tests {
187213
t.Run(tt.name, func(t *testing.T) {

‎pkg/detector/library/testdata/fixtures/data-source.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@
2525
ID: "ghsa"
2626
Name: "GitHub Security Advisory Pip"
2727
URL: "https://github.com/advisories?query=type%3Areviewed+ecosystem%3Apip"
28+
- key: "go::GitHub Security Advisory Go"
29+
value:
30+
ID: "ghsa"
31+
Name: "GitHub Security Advisory Go"
32+
URL: "https://github.com/advisories?query=type%3Areviewed+ecosystem%3Ago"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- bucket: "go::GitHub Security Advisory Go"
2+
pairs:
3+
- bucket: github.com/docker/docker
4+
pairs:
5+
- key: "GHSA-v23v-6jw2-98fq"
6+
value:
7+
PatchedVersions:
8+
- "23.0.15"
9+
- "26.1.5"
10+
- "27.1.1"
11+
- "25.0.6"
12+
VulnerableVersions:
13+
- ">=19.03.0, <23.0.15"
14+
- ">=26.0.0, <26.1.5"
15+
- ">=27.0.0, <27.1.1"
16+
- ">=24.0.0, <25.0.6"
17+
Custom:
18+
Severity: 2

‎pkg/rpc/convert.go

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func ConvertToRPCPkgs(pkgs []ftypes.Package) []*common.Package {
7171
DependsOn: pkg.DependsOn,
7272
Digest: pkg.Digest.String(),
7373
Indirect: pkg.Indirect,
74+
Maintainer: pkg.Maintainer,
7475
})
7576
}
7677
return rpcPkgs
@@ -226,6 +227,7 @@ func ConvertFromRPCPkgs(rpcPkgs []*common.Package) []ftypes.Package {
226227
DependsOn: pkg.DependsOn,
227228
Digest: digest.Digest(pkg.Digest),
228229
Indirect: pkg.Indirect,
230+
Maintainer: pkg.Maintainer,
229231
})
230232
}
231233
return pkgs

‎pkg/rpc/convert_test.go

+72
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,78 @@ func TestConvertFromRpcPkgs(t *testing.T) {
183183
},
184184
},
185185
},
186+
{
187+
args: args{
188+
rpcPkgs: []*common.Package{
189+
{
190+
Name: "binary",
191+
Version: "4.2+dfsg",
192+
Release: "0.1+deb7u4",
193+
Epoch: 0,
194+
Arch: "amd64",
195+
SrcName: "bash",
196+
SrcVersion: "4.2+dfsg",
197+
SrcRelease: "0.1+deb7u4",
198+
SrcEpoch: 0,
199+
Licenses: []string{"GPL-3.0"},
200+
Locations: []*common.Location{
201+
{
202+
StartLine: 10,
203+
EndLine: 20,
204+
},
205+
{
206+
StartLine: 22,
207+
EndLine: 32,
208+
},
209+
},
210+
Layer: &common.Layer{
211+
Digest: "sha256:8d42b73fc1ddc2e9e66c954966f144665825e69f4ed10c66342ae7c26b38d4e4",
212+
DiffId: "sha256:745d171eb8c3d69f788da3a1b053056231ad140b80be71d6869229846a1f3a77",
213+
},
214+
Digest: "SHA1:901a7b55410321c4d35543506cff2a8613ef5aa2",
215+
Indirect: false,
216+
Identifier: &common.PkgIdentifier{
217+
Uid: "63f8bef824b960e3",
218+
},
219+
Maintainer: "alice@example.com",
220+
},
221+
},
222+
},
223+
want: []ftypes.Package{
224+
{
225+
Name: "binary",
226+
Version: "4.2+dfsg",
227+
Release: "0.1+deb7u4",
228+
Epoch: 0,
229+
Arch: "amd64",
230+
SrcName: "bash",
231+
SrcVersion: "4.2+dfsg",
232+
SrcRelease: "0.1+deb7u4",
233+
SrcEpoch: 0,
234+
Licenses: []string{"GPL-3.0"},
235+
Locations: []ftypes.Location{
236+
{
237+
StartLine: 10,
238+
EndLine: 20,
239+
},
240+
{
241+
StartLine: 22,
242+
EndLine: 32,
243+
},
244+
},
245+
Layer: ftypes.Layer{
246+
Digest: "sha256:8d42b73fc1ddc2e9e66c954966f144665825e69f4ed10c66342ae7c26b38d4e4",
247+
DiffID: "sha256:745d171eb8c3d69f788da3a1b053056231ad140b80be71d6869229846a1f3a77",
248+
},
249+
Digest: "SHA1:901a7b55410321c4d35543506cff2a8613ef5aa2",
250+
Indirect: false,
251+
Identifier: ftypes.PkgIdentifier{
252+
UID: "63f8bef824b960e3",
253+
},
254+
Maintainer: "alice@example.com",
255+
},
256+
},
257+
},
186258
}
187259
for _, tt := range tests {
188260
t.Run(tt.name, func(t *testing.T) {

‎rpc/common/service.pb.go

+12-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/common/service.proto

+6-5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ message Package {
5454
string digest = 16;
5555
bool dev = 17;
5656
bool indirect = 18;
57+
string maintainer = 21;
5758
}
5859

5960
message PkgIdentifier {
@@ -68,11 +69,11 @@ message Location {
6869
}
6970

7071
message Misconfiguration {
71-
string file_type = 1;
72-
string file_path = 2;
73-
repeated MisconfResult successes = 3;
74-
repeated MisconfResult warnings = 4;
75-
repeated MisconfResult failures = 5;
72+
string file_type = 1;
73+
string file_path = 2;
74+
repeated MisconfResult successes = 3;
75+
repeated MisconfResult warnings = 4;
76+
repeated MisconfResult failures = 5;
7677

7778
reserved 6; // deprecated 'exceptions'
7879
}

0 commit comments

Comments
 (0)
Please sign in to comment.