From ec1599498d36abf4db1df299b7ed386758d1cbb0 Mon Sep 17 00:00:00 2001 From: don-petry <36422719+don-petry@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:12:49 +0000 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20implement=20issue=20#447=20?= =?UTF-8?q?=E2=80=94=20Compliance:=20unpinned-actions-shell-tests.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/tests/shell-tests-workflow.bats | 37 +++++++++++++++++++ .github/workflows/shell-tests.yml | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .github/scripts/tests/shell-tests-workflow.bats diff --git a/.github/scripts/tests/shell-tests-workflow.bats b/.github/scripts/tests/shell-tests-workflow.bats new file mode 100644 index 00000000..ffe7408c --- /dev/null +++ b/.github/scripts/tests/shell-tests-workflow.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats +# Tests for .github/workflows/shell-tests.yml — static YAML assertions, +# no live API calls. +# +# Regression guard for issue #447 (unpinned-actions-shell-tests.yml): the +# action-pinning standard requires every third-party action `uses:` ref to be +# pinned to a full commit SHA, not a moving `@vN` tag. shell-tests.yml checked +# out with `actions/checkout@v7`. These tests pin that the checkout step stays +# on a 40-char commit SHA so a future edit reverting to a floating tag is caught. + +WORKFLOW="$(cd "$(dirname "$BATS_TEST_FILENAME")/../../.." && pwd)/.github/workflows/shell-tests.yml" + +@test "workflow file exists" { + [ -f "$WORKFLOW" ] +} + +@test "workflow is valid YAML" { + yq '.' "$WORKFLOW" >/dev/null +} + +@test "every action uses: ref is pinned to a full commit SHA (issue #447)" { + # Each `uses` must be owner/repo@<40-hex-sha>; a floating @vN tag fails this. + run yq -r '.jobs[].steps[] | select(has("uses")) | .uses' "$WORKFLOW" + [ "$status" -eq 0 ] + [ -n "$output" ] + while IFS= read -r ref; do + [ -n "$ref" ] || continue + [[ "$ref" =~ @[0-9a-f]{40}$ ]] + done <<< "$output" +} + +@test "checkout step is pinned to a SHA, not a moving tag (issue #447)" { + run yq -r '.jobs.bats.steps[] | select((.uses // "") | test("^actions/checkout@")) | .uses' "$WORKFLOW" + [ "$status" -eq 0 ] + [ -n "$output" ] + [[ "$output" =~ ^actions/checkout@[0-9a-f]{40}$ ]] +} diff --git a/.github/workflows/shell-tests.yml b/.github/workflows/shell-tests.yml index 105248e5..1ad9b497 100644 --- a/.github/workflows/shell-tests.yml +++ b/.github/workflows/shell-tests.yml @@ -29,7 +29,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install bats run: sudo npm install -g bats@1.11.1 --ignore-scripts From f88f91ea2d11b6f83912c1cdbff2f4334b57023c Mon Sep 17 00:00:00 2001 From: don-petry <36422719+don-petry@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:16:10 +0000 Subject: [PATCH 2/3] chore: dev-lead update (review-changes) [skip ci-relay] --- .github/scripts/tests/apply-code-quality-ruleset.bats | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/tests/apply-code-quality-ruleset.bats b/.github/scripts/tests/apply-code-quality-ruleset.bats index 7b64b2b8..5c3e117e 100644 --- a/.github/scripts/tests/apply-code-quality-ruleset.bats +++ b/.github/scripts/tests/apply-code-quality-ruleset.bats @@ -101,6 +101,7 @@ assert_required_check() { # bypass while de-duplicating the pre-existing OrganizationAdmin (the removal # branch of the merge), so the result is exactly the two required actors. @test "update adds the dependabot bypass when an existing ruleset has OrganizationAdmin but is missing it" { + export GH_TOKEN="mock-token" gh() { if [ "$1" = "api" ]; then if [ "$2" = "repos/petry-projects/markets/rulesets" ]; then @@ -110,7 +111,7 @@ assert_required_check() { echo '[{"actor_type":"OrganizationAdmin","bypass_mode":"always"}]' return 0 elif [ "$2" = "-X" ] && [ "$3" = "PUT" ]; then - cat > "$TEST_TMPDIR/payload.json" + cat > "$BATS_TEST_TMPDIR/payload.json" echo '{}' return 0 fi @@ -122,5 +123,5 @@ assert_required_check() { run bash "$SCRIPT" [ "$status" -eq 0 ] - jq -e '.bypass_actors == [{"actor_type":"OrganizationAdmin","bypass_mode":"always"},{"actor_id":3167543,"actor_type":"Integration","bypass_mode":"always"}]' "$TEST_TMPDIR/payload.json" + jq -e '.bypass_actors == [{"actor_type":"OrganizationAdmin","bypass_mode":"always"},{"actor_id":3167543,"actor_type":"Integration","bypass_mode":"always"}]' "$BATS_TEST_TMPDIR/payload.json" } From dd0f70d14f93eb030b0c24c13edddef872d00afd Mon Sep 17 00:00:00 2001 From: don-petry <36422719+don-petry@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:25:28 +0000 Subject: [PATCH 3/3] fix(reviews): address review comments [skip ci-relay] --- .../scripts/tests/shell-tests-workflow.bats | 21 +++++++++++++++---- .github/workflows/shell-tests.yml | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/scripts/tests/shell-tests-workflow.bats b/.github/scripts/tests/shell-tests-workflow.bats index ffe7408c..d231b8e4 100644 --- a/.github/scripts/tests/shell-tests-workflow.bats +++ b/.github/scripts/tests/shell-tests-workflow.bats @@ -19,19 +19,32 @@ WORKFLOW="$(cd "$(dirname "$BATS_TEST_FILENAME")/../../.." && pwd)/.github/workf } @test "every action uses: ref is pinned to a full commit SHA (issue #447)" { - # Each `uses` must be owner/repo@<40-hex-sha>; a floating @vN tag fails this. - run yq -r '.jobs[].steps[] | select(has("uses")) | .uses' "$WORKFLOW" + # Every third-party `uses` — step-level and job-level reusable-workflow refs — + # must be owner/repo@<40-hex-sha>; a floating @vN tag fails this. Local actions + # (starting with `./`) need no SHA pin and are skipped. Failures are accumulated + # so a later valid ref can't mask an earlier invalid one. + run yq -r '.jobs[] | ( (.steps[]? | select(has("uses")) | .uses) , (select(has("uses")) | .uses) )' "$WORKFLOW" [ "$status" -eq 0 ] [ -n "$output" ] + local failed=0 while IFS= read -r ref; do [ -n "$ref" ] || continue - [[ "$ref" =~ @[0-9a-f]{40}$ ]] + [[ "$ref" =~ ^\./ ]] && continue + [[ "$ref" =~ @[0-9a-f]{40}$ ]] || failed=1 done <<< "$output" + [ "$failed" -eq 0 ] } @test "checkout step is pinned to a SHA, not a moving tag (issue #447)" { + # Validate every matching checkout step so multiple checkouts can't let one + # unpinned ref slip through; accumulate failures across all output lines. run yq -r '.jobs.bats.steps[] | select((.uses // "") | test("^actions/checkout@")) | .uses' "$WORKFLOW" [ "$status" -eq 0 ] [ -n "$output" ] - [[ "$output" =~ ^actions/checkout@[0-9a-f]{40}$ ]] + local failed=0 + while IFS= read -r ref; do + [ -n "$ref" ] || continue + [[ "$ref" =~ ^actions/checkout@[0-9a-f]{40}$ ]] || failed=1 + done <<< "$output" + [ "$failed" -eq 0 ] } diff --git a/.github/workflows/shell-tests.yml b/.github/workflows/shell-tests.yml index 1ad9b497..2c64dced 100644 --- a/.github/workflows/shell-tests.yml +++ b/.github/workflows/shell-tests.yml @@ -30,6 +30,8 @@ jobs: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Install bats run: sudo npm install -g bats@1.11.1 --ignore-scripts