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
7 changes: 5 additions & 2 deletions .agents/scripts/release-signing-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
# so fall back to it for the same authenticated login rather than failing.
_release_signing_registered_keys() {
local kind="$1"
local login=""
local login="" keys=""
case "$kind" in
ssh_signing_keys | gpg_keys) ;;
*) return 1 ;;
esac
if gh api --paginate --slurp "user/${kind}" 2>/dev/null; then
# Failed gh requests can emit error JSON on stdout. Do not concatenate it
# (or partial pagination output) with the successful public fallback pages.
if keys=$(gh api --paginate --slurp "user/${kind}" 2>/dev/null); then
printf '%s\n' "$keys"
return 0
fi
login=$(gh api user --jq '.login' 2>/dev/null) || return 1
Expand Down
21 changes: 19 additions & 2 deletions .agents/scripts/tests/test-release-signing-preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ gh() {
if [[ "$PUBLIC_ONLY" -eq 1 ]]; then
case "$*" in
'api user --jq .login') printf 'operator\n' ;;
'api --paginate --slurp users/operator/ssh_signing_keys') printf '%s\n' "$KEY_JSON" ;;
'api --paginate --slurp users/operator/ssh_signing_keys' | 'api --paginate --slurp users/operator/gpg_keys') printf '%s\n' "$KEY_JSON" ;;
'api --paginate --slurp user/ssh_signing_keys' | 'api --paginate --slurp user/gpg_keys')
# Real gh (GH#34762) exits 1 but still writes the slurped error body
# to stdout; concatenated with fallback pages it broke `.[][] | .key`.
printf '[{"message":"Not Found","status":"404"}]\n'
return 1
;;
*) return 1 ;;
esac
return 0
Expand Down Expand Up @@ -54,7 +60,11 @@ if release_signing_preflight "$ROOT/repo" 2>/dev/null; then
fi
API_FAIL=0
PUBLIC_ONLY=1
release_signing_preflight "$ROOT/repo"
release_signing_preflight "$ROOT/repo" 2>"$ROOT/err"
if [[ -s "$ROOT/err" ]]; then
printf 'FAIL successful public SSH fallback emitted diagnostics\n'
exit 1
fi
KEY_JSON=$(jq -nc --arg key "$(<"$ROOT/other.pub")" '[[{key:$key}]]')
if release_signing_preflight "$ROOT/repo" 2>/dev/null; then
printf 'FAIL public-listing fallback accepted a different key\n'
Expand Down Expand Up @@ -112,6 +122,13 @@ git -C "$ROOT/repo" config gpg.format openpgp
git -C "$ROOT/repo" config user.signingkey 0123456789ABCDEF
KEY_JSON='[[{"key_id":"0123456789ABCDEF","subkeys":[{"key_id":"FEDCBA9876543210"}]}]]'
release_signing_preflight "$ROOT/repo"
PUBLIC_ONLY=1
release_signing_preflight "$ROOT/repo" 2>"$ROOT/err"
if [[ -s "$ROOT/err" ]]; then
printf 'FAIL successful public GPG fallback emitted diagnostics\n'
exit 1
fi
PUBLIC_ONLY=0
KEY_JSON='[[{"key_id":"AAAAAAAAAAAAAAAA","subkeys":[]}]]'
if release_signing_preflight "$ROOT/repo" 2>/dev/null; then
printf 'FAIL unregistered GPG key accepted\n'
Expand Down
Loading