Skip to content

Commit 169d3e4

Browse files
7a9c8f0147a0755c5d499320bda5535cd5014715e52fb7757dfe3dadde1cef09@buzz.block.builderlab.xyznpub1re830n24qhgstulznk5dxdluccspxkxxdq643lm4q3zwwwjgsuqqmcmdrm
authored andcommitted
fix(release): verify sole ruleset bypass actor
Co-authored-by: npub102wg7q285p64ch2fjvstmf2ntn2sz3c4u5hmwatalc76mhsuauysftjtfj <7a9c8f0147a0755c5d499320bda5535cd5014715e52fb7757dfe3dadde1cef09@buzz.block.builderlab.xyz> Signed-off-by: npub102wg7q285p64ch2fjvstmf2ntn2sz3c4u5hmwatalc76mhsuauysftjtfj <7a9c8f0147a0755c5d499320bda5535cd5014715e52fb7757dfe3dadde1cef09@buzz.block.builderlab.xyz>
1 parent f28fa7d commit 169d3e4

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

‎RELEASING.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,8 @@ release App because strict tag protection denies direct human creation. The App
221221
must be installed on `block/buzz`, have Contents write and Metadata read, and
222222
retain an `always` bypass on the immutable `mobile-v*` tag rules. It does not
223223
require GitHub Releases permissions, repository Administration permission, or a
224-
mobile release-branch ruleset. The publisher validates the App token's effective
225-
`current_user_can_bypass` value rather than reading the ruleset's hidden bypass
226-
actor list.
224+
mobile release-branch ruleset. The publisher validates both the App token's
225+
effective `current_user_can_bypass` value and the exact ruleset bypass actor set.
227226

228227
---
229228

‎scripts/release-rulesets.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require_canonical_repository() {
2222
}
2323

2424
require_release_tag_ruleset() {
25-
local ruleset_endpoint state can_bypass rule_types includes excludes
25+
local ruleset_endpoint state can_bypass bypass_actors rule_types includes excludes
2626

2727
command -v gh >/dev/null 2>&1 || fail_release_ruleset "gh is required" || return 1
2828
ruleset_endpoint="repos/block/buzz/rulesets/$RELEASE_TAG_RULESET_ID"
@@ -37,6 +37,11 @@ require_release_tag_ruleset() {
3737
[[ "$can_bypass" == "always" ]] || \
3838
fail_release_ruleset "release App cannot always bypass Release tag ruleset $RELEASE_TAG_RULESET_ID (reported '$can_bypass')" || return 1
3939

40+
bypass_actors="$(gh api "$ruleset_endpoint" --jq '[.bypass_actors[] | [.actor_type, (.actor_id | tostring), .bypass_mode] | join(":")] | sort | join(",")')" || \
41+
fail_release_ruleset "could not verify Release tag ruleset $RELEASE_TAG_RULESET_ID bypass actors" || return 1
42+
[[ "$bypass_actors" == "Integration:4349119:always" ]] || \
43+
fail_release_ruleset "Release tag ruleset $RELEASE_TAG_RULESET_ID has unexpected bypass actors: '$bypass_actors'" || return 1
44+
4045
rule_types="$(gh api "$ruleset_endpoint" --jq '[.rules[].type] | sort | join(",")')" || \
4146
fail_release_ruleset "could not verify Release tag ruleset $RELEASE_TAG_RULESET_ID rules" || return 1
4247
[[ "$rule_types" == "creation,deletion,non_fast_forward,update" ]] || \

‎scripts/test-mobile-release-candidate-publisher.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ case "${1:-}:${2:-}" in
2121
case "$*" in
2222
*'.enforcement'*) printf '%s\n' "${GH_TAG_RULESET_STATE:-active}" ;;
2323
*'.current_user_can_bypass'*) printf '%s\n' "${GH_CURRENT_USER_CAN_BYPASS-always}" ;;
24+
*'.bypass_actors[]'*) printf '%s\n' "${GH_BYPASS_ACTORS:-Integration:4349119:always}" ;;
2425
*'[.rules[].type]'*) printf '%s\n' "${GH_TAG_RULE_TYPES:-creation,deletion,non_fast_forward,update}" ;;
2526
*'.conditions.ref_name.include[]'*) printf '%s\n' "${GH_TAG_INCLUDES:-refs/tags/mobile-v*}" ;;
2627
*'.conditions.ref_name.exclude[]'*) printf '%s\n' "${GH_TAG_EXCLUDES:-}" ;;
@@ -90,6 +91,21 @@ if GH_CURRENT_USER_CAN_BYPASS='' "$publisher" 1.2.3 1 "$GH_TARGET_SHA" >/dev/nul
9091
echo "publisher accepted a ruleset response without an effective bypass" >&2
9192
exit 1
9293
fi
94+
if GH_BYPASS_ACTORS='Integration:4349119:always,Integration:9876543:always' \
95+
"$publisher" 1.2.3 1 "$GH_TARGET_SHA" >/dev/null 2>&1; then
96+
echo "publisher accepted an extra ruleset bypass actor" >&2
97+
exit 1
98+
fi
99+
if GH_BYPASS_ACTORS='Integration:9876543:always' \
100+
"$publisher" 1.2.3 1 "$GH_TARGET_SHA" >/dev/null 2>&1; then
101+
echo "publisher accepted a substituted ruleset bypass actor" >&2
102+
exit 1
103+
fi
104+
if GH_BYPASS_ACTORS='Integration:4349119:pull_request' \
105+
"$publisher" 1.2.3 1 "$GH_TARGET_SHA" >/dev/null 2>&1; then
106+
echo "publisher accepted a ruleset bypass actor with the wrong mode" >&2
107+
exit 1
108+
fi
93109
if GH_TAG_RULESET_STATE=disabled "$publisher" 1.2.3 1 "$GH_TARGET_SHA" >/dev/null 2>&1; then
94110
echo "publisher accepted disabled tag protection" >&2
95111
exit 1

0 commit comments

Comments
 (0)