Repository navigation
feat(artifacts): decode UnityFS LZMA blocks - #14699
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The reviewed changes appear safe to merge. SummaryAdds LZMA support for UnityFS data blocks and directory tables.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[UnityFS compressed block] --> B{Supported compression?}
B -->|No| C[Keep available directory facts]
B -->|Yes| D{Within block budgets?}
D -->|No| E[Keep directory and name the exceeded budget]
D -->|Yes| F[Decode LZ4 or LZMA]
F --> G[Read member bytes and compute hashes]
Reviews (10) · Last reviewed commit: "fix(unityfs): name the encoded or decode..." · Reviewed by Greptile |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Unity's default AssetBundle compression (type 1) left members as hash_status unavailable. Decode 5-byte Unity LZMA streams with the existing lzma-purejs dependency so inventory can hash and extract them.
Architecture guards forbid raw Buffer numeric reads outside binaryContainer; match the UEFI LZMA path.
Accept optional LZMA end markers without trailing junk, decode off-thread so timer aborts land, return one expected-sized buffer, and mark xinzexi unverified.
Await worker.terminate() before settling abort/reply paths, and allocate the synthesized alone header with allocUnsafeSlow so the worker receives it without a second encoded-stream copy.
Retriggers Actions after the worker-exit follow-up push did not receive a GitHub Actions check suite.
cecc08d to
c5ef3e9
Compare
…de spec-valid streams UnityFS writers emit one LZMA block for a whole data stream, so the per-block decode budget refused the whole inventory of any LZMA bundle above 64 MiB, where before this change the directory was retained. An over-budget block now keeps the directory and only members inside it report an unavailable read naming the budget, for LZ4 and LZMA alike. The LZMA decoder window is bounded by the declared output instead of the declared dictionary, so a large dictionary on a small block decodes and no longer allocates a dictionary-sized window. Properties follow the LZMA specification (lc 0-8, lp 0-4, pb 0-4) rather than the LZMA2 lc + lp limit. Worker error events and exits without a reply stay runtime failures instead of being reported as a malformed block. Tests decode a liblzma-produced stream as a known answer, settle only after the worker exits on completion and cancellation, and share one encoder.
Overflow past the bundle's declared length is a format error, not a decoder budget exhaustion. Declarations above maximumBytes still fail closed as a resource limit before decode starts.
A block refused by its encoded size reported its decoded size against the decoded budget. The block now records which bound refused it, and the member read names that bound, its declared size and the budget.
|
Thanks for this. I reviewed the whole PR, merged Defects fixed
Brittleness pass
Threads
All three threads are replied to and resolved. Sources
Validation
|
Summary
Fixes #14176. UnityFS AssetBundles that use Unity's default LZMA block compression (type 1) no longer report members as
hash_status: unavailable. LZMA blocks and blocks-info tables decode with the existinglzma-purejsdependency so inventory can hash, compare, and extract members the same way LZ4 bundles already do.Problem and expected behavior
Before: compression 1 data blocks and blocks-info tables were refused as unsupported; members kept directory names/sizes but had no content hash or child artifact.
After: valid Unity LZMA streams (5-byte properties plus raw data, size taken from the block table) decode under the existing 64 MiB per-block and archive plaintext-work budgets, and members report verified hashes when the stream is well-formed. Malformed LZMA remains a format error. Other codecs (for example LZHAM) stay unsupported.
Change and scope
decodeUnityLzmaBlockinsrc/compression/LzmaUnityBlock.ts: synthesize an LZMA-Alone size field from the declared uncompressed length, bound output while decoding, and reuse the small-dictionary promotion already needed bylzma-purejs.UnityFsStructures/UnityFsArtifactReaderfor both blocks-info tables and data blocks.Intentionally not included: routing UnityFS through the UEFI owned worker process (LZ4 already decodes in-process; the same admission pattern is applied here), LZHAM, encryption, and re-running the external UnityPy corpus samples in CI.
Contribution scope: ordinary format inspection within the existing UnityFS reader. Maintainer scope decision: not applicable.
Contract and boundary impact
UnityFsStructures/UnityFsArtifactReaderown UnityFS block decode; consumers (inspect-artifact,extract-artifact,compare-artifacts) see verified member hashes instead of unavailable compression 1.unityfsinputs).lzma-purejs; no new dependency.completewhen every member decodes.docs/public/product-catalog.json), package, or installation impact: none.Expected effects:
Evidence and regression coverage
Tests added or updated:
src/compression/LzmaUnityBlock.test.ts(round-trip, truncated header, bad properties, unfinished stream, budget);UnityFsArtifactReader.test.ts(LZMA blocks-info inventory, member decode, malformed member, LZHAM still unknown); boundaries/CLI/MCP fixtures updated from LZMA refusal to verified decode; unsupported-compression probes now use LZHAM (4).Base reproduction or other evidence: prior tests pinned
blocksInfoCompression: 1/blockCompression: 1as unsupported; those now expect directory availability and member bytes.User-visible CLI/MCP output:
inspect-artifacton an LZMA member reportshash_status: verifiedandcoverage: completein the updated CLI/MCP expectations.Remaining proof gaps: Cytoid
character_kaedeand UnityPyxinzexi_2_n_texwere not re-run in this environment; synthetic Unity-shaped LZMA covers the codec path.Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:local -- src/compression/LzmaUnityBlock.test.ts src/artifacts/UnityFsArtifactReader.test.ts src/artifacts/UnityFsArtifactReader.boundaries.test.ts— 3 files, 60 tests passed.tsc --noEmitwas attempted but killed by host memory limits; Vitest transform of the changed modules succeeded under the focused run above.Compatibility, safety, and release
Author readiness
Human owner: @BeqaKs
Author checklist (completed by the PR author before requesting review)
type(scope): outcome.REA_runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.