-
Notifications
You must be signed in to change notification settings - Fork 40
chore(signing): verify signature on att push #2606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,8 +322,19 @@ func (uc *WorkflowRunUseCase) SaveAttestation(ctx context.Context, id string, en | |
| return nil, fmt.Errorf("extracting predicate: %w", err) | ||
| } | ||
|
|
||
| // verify attestation (only if chainloop is the signer) | ||
| result, err := uc.verifyBundle(ctx, rawContent) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // if it's verifiable, make sure it passed | ||
| if result != nil && !result.Result { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, so result will be nil if can't be verified? I'd make it more explicit somehow
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes in that case it would return |
||
| return nil, NewErrValidation(fmt.Errorf("attestation verification failed: %s", result.FailureReason)) | ||
| } | ||
|
|
||
| // Run some validations on the predicate | ||
| // Attestations can include dependent attestations and we want to make sure they exist in the system | ||
| // Attestations can include dependent attestations, and we want to make sure they exist in the system | ||
| // Find any material of kind attestation and make sure they exist already | ||
| for _, m := range predicate.GetMaterials() { | ||
| if m.Type == schemaapi.CraftingSchema_Material_ATTESTATION.String() { | ||
|
|
@@ -440,7 +451,11 @@ type VerificationResult struct { | |
| FailureReason string | ||
| } | ||
|
|
||
| func (uc *WorkflowRunUseCase) Verify(ctx context.Context, run *WorkflowRun) (*VerificationResult, error) { | ||
| func (uc *WorkflowRunUseCase) VerifyRun(ctx context.Context, run *WorkflowRun) (*VerificationResult, error) { | ||
| return uc.verifyBundle(ctx, run.Attestation.Bundle) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any case where run.Attestation would be empty?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems it will not, makes sense. |
||
| } | ||
|
|
||
| func (uc *WorkflowRunUseCase) verifyBundle(ctx context.Context, bundle []byte) (*VerificationResult, error) { | ||
| tr, err := uc.signingUseCase.GetTrustedRoot(ctx) | ||
| if err != nil { | ||
| if IsErrNotImplemented(err) { | ||
|
|
@@ -453,7 +468,7 @@ func (uc *WorkflowRunUseCase) Verify(ctx context.Context, run *WorkflowRun) (*Ve | |
| if err != nil { | ||
| return nil, fmt.Errorf("parsing roots: %w", err) | ||
| } | ||
| err = verifier.VerifyBundle(ctx, run.Attestation.Bundle, verifierRoots) | ||
| err = verifier.VerifyBundle(ctx, bundle, verifierRoots) | ||
| if err != nil { | ||
| // if no verification material found, it's not verifiable | ||
| if errors.Is(err, verifier.ErrMissingVerificationMaterial) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the logic that makes sure the bundle is verified when keyless signing was used?