Implement audit events related to security policy violations in merge requests

Description

This task involves implementing audit events for security policy violations in merge requests to help security and compliance teams monitor policy enforcement and violations.

Links / references

Use Cases

  • Generate an audit event when a policy violation is detected from an MR approval policy ( Stream only )
  • Generate an audit event when a policy violation is resolved in the same MR ( Stream only )
  • Generate an audit event when an MR is merged with violations, differentiating between:
    • Violated MR merged with approval
    • MR merged without policy-related approval due to "fail open" configuration

Implementation Details

Technical Considerations:

  • When MR is merged with violations, there can be two types of scenarios: 1. Violated MR was merged with approval, and 2. The policy was "fail open" and user was able to merge the MR without policy-related approval. Track both types of events but with a differentiation to help identify the events.
  • Do not track policy violations with MR approval policy type "any_merge_request"

Success Criteria

  • Audit events are generated for all violation scenarios with differentiate between different violation scenarios

Verification Steps

Edited by 🤖 GitLab Bot 🤖