awc_shorts: refuse a catalog destination that aliases an input bank #196

Closed
github-bot wants to merge 1 commit from gh-pr/196/head into gh-pr/196/base
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:40 UTC · original
ubiquitarianism:old-pr/9927 → main · +35 −1 · 2 files · 1 commits · closed without merging

Carried over from old PR 9927 by neoisg8 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9927, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
neoisg8: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue: https://github.com/ProjectLeonida/Leonida/issues/9677 (from finding by @kawaii-shakal: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7115664188)

Depends on: none.

What and why

In tools/awc_shorts.py, the output catalog was previously published to <out>/shorts.csv without verifying whether that path collided with an input bank. When an input bank was named shorts.csv or exported into a directory of that name, publishing the catalog replaced the source input file with the CSV header/rows and exited 0.

Fix:

  1. Import same_report_path from report_paths.
  2. Check upfront before creating directories or exporting clips whether <out>/shorts.csv aliases any bank in banks, reporting awc_shorts: error: catalog would overwrite the input bank <path> and exiting 2.
  3. Check whether <out>/shorts.csv collides with any bank export directory <out>/<bank>, reporting awc_shorts: error: catalog would collide with bank export directory <target> and exiting 2.

Tested

  • Windows 11 Pro 26100, Python 3.12.10, CPU only, no GPU, no game files.
  • Negative control on main (5d74c2723):
    An input file shorts.csv was overwritten with CSV contents and exited with returncode 0.
  • Positive control on fix/awc-shorts-protect-input-catalog:
    The collision is refused with exit code 2 and diagnostic message before directory creation; input file contents remain untouched.
  • Unit tests:
    python -I tests/test_awc_shorts.py -> 17 tests passed (1 expected skip: case-distinct test on Windows).
  • Hygiene checks:
    python -m compileall -q tools/awc_shorts.py tests/test_awc_shorts.py: clean.
    python -I scripts/check_no_game_data.py tools/awc_shorts.py tests/test_awc_shorts.py: clean.
    git diff --check origin/main: clean.

AI-assisted: yes.

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, with how it was confirmed. (Not applicable: no translator change.)
**@⁠Andretuta** on GitHub · 2026-11-24 02:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/196) `ubiquitarianism:old-pr/9927` → `main` · +35 −1 · 2 files · 1 commits · closed without merging > Carried over from **old PR 9927** by `neoisg8` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9927`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `neoisg8`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claimed in the coordination issue: https://github.com/ProjectLeonida/Leonida/issues/9677 (from finding by `@kawaii-shakal`: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7115664188) Depends on: none. ### What and why In `tools/awc_shorts.py`, the output catalog was previously published to `<out>/shorts.csv` without verifying whether that path collided with an input bank. When an input bank was named `shorts.csv` or exported into a directory of that name, publishing the catalog replaced the source input file with the CSV header/rows and exited 0. Fix: 1. Import `same_report_path` from `report_paths`. 2. Check upfront before creating directories or exporting clips whether `<out>/shorts.csv` aliases any bank in `banks`, reporting `awc_shorts: error: catalog would overwrite the input bank <path>` and exiting 2. 3. Check whether `<out>/shorts.csv` collides with any bank export directory `<out>/<bank>`, reporting `awc_shorts: error: catalog would collide with bank export directory <target>` and exiting 2. ### Tested - Windows 11 Pro 26100, Python 3.12.10, CPU only, no GPU, no game files. - Negative control on `main` (`5d74c2723`): An input file `shorts.csv` was overwritten with CSV contents and exited with returncode 0. - Positive control on `fix/awc-shorts-protect-input-catalog`: The collision is refused with exit code 2 and diagnostic message before directory creation; input file contents remain untouched. - Unit tests: `python -I tests/test_awc_shorts.py` -> 17 tests passed (1 expected skip: case-distinct test on Windows). - Hygiene checks: `python -m compileall -q tools/awc_shorts.py tests/test_awc_shorts.py`: clean. `python -I scripts/check_no_game_data.py tools/awc_shorts.py tests/test_awc_shorts.py`: clean. `git diff --check origin/main`: clean. AI-assisted: yes. ### Checklist - [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. (Not applicable: no translator change.)
ools/awc_shorts.py previously published <out>/shorts.csv without
checking whether the catalog path collided with an input bank. When
an input was named shorts.csv or exported into a directory of that
name, publishing the catalog replaced the source input file with CSV
output and exited 0.

Verify upfront using same_report_path() that <out>/shorts.csv does
not alias any input bank or bank export destination directory, refusing
the collision with error diagnostic and exit code 2 before creating
directories or exporting clips.

Add regression tests covering input bank and directory export collisions.

AI-assisted: yes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:48:24 +00:00
github-bot closed this pull request 2026-11-26 08:48:24 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:18 UTC · original

This carry-over of old upstream PR 9927 has been taken over in #934, so I'm closing this draft as #17 describes. The branch old-pr/9927 stays.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 19:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/196#issuecomment-7141898382) This carry-over of old upstream PR 9927 has been taken over in #934, so I'm closing this draft as #17 describes. The branch `old-pr/9927` stays. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.