test: add path safety, validation, and JSON deserialize regression coverage#334
Draft
cursor[bot] wants to merge 4 commits into
Draft
test: add path safety, validation, and JSON deserialize regression coverage#334cursor[bot] wants to merge 4 commits into
cursor[bot] wants to merge 4 commits into
Conversation
Co-authored-by: PuritanWizard <th3w1zard1@users.noreply.github.com>
Co-authored-by: PuritanWizard <th3w1zard1@users.noreply.github.com>
Co-authored-by: PuritanWizard <th3w1zard1@users.noreply.github.com>
Co-authored-by: PuritanWizard <th3w1zard1@users.noreply.github.com>
Contributor
|
Message that will be displayed on users' first pull request |
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os |
|
|
||
| import pytest | ||
|
|
||
| from pykotor.resource.formats.gff import bytes_gff, read_gff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Risky behavior now covered
path_safety.py): rejects writes outside allowed base,../escapes, overlong paths, and strict missing-path mode; validatesPYKOTOR_EXTRACT_DIRbehavior.getoutput safety:cmd_getreturns exit code 1 and logs rejection when output resolves outside CWD.validation.py): missing essential 2DAs, TXI/2DA lookup, module resource reference checks, andget_installation_summarycounts.resource_json.py/archive_serializer.py): base64 and GFF-JSON embedded payloads, direct JSON binary wrapper, and ERF base64 round-trip viadict_to_archive.Test files added/updated
Libraries/PyKotor/tests/test_path_safety.pyLibraries/PyKotor/tests/test_validation.pyLibraries/PyKotor/tests/test_resource_json_deserialize.pyLibraries/PyKotor/tests/resource/formats/test_archive_serializer_regressions.pyLibraries/PyKotor/tests/cli/test_json_commands.pycmd_getpath rejectionProduction fixes uncovered by new tests
deserialize_embedded_resource_payload: pass rawbytesinstead ofBytesIOto JSON readers (peek pass closed the stream)._dict_to_erf/_dict_to_rim: usebytearrayinstead ofBytesIOafterwrite_*closes the stream.Why this reduces regression risk
These areas guard high-blast-radius flows: MCP/CLI extract path safety, installation health checks used by CLI and MCP tools, and archive JSON round-trips used by
from-json/ archive conversion. The new tests are deterministic, usetmp_pathfixtures, and do not require a game install.Validation
29 passed