Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(pcap): retain timestamps from supported Wireshark 4.x labels

morluto95957d748d8c
diff --git a/scripts/verify-packet-capture.mjs b/scripts/verify-packet-capture.mjs
index 4f7452983..040b696b4 100644
--- a/scripts/verify-packet-capture.mjs
+++ b/scripts/verify-packet-capture.mjs
@@ -111,6 +111,20 @@ let primaryError;
try {
await writeFile(path, source);
await writeFile(bluetooth, bluetoothSource);
+ const capinfosOutput = (
+ await execute(
+ process.env.REA_CAPINFOS_COMMAND ?? "capinfos",
+ ["-M", "--", path],
+ { env: environment, timeout: 60000, maxBuffer: 64 * 1024 },
+ )
+ ).stdout;
+ const expectedCaptureStart =
+ /^(?:Earliest|First) packet time:\s*(.+)$/mu.exec(capinfosOutput)?.[1] ??
+ null;
+ const expectedCaptureEnd =
+ /^(?:Latest|Last) packet time:\s*(.+)$/mu.exec(capinfosOutput)?.[1] ?? null;
+ assert.ok(expectedCaptureStart, capinfosOutput);
+ assert.ok(expectedCaptureEnd, capinfosOutput);
await client.connect(transport);
const tool = (await client.listTools()).tools.find(
({ name }) => name === "inspect_packet_capture",
@@ -137,6 +151,10 @@ try {
.update(await readFile(input.path))
.digest("hex"),
);
+ if (input.path === path) {
+ assert.equal(report.capture_start, expectedCaptureStart);
+ assert.equal(report.capture_end, expectedCaptureEnd);
+ }
assert.equal(report.hardware_acquisition, "not-performed");
assert.equal(report.limits.address_space_bytes, expectedAddressSpace);
assert.equal(report.tool.configured_path, process.env.REA_TSHARK_COMMAND);
diff --git a/src/pcap/PcapConfiguration.test.ts b/src/pcap/PcapConfiguration.test.ts
index edbd223b2..decca2812 100644
--- a/src/pcap/PcapConfiguration.test.ts
+++ b/src/pcap/PcapConfiguration.test.ts
@@ -68,6 +68,26 @@ describe("parseCapinfosOutput", () => {
});
});
+ it("retains timestamps from the older capinfos labels", () => {
+ const output = REAL_CAPINFOS.replace(
+ "Earliest packet time",
+ "First packet time",
+ ).replace("Latest packet time", "Last packet time");
+ const metadata = parseCapinfosOutput(output);
+ expect(metadata.captureStart).toBe("2026-10-11 14:13:40.608505");
+ expect(metadata.captureEnd).toBe("2026-10-11 14:13:40.981978");
+ });
+
+ it("keeps missing capture timestamps unknown", () => {
+ const output = REAL_CAPINFOS.split("\n")
+ .filter((line) => !line.includes("packet time:"))
+ .join("\n");
+ expect(parseCapinfosOutput(output)).toMatchObject({
+ captureStart: null,
+ captureEnd: null,
+ });
+ });
+
it("rejects empty metadata rather than reporting complete unknown facts", () => {
expect(() => parseCapinfosOutput("")).toThrow(/machine-readable/u);
});
diff --git a/src/pcap/PcapOutput.ts b/src/pcap/PcapOutput.ts
index b14d7ba3c..274a85e81 100644
--- a/src/pcap/PcapOutput.ts
+++ b/src/pcap/PcapOutput.ts
@@ -66,8 +66,12 @@ export const parseCapinfosOutput = (stdout: string): CapinfosMetadata => {
fileType,
encapsulation,
packetCount,
- captureStart: lines.get("Earliest packet time") ?? null,
- captureEnd: lines.get("Latest packet time") ?? null,
+ captureStart:
+ lines.get("Earliest packet time") ??
+ lines.get("First packet time") ??
+ null,
+ captureEnd:
+ lines.get("Latest packet time") ?? lines.get("Last packet time") ?? null,
captureDurationSeconds: duration === null ? null : Number(duration[1]),
snapshotLength:
snapshotLength !== null &&