xtask: preserve filenames during asset-policy checks #2579
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2581"
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 Marvisak/VIctory. Originally posted by XeNS1 on 2026-11-25T16:10:10Z.
Claimed as: XTASK-POLICY-FILENAME-FIDELITY
https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7167509180
Problem and change
On POSIX,
literal\name.rsis a legal filename. Asset-policy enumeration changed the backslash into/, so it inspectedliteral/name.rsinstead. If that path was absent, the check skipped the contents; if it held clean text, it checked the wrong file. Non-UTF-8 filenames were similarly replaced with a different name by lossy decoding. The policy could report success while a synthetic NUL-bearing file went unchecked.Keep Git's UTF-8 paths verbatim: Git already emits
/directory separators. For source trees without Git, normalize only the native directory separator. Refuse non-UTF-8 filenames explicitly rather than substituting a name that can identify another file.Add temporary-file regressions for Git worktree/untracked scans, staged content, source exports without
.git, literal backslashes, invalid UTF-8 names and Unicode controls. The controls also verify that staged mode reads the index rather than unstaged worktree contents. Every binary test input is a generated single NUL byte in a temporary directory; no game files are used.tempfileis an existing workspace dependency, added only as an xtask dev-dependency. No dependency versions change.Validation
Linux x86-64, Rust/Cargo 1.100.0; 2 test/build workers:
cargo test -p xtask --locked --offline -j 2 -- --test-threads=2: 9 passed.cargo clippy -p xtask --all-targets --all-features --locked --offline -j 2 -- -D warnings: passed.cargo fmt --package xtask -- --check: passed.cargo run --quiet --locked --offline -p xtask -- policy: 184 files passed.policy --staged: exactly the three changed files passed.git diff --check: passed.The pinned Rust 1.98.1 and native Windows were not tested locally. POSIX-only filename cases are gated with
cfg(unix); the ordinary Unicode/index regression also runs on Windows. The whole Windows runtime workspace and game were not run.Related: #2246 changes the same policy file for decimal-array detection; #2166 adds CPU verification tooling. Their behavior is outside this change. Depends on: none.
GPUs tested: n/a, CPU-only filesystem/Git checks.
AI-assisted: OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T16:33:53Z.
oni-swr verification — head
2c13b1c48dea5db6bb12a364b39bce4ea9ac1b9e,origin/main67e8ae1401df112248aed36d0024483181b718b7Environment: Windows 11 Pro (26200), rustc 1.98.1, CPU only (no GPU involved, no game files). Merge check:
git merge-tree --write-tree origin/main <head>is clean.Commands / results
cargo test --locked -p xtask: 7 passed, 0 failed, 0 ignored (incl.ordinary_unicode_paths_are_checked_in_both_modesandrepository_passes_policy).literal_backslashes_do_not_hide_file_contentsandnon_utf8_names_are_refused_instead_of_substitutedare#[cfg(unix)], so they were compiled out, not run here, and NTFS cannot create such filenames anyway. Those two paths are therefore unverified by me and need a Linux/macOS run (CI).Review: the git branch now uses the NUL-separated names as-is (git already emits
/) and fails loudly on non-UTF-8 instead offrom_utf8_lossy+\replacement; the walkdir branch errors on a non-UTF-8 relative path and only normalizesMAIN_SEPARATOR(so on POSIX a literal\stays in the name).tempfileis a dev-dependency only;Cargo.lockchange matches. Behaviour on Windows is unchanged for ordinary names. I found no defects.Overlap: none; no other open PR touches
xtask.AI disclosure: this review and verification were done by Claude Code (Claude Sonnet 5.5), not a human reviewer. Comment-only; no code changed.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:19:05Z.
Automated triage for the maintainers.
Needs the maintainer's decision. The change tightens
xtask/src/policy.rsand does not loosen it.list_fileskeeps git's NUL-separated names verbatim instead of turning\into/and decoding lossily, the walkdir fallback normalises onlyMAIN_SEPARATOR, and non-UTF-8 names now fail the check instead of being replaced by another name. By my reading this is correct, and the tests generate their inputs (single NUL bytes) in temp dirs. It merges cleanly and CI (check) passes, but the twocfg(unix)tests do not run on the Windows CI.It adds
tempfileas a dev-dependency ofxtask(xtask/Cargo.toml,Cargo.lock), and its tests spawngitprocesses. Dependency changes and process spawning are left to the maintainer, so this cannot be marked a merge candidate by triage. Nothing is needed from the author unless the maintainer asks.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T15:13:18Z.
Independent CPU-only verification on Windows / Rust 1.100.0 / MSVC.
2c13b1c48dea5db6bb12a364b39bce4ea9ac1b9e, merge base67e8ae1401df112248aed36d0024483181b718b7.cargo test --locked -p xtask --bin xtask -- policy::tests::ordinary_unicode_paths_are_checked_in_both_modes --exact --test-threads=1 --quiettest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out, exit 0.git grep -F -c ordinary_unicode_paths_are_checked_in_both_modes 67e8ae14 -- .→ exit 1 / 0 hits (test genuinely new); present on PR head.git diff --check 67e8ae14 HEAD→ exit 0.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.