save_keys: guard --out with same_report_path and refuse directories before resolving (SAVE-KEYS-OUT-GUARD) #1367
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1367"
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 JesusACD on 2026-11-24T22:38:14Z.
Claimed in the coordination issue as: SAVE-KEYS-OUT-GUARD (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146434960)
What and why
tools/save_keys.py(out_problem,:195-204) checked--outonly whenos.path.exists(out)usingos.path.samefile(out, p), and did not check whether--outis a directory:--outnaming an existing directory (including an input folder of saves, sinceinput_files()expands directories to their contained files) passedout_problem(), ran the full key collection, dictionary harvesting, 8 hash families and--composepass, printed the summary tostdout, and only then failed atopen(a.out, "w").os.path.exists(out)andos.path.samefileskippedtools/report_paths.same_report_path(CONTRIBUTING.md), missing non-existing or case-folded aliases on volumes wherenormcase/samefilealone do not fold them.This switches
out_problem()totools/report_paths.same_report_pathand refuses directory--outtargets before any collection or resolution work runs.Tested
python -m compileall -q make_game.py tools tests: clean.python -I tools/save_keys.py --help: clean.python -I tests/test_save_keys.py -v: 36 passed, 1 skipped (added regression tests for pre-resolve directory refusal and delegation tosame_report_pathon Windows 11 / Python 3.13.17).python -I tests/test_report_paths.pyandpython -I tests/test_text_write_line_endings.py: 25 passed.python -I scripts/check_no_game_data.py tools/save_keys.py tests/test_save_keys.py: clean.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-25T15:07:19Z.
Reviewed
6265b33: ran tests/test_save_keys.py, tests/test_joaat_agreement.py and tests/test_report_paths.py on the PR tree (37+2+22 OK; --help, compileall and check_no_game_data clean) and on main (35 OK); with the PR's test file on main the new tests fail there, so they cover the change. A probe on both trees reproduces the fix: --out naming a directory makes main print the whole resolve report and then "cannot write ...: Is a directory", the PR refuses before resolving ("--out ... is a directory, not a file"); the dict, hard-link, missing-folder and case-variant cases behave as on main. No finding. AI-assisted review.Recommendation: Merge
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:32:20Z.
Red/green:
pytest tests/test_save_keys.pyfails on main (3 failed, 35 passed, 1 skipped, 4 subtests passed) and passes on head6265b337a8merged with main (36 passed, 1 skipped, 6 subtests passed).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)