Create on OCSF mapping inside a Tenzir package
Adds OCSF mapping to a TQL parsing pipeline for cybersecurity data normalization.
/plugin marketplace add tenzir/claude-plugins/plugin install meta@tenzirGuide the user through adding OCSF (Open Cybersecurity Schema Framework) mapping to an existing parser package.
Begin by invoking these skills:
tql:managing-packagestql:writing-programsocsf:understanding-ocsfFor specific OCSF questions during the mapping process, spawn the ocsf:guide
subagent.
You MUST follow the following phases in EXACT order.
Objective: Ensure a parser package exists before adding OCSF mapping.
Steps:
operators/parse.tql), note the package
directory and identifier, then proceed to Phase 1/tql:make_parser to create one firstYou MUST state "Phase 0 complete" before proceeding.
Objective: Identify the appropriate OCSF event class and plan the mapping.
Prerequisites: (read with the docs:reader subagent once per session)
Steps:
parse operator output) to
understand available fieldsocsf:guide subagent to explore available classes:
category_uid, class_uid, type_uid, activity_idtime, timezone_offsetmetadata, observablessrc_endpoint, dst_endpoint)You MUST state "Phase 1 complete" before proceeding.
Objective: Create the OCSF mapping operator with proper structure.
Let pkg be the package ID from Phase 0.
Steps:
Create a new operator operators/ocsf/<type>.tql where <type> is the event
type (e.g., proxy, flow, process, auth)
Write TQL code that transforms parsed data into OCSF format. Structure the code with clear section comments:
// --- Preamble ---------------------------------
// Initial setup, invoke the parse operator if needed
// --- OCSF: Classification ---------------------
// category_uid, class_uid, type_uid, activity_id, severity_id
// --- OCSF: Occurrence -------------------------
// time, timezone_offset
// --- OCSF: Context ----------------------------
// metadata (log_name, product, uid, version)
// --- OCSF: Primary ----------------------------
// Class-specific required and recommended fields
// --- OCSF: Profile: Host ----------------------
// Host profile fields (if applicable)
// --- OCSF: Profile: Network Proxy -------------
// Proxy profile fields (if applicable)
// --- Epilogue ---------------------------------
// Final cleanup, unmapped fields handling
For the metadata object:
log_name: Populate only when unambiguous (static or from data)product: Populate from log data or staticallyuid: Extract a unique event ID from the data if availableversion: Set to the OCSF version (e.g., "1.4.0")Create a test file tests/ocsf/<type>.tql:
from_file f"{env("TENZIR_INPUTS")}/parse.txt" {
pkg::parse
}
pkg::ocsf::<type>
ocsf::cast
The ocsf::cast operator validates the output against the OCSF schema and
emits warnings on mismatches.
Run uvx tenzir-test --root <pkg> --summary and iterate until:
ocsf::cast are resolvedunmapped field is minimized (move fields to proper OCSF locations)Update the baseline with uvx tenzir-test --root <pkg> -u --summary
You MUST state "Phase 2 complete" before proceeding.
Provide a final summary of the complete parser with OCSF mapping:
unmapped contents