FIRST-LOOK-PS1-GAMEDIR-VALIDATION-HANDLE-CLEANUP-AND-REPORT-CHECK #2345

Merged
leonida/mandy
kirigayakazima merged 2 commits from fix/first-look-ps1-safety into main 2026-11-29 00:59:10 +00:00

Pull request successfully merged and closed

kirigayakazima commented 2026-11-26 14:19:11 +00:00

Claimed in the coordination issue as: FIRST-LOOK-PS1-GAMEDIR-VALIDATION-HANDLE-CLEANUP-AND-REPORT-CHECK (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194523743)

What and why

  • Resolve explicit -GameDir arguments via GetUnresolvedProviderPathFromPSPath in scripts/first_look.ps1 and validate -PathType Container before creating the report directory under reports\exe.
  • Guard $out with Test-Path -LiteralPath $out -PathType Leaf and create it via [IO.Directory]::CreateDirectory($out) so wildcard-metacharacter exe names and file-occupied report paths fail cleanly.
  • Dispose the [IO.File]::OpenRead($Exe) stream in try/finally and verify a 2-byte read before checking the "MZ" header so non-MZ or 0-byte inputs do not leak open handles.
  • Reset $global:LASTEXITCODE = 0 before invoking build_runtime.ps1 and throw when $LASTEXITCODE -ne 0; check $reportPath exists with -PathType Leaf before Get-Content | ConvertFrom-Json.
  • Add standard-library tests in tests/test_first_look_safety.py.

Tested

  • python -I tests/test_first_look_safety.py -v: 2 passed, 0 failed (detached upstream/main baseline with only the new test file fails with 2 failures).
  • python -I tests/test_first_look_exit.py -v: 1 passed (11 subtests).
  • python -I tests/test_first_look_paths.py -v: 1 passed.
  • python -I tests/test_first_look_rebuild.py -v: 5 passed.
  • python -I tests/test_first_look_shim_report.py -v: 1 passed.
  • 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 tests/test_first_look_safety.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.
Claimed in the coordination issue as: FIRST-LOOK-PS1-GAMEDIR-VALIDATION-HANDLE-CLEANUP-AND-REPORT-CHECK (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194523743) ### What and why - Resolve explicit `-GameDir` arguments via `GetUnresolvedProviderPathFromPSPath` in `scripts/first_look.ps1` and validate `-PathType Container` before creating the report directory under `reports\exe`. - Guard `$out` with `Test-Path -LiteralPath $out -PathType Leaf` and create it via `[IO.Directory]::CreateDirectory($out)` so wildcard-metacharacter exe names and file-occupied report paths fail cleanly. - Dispose the `[IO.File]::OpenRead($Exe)` stream in `try`/`finally` and verify a 2-byte read before checking the `"MZ"` header so non-MZ or 0-byte inputs do not leak open handles. - Reset `$global:LASTEXITCODE = 0` before invoking `build_runtime.ps1` and throw when `$LASTEXITCODE -ne 0`; check `$reportPath` exists with `-PathType Leaf` before `Get-Content | ConvertFrom-Json`. - Add standard-library tests in `tests/test_first_look_safety.py`. ### Tested - `python -I tests/test_first_look_safety.py -v`: 2 passed, 0 failed (detached `upstream/main` baseline with only the new test file fails with 2 failures). - `python -I tests/test_first_look_exit.py -v`: 1 passed (11 subtests). - `python -I tests/test_first_look_paths.py -v`: 1 passed. - `python -I tests/test_first_look_rebuild.py -v`: 5 passed. - `python -I tests/test_first_look_shim_report.py -v`: 1 passed. - `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 tests/test_first_look_safety.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.
lixonik reviewed 2026-11-26 20:50:19 +00:00
lixonik left a comment
No description provided.
On the merge with `main` at `fac8b4bb9`, all 10 `test_first_look_*.py` tests passed on Windows 11 with the standard Windows PowerShell module path. I also ran the missing-report fixture a second way, retaining the previous JSON as happens when the command is rerun. The wrapper returned success and printed a shim from the previous report. Details inline. AI-assisted.
kirigayakazima reviewed 2026-11-27 12:02:48 +00:00
lixonik reviewed 2026-11-27 14:23:21 +00:00
lixonik left a comment
No description provided.
Re-checked at `f43076b07` (merged onto `main` `ec91d695c`). Clearing `` before invoking `pe_inspect.py` and testing with a pre-existing stale JSON in `tests/test_first_look_safety.py` cleanly address the stale-report issue. Verified locally on Windows 11 (PowerShell + Python 3): - `tests/test_first_look_exit.py`, `test_first_look_paths.py`, `test_first_look_rebuild.py`, `test_first_look_safety.py`, `test_first_look_shim_report.py`: 10/10 passed - PowerShell AST parse of `tools/first_look.ps1`: clean - `scripts/check_no_game_data.py` and `git diff --check`: clean No remaining findings. AI-assisted.
zmasi commented 2026-11-28 20:31:08 +00:00

#2345 | head f43076b07f1d792616cf68ad1d1940ced13e9c54 (merged cleanly with main 1bc055e6c2) | python -I tests/test_first_look_safety.py | red on main: FAILED (failures=2) (accepted missing/file -GameDir and created reports/exe before failing, leaked open file handle on 0-byte non-MZ exe, ignored non-zero build_runtime.ps1 exit code, and read stale game.exe.json when pe_inspect.py produced no output) | green on PR+main: 2 tests OK (all 7 runtime guard cases + static checks) | Windows 11 (10.0.26200.9974, powershell.exe 5.1.26100.9818), Python 3.12.10 | AI-assisted: yes

Audited scripts/first_look.ps1 and tests/test_first_look_safety.py on Windows 11 PowerShell 5.1, verifying literal provider-path resolution and -PathType Container validation on -GameDir (including bracketed data [1]), try / finally $fs.Dispose() + $read -ne 2 guard on short/non-MZ files so Windows file handles never leak, leaf-blocker check on $out, $global:LASTEXITCODE = 0 + exit-code check around build_runtime.ps1, and stale $reportPath removal + existence verification around pe_inspect.py. Also verified tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

#2345 | head f43076b07f1d792616cf68ad1d1940ced13e9c54 (merged cleanly with main 1bc055e6c2) | `python -I tests/test_first_look_safety.py` | red on main: `FAILED (failures=2)` (accepted missing/file `-GameDir` and created `reports/exe` before failing, leaked open file handle on 0-byte non-MZ exe, ignored non-zero `build_runtime.ps1` exit code, and read stale `game.exe.json` when `pe_inspect.py` produced no output) | green on PR+main: `2 tests OK` (all 7 runtime guard cases + static checks) | Windows 11 (`10.0.26200.9974`, `powershell.exe` `5.1.26100.9818`), Python 3.12.10 | AI-assisted: yes Audited `scripts/first_look.ps1` and `tests/test_first_look_safety.py` on Windows 11 PowerShell 5.1, verifying literal provider-path resolution and `-PathType Container` validation on `-GameDir` (including bracketed `data [1]`), `try / finally` `$fs.Dispose()` + `$read -ne 2` guard on short/non-MZ files so Windows file handles never leak, leaf-blocker check on `$out`, `$global:LASTEXITCODE = 0` + exit-code check around `build_runtime.ps1`, and stale `$reportPath` removal + existence verification around `pe_inspect.py`. Also verified `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
TheGeogeo commented 2026-11-28 23:38:06 +00:00

Tested f43076b07 merged (no commit) with main aa918e5d9: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_first_look_safety.py, 2 tests pass.
  • Red: with scripts/first_look.ps1 back to main, it fails: GetUnresolvedProviderPathFromPSPath($GameDir) is not found.
  • Note: that check matches the script's text rather than running it.

No blocker from my side.

AI-assisted (Claude Code).

Tested `f43076b07` merged (no commit) with `main` `aa918e5d9`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_first_look_safety.py`, 2 tests pass. - Red: with `scripts/first_look.ps1` back to `main`, it fails: `GetUnresolvedProviderPathFromPSPath($GameDir)` is not found. - Note: that check matches the script's text rather than running it. No blocker from my side. AI-assisted (Claude Code).
DadaCap commented 2026-11-29 00:59:22 +00:00

Merged, thank you! Its own tests failed on main without the change and passed with it, and a batch test with eight other tool PRs (main's Python suite plus a game run on an RTX 5080) showed no regression.

AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.

Merged, thank you! Its own tests failed on main without the change and passed with it, and a batch test with eight other tool PRs (main's Python suite plus a game run on an RTX 5080) showed no regression. AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.
Sign in to join this conversation.
No description provided.