Skip to content

feat(captures): discover installed protocol and field definitions - #2496

Merged
baron merged 8 commits into
morluto:mainfrom
Olorinm:feat/packet-field-discovery
Oct 13, 2026
Merged

baron merged 8 commits into
morluto:mainfrom
Olorinm:feat/packet-field-discovery

Conversation

@Olorinm

@Olorinm Olorinm commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add inspect_packet_fields / inspect-packet-fields so analysts can find the installed TShark protocol and field definitions before selecting fields for inspect_packet_capture. For example, { "kind": "fields", "protocol": "usb", "query": "idVendor" } returns usb.idVendor, its FT_UINT16 type, parent usb, display base and bitmask.

Problem and expected behavior

Capture inspection requires exact field names but currently offers no installation-specific discovery. Search protocol registrations or field definitions by literal substring, optionally selecting an exact protocol. Return 50 matches by default, offset/limit paging, explicit full output within resource limits, and examined/matching/returned counts. Duplicate abbreviations remain separate records with source line numbers. No linked issue: this is a focused follow-up to #2318.

Change and scope

Extend the existing TShark adapter and its shared CLI/MCP Evidence workflow. Reuse the same admission slot, owned process execution, executable verification, inherited Linux limits, private empty personal profile and retryable cleanup. The common resource owner accepts a per-request operation so discovery failures have the correct identity; it does not create a second queue. This small common-owner change is identical to #2487; both PRs are independently based on main.

Contract and boundary impact

  • Semantic owner: strict discovery schemas and one adapter parser for the native -G fields P/F grammar. Preserve names, types, parents, display bases, masks, descriptions and duplicate registrations.
  • Scope decision: not applicable; this extends an integrated provider's installation inspection, with no new provider or target execution/mutation authority.
  • CLI/MCP: additive tool/command; kind, protocol, query, offset, limit. CLI --all conflicts with --limit. Catalog registrations describe tool capabilities, not observed traffic.
  • Compatibility: existing Linux/TShark 4.x/util-linux requirements. Discovery reads no capture file and selects no interface.
  • Evidence: executable and limiter paths/digests, version/warnings, argv, selection and coverage. Global configuration, libraries and plugins remain trusted and are not fully fingerprinted; each request probes again, without caching or frozen-page claims.
  • Resources: the measured TShark 4.6.9 glossary is 22,303,197 bytes, so discovery alone allows 32 MiB producer output; capture analysis retains its 4 MiB cap. Parse incrementally, allocate only selected records, conservatively budget selected representation at 8 MiB, and copy every retained column out of the producer buffer. Over-budget/malformed output fails with captured diagnostics.
  • Installation/generated metadata: contracts, authored skill, guide and existing real-provider lane updated; no new dependencies or committed generated files.

Expected effects:

  • Read existing tool files and installation metadata.
  • Launch an owned local analysis process.
  • Create and clean a private temporary workspace/profile.

Evidence and regression coverage

Parser/provider tests cover duplicate registrations, malformed off-page records, paging/filtering/no matches, representation and command-output budgets, failed version probes, shared admission, executable changes, shutdown, cancellation and cleanup retry. MCP tests validate SDK-converted schemas and actionable unavailable results. Existing signal-provider regressions pass after the common-owner change.

The real verifier compares source ordinals and native field columns against direct TShark output under a separate empty profile; checks USB vendor-ID discovery, protocol paging, full UDP field selection, negative queries and CLI/MCP parity; and retains the existing packet-capture workflow and cleanup checks.

  • Observed facts and interpretation remain distinguishable.
  • Provenance and failed attempts remain preserved.
  • Coverage and unavailable outcomes remain explicit.

Validation performed

Cleanup follow-up on b2aff43e8: retained workspaces now keep the operation that acquired them alongside process ownership. Shutdown and pre-request cleanup retries use that identity, rather than the provider default or the next request's operation. Extended the existing field discovery boundary regression to reject a different operation while cleanup is pending, verify two failed shutdown attempts keep the original operation, and then complete cleanup. No public contract or execution scope changed.

  • Latest local validation: 62 focused regressions, npm run check, git diff --check, and a Gitleaks diff scan passed.
  • Native TShark verification on b2aff43e8 passed: 60 focused tests and 23 real CLI/MCP cases. Full CI is still running; the historical runs below apply to the preceding heads.

Earlier feature validation:

  • npm run check, npm run docs:check, npm run verify:test-discovery — passed; 1,023 test files discovered exactly once.
  • npm run jscpd — passed, 2.95% duplicated lines.
  • Focused local regression on the rebased head — 56 passed, including the product catalog, CLI help and portable advertised-pattern checks.
  • Linux verification on df821f83d — 60 tests and 23 real TShark CLI/MCP cases passed.
  • Full upstream CI on df821f83d — passed.
  • Final diff Gitleaks scan and git diff --check — passed.

Six discovery cases measured 651–761 ms per MCP call and 7.5–20.3 KB response envelopes. tokenx estimates including one tool definition, request and response were 6,634–11,253 tokens. Warm MCP server, fresh native processes, no filesystem-cache control; these are estimates, not billed usage or evidence of improved agent task completion.

Compatibility, safety, and release

No breaking call/configuration changes or migrations. macOS/Windows integration remains unsupported. The private profile does not sandbox installed plugins or libraries. Limits are per process/file, not aggregate quotas. Ambient environment is not serialized. Model-driven task selection, CPU time and peak process-family memory remain unmeasured; no cache or speedup claim.

Before merge

  • Concrete problem and one focused outcome; no material authority expansion.
  • Related upstream work and no-linked-issue reason stated above.
  • Observable behavior, meaningful failures and real public workflows covered.
  • Owning contracts/docs updated; ignored metadata regenerated and checked.
  • Final diff checked for secrets, unrelated cleanup and unsupported claims.

Summary by CodeRabbit

  • New Features
    • Added packet-field discovery through the command-line and MCP interfaces. Search installed protocol and field registrations, filter results, and page through matching records.
  • Improvements
    • Source-map comparisons now recognize Unicode-equivalent paths as possible matches while keeping ambiguous file identities unconfirmed.
    • Ghidra installation checks now account for declared Java version requirements and report unresolved or malformed installation metadata.
  • Bug Fixes
    • Invalid UTF-8 in APK metadata is now reported as unreadable output rather than silently replaced.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@Olorinm
Olorinm force-pushed the feat/packet-field-discovery branch from 776da8f to df821f8 Compare October 13, 2026 05:30
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0277cbdc-a009-4f78-a794-4f027bed185f
📥 Commits

Reviewing files that changed from the base of the PR and between f5d9724 and 9ca3c87.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 311af882-403b-43d2-ab9c-1bb24c6ffa72
📥 Commits

Reviewing files that changed from the base of the PR and between df821f8 and f5d9724.

📒 Files selected for processing (31)
  • docs/javascript-application-workflows.md
  • scripts/verify-packet-capture.mjs
  • src/apktool/ApktoolProvider.test.ts
  • src/apktool/ApktoolProvider.ts
  • src/application/javascript/JavaScriptArtifactAnalysis.sourceMaps.test.ts
  • src/application/javascript/JavaScriptArtifactAnalysis.ts
  • src/browser/WebSourceMapFetcher.ts
  • src/domain/analysisView/analysisView.test.ts
  • src/domain/javascript/javascriptApplicationGraph.fixture.ts
  • src/domain/javascript/javascriptApplicationGraph.test.ts
  • src/domain/javascript/javascriptSourceMapPaths.ts
  • src/domain/javascript/sourceToBundleComparison.test.ts
  • src/domain/javascript/sourceToBundleComparison.ts
  • src/domain/javascript/sourceToBundleComparisonSchemas.ts
  • src/domain/javascript/sourceToBundleSignals.ts
  • src/filesystem/RegularFile.ts
  • src/ghidra/GhidraAnalysisSeeds.test.ts
  • src/ghidra/GhidraDoctor.test.ts
  • src/ghidra/GhidraInstallation.test.ts
  • src/ghidra/GhidraInstallation.ts
  • src/ghidra/GhidraInstallationPolicy.ts
  • src/ghidra/GhidraLanguageOverride.test.ts
  • src/ghidra/GhidraMipsProfile.test.ts
  • src/ghidra/GhidraProvider.behavior.test.ts
  • src/ghidra/GhidraRiscvProfile.test.ts
  • src/ghidra/GhidraSnapshotCache.test.ts
  • src/javascript/sourceMaps/DecodedSourceMap.ts
  • tests/boundary/filesystem/sourceToBundlePaths.test.ts
  • tests/boundary/mcp/applicationEvidenceMcp.test.ts
  • tests/boundary/process/sourceMapUncHosts.test.ts
  • tests/process-global/regularFileNoFollowFallback.test.ts
💤 Files with no reviewable changes (1)
  • src/javascript/sourceMaps/DecodedSourceMap.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

📝 Walkthrough

Adds TShark packet-field discovery with filtering and pagination. The feature is available through the capture service, CLI, and MCP, with shared resource handling and Linux verification.

Changes: Packet-field discovery

Layer / File(s) Summary
Catalog contract and parsing
src/domain/captures/packetFields.ts, src/captures/parseFieldDiscovery.ts, tests/boundary/captures/fieldDiscovery.test.ts
Adds schemas for discovery inputs and catalog results. Parses TShark glossary records, applies filters and paging, and enforces a record representation budget.
TShark execution and resource handling
src/captures/TsharkCaptureProvider.ts, src/process/ArtifactAnalysisResources.ts, tests/boundary/captures/captureProvider.test.ts
Runs TShark field discovery with request-specific output limits and operation-aware errors. Tests cover catalog results, limits, failures, capacity, cancellation, and cleanup.
Service and tool exposure
src/application/captures/PacketCaptureService.ts, src/contracts/captures/captureToolContracts.ts, src/contracts/toolEffects.ts, src/server/registerCaptureTools.ts, src/application/CapabilityInventory.ts, src/cli/captureCommands.ts, src/cliCommandNames.ts, tests/boundary/cli/captureCleanup.test.ts, tests/boundary/mcp/packetCaptureMcp.test.ts
Adds field discovery to the service, CLI, and MCP. The service validates catalog results and uses shared evidence construction; the CLI shares cleanup handling with capture inspection.
Verification and documentation
docs/packet-captures.md, .agents/skills/reverse-engineer-anything/SKILL.md, .github/workflows/real-packet-capture.yml, scripts/verify-packet-capture.mjs
Documents field discovery and adds it to the focused test command. The Linux verifier checks CLI and MCP results, computes the expected address-space limit from inherited limits, and reports discovery measurements.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~55 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant registerCaptureTools
  participant PacketCaptureService
  participant TsharkCaptureProvider
  participant TShark
  MCPClient->>registerCaptureTools: Call inspect_packet_fields
  registerCaptureTools->>PacketCaptureService: Submit discovery input
  PacketCaptureService->>TsharkCaptureProvider: Inspect fields
  TsharkCaptureProvider->>TShark: Run -G fields
  TShark-->>TsharkCaptureProvider: Return glossary output
  TsharkCaptureProvider-->>PacketCaptureService: Return catalog execution
  PacketCaptureService-->>MCPClient: Return evidence
Loading

Suggested reviewers: n0zom1z0

Merge Risk: ⚪ Minimal · up to f5d97

No identified issue remains that should prevent merging after normal checks.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 44 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: adding discovery for installed TShark protocol and field definitions.
Description check Passed The description covers the problem, expected behavior, implementation scope, contracts, effects, evidence, validation, compatibility, safety, and merge checklist. It provides concrete test results and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 44 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed on 9ca3c87. The feature/real-verifier bytes match the tested f5d9724 tree; the additional main sync only updates README counts and Ghidra fixtures. The follow-up strengthens the real TShark verifier with independent matching counts, exact page source ordinals, display bases and masks.

Linux x64, pinned Node 24.18.0/npm 11.16.0, actual TShark 4.0.17: 42 focused tests, 23 native CLI/MCP cases, advertised schemas, cancellation/cleanup, and a real recorded TLS/DNS traffic workflow passed. The installation glossary contained 236,481 records / 19,271,694 bytes; selected records and coverage matched independently invoked native output. The capture remained byte-identical.

For the same two-call DNS task, three alternating warm pairs measured o200k_base request/response estimates of 41,449 tokens (all DNS fields) vs 5,878 (focused query). Including the same 135,311-token input-schema catalog projection gives 176,760 vs 141,189. Median wall time was 1.931 vs 1.763 s; server plus waited-child CPU was 2.34 vs 2.05 s. This is a bounded local task measurement, not billed usage or a general speedup claim. The benchmark family peaked at 1,149 MiB; the largest local verification/check family at 3,841 MiB, without OOM.

No persistent glossary cache was added: the executable digest alone does not cover installed plugins/global configuration. Discovery remains installation evidence, not observed traffic. macOS/Windows remain unsupported.

The earlier static/Ghidra CI failures came from unchanged main fixtures missing application.java.min. Main fixed those in 18d56f5; this PR now includes that update. The complete local npm run check passes, including format, typecheck/lint, Knip, metadata and architecture guards; docs pass and duplication is 2.94%.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new actionable issue remains.

Summary

Adds inspect_packet_fields and inspect-packet-fields to search installed TShark protocol and field definitions.

  • Analysts can search installed TShark definitions before choosing capture fields.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  CLI["inspect-packet-fields"] --> Service["PacketCaptureService.inspectFields"]
  MCP["inspect_packet_fields"] --> Service
  Capture["inspect_packet_capture"] --> Gate["Shared admission slot"]
  Service --> Gate
  Gate --> Profile["Private empty profile"]
  Profile --> Version["Verify TShark and limiter"]
  Version --> Operation{"Requested operation"}
  Operation --> Fields["-G fields → filter and page"]
  Operation --> Packets["Private capture copy → packet analysis"]
  Fields --> Cleanup["Release owned resources"]
  Packets --> Cleanup
  Cleanup --> Evidence["Return Evidence or retained failure"]
Loading

Reviews (2) · Last reviewed commit: "fix(captures): retain discovery operatio..." · Reviewed by Greptile

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@baron
baron merged commit 9c34c09 into morluto:main Oct 13, 2026
40 checks passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: setup Setup, packaging, upgrade, install, Doctor, and client registration labels Oct 14, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants