Refactor image signature in acceptance tests#2948
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
d8b4d7b to
906711b
Compare
| // statement as required by the tests | ||
| // statement as required by the tests. This implementation now includes transparency | ||
| // log upload to generate bundle information like Tekton Chains does for attestations. | ||
| func createAndPushAttestationWithPatches(ctx context.Context, imageName, keyName string, patches *godog.Table) (context.Context, error) { |
There was a problem hiding this comment.
this function was also refactored to align it to the signing process of the image
| // do it. This implementation includes transparency log upload to generate bundle information. | ||
| func CreateAndPushImageSignature(ctx context.Context, imageName string, keyName string) (context.Context, error) { |
There was a problem hiding this comment.
this function is the main focus of the refactoring in this PR
| return ctx, err | ||
| } | ||
|
|
||
| err = rekor.RekorEntryForImageSignature(ctx, imageRef) |
There was a problem hiding this comment.
Rekor entry creation is now handled directly during signature creation
| return ctx, err | ||
| } | ||
|
|
||
| err = rekor.RekorEntryForAttestation(ctx, imageRef) |
There was a problem hiding this comment.
Rekor entry creation is now handled directly during signature creation
7c7c7e7 to
315e53f
Compare
|
|
||
| Scenario: rekor entries required | ||
| Scenario: signatures with embedded bundles verify without external rekor queries | ||
| Given a key pair named "known" | ||
| Given an image named "acceptance/rekor-by-default" | ||
| Given a valid image signature of "acceptance/rekor-by-default" image signed by the "known" key | ||
| Given a valid attestation of "acceptance/rekor-by-default" signed by the "known" key | ||
| Given rekor entries are cleared | ||
| Given a git repository named "rekor-by-default" with | ||
| | main.rego | examples/happy_day.rego | | ||
| Given policy configuration named "ec-policy" with specification | ||
| """ | ||
| {"sources": [{"policy": ["git::https://${GITHOST}/git/rekor-by-default.git"]}]} | ||
| """ | ||
| When ec command is run with "validate image --image ${REGISTRY}/acceptance/rekor-by-default --rekor-url ${REKOR} --policy acceptance/ec-policy --public-key ${known_PUBLIC_KEY} --output json" | ||
| Then the exit status should be 1 | ||
| Then the exit status should be 0 | ||
| Then the output should match the snapshot |
There was a problem hiding this comment.
the original scenario was no longer relevant, given the refactoring to the signing flows.
this updated version tests that if a signature has bundle information in it, the verification doesn't need to query rekor to pass
|
|
||
| // creates the signature image with the correct media type and config and appends | ||
| // the signature layer to it | ||
| singnatureImage := mutate.MediaType(empty.Image, types.OCIManifestSchema1) |
There was a problem hiding this comment.
No more nature singing.. ? 😜
|
Seems like a lot of effort figure it out, nice work. Lgtm. My one thought: For Konflux right now, iiuc, Chains is configured to not use Rekor when signing things. Is there a code path in our acceptance tests where we sign things with no transparency log? If not, do you think we should have one? Either way it's not a blocker for this PR, I'm just wondering about it. |
No, with this PR all the signatures generated in the acceptance tests will have a bundle attached, with rekor entry data in it. |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
|
i think this was closed by mistake (closed instead of merged), since i can't find or recall any information about its closure. i will rebase and merge it |
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
315e53f to
235c812
Compare
This commit refactors the functions 'CreateAndPushImageSignature' and 'createAndPushAttestationWithPatches' so that they now replicate the transparency log entry creation on the rekor stub. The signature and the attestation are now created using the cosign.TLogUpload function, and stubbing the rekor endpoints that get called during the tlog entry creation process. The result is a signature that can be successfully verified using the 'cosign verify' command, and an attestation that has a corresponding entry in rekor. This refactor also removed the need to explicitly create rekor entries in the acceptance tests, since this is now part of the cosign flow. The acceptance tests using this new rekor flow now reflect more accuratly the real-world scenario. Assisted by: Claude Code Ref: https://issues.redhat.com/browse/EC-1210
235c812 to
5387e73
Compare
After PR conforma#2948 was merged, we don't need these steps any more. IIUC the rekor entries get created automatically in a more realistic way. The PR for EC-1210 was accidentally left unmerged for a long time, which explains why the new VSA feature testing still had the obsolete step. Related to... Ref: https://issues.redhat.com/browse/EC-1210
User description
This commit refactors the function 'CreateAndPushImageSignature' so that it now creates a cosign signature that also contains the bundle with transparency log data.
The signature is created using the cosign.TLogUpload function, and stubbing the rekor endpoints that get called during the tlog entry creation process.
The result is a signature that can be successfully verified using the 'cosign verify' command.
The acceptance tests using this new signature will be closer to the real-world scenario, but they need some refactoring that will be done in a later PR.
Assisted by: Claude Code
Ref: https://issues.redhat.com/browse/EC-1210
PR Type
Enhancement
Description
Refactor image signature and attestation creation to include transparency log uploads
Implement cosign.TLogUpload flow with bundle information in signatures and attestations
Replace manual Rekor entry creation with automatic stubs during cosign operations
Update Rekor entry types: hashedrekord for signatures, intoto v0.0.2 for attestations
Remove explicit Rekor entry creation steps from acceptance test scenarios
Diagram Walkthrough
File Walkthrough
3 files
Add transparency log upload to signature and attestation creationRemove explicit Rekor entry creation callsRefactor Rekor entry creation for signatures and attestations4 files
Add hashicorp HTTP client dependenciesUpdate dependency checksumsUpdate Kubernetes dependency versionUpdate Kubernetes dependency version3 files
Add stub rekord to background setupRemove manual Rekor entry creation steps from scenariosRemove manual Rekor entry creation steps from scenarios