[PR #2345] FIRST-LOOK-PS1-GAMEDIR-VALIDATION-HANDLE-CLEANUP-AND-REPORT-CHECK #2348

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2345
Author: @kirigayakazima
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/first-look-ps1-safety


📝 Commits (1)

  • 18a9ec3 FIRST-LOOK-PS1-GAMEDIR-VALIDATION-HANDLE-CLEANUP-AND-REPORT-CHECK

📊 Changes

2 files changed (+176 additions, -5 deletions)

View changed files

📝 scripts/first_look.ps1 (+21 -5)
➕ tests/test_first_look_safety.py (+155 -0)

📄 Description

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.

🔄 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/2345 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/first-look-ps1-safety` --- ### 📝 Commits (1) - [`18a9ec3`](https://github.com/ubiquitarianism/leonida/commit/18a9ec373c6c654f7d025533738a957020e40903) FIRST-LOOK-PS1-GAMEDIR-VALIDATION-HANDLE-CLEANUP-AND-REPORT-CHECK ### 📊 Changes **2 files changed** (+176 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `scripts/first_look.ps1` (+21 -5) ➕ `tests/test_first_look_safety.py` (+155 -0) </details> ### 📄 Description 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. --- <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#2348
No description provided.