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
53098c16
Commit
53098c16
authored
Dec 06, 2021
by
Alexander Turinske
Committed by
Nicolò Maria Mezzopera
Dec 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update scan execution policy drawer
parent
969ab7fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/scan_execution_policy/lib/humanize.js
...nents/policy_editor/scan_execution_policy/lib/humanize.js
+7
-1
ee/spec/frontend/threat_monitoring/components/policy_editor/scan_execution_policy/lib/humanize_spec.js
.../policy_editor/scan_execution_policy/lib/humanize_spec.js
+15
-7
locale/gitlab.pot
locale/gitlab.pot
+3
-0
No files found.
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/scan_execution_policy/lib/humanize.js
View file @
53098c16
...
...
@@ -47,6 +47,12 @@ const humanizePipelineRule = (rule) => {
};
const
humanizeScheduleRule
=
(
rule
)
=>
{
if
(
rule
.
clusters
)
{
return
sprintf
(
s__
(
'
SecurityOrchestration|Scan to be performed %{cadence}
'
),
{
cadence
:
humanizeCadence
(
rule
.
cadence
),
});
}
return
sprintf
(
s__
(
'
SecurityOrchestration|Scan to be performed %{cadence} on the %{branches}
'
),
{
cadence
:
humanizeCadence
(
rule
.
cadence
),
branches
:
humanizeBranches
(
rule
.
branches
),
...
...
@@ -74,7 +80,7 @@ export const humanizeActions = (actions) => {
*/
export
const
humanizeRules
=
(
rules
)
=>
{
const
humanizedRules
=
rules
.
reduce
((
acc
,
curr
)
=>
{
return
curr
.
branches
?
[...
acc
,
HUMANIZE_RULES_METHODS
[
curr
.
type
](
curr
)]
:
acc
;
return
curr
.
branches
||
curr
.
clusters
?
[...
acc
,
HUMANIZE_RULES_METHODS
[
curr
.
type
](
curr
)]
:
acc
;
},
[]);
return
humanizedRules
.
length
?
humanizedRules
:
[
NO_RULE_MESSAGE
];
...
...
ee/spec/frontend/threat_monitoring/components/policy_editor/scan_execution_policy/lib/humanize_spec.js
View file @
53098c16
...
...
@@ -4,6 +4,13 @@ import {
NO_RULE_MESSAGE
,
}
from
'
ee/threat_monitoring/components/policy_editor/scan_execution_policy/lib
'
;
jest
.
mock
(
'
~/locale
'
,
()
=>
({
getPreferredLocales
:
jest
.
fn
().
mockReturnValue
([
'
en
'
]),
sprintf
:
jest
.
requireActual
(
'
~/locale
'
).
sprintf
,
s__
:
jest
.
requireActual
(
'
~/locale
'
).
s__
,
// eslint-disable-line no-underscore-dangle
n__
:
jest
.
requireActual
(
'
~/locale
'
).
n__
,
// eslint-disable-line no-underscore-dangle
}));
const
mockActions
=
[
{
scan
:
'
dast
'
,
scanner_profile
:
'
Scanner Profile
'
,
site_profile
:
'
Site Profile
'
},
{
scan
:
'
dast
'
,
scanner_profile
:
'
Scanner Profile 01
'
,
site_profile
:
'
Site Profile 01
'
},
...
...
@@ -14,6 +21,11 @@ const mockRules = [
{
type
:
'
schedule
'
,
cadence
:
'
*/10 * * * *
'
,
branches
:
[
'
main
'
]
},
{
type
:
'
pipeline
'
,
branches
:
[
'
release/*
'
,
'
staging
'
]
},
{
type
:
'
pipeline
'
,
branches
:
[
'
release/1.*
'
,
'
canary
'
,
'
staging
'
]
},
{
type
:
'
schedule
'
,
cadence
:
'
* */20 4 * *
'
,
clusters
:
{
protect
:
{
namespaces
:
[
'
default-cluster
'
]
}
},
},
{
type
:
'
pipeline
'
},
];
...
...
@@ -34,17 +46,12 @@ describe('humanizeActions', () => {
});
describe
(
'
humanizeRules
'
,
()
=>
{
beforeEach
(()
=>
{
// Need to spy on window.navigator.languages as it is read-only
jest
.
spyOn
(
window
.
navigator
,
'
languages
'
,
'
get
'
).
mockReturnValueOnce
([
'
en
'
]);
});
it
(
'
returns the empty rules message in an Array if no rules are specified
'
,
()
=>
{
expect
(
humanizeRules
([])).
toStrictEqual
([
NO_RULE_MESSAGE
]);
});
it
(
'
returns the empty rules message in an Array if a single rule is passed in without a branch
'
,
()
=>
{
expect
(
humanizeRules
([])).
toStrictEqual
([
NO_RULE_MESSAGE
]);
it
(
'
returns the empty rules message in an Array if a single rule is passed in without a branch
or cluster
'
,
()
=>
{
expect
(
humanizeRules
([
mockRules
[
4
]
])).
toStrictEqual
([
NO_RULE_MESSAGE
]);
});
it
(
'
returns a single rule as a human-readable string
'
,
()
=>
{
...
...
@@ -58,6 +65,7 @@ describe('humanizeRules', () => {
'
Scan to be performed every 10 minutes, every hour, every day on the main branch
'
,
'
Scan to be performed on every pipeline on the release/* and staging branches
'
,
'
Scan to be performed on every pipeline on the release/1.*, canary and staging branches
'
,
'
Scan to be performed every minute, every 20 hours, on day 4 of the month
'
,
]);
});
});
locale/gitlab.pot
View file @
53098c16
...
...
@@ -30959,6 +30959,9 @@ msgstr ""
msgid "SecurityOrchestration|Scan execution policies can only be created by project owners."
msgstr ""
msgid "SecurityOrchestration|Scan to be performed %{cadence}"
msgstr ""
msgid "SecurityOrchestration|Scan to be performed %{cadence} on the %{branches}"
msgstr ""
...
...
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