Draft: [Spike] MR Widget - Backend MVC for MR Approval Policies Warn Mode
What does this MR do and why?
Introduces enforcement_type for scan result policies, allowing them to be configured as 'warn' or 'enforce'. 'Warn' mode policies will not block merge requests if their violations are dismissed, providing more flexibility in security policy enforcement.
This includes database schema updates, model changes, and mergeability service adjustments to support the new behavior.
References
Screenshots or screen recordings
Monosnap_screencast_2025-08-22_5_PM-59-37
| Before | After |
|---|---|
How to set up and validate locally
- Create security policy for a project
---
approval_policy:
- name: MR - Security Scan
description: Security Scan
enabled: true
enforcement_type: "warn"
rules:
- type: scan_finding
scanners:
- sast
vulnerabilities_allowed: 0
severity_levels: []
vulnerability_states: []
branch_type: protected
actions:
- type: require_approval
approvals_required: 1
role_approvers:
- developer
- maintainer
- owner
- type: send_bot_message
enabled: true
approval_settings:
block_branch_modification: false
prevent_pushing_and_force_pushing: false
prevent_approval_by_author: false
prevent_approval_by_commit_author: false
remove_approvals_with_new_commit: false
require_password_to_approve: false
fallback_behavior:
fail: open
- Create MR with security policy violations - MR is blocked from security policy violations
- Dismiss the violations
mr = MergeRequest.find(<id>)
project = Project.find_by_full_path(<path>)
Security::SecurityOrchestrationPolicies::DismissForMergeRequestService.new(mr, proj
ect.security_policies.first, User.find_by_username('root') ).execute
- MR is unblocked and allowed to merged
- Make additional commits in the MR, the dismissal is persisted
- Introduce new violations for the same policy - MR is blocked again
- [For testing purpose] If we delete the dismissal records, MR is blocked again
Security::PolicyDismissal.where(merge_request: @mr).delete_all
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #536153 (closed)
Edited by Imam Hossain