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

cosign attach command couldn't attach the rekor-bundle to an image #3458

Open
viveksahu26 opened this issue Jan 1, 2024 · 5 comments · May be fixed by #3461
Open

cosign attach command couldn't attach the rekor-bundle to an image #3458

viveksahu26 opened this issue Jan 1, 2024 · 5 comments · May be fixed by #3461
Labels
bug Something isn't working

Comments

@viveksahu26
Copy link
Contributor

Description

Basically when we sign the Image using Cosign signing tool, then by default, it adds the rekor-bundle to an image in form of annotation as a value of a key dev.sigstore.cosign/bundle.

But when we customize things, like using OpenSSL tool as a signing tool, in such case user need to manually add those things. For the same, cosign attach command provide the functionally to attach payload, signature, rekor-response, tsr, etc. Although, the command properly works for payload, signature, --tsr, but fails to attach rekor-response.

Command ran:
cosign attach signature --payload payload.json --signature payload.json.base64.sig --rekor-response rekor_bundle.json $IMAGE_DIGEST

cat rekor_bundle.json | jq
{
  "SignedEntryTimestamp": "MEYCIQDCBEsMQKGMopTKw9/NNnxUNqEPcmJotc7VuRlkcSaS2gIhAIoHOgkFXIOy2rI843w79yLVYc6/M/QMUApLvbFcF7Qj",
  "Payload": {
    "body": "eyJhcGlWZXJzaW9uIjoiMC4wLjEiLCJraW5kIjoicmVrb3JkIiwic3BlYyI6eyJkYXRhIjp7Imhhc2giOnsiYWxnb3JpdGhtIjoic2hhMjU2IiwidmFsdWUiOiI0ODEwZmQ5YjEzODdlNDZhZWMyM2NmNTYwNjU3OTcxOTllZmU3NzM3YmQ0NmNiMTViYzI0Y2VkMjY5MGNhYzUyIn19LCJzaWduYXR1cmUiOnsiY29udGVudCI6IkdPOUlIcCsyemkvNUI4SEZWWkVYQStIN0JIVGxBZm1OQ2FMbGNxeFhLaENMQmdmazZjNFo4UkFGUnFodGVOWGMxNzlIaXkweSsvbjR5d0tyc2Q4UFh2Y3VObmlLM2tneXhXYzJ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ia0pEV1VSTE0ydHVSekZzWnpKWVIyRnpDazF0V0VsdFFYQlFTMWcwTDA5a1RVdzVaVXMwY0dZd1EwRjNSVUZCVVQwOUNpMHRMUzB0UlU1RUlGQlZRa3hKUXlCTFJWa3RMUzB0TFFvPSJ9fX19",
    "integratedTime": "1704106175",
    "logIndex": "60606559",
    "logID": "c0d23d6ad406973f9559f3ba2d1ca01f84147d8ffc5b8445c224f98b9591801d"
  }
}

Version
cosign version: 2.2.1

Solution:
Cosign attach should attach the rekor-bundle if rekor-response flag is provided by the user.

Discussion at #3457

@viveksahu26 viveksahu26 added the bug Something isn't working label Jan 1, 2024
@haydentherapper
Copy link
Contributor

This feature was added in #2904. Is there a formatting issue with the rekor response you’re trying to attach?

@viveksahu26
Copy link
Contributor Author

Yeah @haydentherapper , I did already looked at that PR and figuring out why it wasn't working then, and find out that there is small bug. With current parsing which is:

err = json.Unmarshal(rekorBundleByte, &localCosignPayload)

the value of rekorBundle is nil. If there was logic to handle nil value of rekorBundle, then it would have an easy catch.

So, it needs small changes to parse the bundle correctly and that is:

err = json.Unmarshal(rekorBundleByte, &localCosignPayload.Bundle)

@viveksahu26
Copy link
Contributor Author

No, it wasn't case of formatting issue btw.

@viveksahu26
Copy link
Contributor Author

viveksahu26 commented Jan 1, 2024

At present, I had to build a rekor-response which is shown below, is a bit tedious task and chances of errors. Is there any command which can directly build a rekor-response by simply providing logIndex. Like command such as cosign generate which generates payload for us for the provided image.

$  cat rekor_bundle.json | jq
{
  "SignedEntryTimestamp": "MEYCIQDCBEsMQKGMopTKw9/NNnxUNqEPcmJotc7VuRlkcSaS2gIhAIoHOgkFXIOy2rI843w79yLVYc6/M/QMUApLvbFcF7Qj",
  "Payload": {
    "body": "eyJhcGlWZXJzaW9uIjoiMC4wLjEiLCJraW5kIjoicmVrb3JkIiwic3BlYyI6eyJkYXRhIjp7Imhhc2giOnsiYWxnb3JpdGhtIjoic2hhMjU2IiwidmFsdWUiOiI0ODEwZmQ5YjEzODdlNDZh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EVGWWF6aGpVMnBZWjI5eE1rRXdabEZNVFdJS2RFWjZWVXA1YkU5elltSjJTV3N6VUV0S2VXeFpSMDVDZG5rek56SkdkRlV3ZWtaTVVWQlRiMW93TWxaSFVTODBWbXR0YVZScU5GcFRkakZaYlV4UVNRcFhiVE01ZUVkd2FEaFpVbVpGUVhKR1JWRlNOeTlLV2tad2JVc3pPV1ZwTkZsWmVsRndjRXhqVW1sRVdHUjBia0pEV1VSTE0ydHVSekZzWnpKWVIyRnpDazF0V0VsdFFYQlFTMWcwTDA5a1RVdzVaVXMwY0dZd1EwRjNSVUZCVVQwOUNpMHRMUzB0UlU1RUlGQlZRa3hKUXlCTFJWa3RMUzB0TFFvPSJ9fX19",
    "integratedTime": 1704106175,
    "logIndex": 60606559,
    "logID": "c0d23d6ad406973f9559f3ba2d1ca01f84147d8ffc5b8445c224f98b9591801d"
  }
}

@viveksahu26 viveksahu26 linked a pull request Jan 2, 2024 that will close this issue
@viveksahu26
Copy link
Contributor Author

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants