-
Notifications
You must be signed in to change notification settings - Fork 546
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
Conversation
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
}{ | ||
{ |
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.
Use {{
and }, {
to reduce the bloat on these.
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.
done
} | ||
|
||
// NewInTotoAttestor returns a `cosign.Attestor` which uploads the InToto attestation to Rekor | ||
func NewInTotoAttestor(inner cosign.Attestor, rClient *client.Rekor) cosign.Attestor { |
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.
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 🤷
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.
done
|
||
var _ cosign.Attestor = (*attestorWrapper)(nil) | ||
|
||
func (ra *attestorWrapper) Attest(ctx context.Context, payload io.Reader) (oci.Signature, crypto.PublicKey, error) { |
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.
You put the fulcio
signer/attestor in the same file, but split things here. Can we be consistent?
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.
? did you mean the payload
signer/attestor?
yeah, I can
Signatures: []dsse.Signature{ | ||
{ | ||
Sig: base64.StdEncoding.EncodeToString(sig), | ||
}, | ||
}, |
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.
Signatures: []dsse.Signature{ | |
{ | |
Sig: base64.StdEncoding.EncodeToString(sig), | |
}, | |
}, | |
Signatures: []dsse.Signature{{ | |
Sig: base64.StdEncoding.EncodeToString(sig), | |
}}, |
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.
done
internal/pkg/cosign/attest.go
Outdated
// 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()` |
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.
specifically call out DSSE?
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.
done
var s icos.Signer | ||
s = ipayload.NewSigner(sv, nil, nil) | ||
s = ipayload.NewSigner(sv, nil, nil, nil, nil) |
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.
This has a code smell to it. We're going something wrong here 😅
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.
Potential solutions: 1) populate the struct directly 2) option
s 3) hoist the cert stuff into a higher-level wrapper
// 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 { |
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.
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.
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.
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
Signed-off-by: Jake Sanders <jsand@google.com>
Signed-off-by: Jake Sanders <jsand@google.com>
b441219
to
6458dd7
Compare
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>
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. |
This PR was closed because it has been stalled for 10 days with no activity. |
This is the
Attestation
equivalent of the previousSigner
refactoring, plus nips and tucks here and thereTODO:
/pkg
librariesTickets: #844 #931