Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/artifacts/signable.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@ func ExtractOCIImagesFromResults(ctx context.Context, results []objects.Result)
}
}

// Also check structured ARTIFACT_OUTPUTS for OCI artifacts that are marked as build artifacts
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if artifact is declared via both IMAGE_URL/IMAGE_DIGEST and ARTIFACT_OUTPUTS ?
are falling in double signing ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the current behavior when both IMAGE_URL/IMAGE_DIGEST & IMAGES define the same artifact?

// These are results that contain object values with "uri", "digest" and isBuildArtifact=="true"
for _, s := range ExtractBuildArtifactsFromResults(ctx, results) {
if !hasImageRequirements(*s) {
continue
}
dgst, err := name.NewDigest(fmt.Sprintf("%s@%s", s.URI, s.Digest))
if err != nil {
logger.Errorf("error getting digest for structured output %s@%s: %v", s.URI, s.Digest, err)
continue
}
objs = append(objs, dgst)
}

return objs
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/artifacts/signable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,15 @@ func TestExtractOCIImagesFromResults(t *testing.T) {
{Name: "img5_IMAGE_DIGEST", Value: *v1.NewStructuredValues("sha123:abc")},
{Name: "empty_str_IMAGE_DIGEST", Value: *v1.NewStructuredValues("")},
{Name: "empty_str_IMAGE_URL", Value: *v1.NewStructuredValues("")},
// structured ARTIFACT_OUTPUTS should also be detected as OCI images when marked as build artifacts
{Name: "art1-ARTIFACT_OUTPUTS", Value: v1.ParamValue{ObjectVal: map[string]string{"uri": "gcr.io/new/image", "digest": digest2, isBuildArtifactField: "true"}}},
}

want := []interface{}{
createDigest(t, fmt.Sprintf("img1@%s", digest1)),
createDigest(t, fmt.Sprintf("img2@%s", digest2)),
createDigest(t, fmt.Sprintf("img3@%s", digest1)),
createDigest(t, fmt.Sprintf("gcr.io/new/image@%s", digest2)),
}
ctx := logtesting.TestContextWithLogger(t)
got := ExtractOCIImagesFromResults(ctx, results)
Expand Down
Loading