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

Open
opened 2026-11-26 20:21:07 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1367
Author: @JesusACD
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/save-keys-out-guard


📝 Commits (1)

  • 6265b33 save_keys: guard --out with same_report_path and refuse directories before resolving (SAVE-KEYS-OUT-GUARD)

📊 Changes

2 files changed (+41 additions, -6 deletions)

View changed files

📝 tests/test_save_keys.py (+29 -0)
📝 tools/save_keys.py (+12 -6)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1367 **Author:** [@JesusACD](https://github.com/JesusACD) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/save-keys-out-guard` --- ### 📝 Commits (1) - [`6265b33`](https://github.com/ubiquitarianism/leonida/commit/6265b337a84ee92232190c83ef37a0e29f1a1f63) save_keys: guard --out with same_report_path and refuse directories before resolving (SAVE-KEYS-OUT-GUARD) ### 📊 Changes **2 files changed** (+41 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_save_keys.py` (+29 -0) 📝 `tools/save_keys.py` (+12 -6) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1396
No description provided.