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
680eb56c
Commit
680eb56c
authored
Nov 26, 2019
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix xss on frequent groups dropdown
- Sanitize group attributes before rendering.
parent
17fc902d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
4 deletions
+39
-4
app/assets/javascripts/frequent_items/components/app.vue
app/assets/javascripts/frequent_items/components/app.vue
+4
-2
app/assets/javascripts/frequent_items/components/frequent_items_list.vue
...scripts/frequent_items/components/frequent_items_list.vue
+5
-1
app/assets/javascripts/frequent_items/utils.js
app/assets/javascripts/frequent_items/utils.js
+7
-0
changelogs/unreleased/security-fix-xss-on-frequent-groups-dropdown.yml
...released/security-fix-xss-on-frequent-groups-dropdown.yml
+5
-0
spec/javascripts/frequent_items/utils_spec.js
spec/javascripts/frequent_items/utils_spec.js
+18
-1
No files found.
app/assets/javascripts/frequent_items/components/app.vue
View file @
680eb56c
...
...
@@ -5,7 +5,7 @@ import AccessorUtilities from '~/lib/utils/accessor';
import
eventHub
from
'
../event_hub
'
;
import
store
from
'
../store/
'
;
import
{
FREQUENT_ITEMS
,
STORAGE_KEY
}
from
'
../constants
'
;
import
{
isMobile
,
updateExistingFrequentItem
}
from
'
../utils
'
;
import
{
isMobile
,
updateExistingFrequentItem
,
sanitizeItem
}
from
'
../utils
'
;
import
FrequentItemsSearchInput
from
'
./frequent_items_search_input.vue
'
;
import
FrequentItemsList
from
'
./frequent_items_list.vue
'
;
import
frequentItemsMixin
from
'
./frequent_items_mixin
'
;
...
...
@@ -64,7 +64,9 @@ export default {
this
.
fetchFrequentItems
();
}
},
logItemAccess
(
storageKey
,
item
)
{
logItemAccess
(
storageKey
,
unsanitizedItem
)
{
const
item
=
sanitizeItem
(
unsanitizedItem
);
if
(
!
AccessorUtilities
.
isLocalStorageAccessSafe
())
{
return
false
;
}
...
...
app/assets/javascripts/frequent_items/components/frequent_items_list.vue
View file @
680eb56c
<
script
>
import
FrequentItemsListItem
from
'
./frequent_items_list_item.vue
'
;
import
frequentItemsMixin
from
'
./frequent_items_mixin
'
;
import
{
sanitizeItem
}
from
'
../utils
'
;
export
default
{
components
:
{
...
...
@@ -48,6 +49,9 @@ export default {
?
this
.
translations
.
itemListErrorMessage
:
this
.
translations
.
itemListEmptyMessage
;
},
sanitizedItems
()
{
return
this
.
items
.
map
(
sanitizeItem
);
},
},
};
</
script
>
...
...
@@ -59,7 +63,7 @@ export default {
{{
listEmptyMessage
}}
</li>
<frequent-items-list-item
v-for=
"item in
i
tems"
v-for=
"item in
sanitizedI
tems"
v-else
:key=
"item.id"
:item-id=
"item.id"
...
...
app/assets/javascripts/frequent_items/utils.js
View file @
680eb56c
import
_
from
'
underscore
'
;
import
{
GlBreakpointInstance
as
bp
}
from
'
@gitlab/ui/dist/utils
'
;
import
sanitize
from
'
sanitize-html
'
;
import
{
FREQUENT_ITEMS
,
HOUR_IN_MS
}
from
'
./constants
'
;
export
const
isMobile
=
()
=>
[
'
md
'
,
'
sm
'
,
'
xs
'
].
includes
(
bp
.
getBreakpointSize
());
...
...
@@ -43,3 +44,9 @@ export const updateExistingFrequentItem = (frequentItem, item) => {
lastAccessedOn
:
accessedOverHourAgo
?
Date
.
now
()
:
frequentItem
.
lastAccessedOn
,
};
};
export
const
sanitizeItem
=
item
=>
({
...
item
,
name
:
sanitize
(
item
.
name
.
toString
(),
{
allowedTags
:
[]
}),
namespace
:
sanitize
(
item
.
namespace
.
toString
(),
{
allowedTags
:
[]
}),
});
changelogs/unreleased/security-fix-xss-on-frequent-groups-dropdown.yml
0 → 100644
View file @
680eb56c
---
title
:
Fix xss on frequent groups dropdown
merge_request
:
author
:
type
:
security
spec/javascripts/frequent_items/utils_spec.js
View file @
680eb56c
import
{
GlBreakpointInstance
as
bp
}
from
'
@gitlab/ui/dist/utils
'
;
import
{
isMobile
,
getTopFrequentItems
,
updateExistingFrequentItem
}
from
'
~/frequent_items/utils
'
;
import
{
isMobile
,
getTopFrequentItems
,
updateExistingFrequentItem
,
sanitizeItem
,
}
from
'
~/frequent_items/utils
'
;
import
{
HOUR_IN_MS
,
FREQUENT_ITEMS
}
from
'
~/frequent_items/constants
'
;
import
{
mockProject
,
unsortedFrequentItems
,
sortedFrequentItems
}
from
'
./mock_data
'
;
...
...
@@ -92,4 +97,16 @@ describe('Frequent Items utils spec', () => {
expect
(
result
.
frequency
).
toBe
(
mockedProject
.
frequency
);
});
});
describe
(
'
sanitizeItem
'
,
()
=>
{
it
(
'
strips HTML tags for name and namespace
'
,
()
=>
{
const
input
=
{
name
:
'
<br><b>test</b>
'
,
namespace
:
'
<br>test
'
,
id
:
1
,
};
expect
(
sanitizeItem
(
input
)).
toEqual
({
name
:
'
test
'
,
namespace
:
'
test
'
,
id
:
1
});
});
});
});
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