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
63718b04
Commit
63718b04
authored
Jan 27, 2022
by
Zamir Martins Filho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add text for all branches
on scan result policy drawer. EE: true Changelog: changed
parent
99be341f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
7 deletions
+45
-7
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/scan_result_policy/lib/humanize.js
...mponents/policy_editor/scan_result_policy/lib/humanize.js
+23
-6
ee/spec/frontend/threat_monitoring/components/policy_editor/scan_result_policy/lib/humanize_spec.js
...nts/policy_editor/scan_result_policy/lib/humanize_spec.js
+15
-0
locale/gitlab.pot
locale/gitlab.pot
+7
-1
No files found.
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/scan_result_policy/lib/humanize.js
View file @
63718b04
...
...
@@ -64,6 +64,27 @@ const humanizeItems = ({
return
finalSentence
.
join
(
''
);
};
/**
* Create a human-readable version of the branches
* @param {Array} branches
* @returns {String}
*/
const
humanizeBranches
=
(
branches
)
=>
{
const
hasNoBranch
=
branches
.
length
===
0
;
if
(
hasNoBranch
)
{
return
s__
(
'
SecurityOrchestration|all branches
'
);
}
return
sprintf
(
s__
(
'
SecurityOrchestration|the %{branches}
'
),
{
branches
:
humanizeItems
({
items
:
branches
,
singular
:
s__
(
'
SecurityOrchestration|branch
'
),
plural
:
s__
(
'
SecurityOrchestration|branches
'
),
}),
});
};
/**
* Create a human-readable string, adding the necessary punctuation and conjunctions
* @param {Object} action containing or not arrays of string and integers representing approvers
...
...
@@ -146,7 +167,7 @@ export const humanizeAction = (action) => {
const
humanizeRule
=
(
rule
)
=>
{
return
sprintf
(
s__
(
'
SecurityOrchestration|The %{scanners} %{severities} in an open merge request targeting
the
%{branches}.
'
,
'
SecurityOrchestration|The %{scanners} %{severities} in an open merge request targeting %{branches}.
'
,
),
{
scanners
:
humanizeItems
({
...
...
@@ -160,11 +181,7 @@ const humanizeRule = (rule) => {
plural
:
s__
(
'
SecurityOrchestration|vulnerabilities
'
),
hasArticle
:
true
,
}),
branches
:
humanizeItems
({
items
:
rule
.
branches
,
singular
:
s__
(
'
SecurityOrchestration|branch
'
),
plural
:
s__
(
'
SecurityOrchestration|branches
'
),
}),
branches
:
humanizeBranches
(
rule
.
branches
),
},
);
};
...
...
ee/spec/frontend/threat_monitoring/components/policy_editor/scan_result_policy/lib/humanize_spec.js
View file @
63718b04
...
...
@@ -59,6 +59,15 @@ const mockRules = [
},
];
const
mockRulesEmptyBranch
=
{
type
:
'
scan_finding
'
,
branches
:
[],
scanners
:
[
'
sast
'
],
vulnerabilities_allowed
:
1
,
severity_levels
:
[
'
critical
'
],
vulnerability_states
:
[
'
newly_detected
'
],
};
describe
(
'
humanizeRules
'
,
()
=>
{
it
(
'
returns the empty rules message in an Array if no rules are specified
'
,
()
=>
{
expect
(
humanizeRules
([])).
toStrictEqual
([
NO_RULE_MESSAGE
]);
...
...
@@ -76,6 +85,12 @@ describe('humanizeRules', () => {
'
The dast or sast scanners find info or critical vulnerabilities in an open merge request targeting the master or main branches.
'
,
]);
});
it
(
'
returns a single rule as a human-readable string for all branches
'
,
()
=>
{
expect
(
humanizeRules
([
mockRulesEmptyBranch
])).
toStrictEqual
([
'
The sast scanner finds a critical vulnerability in an open merge request targeting all branches.
'
,
]);
});
});
describe
(
'
humanizeAction
'
,
()
=>
{
...
...
locale/gitlab.pot
View file @
63718b04
...
...
@@ -31828,7 +31828,7 @@ msgstr ""
msgid "SecurityOrchestration|Status"
msgstr ""
msgid "SecurityOrchestration|The %{scanners} %{severities} in an open merge request targeting
the
%{branches}."
msgid "SecurityOrchestration|The %{scanners} %{severities} in an open merge request targeting %{branches}."
msgstr ""
msgid "SecurityOrchestration|There was a problem creating the new security policy"
...
...
@@ -31852,6 +31852,9 @@ msgstr ""
msgid "SecurityOrchestration|a"
msgstr ""
msgid "SecurityOrchestration|all branches"
msgstr ""
msgid "SecurityOrchestration|an"
msgstr ""
...
...
@@ -31879,6 +31882,9 @@ msgstr ""
msgid "SecurityOrchestration|scanners find"
msgstr ""
msgid "SecurityOrchestration|the %{branches}"
msgstr ""
msgid "SecurityOrchestration|user with id"
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