DocsSecurity & ComplianceAudit Logging

Audit Logging

The platform audit log answers "who did what, and when": logins, MFA, users and roles, agent and relay keys, enrollment and API tokens, SLA policy, suppression rules, notification channels and image classifications. Events are append-only, never contain secrets, can be filtered and exported by admins, and are kept for AUDIT_RETENTION_DAYS (730 days by default).


What Is Recorded

Every security-relevant action on the platform writes one audit event, after the action succeeded (in the same database transaction when there is one, so a rolled-back action leaves no event). Each action has a stable identifier, shown in the Action filter and in the export.

  • auth.login_succeeded / auth.login_failed: password logins (with mfa true/false) and SSO (OIDC) logins with the provider. A failed login records the username that was attempted and the reason: invalid_credentials, invalid_mfa_code or oidc_error. The "MFA required" step of a login records nothing.
  • auth.mfa_enabled / auth.mfa_disabled: a user turning MFA on or off.
  • user.created, user.role_changed (from / to), user.deactivated, user.activated: from User Management or the Django admin; user.created also on self-registration (source self_registration) and on the first SSO login (source oidc), user.role_changed also when the SSO group mapping changes the role (source oidc). In the Django admin, a direct change of the staff or superuser flag records user.role_changed with the flags as [old, new]. Any other update that changes neither the role nor the active flag records nothing.
  • agent_key.created / agent_key.revoked, relay_key.created / relay_key.revoked: with the key prefix, never the key. Revoking a key that is already inactive records nothing.
  • agent_key.enrolled: an agent exchanged an enrollment token for its own key (no user actor; the target is the agent_id, with the token and key prefixes).
  • agent_cert.issued: the platform CA signed a client certificate for an agent (automatic mTLS, no user actor; the target is the agent_id, with the certificate fingerprint, its expiry, whether it was a renewal and, on a first certificate obtained with a zone key, the prefix of the own key issued with it).
  • agent_cert.reset: an admin unbound the client certificate of an agent (lost or compromised key), with the old fingerprint.
  • enrollment_token.created / enrollment_token.revoked: with the token prefix, zone, expiry and maximum uses.
  • api_token.created / api_token.revoked: an admin created or revoked an API token for integrations, with the prefix, scopes, owner and expiry, never the token value (see /docs/api/api-tokens). Revoking a token that is already revoked records nothing. A service account created with the token also records user.created with service_account: true.
  • sla_policy.updated: the changed SLA targets as [old, new] pairs.
  • suppression_rule.created / suppression_rule.deactivated: the rule criteria, action and expiry (dry-run previews are not recorded).
  • notification_channel.created / notification_channel.updated / notification_channel.deleted: the names of the changed fields; the URL and the secret appear only as url_changed / secret_changed: true.
  • image_classification.changed: the image repository and the classification before and after (from / to).

Note: Not recorded: Django admin logins, logout, token refresh, password changes, reads, channel test messages and on-demand scans.

Event Fields

Every event has the same shape:

  • created_at: when the action happened (UTC).
  • actor / actor_username: the user who acted. actor_username is a snapshot, so the event stays readable when the user is deleted, and holds the attempted username of a failed login.
  • action and action_label: the action identifier (e.g. user.role_changed) and its readable label.
  • target_type, target_id, target_label: what the action was about (e.g. user / 42 / alice; agent_key, enrollment_token, api_token, relay_key, sla_policy, suppression_rule, notification_channel, image, agent).
  • ip and user_agent: the client address and browser/tool of the request.
  • changes: a small JSON object describing the change (e.g. {"from": "viewer", "to": "manager"}).

Append-Only and Secret-Free

Audit events cannot be edited or deleted: the API has no write endpoint (POST, PUT, PATCH and DELETE answer 405), the Django admin shows them read-only, and the model refuses updates and deletes. The only deletion is the retention purge.

  • Secrets never reach changes: any key containing password, secret, token, key, otp, backup_code or url has its value replaced by "[redacted]" (keys ending in prefix or _changed, such as key_prefix or url_changed, are kept).
  • Long strings are cut to 500 characters; a changes object larger than 4 KB is replaced by {"truncated": true, "keys": [...]}.
  • Writing an event never blocks the action: if the audit write fails, the error is logged and the login or change goes through.

Audit Log Page

Admins open Audit Log (/dashboard/admin/audit) in the Platform section of the sidebar, right after User Management; managers and viewers do not see the page nor the menu entry. The table shows time, actor, action, target, IP and a compact view of the changes, newest first, with pagination.

  • Filters: Actor (username contains, case-insensitive), Action, Target type, Target ID, From and To (whole UTC days, inclusive).
  • Actor and Target ID apply on Enter or after a short pause while typing; the other filters apply immediately.
  • Filters live in the URL: links can be shared, and Back / Forward restore the previous filters.
  • Export downloads the filtered events as CSV or Excel (XLSX), with the same filters as the table; cells starting with = + - @ are neutralised against spreadsheet formula injection.
Audit log of platform events

API

All endpoints require the admin role (401 without login, 403 for managers and viewers).

  • GET /api/v1/audit/events/: paginated list (page, page_size) with the filters actor, action, target_type, target_id, created_after and created_before (YYYY-MM-DD). An unknown action or an invalid date answers 400.
  • GET /api/v1/audit/events/export/?format=csv|xlsx&sep=comma|semicolon: the same filters, CSV by default.
  • GET /api/v1/audit/events/options/: {"actions": [{"value", "label"}], "target_types": [...]} for the filter choices.

Retention and Configuration

A daily task (apps.audit.tasks.purge_audit_events) deletes the events older than AUDIT_RETENTION_DAYS.

  • AUDIT_RETENTION_DAYS: days of audit history to keep (default 730, about two years). 0 or a negative value keeps every event.
  • AUDIT_TRUSTED_PROXIES: comma-separated CIDR ranges of the reverse proxies whose X-Real-IP header is trusted as the client IP (default 127.0.0.1/32,::1/128). The bundled nginx sets X-Real-IP; set this to the nginx container address (a /32) when it runs on another IP. From any other address the connection address is recorded, so a client cannot fake its IP.

Audit Log vs. Finding Timeline

The audit log records platform administration and access. Decisions on individual security findings (status and severity changes, comments, assignments, risk acceptance) have their own append-only history: the finding timeline, shown on each finding. See Finding Timeline (/docs/security/finding-timeline) and GET /api/v1/security/findings/<id>/events/.

Other Tracking Fields

Beyond the audit log, records keep their own tracking fields: created_at / updated_at timestamps, the discovery job history (status, duration, results, errors), agent last_seen and last_data_received, API key last_used, and the provenance of each asset (discovered_by, first discovered, discovery zone).