-
Notifications
You must be signed in to change notification settings - Fork 547
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
Added support for attaching Time stamp authority Response in attach command #3001
Added support for attaching Time stamp authority Response in attach command #3001
Conversation
…ommand Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>
Codecov Report
@@ Coverage Diff @@
## main #3001 +/- ##
==========================================
+ Coverage 30.25% 30.95% +0.70%
==========================================
Files 151 153 +2
Lines 9473 9678 +205
==========================================
+ Hits 2866 2996 +130
- Misses 6162 6224 +62
- Partials 445 458 +13
|
Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>
Signed-off-by: Mukuls77 <mukul.sharma@nokia.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.
LGTM on the feature, just a comment on flag name and testing.
test/e2e_test_attach.sh
Outdated
@@ -46,6 +47,10 @@ IMAGE_URI_DIGEST=$IMAGE_URI@$SRC_DIGEST | |||
|
|||
## Sign with Leafcert Private Key | |||
openssl dgst -sha256 -sign ./private_key -out payload.sig payload.json | |||
## Generate TSR for the signature | |||
openssl ts -query -data payload.sig -sha256 -cert -out payload.tsq | |||
curl -H "Content-Type: application/timestamp-query" --data-binary '@payload.tsq' https://freetsa.org/tsr > payload.tsr |
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.
Can we use the libraries in the sigstore/timestamp-authority repo to generate a timestamp (see unit tests, there should be some examples), or stand up an instance of the tsa for an e2e test (also there should be examples of such). We shouldn’t call out to a third party service as part of our tests.
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 tried to check the instance in the existing e2e test cases where we have used a separate instance of the tsa, but was not able to find any example. In the unit test i could see there are many instance of test cases covering the TSA testing and verification. so i think adding a new unit test case for attach case will not add up much functionality as in unit test case we directly modify the signature structure to include cert, cert-chain and tsa.
If it is ok with you i can remove the changes i did to introduce TSA functionality in attach test case, as it is already covered in unit test of sign and verify.
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 test has an example of spinning up a local server - https://github.com/sigstore/cosign/blob/main/test/e2e_test.go#L724
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.
Hi Hayden i have created a new test cases for using TSR in attach command in e2e_test.go file also i have reverted the changes in e2e_test_attach.sh file which were using freetsa for getting TSR. kindly review the changes,
cmd/cosign/cli/options/attach.go
Outdated
@@ -54,6 +55,8 @@ func (o *AttachSignatureOptions) AddFlags(cmd *cobra.Command) { | |||
"when building the certificate chain for the signing certificate. "+ | |||
"Must start with the parent intermediate CA certificate of the "+ | |||
"signing certificate and end with the root certificate. Included in the OCI Signature") | |||
cmd.Flags().StringVar(&o.TimeStampedSig, "timeStampedSignatureResponse", "", |
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.
Can we use an acronym “—tsr” for the flag name instead?
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.
Agree i will change the flag name from --timeStampedSignatureResponse to --tsr
Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>
Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>
Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>
Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>
…cosign into Mukuls77-AddCmd-Branch
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 LGTM now that the test uses sigstore/timestamp-authority libraries but I'll wait for @haydentherapper to give this another look as well.
Thanks @malancas for the review @haydentherapper can you pls also review the PR changes |
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.
Can you delete this cert?
test/e2e_test.go
Outdated
pemleafRef := mkfile(string(pemLeaf), td, t) | ||
pemrootRef := mkfile(string(pemRoot), td, t) | ||
|
||
certchainRef := mkfile(string(appendSlices([][]byte{pemSub, pemRoot})), td, t) |
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.
nit: Can you just inline the concatenation of these two, string(append(pemSub, pemRoot...))
and remove appendSlices
given it's not used elsewhere?
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.
Looks great! Just two small comments, thanks for updating the tests.
Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>
Thanks @haydentherapper for the review i have done the required changes pls check |
Summary
The PR provide the support to attach Timestamp authority response for signed signature time stamp in attach command.
using this functionality now we can attach a TSR response for the generated signature and attach that along with the associated certificates and certificate chain. This PR will help specifically in private CA cases where now Private CA can issue short lived certificates and attach the Time stamp of the signature. This will help in checking the validity of the associated certificates using the signature time stamp
Release Note
Following files have been modified for the PR.
cmd/cosign/cli/attach.go
cmd/cosign/cli/attach/sig.go
cmd/cosign/cli/options/attach.go
doc/cosign_attach_signature.md
test/e2e_test.go
test/e2e_test_attach.sh
test/testdata/test_attach_freetsacacert.pem
Add a release note for each of the following conditions:
Documentation
This PR introduce a new parameter that can be used in the Attach command to pass the path of the Time stamp Authority response.
The updated command help is as below
$ ./cosign attach signature --help
Attach signatures to the supplied container image
Usage:
cosign attach signature [flags]
Examples:
cosign attach signature
Flags:
--allow-http-registry whether to allow using HTTP protocol while connecting to registries. Don't use this for anything but testing
--allow-insecure-registry whether to allow insecure connections to registries (e.g., with expired or self-signed TLS certificates). Don't use this for anything but testing
--attachment-tag-prefix [AttachmentTagPrefix]sha256-[TargetImageDigest].[AttachmentName] optional custom prefix to use for attached image tags. Attachment images are tagged as: [AttachmentTagPrefix]sha256-[TargetImageDigest].[AttachmentName]
--certificate string path to the X.509 certificate in PEM format to include in the OCI Signature
--certificate-chain string path to a list of CA X.509 certificates in PEM format which will be needed when building the certificate chain for the signing certificate. Must start with the parent intermediate CA certificate of the signing certificate and end with the root certificate. Included in the OCI Signature
-h, --help help for signature
--k8s-keychain whether to use the kubernetes keychain instead of the default keychain (supports workload identity).
--payload string path to the payload covered by the signature
--signature string path to the signature, or {-} for stdin
--timeStampedSignatureResponse string path to the Time Stamped Signature Response from RFC3161 compliant TSA
Global Flags:
--output-file string log output to a file
-t, --timeout duration timeout for commands (default 3m0s)
-d, --verbose log debug output
Testing
Make , lint , Docgen test were done. also e2e test related to attach command were done. attached are the logs
Build_Lint_Docgen_test_logs.txt
e2e_attach_test_logs.txt