save_keys: guard --out with same_report_path and refuse directories before resolving (SAVE-KEYS-OUT-GUARD) #1367

Merged
JesusACD merged 1 commit from upstream-pr/1367 into main 2026-11-28 14:32:24 +00:00
JesusACD commented 2026-11-24 22:38:14 +00:00 (Migrated from github.com)

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 --out only when os.path.exists(out) using os.path.samefile(out, p), and did not check whether --out is a directory:

  • Passing --out naming an existing directory (including an input folder of saves, since input_files() expands directories to their contained files) passed out_problem(), ran the full key collection, dictionary harvesting, 8 hash families and --compose pass, printed the summary to stdout, and only then failed at open(a.out, "w").
  • Gating the input comparison behind os.path.exists(out) and os.path.samefile skipped tools/report_paths.same_report_path (CONTRIBUTING.md), missing non-existing or case-folded aliases on volumes where normcase / samefile alone do not fold them.

This switches out_problem() to tools/report_paths.same_report_path and refuses directory --out targets 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 to same_report_path on Windows 11 / Python 3.13.17).
  • python -I tests/test_report_paths.py and python -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.
  • No game files or GPU needed.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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, with how it was confirmed. (n/a: no translator change)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5481507077 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1367). Originally posted by [JesusACD](https://github.com/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 `--out` only when `os.path.exists(out)` using `os.path.samefile(out, p)`, and did not check whether `--out` is a directory: - Passing `--out` naming an existing directory (including an input folder of saves, since `input_files()` expands directories to their contained files) passed `out_problem()`, ran the full key collection, dictionary harvesting, 8 hash families and `--compose` pass, printed the summary to `stdout`, and only then failed at `open(a.out, "w")`. - Gating the input comparison behind `os.path.exists(out)` and `os.path.samefile` skipped `tools/report_paths.same_report_path` (`CONTRIBUTING.md`), missing non-existing or case-folded aliases on volumes where `normcase` / `samefile` alone do not fold them. This switches `out_problem()` to `tools/report_paths.same_report_path` and refuses directory `--out` targets 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 to `same_report_path` on Windows 11 / Python 3.13.17). - `python -I tests/test_report_paths.py` and `python -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. - No game files or GPU needed. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change)
PierreEbele commented 2026-11-25 15:07:19 +00:00 (Migrated from github.com)

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7166335776 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1367#issuecomment-7166335776). Originally posted by [PierreEbele](https://github.com/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
MoonEyes commented 2026-11-28 14:32:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:32:20Z.


Red/green: pytest tests/test_save_keys.py fails on main (3 failed, 35 passed, 1 skipped, 4 subtests passed) and passes on head 6265b337a8 merged 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 d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7240745105 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1367#issuecomment-7240745105). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:32:20Z. --- Red/green: `pytest tests/test_save_keys.py` fails on main (3 failed, 35 passed, 1 skipped, 4 subtests passed) and passes on head 6265b337a84e merged 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 d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1367
No description provided.