Repository navigation
Add Agentmetry package with OCSF mapping - #211
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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Agentmetry records the tool calls of AI coding agents from their own hooks and correlates them into detections. The library had no mapping for its events, so activity from Cursor, Copilot and the other hook-only agents could not join the OCSF pipelines next to the anthropic and openai packages. The package maps the canonical event and the trail line to OCSF 1.9.0: shell calls to Process Activity, file calls with a path to File System Activity, other tools to API Activity, and detections and changed MCP tool listings to Detection Findings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace nested conditional mappings with lookups and classify tool results once for message selection. Rely on null propagation instead of defensive checks and leave empty source records intact. Preserve unknown agent attributes that cleanup previously discarded. Cover missing and null optional fields and update output snapshots.
4578855 to
ba1245b
Compare
|
Thanks for merging, and for the simplification pass. The lookup table for file activities and the optional-fields test are cleaner than what I had, and I'll follow that style as the schema grows. One related note: 0.10.5 went out today, and an event from an oversized command now carries tool.classification: "partial" over HTTP (an earlier release dropped it at our receiver). It lands in unmapped with no change on your side. And a question, not a request: do you see Tenzir users rolling out Claude Code, Cursor or Codex across a team? If one of them wanted to try the package on a few laptops, I'd set it up with them and fix whatever breaks the same day. "Not yet" is a useful answer too. |
Integrate the Agentmetry package added by #211. The merge has no conflicts; follow-up validation aligns its OCSF tests with this branch.
🔍 Problem
Agentmetry is an open-source recorder for AI coding agents. It records each tool call from the agents' own hooks (Claude Code, Cursor, Codex, GitHub Copilot, Qwen, Kimi and a few more), writes them to a hash-chained JSONL trail, and correlates the calls of a session into detections. The library has no mapping for its events, so agent activity from Cursor, Copilot and the other hook-only agents cannot join the OCSF pipelines next to the
anthropicandopenaipackages.As discussed with @mavam on Discord.
🛠️ Solution
A new
agentmetrypackage with two operators, laid out likekunai. Tenzir reads Agentmetry's JSON natively, so the package starts at the mapper.agentmetry::ocsf::normalizenormalizes a stream of Agentmetry events.agentmetry::ocsf::map agentmetry, ocsfmaps a structured event and consumes it. Whatever has no OCSF attribute stays underunmapped.metadata.sequence.anthropicpackage and the agent-to-OCSF blog post:process.cmd_line.api.operationand the MCP server asapi.service.detectionevents and a changed MCPtools/listfingerprint are Detection Findings.ai_agent.nameand the session asai_agent.instance_uidandmetadata.correlation_uid.policy; a person's answer to an approval request is Approved or Rejected.attacks, the calls it matched asfinding_info.related_events, and the agent as anevidencesentry.💬 Review
agentmetry demoplus a generated session per event type). Host and user names are replaced, and the trail excerpt is re-chained so that it still verifies.tools/listfingerprint (the shape of an MCP rug pull) is a Detection Finding with severity Unknown, because Agentmetry assigns it none. A Base Event would be the conservative alternative.AML.T0109) stay underunmapped, so that ATT&CK consumers ofattacksdon't misread them. I wasn't sure whetherattacksis meant to carry other frameworks.file.unmapped. Record Integrity looked like a fit, but an attestation covers the OCSF event, and these hashes cover the Agentmetry event, so they would not verify.status_detail.unmappedkeeps Agentmetry's own classification of each call (tool.mitre,tool.atlas), DLP matches, andsource_topic. Happy to trim it.✅ Validation
tenzirskill loaded, andkunai,anthropicandopenaias the style references.uvx tenzir-test agentmetry: 7 tests pass on Tenzir v6.20.1, and with--prerelease allow.ocsf_castover all 20 fixture events, so an attribute that OCSF 1.9.0 does not know fails the run..tqlfile passes the syntax check (--dump-irfor examples and tests,--dump-astfor operators).accept_http. The fixtures are the recorder's output, captured to file.I maintain Agentmetry, and the canonical schema changes only additively within 1.x, so the fields this mapping reads are not renamed or moved. I'll keep the package current when the schema grows.
🤖 Generated with Claude Code
📚 Docs PR: tenzir/content#558