Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4d3b7a1
feat(ghidra): admit caller-selected matching dSYM companions
jimpablo Oct 12, 2026
f0eb9c4
fix(targets): partition dSYM identity and match the selected slice
jimpablo Oct 12, 2026
104601e
fix(targets): keep legacy query ids and bound companion admission
jimpablo Oct 12, 2026
c219cb9
fix(targets): bound uuid walking and carry companion provenance
jimpablo Oct 12, 2026
ab3bf42
fix(contracts): budget command spans and partition companions by path
jimpablo Oct 12, 2026
11e1002
fix(ghidra): commit companion identity in the analysis profile
jimpablo Oct 12, 2026
731f243
fix(targets): carry companion identity through split mach-o variants
jimpablo Oct 12, 2026
03f9058
fix(targets): charge traversal reads and bound staged member copies
jimpablo Oct 13, 2026
d3fe4a0
fix(ghidra): document and enforce dSYM admission resource budgets
morluto Oct 13, 2026
dbf8d2c
fix(ghidra): preserve dSYM resource refusals and staging coverage
morluto Oct 13, 2026
dea1571
fix(ghidra): stream dSYM UUID commands through their format owner
morluto Oct 13, 2026
437eb2d
fix(ghidra): retain dSYM input ownership and shared format semantics
morluto Oct 13, 2026
26effd7
fix(ghidra): preserve dSYM companion admission facts
morluto Oct 13, 2026
0ab02a0
fix(ghidra): retain failed source copy owners
morluto Oct 13, 2026
58af2fb
fix(targets): settle merged companion types and heap stub props
jimpablo Oct 14, 2026
7bafafc
fix(macho): retain dSYM admission resources
morluto Oct 13, 2026
71cee08
fix(ghidra): preserve dSYM identity and cleanup failures
morluto Oct 13, 2026
7e7d3d2
fix(targets): settle merged types, heap stub props, and split oversiz…
jimpablo Oct 14, 2026
b735fd3
fix(ghidra): rebase onto main, drop hanging copy helper, restore staging
jimpablo Oct 27, 2026
529d444
fix(targets): settle second rebase: weave dsym admission into new res…
jimpablo Oct 28, 2026
07da6f1
fix(targets): restore upstream code dropped during rebase
jimpablo Oct 28, 2026
1a2fa6a
fix(contracts): omit debug_companion from bare Mach-O summaries
jimpablo Oct 28, 2026
0b4ae16
fix(targets): address companion admission review findings
jimpablo Oct 28, 2026
aa20d1d
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
6b32456
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
4483d21
fix(ghidra): harden dSYM companion admission, staging ownership, and …
jimpablo Nov 5, 2026
a7e17e6
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
d90dcca
fix(ghidra): preserve dSYM cleanup primary causes and reuse Mach-O lo…
jimpablo Nov 5, 2026
8bec33a
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
c50d6f5
fix(ghidra): reject dsym_path in existing-project mode and enforce de…
jimpablo Nov 5, 2026
636d664
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
30e21fa
fix(macho): separate companion EOF truncation from traversal budget a…
jimpablo Nov 5, 2026
97a2e09
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
fbef489
fix(cli): reuse absoluteLocalPathStringSchema for --dsym-path option
jimpablo Nov 5, 2026
f51fb61
fix(macho): clamp initial UUID prefix reads to remaining traversal bu…
jimpablo Nov 5, 2026
2c150cb
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 8, 2026
417b628
fix(dsym): enforce .dSYM bundle directory naming and pin companion di…
jimpablo Nov 8, 2026
0988275
fix(dsym): preserve close cancellation, reject ambiguous FAT slices, …
jimpablo Nov 8, 2026
390918f
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 8, 2026
a0cac2a
fix(dsym): preserve close cancellation during directory and staging c…
jimpablo Nov 8, 2026
a84c8a8
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 8, 2026
6a32f35
fix(dsym): preserve member and directory refusals over final-close ca…
jimpablo Nov 8, 2026
c72fb30
docs(specs): add Mach-O dSYM companion feature specification
jimpablo Nov 8, 2026
dd33451
docs(specs): align module and checkpoint test paths in dsym plan
jimpablo Nov 8, 2026
a6f3b94
docs(specs): match symlink policy and saved-project error contract
jimpablo Nov 8, 2026
ca7d919
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 8, 2026
c50bf0d
fix(dsym): skip checkpoint restaging and harden companion identity
jimpablo Nov 8, 2026
2152709
test(mcp): validate session dsym_path outputs via toolContract
jimpablo Nov 8, 2026
4d3ad8f
fix(dsym): retain both companion and target cleanup owners on dual cl…
jimpablo Nov 8, 2026
57f2edc
fix(dsym): reject duplicate FAT target CPU identities before slice na…
jimpablo Nov 8, 2026
9560a44
fix(dsym): keep post-admission member read faults fatal across close …
jimpablo Nov 9, 2026
9f36e1f
fix(dsym): use tagged member failure union and guard opaque abort rea…
jimpablo Nov 9, 2026
bdd456e
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 10, 2026
616d5dc
chore(dsym): merge upstream/main and remove unused imports
jimpablo Nov 10, 2026
3f8c9ce
chore(dsym): restore upstream files modified by lint-staged during merge
jimpablo Nov 10, 2026
92d9d79
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 11, 2026
b244242
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 15, 2026
ea7612b
fix(contracts): preserve headerless issues alongside dsym_path and ex…
jimpablo Nov 15, 2026
03b3ff8
chore(dsym): restore upstream javascriptStaticAnalysis modified by li…
jimpablo Nov 15, 2026
4d761f9
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 16, 2026
858d124
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 16, 2026
65d40a3
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 17, 2026
b32d1bf
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 21, 2026
cbddb9d
test(target): verify dsym_path rejection on Hopper and IDA databases
jimpablo Nov 21, 2026
336d28c
fix(ghidra): preserve dSYM parse failures, refusals, and staging owne…
jimpablo Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(macho): clamp initial UUID prefix reads to remaining traversal bu…
…dget
  • Loading branch information
jimpablo committed Nov 5, 2026
commit f51fb61a6d8a8cbf63b2e85ddf237604b2cb0f92
30 changes: 20 additions & 10 deletions src/application/DebugCompanionAdmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,28 @@ const readThinUuidEntry = async (
req.offset < range.length &&
(req.offset < windowOffset || neededEnd > windowOffset + window.length)
) {
const remainingRange = range.length - req.offset;
const bufferedPrefix =
req.offset >= windowOffset && req.offset < windowOffset + window.length
? window.subarray(req.offset - windowOffset)
: Buffer.alloc(0);
const unreadOffset = req.offset + bufferedPrefix.length;
const neededUnread = neededEnd - unreadOffset;
const remainingRange = range.length - unreadOffset;
const desiredLength = Math.min(HEADER_READ_LIMIT, remainingRange);
const remainingBudget = TRAVERSAL_BUDGET_BYTES - context.ledger.spent;
if (remainingBudget < neededEnd - req.offset)
return err(traversalLimit());
if (remainingBudget < neededUnread) return err(traversalLimit());
const read = await readUuidWindow(
handle,
range.offset + req.offset,
range.offset + unreadOffset,
Math.min(desiredLength, remainingBudget),
context,
);
if (!read.ok) return read;
windowOffset = req.offset;
window = read.value;
window =
bufferedPrefix.length === 0
? read.value
: Buffer.concat([bufferedPrefix, read.value]);
}
const slice =
req.offset >= range.length
Expand Down Expand Up @@ -298,12 +306,12 @@ export const readMachoFileUuidEntries = async (
ledger: options.ledger ?? { spent: 0 },
signal: options.signal,
};
const prefix = await readUuidWindow(
handle,
const remainingBudget = Math.max(
0,
Math.min(fileSize, HEADER_READ_LIMIT),
context,
TRAVERSAL_BUDGET_BYTES - context.ledger.spent,
);
const prefixLength = Math.min(fileSize, HEADER_READ_LIMIT, remainingBudget);
const prefix = await readUuidWindow(handle, 0, prefixLength, context);
if (!prefix.ok) return prefix;
const container = readFatContainerHeader(prefix.value, fileSize);
if (container.state === "not-fat") {
Expand All @@ -325,7 +333,9 @@ export const readMachoFileUuidEntries = async (
}
if (container.state === "needs-data")
return err(
invalidImage("the universal Mach-O container table is truncated"),
prefixLength < container.requiredBytes
? traversalLimit()
: invalidImage("the universal Mach-O container table is truncated"),
);
if (container.state === "malformed")
return err(invalidImage(container.reason));
Expand Down
96 changes: 96 additions & 0 deletions tests/boundary/filesystem/ghidraDebugCompanion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,99 @@ it("refuses existingProject + debugCompanion in GhidraClient.start before creati
await client.close();
}
});

it("clamps initial prefix reads to the remaining traversal budget and does not double-charge straddled window reads", async () => {
const root = await createTestTempDirectory("rea-dsym-budget-clamp-");
const traversalBudget = 64 * 1024 * 1024;
const thinPath = join(root, "thin-64k");
const thinBytes = Buffer.alloc(64 * 1024);
uuidImage("11111111-2222-3333-4444-555555555555").copy(thinBytes, 0);
await writeFile(thinPath, thinBytes);
const thinHandle = await open(thinPath, "r");
try {
expect(
await readMachoFileUuidEntries(thinHandle, thinBytes.length, {
ledger: { spent: traversalBudget - 56 },
}),
).toEqual({
ok: true,
value: [
{
cpuType: 0x01000007,
cpuSubtypeBase: 0,
uuid: "11111111-2222-3333-4444-555555555555",
},
],
});
expect(
await readMachoFileUuidEntries(thinHandle, thinBytes.length, {
ledger: { spent: traversalBudget - 55 },
}),
).toMatchObject({
ok: false,
error: {
kind: "resource-limit",
},
});
} finally {
await thinHandle.close();
}

const fatPath = join(root, "fat-64k");
const fatBytes = Buffer.alloc(64 * 1024);
fatBytes.writeUInt32BE(0xcafebabe, 0);
fatBytes.writeUInt32BE(1, 4);
await writeFile(fatPath, fatBytes);
const fatHandle = await open(fatPath, "r");
try {
expect(
await readMachoFileUuidEntries(fatHandle, fatBytes.length, {
ledger: { spent: traversalBudget - 6 },
}),
).toMatchObject({
ok: false,
error: {
kind: "resource-limit",
},
});
} finally {
await fatHandle.close();
}

const straddledPath = join(root, "straddled-32bit");
const straddledSize = 65548;
const straddledBytes = Buffer.alloc(straddledSize);
straddledBytes.writeUInt32LE(0xfeedface, 0); // 32-bit Mach-O (28-byte header, 4-byte command alignment)
straddledBytes.writeUInt32LE(7, 4); // x86
straddledBytes.writeUInt32LE(2, 12);
straddledBytes.writeUInt32LE(2, 16);
straddledBytes.writeUInt32LE(straddledSize - 28, 20);
straddledBytes.writeUInt32LE(0x77777777, 28);
straddledBytes.writeUInt32LE(65524 - 28, 32); // Ends at 65524, so LC_UUID header is 65524..65532 and UUID payload straddles 65536 (65532..65548)
straddledBytes.writeUInt32LE(0x1b, 65524);
straddledBytes.writeUInt32LE(24, 65528);
Buffer.from("11111111222233334444555555555555", "hex").copy(
straddledBytes,
65532,
);
await writeFile(straddledPath, straddledBytes);
const straddledHandle = await open(straddledPath, "r");
try {
expect(
await readMachoFileUuidEntries(straddledHandle, straddledBytes.length, {
ledger: { spent: traversalBudget - straddledSize },
}),
).toEqual({
ok: true,
value: [
{
cpuType: 7,
cpuSubtypeBase: 0,
uuid: "11111111-2222-3333-4444-555555555555",
},
],
});
} finally {
await straddledHandle.close();
}
});
Loading