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
1f23ad42
Commit
1f23ad42
authored
Apr 26, 2021
by
jerasmus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent XSS on notebooks
Prevented the use of data attributes for notebooks. Changelog: security
parent
6b4679d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
app/assets/javascripts/notebook/cells/markdown.vue
app/assets/javascripts/notebook/cells/markdown.vue
+1
-0
spec/frontend/notebook/cells/markdown_spec.js
spec/frontend/notebook/cells/markdown_spec.js
+12
-1
No files found.
app/assets/javascripts/notebook/cells/markdown.vue
View file @
1f23ad42
...
...
@@ -195,6 +195,7 @@ export default {
'
var
'
,
],
ALLOWED_ATTR
:
[
'
class
'
,
'
style
'
,
'
href
'
,
'
src
'
],
ALLOW_DATA_ATTR
:
false
,
});
},
},
...
...
spec/frontend/notebook/cells/markdown_spec.js
View file @
1f23ad42
...
...
@@ -39,7 +39,7 @@ describe('Markdown component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.markdown h1
'
)).
not
.
toBeNull
();
});
it
(
'
sanitizes output
'
,
async
()
=>
{
it
(
'
sanitizes
Markdown
output
'
,
async
()
=>
{
Object
.
assign
(
cell
,
{
source
:
[
'
[XSS](data:text/html;base64,PHNjcmlwdD5hbGVydChkb2N1bWVudC5kb21haW4pPC9zY3JpcHQ+Cg==)
\n
'
,
...
...
@@ -50,6 +50,17 @@ describe('Markdown component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toBeNull
();
});
it
(
'
sanitizes HTML
'
,
async
()
=>
{
const
findLink
=
()
=>
vm
.
$el
.
querySelector
(
'
.xss-link
'
);
Object
.
assign
(
cell
,
{
source
:
[
'
<a href="test.js" data-remote=true data-type="script" class="xss-link">XSS</a>
\n
'
],
});
await
vm
.
$nextTick
();
expect
(
findLink
().
getAttribute
(
'
data-remote
'
)).
toBe
(
null
);
expect
(
findLink
().
getAttribute
(
'
data-type
'
)).
toBe
(
null
);
});
describe
(
'
tables
'
,
()
=>
{
beforeEach
(()
=>
{
json
=
getJSONFixture
(
'
blob/notebook/markdown-table.json
'
);
...
...
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