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
3ad30f1f
Commit
3ad30f1f
authored
Jun 29, 2020
by
Scott Stern
Committed by
GitLab Release Tools Bot
Jun 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure user info is sanitized when rendered
parent
d7c0fba9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
25 deletions
+48
-25
app/assets/javascripts/issuables_list/components/issuable.vue
...assets/javascripts/issuables_list/components/issuable.vue
+35
-21
changelogs/unreleased/security-xss-issuables-list.yml
changelogs/unreleased/security-xss-issuables-list.yml
+5
-0
spec/frontend/issuables_list/components/issuable_spec.js
spec/frontend/issuables_list/components/issuable_spec.js
+8
-4
No files found.
app/assets/javascripts/issuables_list/components/issuable.vue
View file @
3ad30f1f
...
...
@@ -6,7 +6,7 @@
// TODO: need to move this component to graphql - https://gitlab.com/gitlab-org/gitlab/-/issues/221246
import
{
escape
,
isNumber
}
from
'
lodash
'
;
import
{
GlLink
,
GlTooltipDirective
as
GlTooltip
,
GlLabel
}
from
'
@gitlab/ui
'
;
import
{
GlLink
,
GlTooltipDirective
as
GlTooltip
,
Gl
Sprintf
,
Gl
Label
}
from
'
@gitlab/ui
'
;
import
{
dateInWords
,
formatDate
,
...
...
@@ -24,12 +24,15 @@ import { isScopedLabel } from '~/lib/utils/common_utils';
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
export
default
{
isScopedLabel
,
i18n
:
{
openedAgo
:
__
(
'
opened %{timeAgoString} by %{user}
'
),
},
components
:
{
Icon
,
IssueAssignees
,
GlLink
,
GlLabel
,
GlSprintf
,
},
directives
:
{
GlTooltip
,
...
...
@@ -105,23 +108,21 @@ export default {
}
return
__
(
'
Milestone
'
);
},
openedAgoByString
()
{
const
{
author
,
created_at
}
=
this
.
issuable
;
issuableAuthor
()
{
return
this
.
issuable
.
author
;
},
issuableCreatedAt
()
{
return
getTimeago
().
format
(
this
.
issuable
.
created_at
);
},
popoverDataAttrs
()
{
const
{
id
,
username
,
name
,
avatar_url
}
=
this
.
issuableAuthor
;
return
sprintf
(
__
(
'
opened %{timeAgoString} by %{user}
'
),
{
timeAgoString
:
escape
(
getTimeago
().
format
(
created_at
)),
user
:
`<a href="
${
escape
(
author
.
web_url
)}
"
data-user-id=
${
escape
(
author
.
id
)}
data-username=
${
escape
(
author
.
username
)}
data-name=
${
escape
(
author
.
name
)}
data-avatar-url="
${
escape
(
author
.
avatar_url
)}
">
${
escape
(
author
.
name
)}
</a>`
,
},
false
,
);
return
{
'
data-user-id
'
:
id
,
'
data-username
'
:
username
,
'
data-name
'
:
name
,
'
data-avatar-url
'
:
avatar_url
,
};
},
referencePath
()
{
return
this
.
issuable
.
references
.
relative
;
...
...
@@ -167,7 +168,7 @@ export default {
mounted
()
{
// TODO: Refactor user popover to use its own component instead of
// spawning event listeners on Vue-rendered elements.
initUserPopovers
([
this
.
$refs
.
openedAgoByContainer
.
querySelector
(
'
a
'
)
]);
initUserPopovers
([
this
.
$refs
.
openedAgoByContainer
.
$el
]);
},
methods
:
{
issuableLink
(
params
)
{
...
...
@@ -233,9 +234,22 @@ export default {
<div
class=
"issuable-info"
>
<span
class=
"js-ref-path"
>
{{
referencePath
}}
</span>
<span
class=
"d-none d-sm-inline-block mr-1"
>
<span
data-testid=
"openedByMessage"
class=
"d-none d-sm-inline-block mr-1"
>
·
<span
ref=
"openedAgoByContainer"
v-html=
"openedAgoByString"
></span>
<gl-sprintf
:message=
"$options.i18n.openedAgo"
>
<template
#timeAgoString
>
<span>
{{
issuableCreatedAt
}}
</span>
</
template
>
<
template
#user
>
<gl-link
ref=
"openedAgoByContainer"
v-bind=
"popoverDataAttrs"
:href=
"issuableAuthor.web_url"
>
{{
issuableAuthor
.
name
}}
</gl-link>
</
template
>
</gl-sprintf>
</span>
<gl-link
...
...
changelogs/unreleased/security-xss-issuables-list.yml
0 → 100644
View file @
3ad30f1f
---
title
:
Fix security issue when rendering issuable
merge_request
:
author
:
type
:
security
spec/frontend/issuables_list/components/issuable_spec.js
View file @
3ad30f1f
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlLabel
}
from
'
@gitlab/ui
'
;
import
{
Gl
Sprintf
,
Gl
Label
}
from
'
@gitlab/ui
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
initUserPopovers
from
'
~/user_popovers
'
;
...
...
@@ -50,6 +50,10 @@ describe('Issuable component', () => {
scopedLabels
,
},
},
stubs
:
{
'
gl-sprintf
'
:
GlSprintf
,
'
gl-link
'
:
'
<a><slot></slot></a>
'
,
},
});
};
...
...
@@ -73,7 +77,7 @@ describe('Issuable component', () => {
const
findConfidentialIcon
=
()
=>
wrapper
.
find
(
'
.fa-eye-slash
'
);
const
findTaskStatus
=
()
=>
wrapper
.
find
(
'
.task-status
'
);
const
findOpenedAgoContainer
=
()
=>
wrapper
.
find
(
{
ref
:
'
openedAgoByContainer
'
}
);
const
findOpenedAgoContainer
=
()
=>
wrapper
.
find
(
'
[data-testid="openedByMessage"]
'
);
const
findMilestone
=
()
=>
wrapper
.
find
(
'
.js-milestone
'
);
const
findMilestoneTooltip
=
()
=>
findMilestone
().
attributes
(
'
title
'
);
const
findDueDate
=
()
=>
wrapper
.
find
(
'
.js-due-date
'
);
...
...
@@ -94,7 +98,7 @@ describe('Issuable component', () => {
factory
();
expect
(
initUserPopovers
).
toHaveBeenCalledWith
([
findOpenedAgoContainer
().
find
(
'
a
'
).
element
]);
expect
(
initUserPopovers
).
toHaveBeenCalledWith
([
wrapper
.
vm
.
$refs
.
openedAgoByContainer
.
$el
]);
});
});
...
...
@@ -191,7 +195,7 @@ describe('Issuable component', () => {
});
it
(
'
renders fuzzy opened date and author
'
,
()
=>
{
expect
(
trimText
(
findOpenedAgoContainer
().
text
())).
to
Equal
(
expect
(
trimText
(
findOpenedAgoContainer
().
text
())).
to
Contain
(
`opened 1 month ago by
${
TEST_USER_NAME
}
`
,
);
});
...
...
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