feat(captures): inspect recorded packets with bounded TShark delivery (#2318)
Inspect selected fields in existing captures through shared CLI/MCP Evidence. Page matching frames without changing dissection or two-pass read coverage; retain failed descriptor/process cleanup ownership and reject excess admission. Verified with real TShark 4.0.17 and 4.2.2, public Wireshark recordings, owned HTTP application traffic, real CLI/MCP workflows and schema checks. Co-authored-by: Olorinm <59321404+Olorinm@users.noreply.github.com> Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { parsePacketOutput } from "../../../src/captures/parsePacketOutput.js";
|
||||
|
||||
it("preserves repeated field values and missing fields while discarding export index metadata", () => {
|
||||
const output = JSON.stringify([
|
||||
{
|
||||
_index: "packets-2026",
|
||||
_score: null,
|
||||
_source: {
|
||||
layers: {
|
||||
"frame.number": ["2"],
|
||||
"ip.addr": ["192.0.2.1", "192.0.2.2"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{ _source: { layers: { "frame.number": ["7"] } } },
|
||||
]);
|
||||
expect(parsePacketOutput(output, ["ip.addr"])).toEqual([
|
||||
{ "frame.number": ["2"], "ip.addr": ["192.0.2.1", "192.0.2.2"] },
|
||||
{ "frame.number": ["7"] },
|
||||
]);
|
||||
});
|
||||
|
||||
it.each(
|
||||
[
|
||||
[{ "ip.addr": ["192.0.2.1"] }],
|
||||
[{ "frame.number": ["1"], "ip.addr": "192.0.2.1" }],
|
||||
[{ "frame.number": ["0"] }],
|
||||
[{ "frame.number": ["1", "2"] }],
|
||||
[{ "frame.number": ["1"], "unselected.field": ["hidden"] }],
|
||||
[{ "frame.number": ["2"] }, { "frame.number": ["2"] }],
|
||||
[{ "frame.number": ["2"] }, { "frame.number": ["1"] }],
|
||||
].map((layers) => [layers]),
|
||||
)("rejects malformed, repeated or reordered producer frames: %j", (layers) => {
|
||||
expect(() =>
|
||||
parsePacketOutput(
|
||||
JSON.stringify(layers.map((value) => ({ _source: { layers: value } }))),
|
||||
["ip.addr"],
|
||||
),
|
||||
).toThrow();
|
||||
});
|
||||
Reference in New Issue
Block a user