Skip to content
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

refactor attestation logic into cosign.Attestor #1124

Closed
wants to merge 9 commits into from

Conversation

dekkagaijin
Copy link
Member

@dekkagaijin dekkagaijin commented Dec 2, 2021

This is the Attestation equivalent of the previous Signer refactoring, plus nips and tucks here and there

TODO:

  • move over fulcio operations as well
  • perform all signing operations via new /pkg libraries

Tickets: #844 #931

NONE

Jake Sanders added 3 commits December 2, 2021 10:03
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
@dekkagaijin dekkagaijin marked this pull request as ready for review December 2, 2021 19:31
Comment on lines 76 to 77
}{
{
Copy link
Member

Choose a reason for hiding this comment

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

Use {{ and }, { to reduce the bloat on these.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

}

// NewInTotoAttestor returns a `cosign.Attestor` which uploads the InToto attestation to Rekor
func NewInTotoAttestor(inner cosign.Attestor, rClient *client.Rekor) cosign.Attestor {
Copy link
Member

Choose a reason for hiding this comment

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

Why InToto here and not the interface name? Isn't the in-toto part implicit in the payload we are passed? I'd have thought DSSE if anything, but 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

done


var _ cosign.Attestor = (*attestorWrapper)(nil)

func (ra *attestorWrapper) Attest(ctx context.Context, payload io.Reader) (oci.Signature, crypto.PublicKey, error) {
Copy link
Member

Choose a reason for hiding this comment

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

You put the fulcio signer/attestor in the same file, but split things here. Can we be consistent?

Copy link
Member Author

Choose a reason for hiding this comment

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

? did you mean the payload signer/attestor?
yeah, I can

Comment on lines 112 to 116
Signatures: []dsse.Signature{
{
Sig: base64.StdEncoding.EncodeToString(sig),
},
},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Signatures: []dsse.Signature{
{
Sig: base64.StdEncoding.EncodeToString(sig),
},
},
Signatures: []dsse.Signature{{
Sig: base64.StdEncoding.EncodeToString(sig),
}},

Copy link
Member Author

Choose a reason for hiding this comment

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

done

// Attestor creates attestations in the form of `oci.Signature`s
type Attestor interface {
// Attest creates an attestation, in the form of an `oci.Signature`, from the given payload.
// The signature and payload are stored as an envelope in `osi.Signature.Payload()`
Copy link
Member

Choose a reason for hiding this comment

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

specifically call out DSSE?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

var s icos.Signer
s = ipayload.NewSigner(sv, nil, nil)
s = ipayload.NewSigner(sv, nil, nil, nil, nil)
Copy link
Member

Choose a reason for hiding this comment

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

This has a code smell to it. We're going something wrong here 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Potential solutions: 1) populate the struct directly 2) options 3) hoist the cert stuff into a higher-level wrapper

Comment on lines +148 to +153
// NewSigner returns a `cosign.Signer` which uses the given `signature.Signer` to sign requested payloads.
// The cert and chain, if provided, will be included in returned `oci.Signature`s.
func NewSigner(s signature.Signer,
sOpts []signature.SignOption,
pkOpts []signature.PublicKeyOption,
certPEM, chainPEM []byte) cosign.Signer {
Copy link
Member

Choose a reason for hiding this comment

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

This is an enormous signature. We are growing payload.NewSigner into the monstrosity that was previously in cmd. The whole point of the fulcio package is to have that encapsulate the variants that deal with chain-based signing, so I think it's time for fulcio.NewSigner to stop wrapping payload.NewSigner and take on some of this logic itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can split the cert and chain into their own layer. Alternatively, we could expose the struct directly.

I think it's time for fulcio.NewSigner to stop wrapping payload.NewSigner and take on some of this logic itself

I don't agree, since I don't think we want to limit the Fulcio path to keyless

Jake Sanders added 2 commits December 2, 2021 14:19
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
Jake Sanders added 4 commits December 2, 2021 16:21
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
@github-actions
Copy link

github-actions bot commented Sep 4, 2022

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions
Copy link

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants