Skip to content

Commit

Permalink
fix: fail if large file sha256 does not match (#2433)
Browse files Browse the repository at this point in the history
As part of
#2365, we
added support for large files.

We forgot to update the "success" computation. This means that even
though the sha256 may differ from the expected, the job continues and we
never record the failure status.

I fix this in the PR. I also delete the downloaded folder / artifact if
the sha256 don't match, to avoid a similar problem in he future

---------

Signed-off-by: laurentsimon <laurentsimon@google.com>
  • Loading branch information
laurentsimon authored Jul 21, 2023
1 parent 75828bd commit a650b15
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/actions/secure-download-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ runs:
echo "computed hash is $UNTRUSTED_COMPUTED_HASH"
if [[ "$UNTRUSTED_COMPUTED_HASH" != "$UNTRUSTED_EXPECTED_HASH" ]]; then
echo "hashes do not match"
rm -rf "${TRUSTED_PATH}"
exit -2
fi
echo "hashes match"
Expand Down
1 change: 1 addition & 0 deletions .github/actions/secure-download-folder/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ runs:
echo "computed hash is ${UNTRUSTED_COMPUTED_HASH}"
if [[ "${UNTRUSTED_COMPUTED_HASH}" != "${UNTRUSTED_EXPECTED_HASH}" ]]; then
echo "hashes do not match"
rm -rf "${TRUSTED_FOLDER}"
exit -2
fi
echo "hashes match"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/generator_generic_slsa3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ jobs:
echo "sha256=${sha256}" >> "$GITHUB_OUTPUT"
- name: Download subjects file
id: download-file
continue-on-error: true
if: inputs.base64-subjects-as-file != ''
uses: slsa-framework/slsa-github-generator/.github/actions/secure-download-artifact@main
Expand All @@ -202,6 +203,7 @@ jobs:
sha256: "${{ steps.metadata.outputs.sha256 }}"

- name: Create subject file
id: create-file
continue-on-error: true
env:
UNTRUSTED_SUBJECTS: "${{ inputs.base64-subjects }}"
Expand Down Expand Up @@ -259,7 +261,7 @@ jobs:
- name: Final outcome
id: final
env:
SUCCESS: ${{ steps.generate-builder.outcome != 'failure' && steps.sign-prov.outcome != 'failure' && steps.upload-prov.outcome != 'failure' }}
SUCCESS: ${{ steps.generate-builder.outcome != 'failure' && steps.metadata.outcome != 'failure' && steps.download-file.outcome != 'failure' && steps.create-file.outcome != 'failure' && steps.sign-prov.outcome != 'failure' && steps.upload-prov.outcome != 'failure' }}
run: |
set -euo pipefail
echo "outcome=$([ "$SUCCESS" == "true" ] && echo "success" || echo "failure")" >> "$GITHUB_OUTPUT"
Expand Down

0 comments on commit a650b15

Please sign in to comment.