chore: reconcile iNES inventory with current main

This commit is contained in:
64579525
2026-10-13 09:36:35 +08:00
646 changed files with 49020 additions and 6280 deletions
@@ -20,6 +20,7 @@ import {
} from "../../../src/application/AppBundleExecutable.js";
import {
dosMz,
elf,
fat,
pe,
thinMach,
@@ -811,6 +812,32 @@ describe("binary Info.plist app bundle targets", () => {
});
describe("DOS binary target I/O", () => {
it("resolves a short-header PE signature beyond the bounded prefix", async () => {
const directory = await createTestTempDirectory(
"rea-short-stub-pe-target-",
);
const path = join(directory, "short-stub.dll");
const offset = 8192;
const stub = dosMz(64);
stub.writeUInt32LE(offset, 60);
const peRecord = pe(0x8664, offset, 0x2002).subarray(offset);
const bytes = Buffer.concat([
stub,
Buffer.alloc(offset - stub.length),
peRecord,
]);
await writeFile(path, bytes);
expect(await parseBinaryTarget(path)).toMatchObject({
ok: true,
value: {
format: "pe",
architecture: "x86_64",
executableRole: "shared-library",
},
});
});
it("validates a complete DOS file beyond the initial metadata probe", async () => {
const directory = await createTestTempDirectory("rea-dos-target-");
const path = join(directory, "legacy.exe");
@@ -827,3 +854,40 @@ describe("DOS binary target I/O", () => {
});
});
});
it.each([
[
"EI_VERSION",
(bytes: Buffer) => {
bytes[6] = 0;
},
],
[
"e_version",
(bytes: Buffer) => {
bytes.writeUInt32LE(0, 20);
},
],
[
"e_ehsize",
(bytes: Buffer) => {
bytes.writeUInt16LE(51, 40);
},
],
])(
"rejects an ELF with malformed %s during public target opening",
async (_name, corrupt) => {
const directory = await createTestTempDirectory("rea-invalid-elf-header-");
const path = join(directory, "invalid.elf");
const bytes = elf(1, 1, 3);
corrupt(bytes);
await writeFile(path, bytes);
expect(await parseBinaryTarget(path)).toMatchObject({
ok: false,
error: {
_tag: "BinaryTargetError",
constraint: "file_format_rejected",
},
});
},
);