diff --git a/.github/workflows/selftest.yml b/.github/workflows/selftest.yml index 1570b9e..309eb47 100644 --- a/.github/workflows/selftest.yml +++ b/.github/workflows/selftest.yml @@ -68,6 +68,16 @@ jobs: "$RUNNER_TEMP/bin/helm" version --short | grep -q '^v3\.22\.0' - name: shellcheck run: shellcheck scripts/*.sh + # The workflows run the scripts directly ("$HARNESS/scripts/"): one + # committed without the executable bit fails a release with "Permission + # denied". Tests run through bash or python3 and may stay as they are. + - name: every script the workflows run is executable + run: | + bad=$(git ls-files -s scripts | awk '$1 != "100755" && $4 !~ /^scripts\/test_/ { print $4 }') + if [ -n "$bad" ]; then + echo "::error::not executable in git (git update-index --chmod=+x ): $bad" + exit 1 + fi - name: sarif-summary unit tests run: python3 -I scripts/test_sarif_summary.py - name: release.sh unit tests diff --git a/scripts/sign-provenance.sh b/scripts/sign-provenance.sh old mode 100644 new mode 100755 diff --git a/scripts/test_sign_provenance.sh b/scripts/test_sign_provenance.sh old mode 100644 new mode 100755 index a64e4dd..0c8c4bf --- a/scripts/test_sign_provenance.sh +++ b/scripts/test_sign_provenance.sh @@ -19,7 +19,7 @@ export EXPECT_RUN=https://github.com/IronFlock/example/actions/runs/123 check() { # check [] local name=$1 want=$2 edit=$3 platform=${4:-linux/amd64} got=0 jq "$edit" "$fixture" >"$work/predicate.json" - bash "$script" check "$work/predicate.json" "$platform" >"$work/log" 2>&1 || got=$? + "$script" check "$work/predicate.json" "$platform" >"$work/log" 2>&1 || got=$? if { [ "$want" = 0 ] && [ "$got" = 0 ]; } || { [ "$want" = 1 ] && [ "$got" != 0 ]; }; then echo "ok $name" else diff --git a/scripts/test_sign_provenance_registry.sh b/scripts/test_sign_provenance_registry.sh old mode 100644 new mode 100755 index 8db23df..5fa8e47 --- a/scripts/test_sign_provenance_registry.sh +++ b/scripts/test_sign_provenance_registry.sh @@ -73,18 +73,18 @@ export EXPECT_REVISION EXPECT_REVISION=$(git -C "$src" rev-parse HEAD) export EXPECT_RUN=$run -expect "another commit expected: refused" 1 env EXPECT_REVISION=fedcba9876543210fedcba9876543210fedcba98 bash "$script" sign "$index" +expect "another commit expected: refused" 1 env EXPECT_REVISION=fedcba9876543210fedcba9876543210fedcba98 "$script" sign "$index" expect " and nothing attached" 0 test "$(attestations "$index" "$work/release.pub")" = 0 -expect "both platforms signed" 0 bash "$script" sign "$index" +expect "both platforms signed" 0 "$script" sign "$index" expect " two attestations verify" 0 test "$(attestations "$index" "$work/release.pub")" = 2 expect " they name both platforms" 0 bash -c "\"$COSIGN\" verify-attestation --allow-http-registry --key '$work/release.pub' --type slsaprovenance1 --insecure-ignore-tlog '$index' 2>/dev/null | jq -r '.payload | @base64d | fromjson | .predicate.buildDefinition.internalParameters.targetPlatform' | sort | paste -sd, - | grep -qx linux/amd64,linux/arm64" expect " another key verifies none" 0 test "$(attestations "$index" "$work/other.pub")" = 0 -expect "re-run signs nothing twice" 0 bash "$script" sign "$index" +expect "re-run signs nothing twice" 0 "$script" sign "$index" expect " still two attestations" 0 test "$(attestations "$index" "$work/release.pub")" = 2 -expect "a single-platform index" 0 env COSIGN_KEY="$work/other.key" COSIGN_PUBLIC_KEY="$work/other.pub" bash "$script" sign "$single" -expect " an attestation by another key does not count" 0 bash "$script" sign "$single" +expect "a single-platform index" 0 env COSIGN_KEY="$work/other.key" COSIGN_PUBLIC_KEY="$work/other.pub" "$script" sign "$single" +expect " an attestation by another key does not count" 0 "$script" sign "$single" expect " one attestation verifies with each key" 0 test "$(attestations "$single" "$work/release.pub")$(attestations "$single" "$work/other.pub")" = 11 -expect "not a digest reference" 1 bash "$script" sign "$image:v0.0.1" +expect "not a digest reference" 1 "$script" sign "$image:v0.0.1" if [ "$failures" -gt 0 ]; then echo "$failures failed"