Documentation
¶
Overview ¶
Package auditexport serialises the tamper-evident audit trail into the formats a compliance pipeline consumes (Task 20167).
Three writers, one interface:
jsonl one JSON object per line — lossless, the format to keep csv a flat table — the format a human opens in a spreadsheet cef ArcSight Common Event Format — the format a SIEM ingests
The package deliberately holds no database handle and no file handle: it writes events from a slice to an io.Writer. That keeps the format rules (which are fiddly, especially CEF's two-level escaping) testable against golden fixtures without a SQLite dependency, and lets the same code serve both the CLI's `--output file` and a future HTTP download.
Hashes are carried through every format. An export that dropped prev_hash and row_hash would be a list of claims about the past with no way to check them; carrying them means a recipient can re-run the chain verification against the export itself.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllFormats = []Format{FormatJSONL, FormatCSV, FormatCEF}
AllFormats lists the supported formats in the order help text shows them.
Functions ¶
Types ¶
type Event ¶
type Event = statedb.AuditEvent
Event is the row shape being exported, re-exported so callers need not import pkg/statedb just to name the type.
type Format ¶
type Format string
Format selects the serialisation.
func ParseFormat ¶
ParseFormat resolves a user-supplied format name, case-insensitively. "json" is accepted as an alias for jsonl: it is the name people reach for, and refusing it teaches nothing.
type Options ¶
type Options struct {
// Format selects the serialisation. Zero value is FormatJSONL.
Format Format
// ProductVersion is stamped into the CEF header so a SIEM can attribute
// a record to the binary that produced it. Ignored by the other formats.
// Defaults to "dev" when empty.
ProductVersion string
// MaxPayloadBytes truncates the payload field in CEF output. CEF has no
// formal size cap but collectors routinely drop records past a few
// kilobytes, and a step payload can be large. 0 selects the default;
// negative disables truncation.
MaxPayloadBytes int
// JSONPayloadLimit bounds the payload of a JSONL record, for a transport
// with a message size limit (the audit forwarder's syslog sink, Task
// 20426). Zero, the default, never cuts: an export is lossless. A
// payload over the limit is left out of the record, which says so —
// payload_truncated, the payload's length and SHA-256, and an excerpt —
// rather than arriving cut and looking whole.
JSONPayloadLimit int
// Provenance labels each record with the chain it came from and the hub
// that sent it, for a stream that mixes chains (Task 20426). Nil leaves
// the records as a single-chain export writes them.
Provenance *Provenance
}
Options tunes an export run.
type Provenance ¶ added in v0.0.6
type Provenance struct {
// Source is the chain's role: control-plane or project.
Source string
// Dir is the directory whose .cloop/state.db holds the chain.
Dir string
// Hub names the hub that sent the row. Empty leaves it out.
Hub string
}
Provenance is where a row came from.