Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
86775169
Commit
86775169
authored
Jan 14, 2022
by
Zamir Martins
Committed by
Alex Kalderimis
Jan 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit the amount of rules per policy to 5
EE: true
parent
21502cab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-1
ee/app/services/security/security_orchestration_policies/process_scan_result_policy_service.rb
...hestration_policies/process_scan_result_policy_service.rb
+1
-1
ee/app/validators/json_schemas/security_orchestration_policy.json
...alidators/json_schemas/security_orchestration_policy.json
+1
-0
ee/spec/services/security/security_orchestration_policies/process_scan_result_policy_service_spec.rb
...ation_policies/process_scan_result_policy_service_spec.rb
+35
-0
No files found.
ee/app/services/security/security_orchestration_policies/process_scan_result_policy_service.rb
View file @
86775169
...
@@ -27,7 +27,7 @@ module Security
...
@@ -27,7 +27,7 @@ module Security
action_info
=
policy
[
:actions
].
find
{
|
action
|
action
[
:type
]
==
Security
::
ScanResultPolicy
::
REQUIRE_APPROVAL
}
action_info
=
policy
[
:actions
].
find
{
|
action
|
action
[
:type
]
==
Security
::
ScanResultPolicy
::
REQUIRE_APPROVAL
}
return
unless
action_info
return
unless
action_info
policy
[
:rules
].
each_with_index
do
|
rule
,
rule_index
|
policy
[
:rules
].
first
(
Security
::
ScanResultPolicy
::
LIMIT
).
each_with_index
do
|
rule
,
rule_index
|
next
if
rule
[
:type
]
!=
Security
::
ScanResultPolicy
::
SCAN_FINDING
next
if
rule
[
:type
]
!=
Security
::
ScanResultPolicy
::
SCAN_FINDING
::
ApprovalRules
::
CreateService
.
new
(
project
,
author
,
rule_params
(
rule
,
rule_index
,
action_info
)).
execute
::
ApprovalRules
::
CreateService
.
new
(
project
,
author
,
rule_params
(
rule
,
rule_index
,
action_info
)).
execute
...
...
ee/app/validators/json_schemas/security_orchestration_policy.json
View file @
86775169
...
@@ -238,6 +238,7 @@
...
@@ -238,6 +238,7 @@
},
},
"rules"
:
{
"rules"
:
{
"type"
:
"array"
,
"type"
:
"array"
,
"maxItems"
:
5
,
"additionalItems"
:
false
,
"additionalItems"
:
false
,
"items"
:
{
"items"
:
{
"type"
:
"object"
,
"type"
:
"object"
,
...
...
ee/spec/services/security/security_orchestration_policies/process_scan_result_policy_service_spec.rb
View file @
86775169
...
@@ -77,6 +77,41 @@ RSpec.describe Security::SecurityOrchestrationPolicies::ProcessScanResultPolicyS
...
@@ -77,6 +77,41 @@ RSpec.describe Security::SecurityOrchestrationPolicies::ProcessScanResultPolicyS
it_behaves_like
'create approval rule with specific approver'
it_behaves_like
'create approval rule with specific approver'
end
end
context
'with a specific number of rules'
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:rule
)
do
{
type:
'scan_finding'
,
branches:
%w[master]
,
scanners:
%w[container_scanning]
,
vulnerabilities_allowed:
0
,
severity_levels:
%w[critical]
,
vulnerability_states:
%w[detected]
}
end
let
(
:rules
)
{
[
rule
]
*
rules_count
}
let
(
:policy
)
{
build
(
:scan_result_policy
,
name:
'Test Policy'
,
rules:
rules
)
}
where
(
:rules_count
,
:expected_rules_count
)
do
[
[
Security
::
ScanResultPolicy
::
LIMIT
-
1
,
Security
::
ScanResultPolicy
::
LIMIT
-
1
],
[
Security
::
ScanResultPolicy
::
LIMIT
,
Security
::
ScanResultPolicy
::
LIMIT
],
[
Security
::
ScanResultPolicy
::
LIMIT
+
1
,
Security
::
ScanResultPolicy
::
LIMIT
]
]
end
with_them
do
it
'creates approval rules up to limit'
do
subject
expect
(
project
.
approval_rules
.
count
).
to
be
expected_rules_count
end
end
end
it
'sets project approval rules names based on policy name'
,
:aggregate_failures
do
it
'sets project approval rules names based on policy name'
,
:aggregate_failures
do
subject
subject
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment