Skip to content

Commit

Permalink
fix: add image digest to report (#1446)
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <hen.keinan@gmail.com>
  • Loading branch information
chen-keinan authored Aug 21, 2023
1 parent 77b44fe commit 2d3ad4d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/plugins/trivy/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ func (p *plugin) ParseReportData(ctx trivyoperator.PluginContext, imageRef strin
return vulnReport, secretReport, &sbomReport, err
}
}
registry, artifact, err := p.parseImageRef(imageRef)
registry, artifact, err := p.parseImageRef(imageRef, reports.Metadata.ImageID)
if err != nil {
return vulnReport, secretReport, &sbomReport, err
}
Expand Down Expand Up @@ -2030,7 +2030,7 @@ func (p *plugin) secretSummary(secrets []v1alpha1.ExposedSecret) v1alpha1.Expose
return s
}

func (p *plugin) parseImageRef(imageRef string) (v1alpha1.Registry, v1alpha1.Artifact, error) {
func (p *plugin) parseImageRef(imageRef string, imageID string) (v1alpha1.Registry, v1alpha1.Artifact, error) {
ref, err := containerimage.ParseReference(imageRef)
if err != nil {
return v1alpha1.Registry{}, v1alpha1.Artifact{}, err
Expand All @@ -2047,6 +2047,9 @@ func (p *plugin) parseImageRef(imageRef string) (v1alpha1.Registry, v1alpha1.Art
case containerimage.Digest:
artifact.Digest = t.DigestStr()
}
if len(artifact.Digest) == 0 {
artifact.Digest = imageID
}
return registry, artifact, nil
}

Expand Down

0 comments on commit 2d3ad4d

Please sign in to comment.