Skip to content

[upstream #1141] PR checks: require hex commit hashes in xcl-smoke blocks - #21

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1141
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1141

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

scripts/pr_check.py accepted any 7+ character token on an xcl-smoke block's commit: line and passed it verbatim to gh api repos/<repo>/compare/<sha>...main (running under pull_request_target) and git merge-base --is-ancestor.

As a result, symbolic refs and rev expressions such as refs/heads/main and main~00 returned identical from GitHub's compare API (and origin/main / HEAD~000 exited 0 locally), passing the main-baseline check without naming any commit hash. Untrusted path segments (../../pulls, query strings) and leading-dash git flags (--version) were also interpolated directly into those calls.

Note on overlap with xcl-dev#834: xcl-dev#834 checks the first word's length (≥ 7) to reject short prefixes like 1 some other, but still allows non-hex refs, paths, and options through to is_main_ancestor(). Validating 7–40 hex digits handles both.

What is in it

  • scripts/pr_check.py: add COMMIT_SHA ([0-9a-f]{7,40}, case-insensitive) and commit_sha() to extract and lowercase valid hex SHAs before matching head or calling is_main_ancestor(), plus the same check inside is_main_ancestor() as defense-in-depth.
  • scripts/test_pr_check.py: cover non-hex refs, path traversal, query strings, leading-dash flags, out-of-range lengths, short/non-hex PR head commits, and valid 7–40 character lowercase/uppercase hex SHAs.

Tested

  • NVIDIA GeForce RTX 3070 (driver 32.0.16.1742), AMD Ryzen 5 5600X, Windows 11 Pro (build 22631), Rust 1.100.0 (stable-x86_64-pc-windows-msvc, debug), Python 3.11.3
  • python -I -m unittest discover -s scripts -p "test_*.py" -v: 12 passed, 0 failed (before the fix on 47efa2e, all 3 new tests failed with 12 subtest failures)
  • python -I scripts/pr_check.py --local against origin/main (47efa2e): origin/main, refs/heads/main, HEAD~000, and --version exit 1; 47efa2e exits 0 (description ok)
  • Checked commit_sha() against the 25 most recently merged PRs on ivall/xcl: 16 PRs with xcl-smoke blocks (32 blocks total), 0 rejected commits
  • .\scripts\test.ps1 --skip test_title_runs_and_game_folder_is_untouched --skip test_title_draws_with_a_root_signature_under_the_debug_layer (on 47efa2e with this diff; touches no Rust): 739 passed, 0 failed, 41 ignored, 2 filtered out
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)
  • python -I scripts/pr_check.py --local on this PR's description and changed files: description ok

Regression run

  • Not needed: changes only scripts/pr_check.py and scripts/test_pr_check.py (no runtime or build-input files).

Not tested

  • Live GitHub Actions pull_request_target execution (uses main's copy of scripts/pr_check.py until merged)
  • The two skipped e2e tests (test_title_runs_and_game_folder_is_untouched, test_title_draws_with_a_root_signature_under_the_debug_layer)
  • AMD / wave64 GPUs and retail titles

AI use

  • Antigravity (Gemini 4 Neon): audited scripts/pr_check.py, wrote the fix, unit tests, and this PR description, and ran the verification commands above.

Mirror of xcl-dev#1141 (auto-synced, do not edit).

check() accepted any 7+ character token on an xcl-smoke block's commit
line and passed it verbatim to gh api repos/<repo>/compare/<sha>...main
(under pull_request_target) and git merge-base --is-ancestor.

Symbolic refs and rev expressions such as refs/heads/main and main~00
return identical from GitHub's compare API (and origin/main / HEAD~000
exit 0 locally), so a smoke block could satisfy the main-baseline check
without naming a real commit hash. Arbitrary path segments (../../pulls,
query strings) and leading-dash git options (--version) were also passed
through unvalidated.

Validate commit tokens as 7-40 hex digits via commit_sha() before
matching head or calling is_main_ancestor(), normalize to lowercase for
comparison, and guard is_main_ancestor() with the same pattern.

Assisted-by: Antigravity (Gemini 4 Neon)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1141 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1141 branch November 25, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants