Repository navigation
PR checks: require hex commit hashes in xcl-smoke blocks - #1141
microwave805 wants to merge 1 commit into
Conversation
|
Independent verification on current Machine: Windows 11, Ryzen 9 7900X; Python 3.
AI use: test runs by Devin (Cognition, SWE-2); no code changes. |
|
Tested exact head Tested
Not tested
AI use
|
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)
b00fd33 to
eebd284
Compare
GonZiin
left a comment
There was a problem hiding this comment.
I checked whether #834 still needs a separate merge. All four of its SmokeBlockCommitTests pass with this PR's checker, including acceptance of valid abbreviations and rejection of dirty and short-head blocks. This PR also validates the baseline's commit token. I would consolidate the work here and retain any additional test cases from #834 in the same branch.
Tested
- Linux x86_64, Python 3.14.4.
python3 -B -m unittest discover -s scripts -p 'test_*.py'ran 13 tests on #834 atf0bc702589cd694ca37db95c7f7268cedc095aecand 19 tests on #1141 ateebd2849f4e8305198cc92e66518e76a33d7cda2. Both passed. git merge-tree --write-treecombined #1141 withmainat9e3831e1f570d3646e53ab753b19ec07eb8f1485without conflicts. I copied only #834's four regression tests into the temporary merged tree. The same Python command reported 23 passed, 0 failed, 0 ignored.
Not tested
The Windows workspace and live GitHub Actions execution of the checker.
AI use
Codex (gpt-6.2-sol) compared the diffs, ran the tests and drafted this review.
|
@GonZiin Thanks for cross-checking #834 against (Comment drafted with Antigravity (Gemini 4 Neon).) |
scripts/pr_check.pyaccepted any 7+ character token on anxcl-smokeblock'scommit:line and passed it verbatim togh api repos/<repo>/compare/<sha>...main(running underpull_request_target) andgit merge-base --is-ancestor.As a result, symbolic refs and rev expressions such as
refs/heads/mainandmain~00returnedidenticalfrom GitHub's compare API (andorigin/main/HEAD~000exited0locally), 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 #834: #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 tois_main_ancestor(). Validating 7–40 hex digits handles both.What is in it
scripts/pr_check.py: addCOMMIT_SHA([0-9a-f]{7,40}, case-insensitive) andcommit_sha()to extract and lowercase valid hex SHAs before matchingheador callingis_main_ancestor(), plus the same check insideis_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
stable-x86_64-pc-windows-msvc, debug), Python 3.11.3eebd284(rebased ontomainb7aa9f3):python -I -m unittest discover -s scripts -p "test_*.py" -v: 19 passed, 0 failed.\scripts\test.ps1(cargo build --workspace && cargo test --workspace -- --test-threads=4): 770 passed, 0 failed, 41 ignoredgpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)b00fd33(base47efa2e): before the fix all 3 new tests failed with 12 subtest failures;python -I scripts/pr_check.py --localrejectedorigin/main,refs/heads/main,HEAD~000, and--version(exit 1) and accepted47efa2e(description ok); checkedcommit_sha()against 25 recently merged PRs onxcl-dev/xcl(16 PRs, 32xcl-smokeblocks, 0 false positives)Regression run
scripts/pr_check.pyandscripts/test_pr_check.py(no runtime or build-input files).Not tested
pull_request_targetexecution (usesmain's copy ofscripts/pr_check.pyuntil merged)AI use
scripts/pr_check.py, wrote the fix, unit tests, rebase conflict resolution, and this PR description, and ran the verification commands above.