fix(artifacts): flag truncated Mach-O headers and keep canonicalization denials

- A file with a recognized Mach-O or FAT magic but fewer than 8 bytes is a
  malformed image, so it stays visible in coverage and root diagnostics.
- Canonicalize the analyzed root and target inside the translated region,
  so a permission revoked after open_binary keeps its reason and path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-07 13:29:12 +00:00
co-authored by Claude Opus 5.5
parent e5c6fccc35
commit 9a487a4e00
4 changed files with 60 additions and 8 deletions
@@ -88,7 +88,11 @@ export const readMachoImage = async (
): Promise<MachoImageFacts> => {
try {
const head = await readAt(0, Math.min(size, 8));
if (head.byteLength < 8) return { status: "not-mach-o" };
if (head.byteLength < 8)
// A recognized magic with no room for a header is a truncated image.
return hasMachoMagic(head)
? { status: "malformed", reason: "Mach-O header is truncated" }
: { status: "not-mach-o" };
const view = viewOf(head);
const magic = view.getUint32(0, false);
if ([FAT_MAGIC, FAT_MAGIC_64, FAT_CIGAM, FAT_CIGAM_64].includes(magic)) {