vs_input_survey: validate index.json filenames, accept UTF-8 BOM, guard inputs, and publish --json atomically (VS-INPUT-SURVEY-SAFE-PATHS-AND-ATOMIC-JSON) #1767
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1767"
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?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T11:43:29Z.
Claimed in the coordination issue as: VS-INPUT-SURVEY-SAFE-PATHS-AND-ATOMIC-JSON https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161333334
What and why
Hardens
scripts/vs_input_survey.py:index.jsonfileentries against path traversal: Validate every VS entry'sfilefield via_safe_shader_stem(rejecting/,\,:, drive prefixes, control characters,., and..) before resolving<dxbc>/disasm/<stem>.s.index.json: Openindex.jsonwithencoding="utf-8-sig"so BOM files written by PowerShell/Windows editors load cleanly.same_report_path& directory guard for--json: Replace bareos.path.samefile(a.json, index_path)withsame_report_pathacrossindex.json,<dxbc>, and every surveyed<dxbc>/disasm/<stem>.s, and refuse existing directory targets cleanly on stderr (exit2).--jsonwrite with Windows read-only cleanup: Stage JSON in the destination directory, applypublished_mode, publish viareplace_retry, and restore0o600before unlinking on failure so failed or read-only writes preserve any previous JSON file intact and leave no.vs_input_survey-*.tmpfiles.Adds synthetic regression checks in
tests/test_vs_input_survey.py.Tested
Windows 11 x64 (
10.0.26100), Python3.14.7, CPU only, syntheticdxbcfixtures only (no game files). Commit51e47a68a4e167417537421eeb1be35412d075e8.python -I tests/test_vs_input_survey.py:main(bcaa13da) with the updated test file: FAILED (11 failures) (path traversal accepted, UTF-8 BOM rejected,--jsondirectory/.soverwrites uncaught, mid-write error wipes existing--json);python -I tests/test_vs_input_survey_rbw.py -v: 12 tests, OK.python -I tests/test_ci_registration.py: 16 tests, OK.python -I tests/test_text_write_line_endings.py: 3 tests, OK.python -I scripts/check_no_game_data.py scripts/vs_input_survey.py tests/test_vs_input_survey.py,python -m compileall -q scripts tools tests,git diff --check: exit0.GPUs 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. (n/a: no translator change)Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T18:40:36Z.
Reviewed
51e47a68a: vs_input_survey filename validation, BOM handling,--jsonguards and atomic publish. Ran on this tree and origin/main:python -I tests/test_vs_input_survey.py(all checks pass; the new checks fail on main),test_vs_input_survey_rbw.py,test_text_write_line_endings.py,pytest tests/test_vs_input_survey.py,check_no_game_data.pyon both changed files, plus a probe of the old behaviour (../../x.dxbctraversal surveys a file outside dxbc;--jsonequal to a surveyed.soverwrites it) and the new refusals. No live staging files remain; destination mode is preserved. The Windows-only test branches did not run. No findings.AI-assisted review.
Recommendation: Merge
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T11:27:52Z.
#1767 | head
51e47a68a4e167417537421eeb1be35412d075e8|python3 -m pytest -q -rA tests/test_vs_input_survey.py,py -3.12 -I tests/test_vs_input_survey.py -v| red: 1 failed (Linux) / 11 failed checks (Windows) | green: 1 passed (Linux) / standalone script passed (0 failed checks) (Windows) | Red → greenThe native Windows script exercised real read-only JSON file handling, in addition to the simulated failures. It reported no failed checks after merging.
Copied the PR tests onto clean main
4a54aedcb6b66525e0c9f72a6ea10263337c9141for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Native Windows used Python 3.12.10. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T11:44:38Z.
Merged, thank you @kirigayakazima! This PR (vs_input_survey: validate index.json filenames, accept UTF-8 BOM, guard inputs, and publish --json atomically (VS-INPUT-SURVEY-SAFE-PATHS-AND-ATOMIC-JSON)) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.