mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
Use zip.js's parsed symlink fact for inventory and open refusal. Treat an unmatched Godot trailer as an unconfirmed candidate while preserving failures for confirmed malformed packs. Report entropy path-resolution failures at the selected-input boundary. Separate Go header discovery from inline string extents in ELF and Mach-O, and apply the aggregate content allowance after validating real source ranges. Normalize binary plist UID widths through the existing scalar-copy owner, budget exact clone growth, preserve source identity, and refuse inexact UIDs. Validation: 389 distinct tests passed, one Linux /proc test skipped on Darwin; build, typecheck/lint, docs, single-thread formatting, and discovery (2142 files) passed. CLI/MCP Go fixtures and public ZIP/Godot/keyed-archive workflows ran. Real producer prevalence and external provider execution were not established. Repeated ordinary keyed-archive CLI inventory facts and estimated reply tokens were equal before/after. Warm median elapsed was 0.5166s / 0.5177s; no speed claim. Fixes #6751 Fixes #6763 Fixes #6754 Fixes #6767 Fixes #6762 Fixes #6779
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
const ascii = (value: string): Buffer => {
|
|
const bytes = Buffer.from(value, "ascii");
|
|
return bytes.length < 15
|
|
? Buffer.concat([Buffer.from([0x50 | bytes.length]), bytes])
|
|
: Buffer.concat([Buffer.from([0x5f, 0x10, bytes.length]), bytes]);
|
|
};
|
|
|
|
/** NSKeyedArchiver with a caller-sized UID for `$top.root`. */
|
|
export const keyedArchiveUidBytes = (
|
|
width = 3,
|
|
uidValue = 0x010203n,
|
|
): Buffer => {
|
|
const uid = Buffer.alloc(width + 1);
|
|
uid[0] = 0x80 | (width - 1);
|
|
for (let byte = width - 1; byte >= 0; byte -= 1) {
|
|
uid[byte + 1] = Number(uidValue & 0xffn);
|
|
uidValue >>= 8n;
|
|
}
|
|
const objects = [
|
|
Buffer.from([0xd3, 1, 3, 4, 2, 8, 5]),
|
|
ascii("$archiver"),
|
|
ascii("NSKeyedArchiver"),
|
|
ascii("$objects"),
|
|
ascii("$top"),
|
|
Buffer.from([0xd1, 6, 7]),
|
|
ascii("root"),
|
|
uid,
|
|
Buffer.from([0xa2, 9, 10]),
|
|
ascii("$null"),
|
|
ascii("payload"),
|
|
];
|
|
const offsets: number[] = [];
|
|
let position = Buffer.byteLength("bplist00", "ascii");
|
|
for (const object of objects) {
|
|
offsets.push(position);
|
|
position += object.length;
|
|
}
|
|
const header = Buffer.from("bplist00", "ascii");
|
|
const trailer = Buffer.alloc(32);
|
|
trailer[6] = 1;
|
|
trailer[7] = 1;
|
|
trailer.writeBigUInt64BE(BigInt(objects.length), 8);
|
|
trailer.writeBigUInt64BE(0n, 16);
|
|
trailer.writeBigUInt64BE(BigInt(position), 24);
|
|
return Buffer.concat([header, ...objects, Buffer.from(offsets), trailer]);
|
|
};
|