#1599
manifest, turing_atlas: refuse report paths that replace inputs or are folders
Claimed in the coordination issue as: https://github.com/ItsNotRexed/Leonida/issues/1548#issuecomment-7079163134
What and why
Two report-path bugs on main 41f44826, both with hand-built folders only (CPU, no game data):
tools/manifest.py create <game> --out <game>/a.txt-> exit 0.walk()excludes only the manifest path itself, soa.txtis hashed first and then replaced by the manifest withos.replace(); the recorded hash no longer matches the copy (a laterverifyreports it CHANGED).tools/turing_atlas.py --out <existing directory>-> the atlas is built and then the write dies with aPermissionErrortraceback.
Fixes:
manifest.py: before hashing, refuse a target that is an existing file inside the folder unless it already reads as a manifest (re-creating one in place stays allowed), and refuse every hard-link alias of a file that will be hashed. Missing parent folders still get created as before.turing_atlas.py: reject a directory--outwith oneturing_atlas: error:line and exit 2.
| command | main | this branch |
|---|---|---|
manifest create <game> --out <game>/a.txt | exit 0, a.txt replaced | exit 2, ERROR: --out would overwrite the input ..., file untouched |
manifest create <game> --out <hard link to a hashed file> | exit 0, input rewritten | exit 2, refused |
manifest create <game> --out <game>/manifest.json (new file) | works | works (allowed) |
manifest create <game> --out <existing dir> | OSError from os.replace | one ERROR: --out is a folder line, exit 2 |
turing_atlas --out <existing dir> | PermissionError traceback | exit 2, one --out is a folder line |
Tested
python -I tests/test_manifest.py-> 26 tests OK (4 new).python -I tests/test_turing_atlas.py-> 12 tests OK (1 new).- Negative control: both test files run against untouched
origin/mainin a separate worktree -> manifest 2 failures + 1 error, atlas 1 error, all from the new cases. - End-to-end: the two commands above now exit 2 and leave the game file untouched.
python -m compileall -q tools/manifest.py tools/turing_atlas.py tests/test_manifest.py tests/test_turing_atlas.pyandgit diff --checkclean.
CPU only, no game data.
AI-assisted.
Checklist
- No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
- A new translator rule is in the contract table of
docs/design.md??not applicable.