Skip to content
代码片段 群组 项目
未验证 提交 ba9f8809 编辑于 作者: Sashi Kumar Kumaresan's avatar Sashi Kumar Kumaresan 提交者: GitLab
浏览文件

Merge branch 'mc/fix-unviolated-rules-violations' into 'master'

Fix policy violations not being deleted properly

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/168373



Merged-by: default avatarSashi Kumar Kumaresan <skumar@gitlab.com>
Approved-by: default avatarSashi Kumar Kumaresan <skumar@gitlab.com>
Co-authored-by: default avatarMartin Čavoj <mcavoj@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -47,7 +47,7 @@ def update_required_approvals(violated_rules, unviolated_rules) ...@@ -47,7 +47,7 @@ def update_required_approvals(violated_rules, unviolated_rules)
ApprovalMergeRequestRule.remove_required_approved(unviolated_rules) if unviolated_rules.any? ApprovalMergeRequestRule.remove_required_approved(unviolated_rules) if unviolated_rules.any?
log_violated_rules(violated_rules) log_violated_rules(violated_rules)
violations.add(violated_rules.map(&:scan_result_policy_read), unviolated_rules) violations.add(violated_rules.map(&:scan_result_policy_read), unviolated_rules.map(&:scan_result_policy_read))
violations.execute violations.execute
end end
......
...@@ -57,7 +57,7 @@ def update_approvals(license_approval_rules) ...@@ -57,7 +57,7 @@ def update_approvals(license_approval_rules)
merge_request.reset_required_approvals(violated_rules) merge_request.reset_required_approvals(violated_rules)
ApprovalMergeRequestRule.remove_required_approved(unviolated_rules) ApprovalMergeRequestRule.remove_required_approved(unviolated_rules)
violations.add(violated_rules.map(&:scan_result_policy_read), unviolated_rules) violations.add(violated_rules.map(&:scan_result_policy_read), unviolated_rules.map(&:scan_result_policy_read))
violations.execute violations.execute
violated_rules.each do |approval_rule| violated_rules.each do |approval_rule|
......
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
it_behaves_like 'sets approvals_required to 0' it_behaves_like 'sets approvals_required to 0'
it_behaves_like 'triggers policy bot comment', :scan_finding, false it_behaves_like 'triggers policy bot comment', :scan_finding, false
it_behaves_like 'does not log violations' it_behaves_like 'does not log violations'
it_behaves_like 'merge request without scan result violations', previous_violation: false it_behaves_like 'merge request without scan result violations'
context 'when there are other scan_finding violations' do context 'when there are other scan_finding violations' do
let_it_be_with_reload(:scan_result_policy_read_other_scan_finding) do let_it_be_with_reload(:scan_result_policy_read_other_scan_finding) do
......
...@@ -31,10 +31,14 @@ ...@@ -31,10 +31,14 @@
let_it_be(:preexisting_states) { false } let_it_be(:preexisting_states) { false }
let(:scan_result_policy_read) do
create(:scan_result_policy_read, project: project, license_states: ['newly_detected'])
end
let!(:license_finding_rule) do let!(:license_finding_rule) do
create(:report_approver_rule, :license_scanning, create(:report_approver_rule, :license_scanning,
merge_request: merge_request, merge_request: merge_request,
scan_result_policy_read: create(:scan_result_policy_read, project: project, license_states: ['newly_detected']), scan_result_policy_read: scan_result_policy_read,
approvals_required: 1 approvals_required: 1
) )
end end
...@@ -96,7 +100,7 @@ ...@@ -96,7 +100,7 @@
end end
end end
context 'for prexisting states' do context 'for preexisting states' do
let_it_be(:preexisting_states) { true } let_it_be(:preexisting_states) { true }
let_it_be(:pipeline) { nil } let_it_be(:pipeline) { nil }
...@@ -142,6 +146,7 @@ ...@@ -142,6 +146,7 @@
it_behaves_like 'does not require approvals' it_behaves_like 'does not require approvals'
it_behaves_like 'triggers policy bot comment', :license_scanning, false it_behaves_like 'triggers policy bot comment', :license_scanning, false
it_behaves_like 'merge request without scan result violations'
it 'does not call logger' do it 'does not call logger' do
expect(Gitlab::AppJsonLogger).not_to receive(:info) expect(Gitlab::AppJsonLogger).not_to receive(:info)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册