fix(artifacts): take nested container families from bytes (#1553)
Inventory gave nested members a ZIP or ASAR family from their path suffix. Byte classification replaced it only for ZIP magic, so text named `.apk` or `.asar` stayed a container, and encrypted entries and symlinks kept the suffix guess. A filesystem `.asar` without an ASAR header failed the whole inventory as a malformed archive. Nested ZIP families now follow ZIP magic and ASAR follows its header pickle, shared with root classification. An unread member named like a container has an unknown format and a limitation naming the suffix. ASAR expansion requires the header. The Android projection adds a limitation when no root AndroidManifest.xml was observed, and its rejection names the observed root format. Fixes #1491 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c8fd2f152b
commit
4b985e5021
@@ -154,9 +154,23 @@ describe("unexpanded ASAR inventory controls", () => {
|
||||
"resources/encrypted.asar": "resources",
|
||||
"resources/ordinary.asar": "resources",
|
||||
});
|
||||
expect(artifactOccurrenceAt(observed, "resources/app.asar")).toMatchObject({
|
||||
artifact_kind: "container",
|
||||
artifact_format: "asar",
|
||||
});
|
||||
expect(
|
||||
artifactOccurrenceAt(observed, "resources/encrypted.asar").hash_status,
|
||||
).toBe("unavailable");
|
||||
artifactOccurrenceAt(observed, "resources/ordinary.asar"),
|
||||
).toMatchObject({ artifact_kind: "resource", artifact_format: "file" });
|
||||
expect(
|
||||
artifactOccurrenceAt(observed, "resources/encrypted.asar"),
|
||||
).toMatchObject({
|
||||
artifact_kind: "unknown",
|
||||
artifact_format: "unknown",
|
||||
hash_status: "unavailable",
|
||||
limitations: [
|
||||
"The path suffix suggests ASAR, but these bytes were not read, so the container family is unknown.",
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps ASAR-named directories as directory parents", async () => {
|
||||
@@ -195,9 +209,30 @@ describe("unexpanded ASAR inventory controls", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps malformed filesystem archives rejected", async () => {
|
||||
const root = await createTestTempDirectory("rea-malformed-asar-");
|
||||
it("records filesystem files without an ASAR header as ordinary bytes", async () => {
|
||||
const root = await createTestTempDirectory("rea-ordinary-asar-");
|
||||
await writeFile(join(root, "ordinary.asar"), "ordinary bytes");
|
||||
const observed = await inventoryArtifact(root);
|
||||
expect(artifactParentPaths(observed)).toEqual({
|
||||
".": null,
|
||||
"ordinary.asar": ".",
|
||||
});
|
||||
expect(artifactOccurrenceAt(observed, "ordinary.asar")).toMatchObject({
|
||||
artifact_kind: "resource",
|
||||
artifact_format: "file",
|
||||
hash_status: "verified",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps filesystem archives with a malformed ASAR header rejected", async () => {
|
||||
const root = await createTestTempDirectory("rea-malformed-asar-");
|
||||
const json = Buffer.from("{not json");
|
||||
const header = Buffer.alloc(16);
|
||||
header.writeUInt32LE(4, 0);
|
||||
header.writeUInt32LE(json.length + 12, 4);
|
||||
header.writeUInt32LE(json.length + 8, 8);
|
||||
header.writeUInt32LE(json.length, 12);
|
||||
await writeFile(join(root, "broken.asar"), Buffer.concat([header, json]));
|
||||
await expect(inventoryArtifact(root)).rejects.toMatchObject({
|
||||
reason: "format",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user