Persist license_scanning violations in security_policy_dismissals
What does this MR do and why?
This MR updates the dismiss_policy_violations_service to persist the license_finding violation data when a policy in warn mode is dismissed/bypassed.
The changes are behind the new feature flag security_policy_warn_mode_license_scanning, since the previous warn mode feature flag is already enabled on GitLab.com.
This MR also reverts the changes from MR !205695 (diffs) to allow the creation of a warn mode policy with license_finding rules.
References
Related to: #570791
How to set up and validate locally
- Enable the feature flag
security_policy_warn_mode_license_scanningFeature.enable(:security_policy_warn_mode_license_scanning) - Create a new project
- Add a
.gitlab-ci.ymlfile with the content
include:
- template: Jobs/Dependency-Scanning.v2.gitlab-ci.yml
- Go to Secure > Policies
- Click on New policy
- Select Merge request approval policy
- Create a new policy with the enforcement_type: warn to deny MIT Licenses
approval_policy:
- name: Deny MIT
description: ''
enabled: true
enforcement_type: warn
rules:
- type: license_finding
match_on_inclusion_license: true
license_types:
- MIT License
license_states:
- newly_detected
branch_type: protected
actions:
- type: require_approval
approvals_required: 1
role_approvers:
- developer
- type: send_bot_message
enabled: true
- Click on Configure with a merge request
- Merge the new MR to add the policy
- Create a new MR adding a
Gemfile.lockfile with the following content:
GEM
remote: https://rubygems.org/
specs:
rack (3.0.4.1)
PLATFORMS
arm64-darwin-22
DEPENDENCIES
rack
BUNDLED WITH
2.4.22
- Verify that the policy blocked the MR
- Go to
/-/graphql-explorerand dismiss the policy using the query
mutation DismissPolicyViolations($projectPath: ID!, $mergeRequestIid: String!, $securityPolicyIds: [ID!]!, $dismissalTypes: [DismissalType!]!, $comment: String!) {
dismissPolicyViolations(input: {
projectPath: $projectPath,
iid: $mergeRequestIid,
securityPolicyIds: $securityPolicyIds,
dismissalTypes: $dismissalTypes,
comment: $comment
}) {
errors
}
}
{
"projectPath": "project_Path",
"mergeRequestIid": "MR_IID",
"securityPolicyIds": [Policy_Id],
"dismissalTypes": ["SCANNER_FALSE_POSITIVE"],
"comment": "false positive"
}
- Verify the license violation information was persisted in the policy dismissal
Security::PolicyDismissal.last
=> #<Security::PolicyDismissal:0x0000000139369608
id: 9,
created_at: Wed, 05 Nov 2025 19:24:35.862239000 UTC +00:00,
updated_at: Wed, 05 Nov 2025 19:24:35.862239000 UTC +00:00,
project_id: 234,
merge_request_id: 512,
security_policy_id: 152,
user_id: 1,
security_findings_uuids: [],
dismissal_types: [1],
comment: "false positive",
status: "open",
license_occurrence_uuids: [],
licenses: {"MIT License" => ["rack"]}>
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.
Edited by Marcos Rocha