tools/int_hw_probe.py: harden realpath --json validation and --hw-arch/--group checks #2293

Merged
kirigayakazima merged 1 commit from upstream-pr/2293 into main 2026-11-28 10:46:48 +00:00
kirigayakazima commented 2026-11-26 12:53:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-26T12:53:07Z.


Claimed in the coordination issue as: INT-HW-PROBE-REALPATH-JSON-GUARD-AND-CLI-VALIDATION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192551919)

What and why

  • Resolve os.path.realpath(out_path) in _validate_json_out() (tools/int_hw_probe.py) so symlinked directories and non-directory ancestors along the resolved target are rejected with ERROR: and exit code 2 before running translator or hardware probes.
  • Validate --hw-arch upfront in main(): reject empty --hw-arch values and reject --hw-arch when --oracle translator is selected (exit code 2).
  • Explicitly reject empty/whitespace --group entries with ERROR: --group must not be empty and exit code 2.
  • Add unit tests in tests/test_int_hw_probe.py.

Tested

  • python -I tests/test_int_hw_probe.py -v: 14 passed, 0 failed (detached upstream/main baseline with only the updated test file fails with 6 failures).
  • python -I tests/test_ci_registration.py: 16 passed.
  • python -I tests/test_text_write_line_endings.py: 3 passed.
  • python -I scripts/check_no_game_data.py, python -I -m compileall -q tools/int_hw_probe.py tests/test_int_hw_probe.py, and git diff --cached --check: passed.

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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5510372763 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2293). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-26T12:53:07Z. --- Claimed in the coordination issue as: INT-HW-PROBE-REALPATH-JSON-GUARD-AND-CLI-VALIDATION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192551919) ### What and why - Resolve `os.path.realpath(out_path)` in `_validate_json_out()` (`tools/int_hw_probe.py`) so symlinked directories and non-directory ancestors along the resolved target are rejected with `ERROR:` and exit code `2` before running translator or hardware probes. - Validate `--hw-arch` upfront in `main()`: reject empty `--hw-arch` values and reject `--hw-arch` when `--oracle translator` is selected (exit code `2`). - Explicitly reject empty/whitespace `--group` entries with `ERROR: --group must not be empty` and exit code `2`. - Add unit tests in `tests/test_int_hw_probe.py`. ### Tested - `python -I tests/test_int_hw_probe.py -v`: 14 passed, 0 failed (detached `upstream/main` baseline with only the updated test file fails with 6 failures). - `python -I tests/test_ci_registration.py`: 16 passed. - `python -I tests/test_text_write_line_endings.py`: 3 passed. - `python -I scripts/check_no_game_data.py`, `python -I -m compileall -q tools/int_hw_probe.py tests/test_int_hw_probe.py`, and `git diff --cached --check`: passed. 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
tiguan26 commented 2026-11-27 04:40:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:40:52Z.

Review: APPROVED


Approving 6a0a43449.

The --json check now looks at the resolved destination as well as the given path (a symlink into a file or a non-folder ancestor is refused), and an empty --hw-arch, --hw-arch with --oracle translator, and a blank --group are usage errors.

Merged onto main d1dff7949 in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13. tests/test_int_hw_probe.py: 14 passed (main: 13). AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6083566921 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2293#pullrequestreview-6083566921). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-27T04:40:52Z. **Review:** APPROVED --- Approving 6a0a43449. The `--json` check now looks at the resolved destination as well as the given path (a symlink into a file or a non-folder ancestor is refused), and an empty `--hw-arch`, `--hw-arch` with `--oracle translator`, and a blank `--group` are usage errors. Merged onto `main` `d1dff7949` in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13. `tests/test_int_hw_probe.py`: 14 passed (main: 13). AI-assisted (Claude Code, Claude Opus 5.5).
MSedgeMC commented 2026-11-27 15:26:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-27T15:26:50Z.

Review: COMMENTED


Verified on the PR branch: python3 -m unittest tests.test_int_hw_probe -v -> 14 tests OK, including the new --json path/hardware-arg validation cases. Not approving yet: the branch is 446 commits behind current main, so a rebase is needed before the final diff can be reviewed.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6090341549 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2293#pullrequestreview-6090341549). Originally posted by [MSedgeMC](https://github.com/MSedgeMC) on 2026-11-27T15:26:50Z. **Review:** COMMENTED --- Verified on the PR branch: python3 -m unittest tests.test_int_hw_probe -v -> 14 tests OK, including the new --json path/hardware-arg validation cases. Not approving yet: the branch is 446 commits behind current main, so a rebase is needed before the final diff can be reviewed.
sodove commented 2026-11-28 10:12:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T10:12:37Z.


#2293 | head 6a0a43449efd7b22db03c6999d2bd2bc8f86deb5 | python3 -I tests/test_int_hw_probe.py -v | red: 14 run, 6 failures | green: 14 passed | Red → green

On main the CLI proceeded to probe work or produced the wrong status for invalid arguments. These checks used the PR’s synthetic cases.

Pinned main 33db04a7010e81c40a7a6a15624525aa0c4a3a58, merged into this PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237745925 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2293#issuecomment-7237745925). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T10:12:37Z. --- #2293 | head `6a0a43449efd7b22db03c6999d2bd2bc8f86deb5` | `python3 -I tests/test_int_hw_probe.py -v` | red: 14 run, 6 failures | green: 14 passed | **Red → green** On main the CLI proceeded to probe work or produced the wrong status for invalid arguments. These checks used the PR’s synthetic cases. Pinned main `33db04a7010e81c40a7a6a15624525aa0c4a3a58`, merged into this PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7237628300).
DadaCap commented 2026-11-28 10:46:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T10:46:50Z.


Merged, thank you @kirigayakazima!

What it does: tools/int_hw_probe.py: harden realpath --json validation and --hw-arch/--group checks

How it was checked: sodove tested this PR at head 6a0a43449 on main 33db04a70: the PR's own test fails on main and passes with this PR merged in (his result is linked from the batch summary in #1608). We then re-ran the same test locally on Windows 11 and got the same verdict: on main, red (6 failures); with the PR, green (14 OK).

CI: the red jobs on this PR fail the same way on main, or on the older main it was built on (the cs_dpp_cmp.asm translator fixture, since fixed on main, and the Windows runner's Visual Studio setup), so none comes from this change.

Merged one by one with 20 other PRs of the same reviewed batch, pinned to the tested head.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238116997 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2293#issuecomment-7238116997). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T10:46:50Z. --- Merged, thank you @kirigayakazima! **What it does:** tools/int_hw_probe.py: harden realpath --json validation and --hw-arch/--group checks **How it was checked:** sodove tested this PR at head `6a0a43449` on main `33db04a70`: the PR's own test fails on main and passes with this PR merged in (his result is linked from the batch summary in #1608). We then re-ran the same test locally on Windows 11 and got the same verdict: on main, red (6 failures); with the PR, green (14 OK). **CI:** the red jobs on this PR fail the same way on main, or on the older main it was built on (the `cs_dpp_cmp.asm` translator fixture, since fixed on main, and the Windows runner's Visual Studio setup), so none comes from this change. Merged one by one with 20 other PRs of the same reviewed batch, pinned to the tested head. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
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!2293
No description provided.