Sync MR approvals after dismissing finding for MR
What does this MR do and why?
This MR implements automatic synchronization of merge request approvals when security vulnerabilities are dismissed, addressing a critical workflow issue where MR approval policies don't get re-evaluated after vulnerability state changes.
Problem Statement
Currently, when developers dismiss vulnerabilities in an MR (marking them as false positives or creating issues to track them), the MR approval policies are not automatically re-evaluated. This forces developers to manually re-run the entire pipeline just to trigger policy re-evaluation, even though no new security findings will be discovered. This creates:
- Developer frustration: Unnecessary waiting for redundant pipeline runs
- Resource waste: Running full pipelines without adding value
- Workflow friction: Delays in MR delivery
- Reduced trust: In GitLab security automation
Solution
This MR adds automatic MR approval synchronization when vulnerabilities are dismissed by:
-
Scheduling a background worker (
Security::ScanResultPolicies::SyncMergeRequestApprovalsWorker) when vulnerabilities are dismissed - Using a 1-minute delay to allow for deduplication when multiple findings are dismissed simultaneously
- Only triggering for MRs that have associated pipelines with merge requests
-
Feature flag protection (
sync_mr_approvals_on_vulnerability_dismiss) for safe rollout
Implementation Details
-
Service Updated:
Security::Findings::DismissServicenow callsschedule_sync_merge_request_approvals_worker -
Feature Flag:
gitlab_com_derisktype for safe deployment and performance monitoring - Worker Scheduling: 1-minute delay prevents duplicate work when multiple vulnerabilities are dismissed
- Comprehensive Tests: Covers all scenarios including feature flag states, pipeline associations, and error conditions
Performance Considerations
- Scoped Impact: Only affects MRs with newly introduced vulnerabilities (single pipeline association)
- Deduplication: 1-minute delay allows batching of multiple dismissals
- Background Processing: Uses Sidekiq worker to avoid blocking the dismissal action
- Feature Flag: Allows immediate rollback if performance issues arise
Changelog: changed EE: true
References
Closes #560563
Screenshots or screen recordings
| Before | After |
|---|---|
| Developers must manually re-run pipelines after dismissing vulnerabilities to trigger policy re-evaluation | MR approval policies are automatically re-evaluated within 1 minute of vulnerability dismissal |
How to set up and validate locally
-
Enable the feature flag in rails console:
Feature.enable(:sync_mr_approvals_on_vulnerability_dismiss) -
Create a project with security scan result policies that include
new_dismissedvulnerability states -
Create an MR that introduces security vulnerabilities
-
Dismiss one or more vulnerabilities from the security findings
-
Verify that the
Security::ScanResultPolicies::SyncMergeRequestApprovalsWorkeris scheduled:# Check scheduled jobs Sidekiq::ScheduledSet.new.select { |job| job.klass == 'Security::ScanResultPolicies::SyncMergeRequestApprovalsWorker' } -
Wait 1 minute or manually execute the worker to see MR approval status update
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 #560563