Skip to content

bug: POST /api/settings/ops/reset writes no audit entry — ent#297's audit half stopped one route short #1966

Description

@vybe

ent#297 / PR #1893 added validation and an audit entry (ops_settings_change) to PUT /api/settings/ops/config. It did not add one to POST /api/settings/ops/reset, but both the PR body and the architecture.md prose it landed read as though it covered both:

Writes are audited. Neither this endpoint nor /ops/reset logged anything, while the generic PUT /{key} directly above them does…

…neither this route nor /ops/reset logged anything before

reset_ops_settings (src/backend/routers/settings.py:2661) is admin-only, deletes rows for every key in OPS_SETTINGS_DEFAULTS, and writes no audit entry.

Scope of what's still unlogged

The retention claim in that prose does hold — reset correctly continues over RETENTION_OPS_KEYS (#1638), so it cannot shrink a retention window. What it can silently reset with no trace:

  • ssh_access_enabled — the security-relevant one; resetting it changes whether ephemeral SSH credentials can be minted at all
  • ops_context_warning_threshold / ops_context_critical_threshold
  • ops_idle_timeout_minutes, ops_max_execution_minutes, ops_alert_suppression_minutes
  • ops_cost_limit_daily_usd
  • ops_health_check_interval
  • ops_log_retention_days

So the asymmetry ent#297 objected to still exists one route over: the generic PUT /{key} audits, /ops/config now audits, /ops/reset doesn't.

Fix

Mirror the /ops/config call — platform_audit_service.log(event_type=AuditEventType.CONFIGURATION, event_action="ops_settings_reset", …) with the reset and skipped key lists in details (keys and counts only; the values are being deleted, and none of these keys is a secret). request is already a parameter on the handler, so actor_ip / endpoint / request_id need no signature change.

Either that, or narrow the two prose claims to /ops/config — but auditing it is four lines and closes the class rather than documenting around it.

Acceptance

  • POST /api/settings/ops/reset writes a CONFIGURATION audit entry naming which keys were reset and which were skipped
  • A test asserts the entry is written (and that retention keys appear under skipped, never reset)
  • architecture.md's "neither this route nor /ops/reset logged anything before" is true after the change

Follow-up to trinity-enterprise#297 · surfaced in review of #1893.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions