mirror of
https://github.com/morluto/rea.git
synced 2026-12-01 19:09:21 +00:00
* fix(artifacts): explain ASAR PE signed-after-packing mismatches When an unpacked PE companion fails ASAR integrity only because Authenticode was applied after packing, record a verifiable signing_explanation on the SHA-256 contradiction and error details instead of an opaque untrusted mismatch. Bytes stay observed-untrusted; any other mutation remains an unexplained contradiction. Fixes #7212 * fix(artifacts): address signed-after-packing Greptile review Catch ParseFailureError so unreadable PKCS#7 keeps the digest explanation, share WIN_CERTIFICATE structural walks, index signer lookups, charge optional reads to acquisition budgets with reported skips, preserve mismatch details through cleanup failures, and inherit the shared MCP test deadline. * fix(pe): walk WIN_CERTIFICATE entries lazily under max_entries Convert the certificate-table walker into a generator so inspection stops at the entry budget without materializing every range, and reconstruction can validate structure with constant memory.
44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
import { createHash } from "node:crypto";
|
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { createPackageWithOptions } from "@electron/asar";
|
|
|
|
import {
|
|
peCertificateFixture,
|
|
peWithoutCertificateTableFixture,
|
|
pkcs7SignedDataFixture,
|
|
} from "../../src/native/pe/PeCertificates.fixture.js";
|
|
import { createTestTempDirectory } from "./temporaryDirectory.js";
|
|
|
|
/** ASAR whose unpacked PE companion was Authenticode-signed after packing. */
|
|
export const createSignedAfterPackingAsarAddon = async () => {
|
|
const root = await createTestTempDirectory("rea-signed-after-packing-asar-");
|
|
const source = join(root, "source");
|
|
const archive = join(root, "app.asar");
|
|
const addon = "node_modules/device/binding.node";
|
|
const addonPath = join(source, "node_modules", "device", "binding.node");
|
|
const signed = peCertificateFixture(false, pkcs7SignedDataFixture());
|
|
signed.writeUInt32LE(0xfeedface, 0x98 + 64);
|
|
const original = peWithoutCertificateTableFixture();
|
|
// This fixture has an available (but empty) security directory before signing.
|
|
original.writeUInt32LE(16, 0x98 + 92);
|
|
await mkdir(join(source, "node_modules", "device"), { recursive: true });
|
|
await writeFile(join(source, "main.js"), "module.exports = 'observed';\n");
|
|
await writeFile(addonPath, original);
|
|
await createPackageWithOptions(source, archive, { unpack: "*.node" });
|
|
await writeFile(
|
|
join(`${archive}.unpacked`, "node_modules", "device", "binding.node"),
|
|
signed,
|
|
);
|
|
return {
|
|
root,
|
|
archive,
|
|
addon,
|
|
original,
|
|
signed,
|
|
declaredSha256: createHash("sha256").update(original).digest("hex"),
|
|
observedSha256: createHash("sha256").update(signed).digest("hex"),
|
|
};
|
|
};
|