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
78f9d9a8
Commit
78f9d9a8
authored
Jun 09, 2020
by
Savas Vedova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attach issue to the vulnerability
- Add tests - Add changelog
parent
69206ffd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
4 deletions
+150
-4
ee/app/assets/javascripts/vulnerabilities/components/issue_link.vue
...ets/javascripts/vulnerabilities/components/issue_link.vue
+32
-0
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_list.vue
...scripts/vulnerabilities/components/vulnerability_list.vue
+22
-4
ee/app/assets/javascripts/vulnerabilities/graphql/vulnerability.fragment.graphql
...ts/vulnerabilities/graphql/vulnerability.fragment.graphql
+10
-0
ee/changelogs/unreleased/197232-display-issue-created.yml
ee/changelogs/unreleased/197232-display-issue-created.yml
+5
-0
ee/spec/frontend/vulnerabilities/issue_link_spec.js
ee/spec/frontend/vulnerabilities/issue_link_spec.js
+60
-0
ee/spec/frontend/vulnerabilities/vulnerability_list_spec.js
ee/spec/frontend/vulnerabilities/vulnerability_list_spec.js
+21
-0
No files found.
ee/app/assets/javascripts/vulnerabilities/components/issue_link.vue
0 → 100644
View file @
78f9d9a8
<
script
>
import
{
GlIcon
,
GlLink
}
from
'
@gitlab/ui
'
;
export
default
{
components
:
{
GlIcon
,
GlLink
,
},
props
:
{
issue
:
{
type
:
Object
,
required
:
true
,
},
},
STATE_OPENED
:
'
opened
'
,
};
</
script
>
<
template
>
<gl-link
v-gl-tooltip=
"issue.title"
:href=
"issue.webUrl"
:data-testid=
"`issue-link-$
{issue.iid}`"
class="d-inline-flex align-items-center ml-2 gl-flex-shrink-0"
>
<gl-icon
class=
"mr-1"
:class=
"
{ cgreen: issue.state === $options.STATE_OPENED }"
:name="issue.state === $options.STATE_OPENED ? 'issue-open-m' : 'issue-close'"
/>
#
{{
issue
.
iid
}}
</gl-link>
</
template
>
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_list.vue
View file @
78f9d9a8
<
script
>
import
{
s__
,
__
}
from
'
~/locale
'
;
import
{
GlEmptyState
,
GlFormCheckbox
,
GlLink
,
GlSkeletonLoading
,
GlTable
}
from
'
@gitlab/ui
'
;
import
{
GlEmptyState
,
GlFormCheckbox
,
GlLink
,
GlSkeletonLoading
,
GlTable
,
GlTooltipDirective
,
}
from
'
@gitlab/ui
'
;
import
RemediatedBadge
from
'
./remediated_badge.vue
'
;
import
SeverityBadge
from
'
ee/vue_shared/security_reports/components/severity_badge.vue
'
;
import
SelectionSummary
from
'
ee/security_dashboard/components/selection_summary.vue
'
;
import
IssueLink
from
'
./issue_link.vue
'
;
import
{
VULNERABILITIES_PER_PAGE
}
from
'
../constants
'
;
export
default
{
...
...
@@ -14,10 +22,14 @@ export default {
GlLink
,
GlSkeletonLoading
,
GlTable
,
IssueLink
,
RemediatedBadge
,
SelectionSummary
,
SeverityBadge
,
},
directives
:
{
GlTooltip
:
GlTooltipDirective
,
},
props
:
{
dashboardDocumentation
:
{
type
:
String
,
...
...
@@ -143,6 +155,9 @@ export default {
this
.
$set
(
this
.
selectedVulnerabilities
,
`
${
vulnerability
.
id
}
`
,
vulnerability
);
}
},
issue
(
item
)
{
return
item
.
issueLinks
?.
nodes
[
0
]?.
issue
;
},
},
VULNERABILITIES_PER_PAGE
,
};
...
...
@@ -188,9 +203,12 @@ export default {
</
template
>
<
template
#cell(title)=
"{ item }"
>
<gl-link
class=
"text-body js-description"
:href=
"item.vulnerabilityPath"
>
{{
item
.
title
}}
</gl-link>
<div
class=
"d-flex flex-column flex-sm-row align-items-end align-items-sm-start"
>
<gl-link
class=
"text-body js-description"
:href=
"item.vulnerabilityPath"
>
{{
item
.
title
}}
</gl-link>
<issue-link
v-if=
"issue(item)"
:issue=
"issue(item)"
/>
</div>
<div
v-if=
"item.location"
:data-testid=
"`location-$
{item.id}`"
...
...
ee/app/assets/javascripts/vulnerabilities/graphql/vulnerability.fragment.graphql
View file @
78f9d9a8
...
...
@@ -4,6 +4,16 @@ fragment Vulnerability on Vulnerability {
state
severity
vulnerabilityPath
issueLinks
(
linkType
:
CREATED
)
{
nodes
{
issue
{
iid
webUrl
title
state
}
}
}
location
{
...
on
VulnerabilityLocationContainerScanning
{
image
...
...
ee/changelogs/unreleased/197232-display-issue-created.yml
0 → 100644
View file @
78f9d9a8
---
title
:
Show issue link on security dashboard when vulnerability has an issue
merge_request
:
34157
author
:
type
:
added
ee/spec/frontend/vulnerabilities/issue_link_spec.js
0 → 100644
View file @
78f9d9a8
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
getBinding
,
createMockDirective
}
from
'
helpers/vue_mock_directive
'
;
import
IssueLink
from
'
ee/vulnerabilities/components/issue_link.vue
'
;
describe
(
'
IssueLink component
'
,
()
=>
{
let
wrapper
;
const
createIssue
=
options
=>
({
title
:
'
my-issue
'
,
iid
:
12
,
webUrl
:
'
http://localhost/issues/~/12
'
,
...
options
,
});
const
createWrapper
=
({
propsData
})
=>
{
return
shallowMount
(
IssueLink
,
{
propsData
,
directives
:
{
GlTooltip
:
createMockDirective
(),
},
});
};
const
findIssueLink
=
id
=>
wrapper
.
find
(
`[data-testid="issue-link-
${
id
}
"]`
);
const
findIssueWithState
=
state
=>
wrapper
.
find
(
state
===
'
opened
'
?
'
issue-open-m
'
:
'
issue-close
'
);
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
describe
.
each
`
state | icon
${
'
opened
'
}
|
${
'
issue-open-m
'
}
${
'
closed
'
}
|
${
'
issue-close
'
}
`
(
'
when issue link is mounted
'
,
({
state
})
=>
{
describe
(
`with state
${
state
}
`
,
()
=>
{
const
issue
=
createIssue
({
state
});
beforeEach
(()
=>
{
wrapper
=
createWrapper
({
propsData
:
{
issue
}
});
});
test
(
'
should contain the correct issue icon
'
,
()
=>
{
expect
(
findIssueWithState
(
state
)).
toBeTruthy
();
});
test
(
'
should contain a link to the issue
'
,
()
=>
{
expect
(
findIssueLink
(
issue
.
iid
).
attributes
(
'
href
'
)).
toBe
(
issue
.
webUrl
);
});
test
(
'
should contain the title
'
,
()
=>
{
const
tooltip
=
getBinding
(
findIssueLink
(
issue
.
iid
).
element
,
'
gl-tooltip
'
);
expect
(
tooltip
).
toBeDefined
();
expect
(
tooltip
.
value
).
toBe
(
issue
.
title
);
});
});
});
});
ee/spec/frontend/vulnerabilities/vulnerability_list_spec.js
View file @
78f9d9a8
...
...
@@ -178,6 +178,27 @@ describe('Vulnerability list component', () => {
});
});
describe
(
'
when has an issue associated
'
,
()
=>
{
let
newVulnerabilities
;
beforeEach
(()
=>
{
newVulnerabilities
=
generateVulnerabilities
();
newVulnerabilities
[
0
].
issueLinks
=
{
nodes
:
[
{
issue
:
{
title
:
'
my-title
'
,
iid
:
114
,
state
:
'
opened
'
,
webUrl
:
'
http://localhost/issues/~/114
'
,
},
},
],
};
wrapper
=
createWrapper
({
props
:
{
vulnerabilities
:
newVulnerabilities
}
});
});
});
describe
(
'
when a vulnerability is resolved on the default branch
'
,
()
=>
{
let
newVulnerabilities
;
...
...
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