perf(artifacts): stream ASAR members without full buffering (#962)

* fix(artifacts): stream ASAR members without full buffering

* fix(artifacts): close unopened ASAR member streams

* fix(artifacts): preserve unpacked ASAR mismatch digests

* fix(artifacts): preserve ASAR read failures

* fix(artifacts): retain unpacked ASAR stat failures

* fix(artifacts): validate ASAR entry producer identity
This commit is contained in:
morluto
2026-10-07 23:57:05 +08:00
committed by GitHub
parent 58381eefa2
commit abd7a5ed09
4 changed files with 873 additions and 33 deletions
@@ -1,4 +1,4 @@
import { mkdir, rm, writeFile } from "node:fs/promises";
import { lstat, mkdir, rm, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { createPackage } from "@electron/asar";
@@ -86,6 +86,24 @@ describe("JavaScript artifact ingestion content identities", () => {
}
});
it("rejects a same-size ASAR replacement against the inventoried root digest", async () => {
const { source, archive } = await fixture();
const snapshot = await scanArtifactInventory(archive);
const original = await lstat(archive);
await writeFile(join(source, "main.js"), "module.exports = 43;\n");
await createPackage(source, archive);
expect((await lstat(archive)).size).toBe(original.size);
const reader = new AsarArtifactReader(archive);
try {
await expect(
readJavaScriptArtifactFiles(reader, snapshot),
).rejects.toMatchObject({ reason: "integrity" });
} finally {
await reader.close();
}
});
it("preserves typed cancellation when the direct ASAR filesystem stream aborts", async () => {
const { archive } = await fixture();
const snapshot = await scanArtifactInventory(archive);