Skip to content

Commit 1130f49

Browse files
GH#25089: fix: verify claim fallback umask at runtime (#25095)
* wip: verify claim fallback umask at runtime * wip: keep claim fallback test under complexity gate * wip: avoid claim fallback complexity regression --------- Co-authored-by: Marcus Quinn <6428977+marcusquinn@users.noreply.github.com>
1 parent c6c7d7e commit 1130f49

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

.agents/scripts/tests/test-dispatch-claim-helper.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ test_claim_retries_transient_post_failure() {
603603
# Test: claim POST stderr fallback avoids predictable /tmp paths when mktemp fails.
604604
#######################################
605605
test_claim_post_error_fallback_avoids_tmp() {
606-
local tmp_dir mock_path old_created_at claim_created_at output exit_code attempts test_home chmod_log chmod_mode chmod_path suppressed_creation_pattern
606+
local tmp_dir mock_path old_created_at claim_created_at output exit_code attempts test_home chmod_log chmod_mode chmod_path pre_chmod_mode suppressed_creation_pattern
607607
tmp_dir=$(mktemp -d)
608608
mock_path=$(create_mock_gh "$tmp_dir")
609609
test_home="${tmp_dir}/home"
@@ -620,6 +620,9 @@ EOF
620620
cat >"${mock_path}/chmod" <<'EOF'
621621
#!/usr/bin/env bash
622622
printf '%s\t%s\n' "${1:-}" "${2:-}" >>"${MOCK_CHMOD_LOG:?}"
623+
if [[ -e "${2:-}" ]]; then
624+
python3 -c 'import os, stat, sys; print(oct(stat.S_IMODE(os.stat(sys.argv[1]).st_mode))[2:])' "${2:-}" >>"${MOCK_CHMOD_LOG:?}.pre" || true
625+
fi
623626
command -p chmod "$@"
624627
EOF
625628
chmod +x "${mock_path}/chmod"
@@ -663,8 +666,6 @@ EOF
663666
print_result "claim POST fallback avoids predictable tmp path" 0
664667
fi
665668

666-
chmod_mode=""
667-
chmod_path=""
668669
if [[ -f "$chmod_log" ]]; then
669670
IFS=$'\t' read -r chmod_mode chmod_path <"$chmod_log" || true
670671
fi
@@ -673,10 +674,13 @@ EOF
673674
else
674675
print_result "claim POST fallback pre-creates private stderr file" 1 "chmod_mode=${chmod_mode:-missing} chmod_path=${chmod_path:-missing} output: $output"
675676
fi
676-
if grep -q "umask 077" "$CLAIM_HELPER"; then
677+
if [[ -f "${chmod_log}.pre" ]]; then
678+
IFS= read -r pre_chmod_mode <"${chmod_log}.pre" || true
679+
fi
680+
if [[ "$pre_chmod_mode" == "600" ]]; then
677681
print_result "claim POST fallback creates file under restrictive umask" 0
678682
else
679-
print_result "claim POST fallback creates file under restrictive umask" 1 "umask 077 not found in helper"
683+
print_result "claim POST fallback creates file under restrictive umask" 1 "pre_chmod_mode=${pre_chmod_mode:-missing} output: $output"
680684
fi
681685
if grep -q "set -C" "$CLAIM_HELPER"; then
682686
print_result "claim POST fallback uses exclusive creation" 0

0 commit comments

Comments
 (0)