mask_channels: validate dimensions/buffers and --json paths, preserve symlinks and /dev/null (MASK-CHANNELS-VALIDATION-AND-ATOMIC-IO) #1597

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

@⁠IlyassRS3 on GitHub · 2026-11-25 05:30 UTC · original
IlyassRS3:fix/mask-channels-validation-and-atomic-io → main · +126 −24 · 2 files · 1 commits · open

Item: MASK-CHANNELS-VALIDATION-AND-ATOMIC-IO (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/mask_channels.py).

Summary

  • Validate positive non-bool integer dimensions and exact buffer lengths in blobs() (len(mask) == width * height) and channel_counts() (len(rgba) == width * height * 4) so zero/negative/mismatched inputs raise ValueError instead of ZeroDivisionError or silently skewed statistics.
  • Validate --json before decoding the DDS texture: reject empty/whitespace strings ("", " ") and trailing-separator directory paths (new_dir/).
  • Harden --json publishing via _write_json_report(): resolve symlinks so symlinked report paths update their target in place, write non-regular targets (such as /dev/null) directly, check write permissions on existing regular files before staging, use replace_retry.replace with allow_nan=False and trailing \n, and publish before printing stdout.

Verification

  • python3 -W error -I tests/test_mask_channels.py -v: 13/13 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/mask_channels.py tests/test_mask_channels.py: passed.
  • python3 -m compileall -q tools/mask_channels.py tests/test_mask_channels.py: passed.
  • Mutation check (running tests/test_mask_channels.py against unpatched main:tools/mask_channels.py): failures=10, errors=0 across all 4 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python texture-mask analysis tool; synthetic RGBA8 DDS only, no game data)

**@⁠IlyassRS3** on GitHub · 2026-11-25 05:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1597) `IlyassRS3:fix/mask-channels-validation-and-atomic-io` → `main` · +126 −24 · 2 files · 1 commits · open Item: `MASK-CHANNELS-VALIDATION-AND-ATOMIC-IO` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/mask_channels.py`). ### Summary - Validate positive non-bool integer dimensions and exact buffer lengths in `blobs()` (`len(mask) == width * height`) and `channel_counts()` (`len(rgba) == width * height * 4`) so zero/negative/mismatched inputs raise `ValueError` instead of `ZeroDivisionError` or silently skewed statistics. - Validate `--json` before decoding the DDS texture: reject empty/whitespace strings (`""`, `" "`) and trailing-separator directory paths (`new_dir/`). - Harden `--json` publishing via `_write_json_report()`: resolve symlinks so symlinked report paths update their target in place, write non-regular targets (such as `/dev/null`) directly, check write permissions on existing regular files before staging, use `replace_retry.replace` with `allow_nan=False` and trailing `\n`, and publish before printing stdout. ### Verification - `python3 -W error -I tests/test_mask_channels.py -v`: 13/13 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/mask_channels.py tests/test_mask_channels.py`: passed. - `python3 -m compileall -q tools/mask_channels.py tests/test_mask_channels.py`: passed. - Mutation check (running `tests/test_mask_channels.py` against unpatched `main:tools/mask_channels.py`): `failures=10, errors=0` across all 4 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python texture-mask analysis tool; synthetic RGBA8 DDS only, no game data)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:57:36 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 05:30 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 05:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1597#pullrequestreview-6052313315) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
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/1597/head:github-bot/gh-1597'
git switch 'github-bot/gh-1597'

Merge

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