Audit changes to the Compliance and Security Policy group
What does this MR do and why?
When an instance administrator designates or changes the Compliance and Security Policy (CSP) group through PUT /api/v4/admin/security/compliance_policy_settings, no audit event was recorded. The CSP group propagates policies and compliance frameworks across the whole instance, so changes to it need a tamper-evident record.
This MR records an instance-scoped compliance_and_security_policy_group_updated audit event from the API whenever csp_namespace_id actually changes:
| Scenario | Message |
|---|---|
| First assignment | Assigned <group_path> as the Compliance and Security Policy group |
| Change | Changed the Compliance and Security Policy group from <old_path> to <new_path> |
Removal (csp_namespace_id: null) |
Removed <group_path> as the Compliance and Security Policy group |
The previous and new group paths are also stored in the event details as from and to. The event is saved to the database and streamed. No event is recorded when the value is unchanged or the update fails validation.
Also included: the audit event type definition, the row in doc/user/compliance/audit_event_types.md, and request specs for all five cases.
The issue only lists assignment and change. Removal is included because the API accepts null, and clearing the CSP group is as security-relevant as setting it. The introduced_by_mr link will be updated to this MR in a follow-up commit.
References
Resolves #601730
Screenshots or screen recordings
Not applicable. Backend only.
How to set up and validate locally
-
On a self-managed GDK with an Ultimate licence, as an administrator:
curl --request PUT --header "PRIVATE-TOKEN: <admin token>" \ "http://gdk.test:3000/api/v4/admin/security/compliance_policy_settings?csp_namespace_id=<top level group id>" -
Go to Admin > Monitoring > Audit events. An event with the message
Assigned <group_path> as the Compliance and Security Policy groupis listed. -
Repeat with a different top-level group ID. The new event says
Changed the Compliance and Security Policy group from ... to ....
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.