Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/selftest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name>"): 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 <file>): $bad"
exit 1
fi
- name: sarif-summary unit tests
run: python3 -I scripts/test_sarif_summary.py
- name: release.sh unit tests
Expand Down
Empty file modified scripts/sign-provenance.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion scripts/test_sign_provenance.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export EXPECT_RUN=https://github.com/IronFlock/example/actions/runs/123
check() { # check <name> <expected exit: 0|1> <jq edit of the fixture> [<platform>]
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
Expand Down
12 changes: 6 additions & 6 deletions scripts/test_sign_provenance_registry.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading