Skip to content

Add a setting to leave request bodies out of the console and file audit logs - #1476

Merged
tomchop merged 1 commit into
yeti-platform:mainfrom
kev365:feat/audit-log-bodies-setting
Nov 19, 2026
Merged

tomchop merged 1 commit into
yeti-platform:mainfrom
kev365:feat/audit-log-bodies-setting

Conversation

@kev365

@kev365 kev365 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #1474.

Audit log lines carry the full request body, which for most requests is investigation data: observable values, context, search terms. This adds audit_log_bodies to [system] (also YETI_SYSTEM_AUDIT_LOG_BODIES). It defaults to true, which is today's behaviour.

With it set to false, the console and audit_logfile lines keep the time, user, path, method, client and status, and leave the body out:

2026-11-16 20:38:30,334 - yeti.audit.log - INFO - Authorized request - probe - /api/v2/observables/ - POST - 127.0.0.1 - 200
{"message": "Authorized request", "severity": "INFO", "timestamp": "2026-11-17T02:38:30.334243+00:00", "logger": "yeti.audit.log", "username": "probe", "path": "/api/v2/observables/", "method": "POST", "client": "127.0.0.1", "status_code": 200}

The auditlog collection still records the body. It sits in the same database as the objects themselves, so the setting only affects the copies that leave it.

How

  • JsonFormatter takes include_body.
  • The console format string is built by text_log_format(include_body). With the default it is the same string as before.
  • The handlers are set up with the setting's value. The record itself is not changed, since all three handlers share it and the database handler still needs the body.

Tests

Four in tests/core_tests/logger.py: the JSON line and the text line, each with the body by default and without it when asked, the other fields kept.

Against a running API with the setting off, 22 requests gave 22 console lines and 22 file lines with no request value in them, and the same 20 auditlog documents with their content as with the setting on.

Checks: ruff, ty and the three test directories in a CI-equivalent environment.

🤖 Generated with Claude Code

…it logs

Audit log lines carry the full request body, which for most requests is
investigation data: observable values, context, search terms. With
[system] audit_log_bodies set to false, the console and audit_logfile lines
keep the user, path, method, client and status and leave the body out. The
auditlog collection still records it. The default is true, which is the
behaviour until now.

JsonFormatter takes include_body, and the console format string comes from
text_log_format(); with the default it is the same string as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@tomchop
tomchop merged commit b649430 into yeti-platform:main Nov 19, 2026
5 checks passed
@kev365
kev365 deleted the feat/audit-log-bodies-setting branch November 20, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit log lines carry every request body: a setting to leave bodies out of the console and file logs

2 participants