Skip to content

Commit 3bf3a46

Browse files
authored
feat(report): add image config (#1231)
* feat(report): add image config * chore(mod): update fanal * test(scanner): fix type
1 parent 8edcc62 commit 3bf3a46

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

pkg/report/writer.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"io"
55
"time"
66

7+
v1 "github.com/google/go-containerregistry/pkg/v1"
78
"golang.org/x/xerrors"
89

910
ftypes "github.com/aquasecurity/fanal/types"
@@ -33,8 +34,11 @@ type Metadata struct {
3334
OS *ftypes.OS `json:",omitempty"`
3435

3536
// Container image
36-
RepoTags []string `json:",omitempty"`
37-
RepoDigests []string `json:",omitempty"`
37+
ImageID string `json:",omitempty"`
38+
DiffIDs []string `json:",omitempty"`
39+
RepoTags []string `json:",omitempty"`
40+
RepoDigests []string `json:",omitempty"`
41+
ImageConfig v1.ConfigFile `json:",omitempty"`
3842
}
3943

4044
// Results to hold list of Result

pkg/scanner/scan.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ func (s Scanner) ScanArtifact(ctx context.Context, options types.ScanOptions) (r
114114
ArtifactType: artifactInfo.Type,
115115
Metadata: report.Metadata{
116116
OS: osFound,
117+
ImageID: artifactInfo.ImageMetadata.ID,
118+
DiffIDs: artifactInfo.ImageMetadata.DiffIDs,
117119
RepoTags: artifactInfo.ImageMetadata.RepoTags,
118120
RepoDigests: artifactInfo.ImageMetadata.RepoDigests,
121+
ImageConfig: artifactInfo.ImageMetadata.ConfigFile,
119122
},
120123
Results: results,
121124
}, nil

pkg/scanner/scan_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func TestScanner_ScanArtifact(t *testing.T) {
4141
ID: "sha256:e7d92cdc71feacf90708cb59182d0df1b911f8ae022d29e8e95d75ca6a99776a",
4242
BlobIDs: []string{"sha256:5216338b40a7b96416b8b9858974bbe4acc3096ee60acbc4dfb1ee02aecceb10"},
4343
ImageMetadata: ftypes.ImageMetadata{
44+
ID: "sha256:e389ae58922402a7ded319e79f06ac428d05698d8e61ecbe88d2cf850e42651d",
45+
DiffIDs: []string{"sha256:9a5d14f9f5503e55088666beef7e85a8d9625d4fa7418e2fe269e9c54bcb853c"},
4446
RepoTags: []string{"alpine:3.11"},
4547
RepoDigests: []string{"alpine@sha256:0bd0e9e03a022c3b0226667621da84fc9bf562a9056130424b5bfbd8bcb0397f"},
4648
},
@@ -100,6 +102,8 @@ func TestScanner_ScanArtifact(t *testing.T) {
100102
Name: "3.10",
101103
Eosl: true,
102104
},
105+
ImageID: "sha256:e389ae58922402a7ded319e79f06ac428d05698d8e61ecbe88d2cf850e42651d",
106+
DiffIDs: []string{"sha256:9a5d14f9f5503e55088666beef7e85a8d9625d4fa7418e2fe269e9c54bcb853c"},
103107
RepoTags: []string{"alpine:3.11"},
104108
RepoDigests: []string{"alpine@sha256:0bd0e9e03a022c3b0226667621da84fc9bf562a9056130424b5bfbd8bcb0397f"},
105109
},

0 commit comments

Comments
 (0)