d3d12_xs_surface: guard GUID negative bounds, SCARAB BOM/CRLF, and bad paths #2263
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2263
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/d3d12-xs-surface-safety"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: D3D12-XS-SURFACE-SCARAB-CRLF-BOM-AND-GUID-BOUNDS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7190940196)
What and why
tools/d3d12_xs_surface.pyhad three validation and SCARAB parsing gaps:check_guid_values()checked upper bounds on GUID fields (> 0xFFFFFFFF,> 0xFFFF,> 0xFF) without rejecting negative components (< 0).parse_scarab_iid_table(),parse_scarab_iid_console(), andparse_scarab_catalogue()opened files with"utf-8"instead of"utf-8-sig", andparse_scarab_catalogue()stripped only"\n"instead of"\r\n".check_scarab()checkedos.path.exists(...)rather than directory/regular-file validity and letOSError/UnicodeDecodeError/ValueErrorcrash unhandled, whilemain()usedif args.scarab:so--scarab ""silently skipped checking and returned 0.This updates the bounds checks, opens SCARAB inputs with
utf-8-sigandrstrip("\r\n"), reports invalid/unreadable SCARAB paths aserrorsentries, checksargs.scarab is not None, and adds unit/CLI tests for these cases.Tested
python -I tests/test_d3d12_xs_surface.pypython -I tools/d3d12_xs_surface.py --checkupstream/mainbaseline negative control: failed with the new tests before the fixpython -I tests/test_ci_registration.py,python -I tests/test_text_write_line_endings.py,python -I scripts/check_no_game_data.py,python -I -m compileall -q, andgit diff --cached --checkGPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_d3d12_xs_surface.py ends "ok" (the Windows SDK header check and the SCARAB_REF check skip here, as expected on Linux). The PR's test file against main's tool fails in test_check_guid_values_rejects_negative_components (AssertionError: []), so the new test fails on main and passes with the change. compileall clean.
AI-assisted: yes (Claude Code)
Approving 15d9ec971.
The GUID check now catches negative fields as well as oversized ones, the SCARAB tables are read BOM- and CRLF-tolerant, and a missing or unreadable checkout or table is reported as an error instead of raising.
Merged onto
maind1dff7949in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_d3d12_xs_surface.py: 11 passed, 2 skipped (main: 8). AI-assisted (Claude Code, Claude Opus 5.5).#2263 | head 15d9ec97156e0c76b8637489416e9302872f689f (merged cleanly with main 6c7f79343) |
python -I tests/test_d3d12_xs_surface.py| red on main:AssertionError: []intest_check_guid_values_rejects_negative_components(check_guid_valuesaccepted negative GUID components) | green on PR+main:ok(11/12checks pass including Windows SDK IID cross-check;SCARAB_REFskipped) | Windows 11, Python 3.12.10 | AI-assisted: yesAudited negative GUID component bounds in
check_guid_values,utf-8-sig+\r\nhandling inparse_scarab_iid_table/parse_scarab_iid_console/parse_scarab_catalogue,args.scarab is not None(--scarab ""returning1withFAIL:), andos.path.isfile+(OSError, UnicodeDecodeError, ValueError)reporting incheck_scarabintools/d3d12_xs_surface.py. Also passedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.py.Red/green:
pytest tests/test_d3d12_xs_surface.pyfails on main (2 failed, 10 passed, 1 skipped) and passes on head 15d9ec97156e merged with main (12 passed, 1 skipped).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)