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

Open
github-bot wants to merge 1 commit from github-bot/gh-1367 into main AGit
Owner

@⁠JesusACD on GitHub · 2026-11-24 22:38 UTC · original
JesusACD:fix/save-keys-out-guard → main · +41 −6 · 2 files · 1 commits · open

Claimed in the coordination issue as: SAVE-KEYS-OUT-GUARD (#14)

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)
**@⁠JesusACD** on GitHub · 2026-11-24 22:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1367) `JesusACD:fix/save-keys-out-guard` → `main` · +41 −6 · 2 files · 1 commits · open Claimed in the coordination issue as: SAVE-KEYS-OUT-GUARD (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:49:05 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 15:07 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-25 15:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1367#issuecomment-7166335776) 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1367/head:github-bot/gh-1367'
git switch 'github-bot/gh-1367'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1367'
git switch 'github-bot/gh-1367'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1367'
git switch 'github-bot/gh-1367'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1367'
git switch 'main'
git merge --squash 'github-bot/gh-1367'
git switch 'main'
git merge --ff-only 'github-bot/gh-1367'
git switch 'main'
git merge 'github-bot/gh-1367'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.