Open hdiederichs opened 1 year ago
Maybe these steps to reproduce help:
cat > Dockerfile << 'EOF'
FROM gcr.io/projectsigstore/cosign:v2.0.1 AS cosign
FROM docker.io/anchore/syft:v0.77.0 AS syft
FROM docker.io/alpine:3.17.3
COPY --from=cosign /ko-app/cosign /usr/local/bin/cosign
COPY --from=syft /syft /usr/local/bin/syft
ENV REGISTRY="docker.io"
ENV REPOSITORY="anchore"
ENV IMAGE_TAG="latest"
ENV USERNAME="AzureDiamond"
ENV REGISTRY_PASSWORD="hunter2"
ENV IMAGE_NAME="syft"
ENV COSIGN_PASSWORD="hunter2too"
RUN cosign generate-key-pair
CMD syft login -u $USERNAME -p $REGISTRY_PASSWORD -vv $REGISTRY && syft attest -o cyclonedx-json --key cosign.key -vv $REGISTRY/$REPOSITORY/$IMAGE_NAME:$IMAGE_TAG > $IMAGE_NAME-$IMAGE_TAG.json
EOF
docker buildx build --load -t test/syft .
docker run -e "USERNAME=yourname" -e "REGISTRY_PASSWORD=s3cret1234!" test/syft
At least I run into the same problem when using this approach.
Hi @hdiederichs, thanks for the report. Our attestation mechanism requires that you have OCI write access to the image that you are working with. I think that is the main problem that you're running into. It does look like we are either missing an error message or maybe it didn't get copied into this issue. We will try to reproduce this and see if we can surface the correct error message.
I didn't omit any output from the debug logs mentioned above.
Currently, my workaround is as follows:
createSbomAndSign() {
# some other stuff
syft -o cyclonedx-json -v "$REGISTRY"/"$REPOSITORY"/"$1"@"$SHA_SUM" > sboms/"$1"_"$IMAGE_TAG".json
cosign attach sbom --sbom sboms/"$1"_"$IMAGE_TAG".json "$REGISTRY"/"$REPOSITORY"/"$1"@"$SHA_SUM"
}
This seemingly does the same thing and doesn't fail.
I got a related error: syft attest --key cosign.key -o spdx-json ubuntu:22.04 --file sbom-attest.json
Creating attestation [running cosign]
░░ This may include the email address associated with the account with which you authenticate your contractual Agreement.
░░ This information will be used for signing this artifact and will be stored in public transparency logs and cannot be removed later, and is subject to the Immutable Record notice at https://lfprojects.org/policies/hosted-project-tools-immutable-records/.
░░
░░ By typing 'y', you attest that (1) you are not submitting the personal data of any other person; and (2) you understand and agree to the statement and the Agreement terms at the URLs listed above.
░░ Are you sure you would like to continue? [y/N] Error: signing ubuntu:22.04: should upload to tlog: user declined the prompt
░░ main.go:74: error during command execution: signing ubuntu:22.04: should upload to tlog: user declined the prompt
2023/06/06 22:22:52 error during command execution: 1 error occurred:
* unable to attest SBOM: exit status 1
But never got a chance to type anything as the prompt is never waiting for a the user input and the output file is empty.
I might add that the logging formatting is sexy but the output is totally garbled, and unhelpful most of the time.
In the most recent version, it seems that local attestation is completely gone. Is this correct?
Newer versions of cosign try to upload attestations to a "transparency log" be default. That's the reason for the prompt and subsequent failure noted by @holongate.
--tlog-upload=false
needs to be added to the cosign attest
command generated in https://github.com/anchore/syft/blob/main/cmd/syft/cli/commands/attest.go#L216 for attestation to work again.
Downgrading to an earlier version of cosign would probably work too, although I don't know when exactly it was introduced (I tested this with cosign 2.1.1 where the issue related to --tlog-upload=false
was already present; I did not have the chance to test earlier versions).
What happened: When trying to attest an image as described in the README.md it fails with exit status 1 and no further information about what went wrong.
What you expected to happen: SBOM should be created. If it is not possible to create an SBOM, the error message should give a hint, what is missing.
Steps to reproduce the issue: I have installed cosign and syft (for versions see below). Perform the following commands to reproduce:
Output of the last command with -vv:
Anything else we need to know?: Ubuntu distro is running inside WSL 2.
Environment:
syft version
:cosign version
:cat /etc/os-release
or similar):