Files
reverse-engineering-anything/tests/fixtures/zipZstandard.ts
T
Sahinur fdc4e3908b fix(artifacts): report ZIP Zstd window refusals as resource limits
Classify a native method-93 decoder window refusal once at the ZIP owner as limit/memory, retaining the fixed 128 MiB cap, native cause and existing corruption/CRC/size/cancellation handling. Derive recovery labels from the cap and share one independent frame fixture.

Validated with 43 reader/translationtests,three actual CLI/stdio MCP cases, a pinned public GLFW payload rewrapped in independently verified ZIP controls, six equivalent CLI calls before/after, static checks and documentation checks. All input bytes remain unchanged, normal extraction matches exactly, and failed outputs are absent. ELF/GPU component refusal-policy gaps remain separate unverified full-format workflows.

The original three unchecked human declarations are preserved. The explicitly authorized readiness-only exception applies after technical CI and review; no human-review attestation is added.

Fixes #8623

Full technical CI 42279406899 passes, including all eight shards and required aggregates. Greptile reviews this head at 5/5; Codex cannot complete because the repository review quota is exhausted. The Author readiness-only exception is explicitly authorized; no human-review attestation is added.

Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage)
2026-11-06 20:12:31 +00:00

56 lines
2.1 KiB
TypeScript

import { crc32, zstdCompressSync } from "node:zlib";
/** A valid independent raw-block frame; its window is unrelated to its tiny output. */
export const zstandardWindowFrameFixture = (windowDescriptor: number) => {
const content = Buffer.from("REA independent frame control\n");
const compressed = Buffer.from(
"28b52ffd0090f1000052454120696e646570656e64656e74206672616d6520636f6e74726f6c0a",
"hex",
);
compressed[5] = windowDescriptor;
return { content, compressed };
};
/** One non-Zip64 member, independently framed from the PKWARE APPNOTE records. */
export const zstandardZipFixture = (
content: Buffer,
options: {
readonly method?: number;
readonly crc?: number;
readonly declaredSize?: number;
readonly compressed?: Buffer;
} = {},
): Buffer => {
const name = Buffer.from("member.txt");
const compressed = options.compressed ?? zstdCompressSync(content);
const method = options.method ?? 93;
const checksum = options.crc ?? crc32(content);
const declaredSize = options.declaredSize ?? content.length;
const local = Buffer.alloc(30);
local.writeUInt32LE(0x04034b50, 0);
local.writeUInt16LE(63, 4);
local.writeUInt16LE(method, 8);
local.writeUInt16LE(0x5021, 12); // 2020-01-01, DOS date.
local.writeUInt32LE(checksum, 14);
local.writeUInt32LE(compressed.length, 18);
local.writeUInt32LE(declaredSize, 22);
local.writeUInt16LE(name.length, 26);
const central = Buffer.alloc(46);
central.writeUInt32LE(0x02014b50, 0);
central.writeUInt16LE(63, 4);
central.writeUInt16LE(63, 6);
central.writeUInt16LE(method, 10);
central.writeUInt16LE(0x5021, 14);
central.writeUInt32LE(checksum, 16);
central.writeUInt32LE(compressed.length, 20);
central.writeUInt32LE(declaredSize, 24);
central.writeUInt16LE(name.length, 28);
const end = Buffer.alloc(22);
end.writeUInt32LE(0x06054b50, 0);
end.writeUInt16LE(1, 8);
end.writeUInt16LE(1, 10);
end.writeUInt32LE(central.length + name.length, 12);
end.writeUInt32LE(local.length + name.length + compressed.length, 16);
return Buffer.concat([local, name, compressed, central, name, end]);
};