Skip to content

world_interior_names: preserve archive and names inputs when writing reports - #4748

Open
illusionart453-max wants to merge 1 commit into
ItsNotRexed:mainfrom
illusionart453-max:fix/interior-names-report-alias
Open

illusionart453-max wants to merge 1 commit into
ItsNotRexed:mainfrom
illusionart453-max:fix/interior-names-report-alias

Conversation

@illusionart453-max

Copy link
Copy Markdown

The --out path can alias either the archive/resource or --names JSON and replace it after the scan. Use report_paths.same_report_path before scanning to refuse such output. Synthetic CLI regressions verify both direct paths and hard links preserve bytes. This is distinct from #4690 window/jobs validation.

Claimed as a new BUILD/TEST item (ID pending assignment)
#4683 (comment)

Verified on Windows 11, Python 3.15.2, CPU only.

  • python -I tests/test_world_interior_names.py passed 11 tests. The new test failed in 4 subcases before the fix.
  • git diff --check passed.

AI-assisted (Codex). Synthetic inputs only.
Depends on no other PR.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at c73f3c8ca on Windows 11: pytest tests/test_world_interior_names.py -q -> 11 passed, 4 subtests passed; git diff --check clean.

The report path is now checked against the archive and the names inputs before writing, so a report alias cannot overwrite either; the added subtests cover the archive alias, the names alias and the ordinary output. No blocking issue.

@Atomic258

Copy link
Copy Markdown
Contributor

Independent verification at head c73f3c8ca56f02ea321b5345429728d4e93c98b3 on Windows 11, Python 3.15.2 (python -I, stdlib only).

  • python -I tests/test_world_interior_names.py — 11 tests, OK (the "--out must not overwrite an input file" line is an expected error-path subcase)
  • git diff --check origin/main...HEAD — clean
  • Red control: git checkout origin/main -- tools/world_interior_names.py (PR test kept) → test_report_cannot_replace_archive_or_names fails in 4 subcases — report bytes land in the archive/names inputs; restored → 11 tests OK. Worktree left clean.

Archive and names input protection verified. No issues found. AI-assisted (Devin).

@kapitche

Copy link
Copy Markdown
Contributor

Tested c73f3c8 merged with main 98fa503 on Linux (WSL2) Python 3.12.16 and native Windows 11 Python 3.13.1: pass

  • python -I tests/test_world_interior_names.py: 11 tests OK on Linux, 11 OK on Windows (run from a clean worktree at the PR head, which already contains main).
  • Negative control (Linux): with tools/world_interior_names.py restored from main, test_report_cannot_replace_archive_or_names fails 4 of its 4 subtests (archive and names file, each as the direct path and as a hard-link alias); with the PR file it passes. Restored the PR file afterwards.
  • Read the diff: the new same_report_path check runs after the existence check and before the scan, so the input is untouched on refusal; exit code 2 via ap.error. No issues found.
  • Not covered by this run: case-insensitive macOS volumes (the Windows run only exercised the same-path and hard-link cases).

@memorypressure

Copy link
Copy Markdown

Verified merged with current main: the direct-path and hard-link refusals work — test_world_interior_names.py runs 11 tests green, and the test_world_names (26) and test_report_paths (15) regressions are unchanged. One gap verified in the code: at tools/world_interior_names.py:268 the guard compares --out against a.path itself, so when path is a carved directory the individual files read from it are not checked — a report can still overwrite one of those. #4747 covers directory members for the navmesh tool; mirroring that here would close the same hole. No CI checks were reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@Atomic258

Copy link
Copy Markdown
Contributor

Tested c73f3c8 on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_world_interior_names.py -> OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@maciejszulia

Copy link
Copy Markdown

Checked head c73f3c8c against main at 3ae06542 (Linux, Python 3.12).

main already has this guard: tools/world_interior_names.py:393-395 refuses an --out that aliases the archive or --names (or lies inside a folder input), prints --out would overwrite an input and returns 2. The new test_report_cannot_replace_archive_or_names sets code = 0 when T.main(...) returns and takes the code only from SystemExit, so against main's tool it fails in all 4 subtests although the input stays intact:

# this PR's tests/test_world_interior_names.py with main's tools/world_interior_names.py
python -I tests/test_world_interior_names.py
FAIL: test_report_cannot_replace_archive_or_names (protected='.../levels.rpf', output='.../levels.rpf')
AssertionError: 0 != 2

The same for alias.json -> levels.rpf, names.json and alias.json -> names.json. The branch conflicts with main; if the test is kept when resolving, it needs the return value (code = T.main([...])). Otherwise the PR can be closed as superseded; the hard link to a file inside a folder input is covered by #5274.

No game data, no GPU. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants