Emit¶
emit
¶
Serialize a validated finding to a transport-agnostic payload.
emit is the boundary: it validates, then returns a JSON-serializable dict.
Transport (Kafka, HTTP, file, ...) is intentionally NOT this package's concern
-- callers ship the returned payload however they like.
emit
¶
Validate finding and return a JSON-serializable dict.
OCSF *_id enums are serialized to their integer values and None
fields are dropped, matching what OCSF consumers expect on the wire.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
finding
|
DetectionFinding
|
The detection finding to validate and serialize. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A JSON-serializable |
Raises:
| Type | Description |
|---|---|
InvalidFindingError
|
If the finding fails schema or invariant validation. |
Source code in src/ocsf_emitter/emit.py
emit_json
¶
Validate finding and return it as a JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
finding
|
DetectionFinding
|
The detection finding to validate and serialize. |
required |
indent
|
int | None
|
Optional indentation passed to :func: |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The finding serialized as a JSON string (keys sorted). |
Raises:
| Type | Description |
|---|---|
InvalidFindingError
|
If the finding fails schema or invariant validation. |