audit
audit
¶
Per-container JSON-lines audit logging.
Writes structured events (setup, teardown, allow, deny) to a single file per container. Can be toggled on/off at runtime without losing the file handle.
AuditLogger(*, audit_path, enabled=True)
¶
JSON-lines audit logger for a single container.
Writes to a single file (audit_path). When disabled, all
write operations are no-ops.
Create an audit logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audit_path
|
Path
|
Path to the |
required |
enabled
|
bool
|
Whether logging is active (can be toggled later). |
True
|
Source code in src/terok_shield/lib/audit.py
enabled
property
writable
¶
Whether audit logging is active.
log_event(container, action, *, dest=None, detail=None)
¶
Write a single audit event to the log file.
No-op when audit is disabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
str
|
Container name. |
required |
action
|
str
|
Event type (setup, teardown, allowed, denied). |
required |
dest
|
str | None
|
Destination IP/domain (optional). |
None
|
detail
|
str | None
|
Additional detail string (optional). |
None
|
Source code in src/terok_shield/lib/audit.py
tail_log(n=50)
¶
Yield the last n audit events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of recent events to yield. |
50
|