Help us shape the future of Go! Take the 2026 Go Developer Survey

ocsf

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ocsf encodes native audit lines as OCSF events (design 12 §6.2, R-384).

Everything in an OCSF event is derived from the line it encodes; nothing is looked up. The line's detail never holds a secret (R-194), so carrying it whole under unmapped adds nothing a native line does not already say.

Index

Constants

View Source
const SchemaVersion = "1.3.0"

SchemaVersion is the OCSF schema version the events conform to.

Variables

View Source
var BaseFields = []Field{
	{"class_uid, class_name", "The action's row under Classes."},
	{"category_uid, category_name", "`class_uid / 1000`."},
	{"activity_id, activity_name", "The action's row under Classes."},
	{"type_uid, type_name", "`class_uid × 100 + activity_id`; the name is `<class>: <activity>`."},
	{"time", "`occurred_at`, in epoch milliseconds."},
	{"severity_id, severity", "1 Informational for `success`, 3 Medium for `denied`, 4 High for `failed`."},
	{"status_id, status", "1 Success for `success`, 2 Failure otherwise."},
	{"status_detail", "`denied` or `failed`; absent on success."},
	{"message", "`<action> by <actor> on <target_kind> <target_id>`. The actor is `actor_name`, else `principal_id`, else `principal_kind`."},
	{"metadata.uid", "`id`, as a string."},
	{"metadata.version", "`" + SchemaVersion + "`."},
	{"metadata.product", "`{name: \"Pando\", vendor_name: \"Pando\", version}`."},
	{"metadata.correlation_uid", "`request_id`, when set."},
	{"metadata.log_name", "`audit`."},
	{"actor.user", "`{uid: principal_id, type_id, type, name: actor_name, email_addr: actor_email}`. `type` is `User` (1), `System` (3) or `Token` (99 Other); absent for an anonymous principal."},
	{"actor.invoked_by", "`on_behalf_of`: the person a token acted for (R-229, R-262)."},
	{"src_endpoint.ip", "`source_ip`, when set."},
	{"http_request.user_agent", "`user_agent`, when set."},
	{"api.operation", "`action`."},
	{"resources", "`{type: target_kind, uid: target_id}`, then `{type: \"app\", uid: app_id}` when `app_id` is set and is not the target."},
	{"unmapped", "`detail` whole, `peer_ip`, `schema_version`, `principal_kind` and `on_behalf_of`."},
}

BaseFields is the field-by-field mapping Encode implements, in the order the generated reference lists it. TestR384_OCSFBaseFields holds Encode's output to it, so a field cannot be added to one and not the other.

View Source
var ProcessFields = []Field{
	{"process.name", "The command's first argument; `shell` when the session opened the runtime's default shell."},
	{"process.cmd_line", "The command's arguments, joined with spaces. The command, never the session's input or output (R-086)."},
	{"process.container.name", "The workload the session ran in."},
}

ProcessFields are the fields Process Activity (1007) adds, which only a terminal session's events carry: `app.exec` and `app.exec.end`.

View Source
var ProductVersion = "dev"

ProductVersion is Pando's version, reported as metadata.product.version. Set by main at startup.

Functions

func Encode

func Encode(line json.RawMessage) (json.RawMessage, error)

Encode is an audit.Encoder: one native line in, one OCSF event out.

Types

type Field

type Field struct {
	OCSF string
	From string
}

Field is one row of the base-field table: an OCSF field and the native column(s) it comes from.

type Mapping

type Mapping struct {
	ClassUID     int
	ClassName    string
	ActivityID   int
	ActivityName string
}

Mapping is the OCSF class and activity one audit action is recorded as.

func Lookup

func Lookup(action string) (Mapping, bool)

Lookup is the mapping for an action, and whether the table has one. An action it does not have is encoded as 6003 API Activity, 99 Other.

func (Mapping) CategoryName

func (m Mapping) CategoryName() string

CategoryName is the category's OCSF caption.

func (Mapping) CategoryUID

func (m Mapping) CategoryUID() int

CategoryUID is the class's category: OCSF numbers a class category*1000+n.

func (Mapping) TypeName

func (m Mapping) TypeName() string

TypeName is the OCSF type caption, "<Class>: <Activity>".

func (Mapping) TypeUID

func (m Mapping) TypeUID() int

TypeUID is class_uid*100 + activity_id, as OCSF defines it.

type Row

type Row struct {
	Action string
	Mapping
}

Row is one line of the mapping table.

func Table

func Table() []Row

Table is the mapping, one row per catalogued action, sorted by action. What docs/audit-formats.md is generated from.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL