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
6f6156f6
Commit
6f6156f6
authored
Nov 21, 2019
by
Daniel Tian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Open in new tab "Learn more about" links for security scanning popovers
parent
dac1e700
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
8 deletions
+53
-8
ee/app/assets/javascripts/vue_shared/security_reports/mixins/security_report_mixin.js
...e_shared/security_reports/mixins/security_report_mixin.js
+16
-8
ee/changelogs/unreleased/13333-secure-open-help-links-in-new-tab.yml
...gs/unreleased/13333-secure-open-help-links-in-new-tab.yml
+6
-0
ee/spec/frontend/vue_shared/security_reports/mixins/security_report_mixin_spec.js
...red/security_reports/mixins/security_report_mixin_spec.js
+31
-0
No files found.
ee/app/assets/javascripts/vue_shared/security_reports/mixins/security_report_mixin.js
View file @
6f6156f6
import
{
sprintf
,
s__
}
from
'
~/locale
'
;
// Securely open external links in a new tab.
function
getLinkStartTag
(
url
)
{
return
`<a href="
${
url
}
" target="_blank" rel="noopener noreferrer">`
;
}
// Add in the external link icon at the end of every link.
const
linkEndTag
=
'
<i class="fa fa-external-link" aria-hidden="true"></i></a>
'
;
export
default
{
computed
:
{
sastPopover
()
{
...
...
@@ -10,8 +18,8 @@ export default {
content
:
sprintf
(
s__
(
'
ciReport|%{linkStartTag}Learn more about SAST %{linkEndTag}
'
),
{
linkStartTag
:
`<a href="
${
this
.
sastHelpPath
}
">`
,
linkEndTag
:
'
</a>
'
,
linkStartTag
:
getLinkStartTag
(
this
.
sastHelpPath
)
,
linkEndTag
,
},
false
,
),
...
...
@@ -25,8 +33,8 @@ export default {
content
:
sprintf
(
s__
(
'
ciReport|%{linkStartTag}Learn more about Container Scanning %{linkEndTag}
'
),
{
linkStartTag
:
`<a href="
${
this
.
sastContainerHelpPath
}
">`
,
linkEndTag
:
'
</a>
'
,
linkStartTag
:
getLinkStartTag
(
this
.
sastContainerHelpPath
)
,
linkEndTag
,
},
false
,
),
...
...
@@ -40,8 +48,8 @@ export default {
content
:
sprintf
(
s__
(
'
ciReport|%{linkStartTag}Learn more about DAST %{linkEndTag}
'
),
{
linkStartTag
:
`<a href="
${
this
.
dastHelpPath
}
">`
,
linkEndTag
:
'
</a>
'
,
linkStartTag
:
getLinkStartTag
(
this
.
dastHelpPath
)
,
linkEndTag
,
},
false
,
),
...
...
@@ -55,8 +63,8 @@ export default {
content
:
sprintf
(
s__
(
'
ciReport|%{linkStartTag}Learn more about Dependency Scanning %{linkEndTag}
'
),
{
linkStartTag
:
`<a href="
${
this
.
dependencyScanningHelpPath
}
">`
,
linkEndTag
:
'
</a>
'
,
linkStartTag
:
getLinkStartTag
(
this
.
dependencyScanningHelpPath
)
,
linkEndTag
,
},
false
,
),
...
...
ee/changelogs/unreleased/13333-secure-open-help-links-in-new-tab.yml
0 → 100644
View file @
6f6156f6
---
title
:
Make "Learn more about" links for security scanning popovers on merge request
page open in new tab
merge_request
:
13333
author
:
Daniel Tian
type
:
changed
ee/spec/frontend/vue_shared/security_reports/mixins/security_report_mixin_spec.js
0 → 100644
View file @
6f6156f6
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
mixin
from
'
ee/vue_shared/security_reports/mixins/security_report_mixin
'
;
describe
(
'
securityReportMixin
'
,
()
=>
{
it
.
each
`
key | link
${
'
sast
'
}
|
${
'
http://fake.url/sast/help/path
'
}
${
'
sastContainer
'
}
|
${
'
http://fake.url/sast/container/help/path
'
}
${
'
dast
'
}
|
${
'
http://fake.url/dast/help/path
'
}
${
'
dependencyScanning
'
}
|
${
'
http://fake.url/dependency/scanning/help/path
'
}
`
(
'
generates correct external link with icon
'
,
({
key
,
link
})
=>
{
// Create a fake component for the mixin with the mock help path data value.
const
component
=
{
render
()
{},
data
:
()
=>
({
[
`
${
key
}
HelpPath`
]:
link
}),
// 'key' -> 'keyHelpPath'
mixins
:
[
mixin
],
};
// Mount the component so that the mixin's computed properties are evaluated.
const
{
vm
}
=
shallowMount
(
component
);
// Get the link that the mixin generated.
const
mixinLink
=
vm
[
`
${
key
}
Popover`
].
content
;
// 'key' -> 'keyPopover'
// Check that for each link, the expected strings exist.
expect
(
mixinLink
).
toContain
(
`href="
${
link
}
`
);
expect
(
mixinLink
).
toContain
(
'
target="_blank"
'
);
expect
(
mixinLink
).
toContain
(
'
rel="noopener noreferrer"
'
);
expect
(
mixinLink
).
toContain
(
'
<i class="fa fa-external-link" aria-hidden="true"></i>
'
);
});
});
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