Skip to content

Commit

Permalink
fix: add artifact_digest
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed Dec 18, 2024
1 parent b0f15f6 commit bb574f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion task/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package task

type OciArtifactVulnerabilities struct {
ImageURL string `json:"imageUrl"`
ArtifactDigest string `json:"artifactDigest"`
Vulnerabilities []VulnerabilityMatch `json:"Vulnerabilities"`
}

func (r OciArtifactVulnerabilities) UniqueID() string {
return r.ImageURL
return r.ArtifactDigest
}

type GrypeOutput struct {
Expand Down
4 changes: 3 additions & 1 deletion task/run-task.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func RunTask(ctx context.Context, esClient opengovernance.Client, logger *zap.Logger, request tasks.TaskRequest, response *scheduler.TaskResponse) error {
var ociArtifactURL, registryType string
var ociArtifactURL, registryType, artifactDigest string
if v, ok := request.TaskDefinition.Params["oci_artifact_url"]; ok {
ociArtifactURL = v
} else {
Expand All @@ -27,6 +27,7 @@ func RunTask(ctx context.Context, esClient opengovernance.Client, logger *zap.Lo
} else {
registryType = "ghcr"
}
artifactDigest, _ = request.TaskDefinition.Params["artifact_digest"]

logger.Info("Fetching image", zap.String("image", ociArtifactURL))

Expand Down Expand Up @@ -61,6 +62,7 @@ func RunTask(ctx context.Context, esClient opengovernance.Client, logger *zap.Lo

result := OciArtifactVulnerabilities{
ImageURL: ociArtifactURL,
ArtifactDigest: artifactDigest,
Vulnerabilities: grypeOutput.Matches,
}

Expand Down

0 comments on commit bb574f9

Please sign in to comment.