Skip to content

Commit f144e91

Browse files
feat: Add local ImageID to SARIF metadata (#6522)
Signed-off-by: knqyf263 <knqyf263@gmail.com> Co-authored-by: knqyf263 <knqyf263@gmail.com>
1 parent 5ee4e9d commit f144e91

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

integration/testdata/alpine-310.sarif.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
}
185185
},
186186
"properties": {
187+
"imageID": "sha256:961769676411f082461f9ef46626dd7a2d1e2b2a38e6a44364bcbecf51e66dd4",
187188
"imageName": "testdata/fixtures/images/alpine-310.tar.gz",
188189
"repoDigests": null,
189190
"repoTags": null

pkg/report/sarif.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func (sw *SarifWriter) Write(ctx context.Context, report types.Report) error {
137137
"imageName": report.ArtifactName,
138138
"repoTags": report.Metadata.RepoTags,
139139
"repoDigests": report.Metadata.RepoDigests,
140+
"imageID": report.Metadata.ImageID,
140141
}
141142
}
142143
if sw.Target != "" {

pkg/report/sarif_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestReportWriter_Sarif(t *testing.T) {
3131
ArtifactName: "debian:9",
3232
ArtifactType: artifact.TypeContainerImage,
3333
Metadata: types.Metadata{
34+
ImageID: "sha256:7640c3f9e75002deb419d5e32738eeff82cf2b3edca3781b4fe1f1f626d11b20",
3435
RepoTags: []string{
3536
"debian:9",
3637
},
@@ -177,6 +178,7 @@ func TestReportWriter_Sarif(t *testing.T) {
177178
PropertyBag: sarif.PropertyBag{
178179
Properties: map[string]any{
179180
"imageName": "debian:9",
181+
"imageID": "sha256:7640c3f9e75002deb419d5e32738eeff82cf2b3edca3781b4fe1f1f626d11b20",
180182
"repoDigests": []any{"debian@sha256:a8cc1744bbdd5266678e3e8b3e6387e45c053218438897e86876f2eb104e5534"},
181183
"repoTags": []any{"debian:9"},
182184
},

0 commit comments

Comments
 (0)