Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a74f0337c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // The provider cleans each call before returning, including failed calls. | ||
| // A second close here could replace a cleanup error carrying partial Evidence. | ||
| run: ({ args, options }) => |
There was a problem hiding this comment.
Retry retained cleanup from the one-shot CLI
When an owned command or private-root cleanup remains incomplete, service.inspect() returns a ProviderCleanupError while TsharkCaptureProvider deliberately keeps the supervisor/root in #pending; the official one-shot CLI path performs no subsequent provider shutdown, and these lines explicitly skip service.close(), so there is no retry and an owned process or the capture copy can survive the command. Preserve the projected original error/partial Evidence, but still join or retry service.close() before the adapter exits.
AGENTS.md reference: AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
| const configured = this.environment.REA_TSHARK_COMMAND ?? ""; | ||
| if (!isAbsolute(configured)) | ||
| throw new Error("Supply absolute REA_TSHARK_COMMAND for TShark 4.x."); | ||
| const command = await realpath(configured); |
There was a problem hiding this comment.
Preserve the configured TShark path before resolving it
When REA_TSHARK_COMMAND points through a symlink, as package-manager shims commonly do, realpath() overwrites the caller-selected path and the report later serializes only tool.path: command; the Evidence therefore cannot say which configured path was chosen even though it records the resolved target and digest. Keep the configured path alongside the resolved executable identity rather than discarding it.
AGENTS.md reference: AGENTS.md:L25-L25
Useful? React with 👍 / 👎.
| Supply an existing TShark 4.x installation: | ||
|
|
||
| ```sh | ||
| export REA_TSHARK_COMMAND=/absolute/path/to/tshark |
There was a problem hiding this comment.
Expose TShark support in the canonical README
When users rely on README as the provider inventory, this setup remains invisible: README.md:163 still maps saved captures only to HAR/mitmdump, and README contains neither REA_TSHARK_COMMAND nor a link to this new guide. Add a TShark packet-capture entry and link to README rather than publishing setup only in the VitePress navigation and skill.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34878b4f2c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| `--as=${LIMITS.address_space_bytes}:${LIMITS.address_space_bytes}`, | ||
| `--fsize=${LIMITS.file_bytes}:${LIMITS.file_bytes}`, | ||
| `--cpu=${LIMITS.cpu_seconds}:${LIMITS.cpu_seconds}`, |
There was a problem hiding this comment.
Respect inherited ceilings when applying prlimit
On a Linux process started with stricter inherited limits, these fixed pairs either raise the child's soft resource policy (for example, AS 256 MiB soft/2 GiB hard becomes 1 GiB/1 GiB) or make prlimit exit with EPERM when the inherited hard limit is below the requested value, so an otherwise safe capture cannot run. I checked util-linux prlimit --help: <limit> is a soft:hard range (or one value defining both), and HARD is the ceiling. Clamp to and report the inherited effective limits rather than unconditionally replacing both.
AGENTS.md reference: AGENTS.md:L46-L46
Useful? React with 👍 / 👎.
| withAdmittedAnalysis?: WithAdmittedAnalysis, | ||
| ): void => { | ||
| const contract = toolContract("inspect_packet_capture"); | ||
| const handler = createEvidenceToolHandler( |
There was a problem hiding this comment.
Record completed partial Evidence in the MCP session
When TShark completes but #release() fails (or cancellation lands after completion), the service returns an error containing a complete Evidence-valued partialObservation. createEvidenceToolHandler exits on !result.ok before invoking recordEvidence (src/server/contractToolHandler.ts:64-66), so this registration exposes the partial result in the response but omits it from get_evidence_bundle; use the recorded-partial path already used by the Electron handler rather than the generic failure path.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
| this.environment.REA_TSHARK_PRLIMIT_COMMAND ?? "/usr/bin/prlimit"; | ||
| if (!isAbsolute(configuredLimiter)) | ||
| throw new Error("REA_TSHARK_PRLIMIT_COMMAND must be absolute."); | ||
| const limiter = await realpath(configuredLimiter); |
There was a problem hiding this comment.
Preserve the configured limiter path before resolving it
The newly added limiter configuration loses provenance when REA_TSHARK_PRLIMIT_COMMAND names a symlink: realpath() replaces the caller-selected lookup path, and the report later serializes only this resolved value as resource_limiter.path. Evidence therefore cannot reconstruct which configured limiter path was chosen; retain the configured value separately from the resolved executable identity and digest.
AGENTS.md reference: AGENTS.md:L25-L25
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43d9641591
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fields: z | ||
| .array(argument) | ||
| .min(1) |
There was a problem hiding this comment.
Bound selector arrays before building argv
On MCP requests with a generated field list whose expanded argv exceeds the host exec limit (getconf ARG_MAX is 2,097,152 in the inspected Linux environment), this schema accepts the list without any count or aggregate-size ceiling; TsharkCaptureProvider.ts:251-254 then adds two argv entries per unique field and spawn fails with E2BIG, which is returned as an output error rather than rejected input. Add bounded selector sizes or an aggregate argv budget before expansion.
AGENTS.md reference: AGENTS.md:L46-L46
Useful? React with 👍 / 👎.
| read_scope: | ||
| input.packet_limit === null ? "to-eof" : "up-to-input-packet-limit", | ||
| configuration: "private-empty-personal-profile", | ||
| diagnostics: output.stderr.text, |
There was a problem hiding this comment.
Retain stderr from the version probe
When TShark's successful --version probe emits a loader, plugin, or configuration warning on stderr, execute captures it in version.stderr, but the report keeps only the later inspection snapshot's output.stderr. The resulting Evidence silently loses configuration diagnostics that can explain dissection behavior even though its limitations claim all stderr is retained; record diagnostics for both invocations.
AGENTS.md reference: AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
| { output_bytes: LIMITS.output_bytes }, | ||
| detail, | ||
| ); | ||
| return new AnalysisOutputError(OPERATION, reason, detail); |
There was a problem hiding this comment.
Classify enforced file-limit exits as resource failures
When a capture hits the enforced file ceiling—for example, a stricter inherited RLIMIT_FSIZE while TShark writes temporary or reassembly data—runOwnedCommand returns a process failure with snapshot.signal === "SIGXFSZ", but this fallback turns it into AnalysisOutputError and the captured object above omits the signal. I checked /usr/bin/prlimit --help, which defines --fsize as “maximum size of files written by the process”; src/evm/EvmoleFailures.ts:80-105 already maps the same signal to AnalysisResourceConstraintError. Preserve the signal and report the effective file limit so CLI/MCP callers receive the actionable resource failure.
AGENTS.md reference: AGENTS.md:L25-L25
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0781d8dfb7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { | ||
| cause, | ||
| userMessage: `${reason} On Linux, configure TShark 4.x through REA_TSHARK_COMMAND and util-linux prlimit through REA_TSHARK_PRLIMIT_COMMAND (default /usr/bin/prlimit).`, | ||
| }, |
There was a problem hiding this comment.
Preserve output from rejected version probes
When --version exits zero with a TShark 3.x or otherwise nonmatching banner, execute() has already populated observedOutput, but this options object omits it, so CLI/MCP error projections expose only the generic expectation and lose the actual banner and stderr. Fresh evidence in the final tree is that successful reports now retain version_diagnostics, while this rejected-version path still discards the probe output; pass it through as capturedOutput.
AGENTS.md reference: AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
| return new AnalysisInputError(OPERATION, { cause }, [ | ||
| { path: ["path"], reason: "invalid_value", message: reason }, | ||
| ]); | ||
| return new AnalysisOutputError(OPERATION, reason, { cause }); |
There was a problem hiding this comment.
Attach captured output to parse failures
When TShark exits zero but stdout is invalid JSON or fails the producer schema parse, execute() has already filled observedOutput, yet this fallback constructs AnalysisOutputError with only the cause. The resulting CLI/MCP error loses the exact stdout and warning stderr needed to diagnose the producer; attach observedOutput as capturedOutput here.
AGENTS.md reference: AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
| .digest("hex"), | ||
| ); | ||
| assert.equal(report.hardware_acquisition, "not-performed"); | ||
| assert.equal(report.limits.address_space_bytes, 1073741824); |
There was a problem hiding this comment.
Honor inherited limits in the real verifier
When the real verifier is launched with an inherited RLIMIT_AS below 1 GiB but still sufficient for this capture, the provider correctly clamps and reports that lower ceiling, so this assertion (and the fixed --as=1073741824:1073741824 assertion below it) falsely fails a valid run. Fresh evidence after the ceiling fix is that the provider now reports effective inherited limits, while this verifier still hard-codes the configured maximum; derive the expected value from the inherited limit and construct the expected limiter argument from the report.
AGENTS.md reference: AGENTS.md:L46-L46
Useful? React with 👍 / 👎.
Summary
Add
inspect_packet_capture/inspect-packet-captureto inspect explicitly selected fields in an existing capture through caller-supplied TShark. An analyst can correlate a device/app investigation with recorded network or Bluetooth traffic and keep the result in REA Evidence without opening a binary target.Problem and expected behavior
Existing web HAR/mitmproxy workflows do not expose packet-capture dissection. This tool accepts a local capture, field names, display filter, decode-as rules, pass mode and optional input-packet limit. Repeated field values remain ordered string arrays and every returned packet retains its original frame number. Missing fields and empty filtered results are not treated as proof of absent device traffic.
No linked issue: this is a focused enhancement proposal. It is independent of the signal-recording proposal #2126 and can be reviewed or merged separately.
Change and scope
One file-analysis contract, optional TShark adapter, shared application validation/Evidence, CLI/MCP registration, capability/catalog entries, guide, canonical README rows in every translation, authored skill guidance and real-provider CI lane. No live capture, interfaces, device commands, installer, arbitrary process flags, automatic protocol guessing or changes to HAR/mitmproxy behavior.
Contract and boundary impact
frame.numberis always included; optionalpacket_limitcounts input packets before filtering, andtwo_passdefaults to true (--no-two_passin CLI requests false).REA_TSHARK_COMMAND, TShark 4.x version gate; Linux with util-linuxprlimitis required; unsupported hosts fail before workspace allocation.REA_TSHARK_PRLIMIT_COMMANDcan override/usr/bin/prlimit. Known producer JSON is validated; no claim that every 4.x version/format/dissector has been exercised._index/_scoreare omitted. Read scope is explicit; no total packet count is inferred from filtered output. Selectors are bounded before argv expansion: up to 1,024 fields/rules per array, 8,192 UTF-16 units per string and 32 KiB total UTF-8 text/terminator/flag/pointer budget, shared by CLI and MCP.prlimitenforces soft and hard limits of at most 1 GiB address space, 64 MiB per file, 30 CPU seconds and no core dumps. Stricter inherited soft/hard limits are preserved and effective values are reported. These are per-process/per-file limits, not aggregate quotas or an OS sandbox; the selected limiter, installed libraries/global configuration/plugins are trusted. Workspace failures are distinguished from invalid input. Post-run identity errors identify the private copy/tool/limiter involved and retain captured output. Resource-signal failures retain the signal and effective limits without claiming the signal proves its cause.Evidence and regression coverage
Executed real TShark verification synthesizes its own Ethernet/IPv4/UDP/DNS and Bluetooth HCI PCAPs. It checks compiled CLI/MCP parity, advertised schemas, persisted Evidence, source digests, repeated and missing fields, both pass modes, filters, decode-as, a prefix limit before matching packets, invalid requests and cleanup.
Representative output for selected network frames is
{"frame.number":["2"],"ip.addr":["192.0.2.1","192.0.2.2"],"udp.port":["40000","5555"]}. Explicit DNS decode-as yieldsexample.test; the HCI fixture yields opcode0x0c03. Setting input limit 1 before the matching frames correctly returns an empty result withup-to-input-packet-limitscope.Command-boundary tests additionally cover invalid producer JSON, changed private copies, nonzero exit, overflow, cancellation, cleanup retry and completed observations on late cancellation. Parser cases cover repeated, unordered, missing and malformed frame identities and unexpected fields. Additional regressions distinguish workspace failures, refuse unsupported hosts, and use a synthetic producer to verify real Linux kernel limits and a refused allocation. A second Linux process test confirms lower inherited file/CPU limits are preserved during the actual launch.
Remaining proof gaps: PCAPNG, USB, BLE ATT, other dissectors/formats and physical acquisition. macOS and Windows are explicitly unsupported. The real provider and Linux kernel-limit checks run in the linked fork workflow below; upstream CI remains visible under Checks; the links below are independently executed fork verification.
Validation performed
npm run check— passed; existing repository lint warnings remain.npm run docs:check— passed.npm run verify:test-discovery— all 921 test files discovered exactly once.0781d8dfb— passed: 39 provider/parser/CLI/MCP/resource-limit tests, plus 12 real TShark CLI/MCP cases on Ubuntu 24.04 with TShark 4.2.2. Kernel tests verify refused oversized allocation, lower inherited file/CPU limits, and a real SIGXFSZ termination retaining its effective file ceiling.git diff --checkand staged-diff Gitleaks scan — passed.Compatibility, safety, and release
Review checklist