mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:00:52 +01:00
[PR #1767] 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) #1779
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1779
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1767
Author: @kirigayakazima
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/vs-input-survey-safe-paths-and-atomic-json📝 Commits (1)
51e47a6vs_input_survey: validate index.json filenames, accept UTF-8 BOM, guard all inputs, and write --json atomically📊 Changes
2 files changed (+155 additions, -16 deletions)
View changed files
📝
scripts/vs_input_survey.py(+83 -16)📝
tests/test_vs_input_survey.py(+72 -0)📄 Description
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)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.