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
efbe0455
Commit
efbe0455
authored
Oct 12, 2021
by
David Pisek
Committed by
Kushal Pandya
Oct 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vulnerability helper: use util to get GraphQL-id
parent
3b3dce4a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
11 deletions
+8
-11
ee/app/assets/javascripts/vulnerabilities/constants.js
ee/app/assets/javascripts/vulnerabilities/constants.js
+0
-3
ee/app/assets/javascripts/vulnerabilities/helpers.js
ee/app/assets/javascripts/vulnerabilities/helpers.js
+3
-3
ee/spec/frontend/vulnerabilities/helpers_spec.js
ee/spec/frontend/vulnerabilities/helpers_spec.js
+4
-4
ee/spec/frontend/vulnerabilities/vulnerability_spec.js
ee/spec/frontend/vulnerabilities/vulnerability_spec.js
+1
-1
No files found.
ee/app/assets/javascripts/vulnerabilities/constants.js
View file @
efbe0455
...
...
@@ -6,9 +6,6 @@ import {
const
falsePositiveMessage
=
s__
(
'
VulnerabilityManagement|Will not fix or a false-positive
'
);
export
const
gidPrefix
=
'
gid://gitlab/Vulnerability/
'
;
export
const
uidPrefix
=
'
gid://gitlab/User/
'
;
export
const
VULNERABILITY_STATE_OBJECTS
=
{
detected
:
{
action
:
'
revert
'
,
...
...
ee/app/assets/javascripts/vulnerabilities/helpers.js
View file @
efbe0455
import
{
getIdFromGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
{
isAbsolute
,
isSafeURL
}
from
'
~/lib/utils/url_utility
'
;
import
{
REGEXES
,
gidPrefix
,
uidPrefix
}
from
'
./constants
'
;
import
{
REGEXES
}
from
'
./constants
'
;
// Get the issue in the format expected by the descendant components of related_issues_block.vue.
export
const
getFormattedIssue
=
(
issue
)
=>
({
...
...
@@ -53,7 +53,7 @@ export const normalizeGraphQLVulnerability = (vulnerability) => {
const
newVulnerability
=
{
...
vulnerability
};
if
(
vulnerability
.
id
)
{
newVulnerability
.
id
=
vulnerability
.
id
.
replace
(
gidPrefix
,
''
);
newVulnerability
.
id
=
getIdFromGraphQLId
(
vulnerability
.
id
);
}
if
(
vulnerability
.
state
)
{
...
...
@@ -62,7 +62,7 @@ export const normalizeGraphQLVulnerability = (vulnerability) => {
[
'
confirmed
'
,
'
resolved
'
,
'
dismissed
'
].
forEach
((
state
)
=>
{
if
(
vulnerability
[
`
${
state
}
By`
]?.
id
)
{
newVulnerability
[
`
${
state
}
ById`
]
=
vulnerability
[
`
${
state
}
By`
].
id
.
replace
(
uidPrefix
,
''
);
newVulnerability
[
`
${
state
}
ById`
]
=
getIdFromGraphQLId
(
vulnerability
[
`
${
state
}
By`
].
id
);
delete
newVulnerability
[
`
${
state
}
By`
];
}
});
...
...
ee/spec/frontend/vulnerabilities/helpers_spec.js
View file @
efbe0455
...
...
@@ -57,11 +57,11 @@ describe('Vulnerabilities helpers', () => {
id
:
'
gid://gitlab/Vulnerability/54
'
,
}),
).
toEqual
({
confirmedById
:
'
16
'
,
resolvedById
:
'
16
'
,
dismissedById
:
'
16
'
,
confirmedById
:
16
,
resolvedById
:
16
,
dismissedById
:
16
,
state
:
'
dismissed
'
,
id
:
'
54
'
,
id
:
54
,
});
});
});
...
...
ee/spec/frontend/vulnerabilities/vulnerability_spec.js
View file @
efbe0455
...
...
@@ -137,7 +137,7 @@ describe('Vulnerability', () => {
expect
(
refreshVulnerability
).
toHaveBeenCalledTimes
(
1
);
await
waitForPromises
();
expect
(
findHeader
().
props
(
'
vulnerability
'
)).
toEqual
(
getVulnerability
({
id
:
'
54
'
,
state
:
'
resolved
'
,
resolvedAt
:
'
2020-09-16T11:13:26Z
'
}),
getVulnerability
({
id
:
54
,
state
:
'
resolved
'
,
resolvedAt
:
'
2020-09-16T11:13:26Z
'
}),
);
});
});
...
...
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