Skip to content

Commit

Permalink
Add work around for provenance generation. (#3015)
Browse files Browse the repository at this point in the history
Cloud build provenance in plain text is not consistent with the base64 payload. This change makes it consistent to pass the validation.

Bug: flutter/flutter#133376
  • Loading branch information
godofredoc authored Aug 29, 2023
1 parent c3ba4f2 commit 5d700be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cloud_build/get_docker_image_provenance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ for attempt in $(seq 1 $MAX_ATTEMPTS)
do
echo "(Attempt $attempt) Obtaining provenance for $1"
gcloud artifacts docker images describe \
$DOCKER_IMAGE_URL --show-provenance --format json > $OUTPUT_DIRECTORY
$DOCKER_IMAGE_URL --show-provenance --format json > tmp.json
COMMAND_RESULT=$?
val=$(cat tmp.json | jq -r '.provenance_summary.provenance[0].envelope.payload' | base64 -d | jq '.predicate.recipe.arguments.sourceProvenance')
cat tmp.json | jq ".provenance_summary.provenance[0].build.intotoStatement.slsaProvenance.recipe.arguments.sourceProvenance = ${val}" > $OUTPUT_DIRECTORY
if [[ $COMMAND_RESULT -eq 0 ]]
then
echo "Successfully obtained provenance and saved to $2"
Expand All @@ -28,4 +30,4 @@ done
if [[ $COMMAND_RESULT -ne 0 ]]
then
echo "Failed to download provenance." && exit $COMMAND_RESULT
fi
fi

0 comments on commit 5d700be

Please sign in to comment.