Skip to content

Commit

Permalink
feat: Add local ImageID to SARIF metadata (#6522)
Browse files Browse the repository at this point in the history
Signed-off-by: knqyf263 <[email protected]>
Co-authored-by: knqyf263 <[email protected]>
  • Loading branch information
charlesoxyer and knqyf263 authored Jun 19, 2024
1 parent 5ee4e9d commit f144e91
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions integration/testdata/alpine-310.sarif.golden
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
}
},
"properties": {
"imageID": "sha256:961769676411f082461f9ef46626dd7a2d1e2b2a38e6a44364bcbecf51e66dd4",
"imageName": "testdata/fixtures/images/alpine-310.tar.gz",
"repoDigests": null,
"repoTags": null
Expand Down
1 change: 1 addition & 0 deletions pkg/report/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (sw *SarifWriter) Write(ctx context.Context, report types.Report) error {
"imageName": report.ArtifactName,
"repoTags": report.Metadata.RepoTags,
"repoDigests": report.Metadata.RepoDigests,
"imageID": report.Metadata.ImageID,
}
}
if sw.Target != "" {
Expand Down
2 changes: 2 additions & 0 deletions pkg/report/sarif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestReportWriter_Sarif(t *testing.T) {
ArtifactName: "debian:9",
ArtifactType: artifact.TypeContainerImage,
Metadata: types.Metadata{
ImageID: "sha256:7640c3f9e75002deb419d5e32738eeff82cf2b3edca3781b4fe1f1f626d11b20",
RepoTags: []string{
"debian:9",
},
Expand Down Expand Up @@ -177,6 +178,7 @@ func TestReportWriter_Sarif(t *testing.T) {
PropertyBag: sarif.PropertyBag{
Properties: map[string]any{
"imageName": "debian:9",
"imageID": "sha256:7640c3f9e75002deb419d5e32738eeff82cf2b3edca3781b4fe1f1f626d11b20",
"repoDigests": []any{"debian@sha256:a8cc1744bbdd5266678e3e8b3e6387e45c053218438897e86876f2eb104e5534"},
"repoTags": []any{"debian:9"},
},
Expand Down

0 comments on commit f144e91

Please sign in to comment.