Repository navigation
feat(artifacts): read WeChat mini-program wxapkg containers - #8148
Conversation
[Medium impact] The code changes look safe, subject to the scope decision already noted by blankym. SummaryAdds read-only
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Package bytes"] --> B{"Plaintext or V1MMWX?"}
B -- V1MMWX --> C["Unknown member coverage"]
C --> D["Refuse extraction"]
B -- Plaintext --> E["Admit supported index layouts"]
E --> F["Check rows and every member range"]
F --> G["Read declared ranges in bounded chunks"]
G --> H["Inventory and extraction"]
Reviews (10) · Last reviewed commit: "fix(artifacts): choose the wxapkg index ..." · Reviewed by Greptile |
cc3ef85 to
f5d7c8c
Compare
f5d7c8c to
2ec95b9
Compare
2ec95b9 to
05c65f9
Compare
1603897 to
3edb927
Compare
Add a read-only reader for plaintext wxapkg packages: the 0xBE/0xED 18-byte big-endian header, the bounded name/offset/size member table, and verbatim member bytes at absolute carrier offsets. - Members retain declared names, absolute offsets and sizes, so source_location reports real carrier positions. - V1MMWX PC-client packages are detected as encrypted coverage with null member facts; extraction refuses with a typed error and no decryption is attempted. - Bounded table and directory budgets are admitted before allocation; malformed marks, truncated tables, invalid UTF-8 names, member extents inside the header or beyond the file, and counts that cannot fit their table are typed format or limit failures. - Member reads stream in bounded 64 KiB chunks with carrier freshness checks; the reader joins outstanding streams before close and bounds active streams and repeated member I/O. Refs morluto#8121. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
3edb927 to
9d245f9
Compare
Codex Review SummaryThis 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. |
Co-authored-by: morluto <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d245f9b38
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Normalize the two indexLength conventions before the table bounds check and the table read. Member ranges must then lie in that declared data region, which has to fit in the file. Record wxapkg format metadata as not compared: header facts repeat the package bytes, and entry source paths keep a producer root prefix.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
Four trailing bytes made the rows-only layout end on the file and dropped the count-inclusive layout. Keep every admitted layout until the parsed rows and member ranges select one.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary
Refs #8121. REA previously reported a
.wxapkgWeChat mini-program package as an opaquefile; analysts had to unpack it by hand before inventorying its members.inspect-artifactandextract-artifactnow recognize plaintext wxapkg packages, list members with their absolute carrier offsets, and extract member bytes verbatim.V1MMWXPC-client packages are detected as encrypted containers whose members are represented as unavailable rather than decrypted or fabricated.Problem and expected behavior
Mini-program reverse engineering starts from the cached
.wxapkgpackage: config, page scripts, style sheets, and subpackage members. Without a reader,inspect-artifact app.wxapkgyielded a single opaque occurrence with no member list, andextract-artifactcould not recoverapp-config.json,pages/**/*.js, or*.wxsspayloads. The expected outcome is the same inventory/extraction contract already provided for UnityFS and Godot PCK containers: declared member names, sizes, and absolute source offsets; verified member hashes; and fail-closed handling for encrypted or malformed packages.Change and scope
src/domain/wxapkgFormat.tsdecodes the 18-byte big-endian header (info length, index length, data length,0xBE/0xEDmarks) and distinguishes plaintext packages fromV1MMWXPC-client encrypted packages; decoding is total on short inputs.src/artifacts/WxapkgStructures.tsparses the bounded member table: per-row length checks, UTF-8 name decoding, and member extents validated against the data region rather than the raw file so members cannot overlap the header or index.src/artifacts/WxapkgArtifactReader.tsstreams member bytes lazily in bounded chunks with carrier freshness checks; the reader bounds active member streams and joins them before close. Members are raw, uncompressed ranges — no decompression or decryption is attempted.wxapkgthrough the same paths as UnityFS and Godot PCK. Encrypted packages produce a root occurrence withencrypted: true,directory_status: "encrypted", null member facts, and a typedunsupported_targetrefusal on extraction.V1MMWXpackages, JavaScript execution or WeChat runtime behavior, mutation, and embedded-carrier discovery inside other files.Contract and boundary impact
decodeWxapkgHeaderowns header facts;parseWxapkgDirectoryowns member rows;WxapkgArtifactReaderowns member streaming and stream lifecycle. Consumers are inventory graph construction, extraction, and the inventory view — all reuse owner-produced facts.inspect_artifact/extract_artifactaccept.wxapkgandV1MMWXinputs through existing classification.wxapkgformat; other readers unchanged.source_locationabsolute offsets,wxapkg-entryformat metadata, and verified or unavailable hash status; encrypted directories report unknown coverage..agentsskill reference and docs updated.Expected effects:
Evidence and regression coverage
Tests added or updated:
WxapkgArtifactReader.test.ts(20) andWxapkgArtifactReader.boundaries.test.ts(11) cover header decode, member listing, verbatim extraction, directory/path semantics, malformed marks/headers/tables, member extents overlapping the header or exceeding the file, unsafe paths, aliased and overlapping member ranges charged per logical occurrence, expansion/directory budgets, active-stream capacity, cancellation, paused traversal, incomplete coverage, carrier freshness, and reader close joining outstanding streams.tests/boundary/mcp/wxapkgMcp.test.ts(2) exercises compiled CLI/MCP inspection and extraction on a synthetic package.Base reproduction or other evidence:
inspect-artifacton a 119-byte synthetic package yields awxapkgroot withfile_count: 3,directory_status: "available", and three member occurrences with realsource_locationoffsets; extraction writes byte-identical members (pages/index/index.jssha256dd411c84…). A syntheticV1MMWXpackage reportsencrypted: true,directory_status: "encrypted", unknown coverage, and refuses extraction with typedunsupported_target.User-visible CLI/MCP output: verified via compiled
scripts/rea.mjson the synthetic packages above.Remaining proof gaps: verification used synthetic fixtures only; no real wxapkg sample was available locally, so real-producer coverage is unverified (sample availability and provenance are open questions in [Feature] Read WeChat mini-program wxapkg containers #8121).
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 check:fast— passed (typecheck + lint clean)npm run test:local -- src/artifacts/WxapkgArtifactReader.test.ts— 20 passednpm run test:local -- src/artifacts/WxapkgArtifactReader.boundaries.test.ts— 11 passednpm run test:focused -- tests/boundary/mcp/wxapkgMcp.test.ts— 2 passed (compiled profiles)npm run docs:check— passednpm run build— 3 tasks successfulnode scripts/rea.mjs inspect-artifact|extract-artifact /tmp/test.wxapkg— detectedwxapkg, complete coverage, byte-identical member extraction;/tmp/test-encrypted.wxapkg— encrypted state, typed extraction refusalnpm test): 38,179 passed / 271 failed / 579 skipped; all observed failures are environmental baseline issues (setup/doctor provider clients, Ghidra/JEB/Hopper/xcrun availability, local zstd) — artifact, inventory, and extraction areas had zero failures; the ZIP zstd failure reproduces standalone on this machine without this change.Compatibility, safety, and release
Author readiness
Human owner: @blankym
Before merge
type(scope): outcome.Review follow-up
Head
89b22190dmergesorigin/mainand bounds wxapkg member ranges to the declared data region.resolveWxapkgIndexLayoutsadmits both index-length conventions (rows only, and rows plus the 4-byte member count) only when that region fits in the file. Both candidates stay until the parsed rows and member ranges select one, so four trailing bytes cannot make the rows-only layout replace a count-inclusive package. Member ranges outside the selected region are format failures. A data region declared past the end of the file is no longer clamped to the file.wxapkgandwxapkg-entrymetadata are not compared by artifact comparison: header facts repeat the package bytes, andsource_pathkeeps a producer root prefix.Validation on this head:
npm run check:fastpassed (typecheck and lint), including the pre-push run.npm run test:local -- src/artifacts/WxapkgArtifactReader.test.ts src/artifacts/WxapkgArtifactReader.boundaries.test.ts— 44 passed.Not re-run on this head:
npm run test:focused -- tests/boundary/mcp/wxapkgMcp.test.ts,npm run docs:check,npm run build, and the manual CLI inspect/extract commands.