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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
3bd607f2
Commit
3bd607f2
authored
Sep 12, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix xss vulnerability sourced from package.json's homepage
parent
2dac058d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
app/models/blob_viewer/package_json.rb
app/models/blob_viewer/package_json.rb
+2
-1
changelogs/unreleased/security-package-json-xss.yml
changelogs/unreleased/security-package-json-xss.yml
+5
-0
spec/models/blob_viewer/package_json_spec.rb
spec/models/blob_viewer/package_json_spec.rb
+17
-4
No files found.
app/models/blob_viewer/package_json.rb
View file @
3bd607f2
...
...
@@ -33,7 +33,8 @@ module BlobViewer
end
def
homepage
json_data
[
'homepage'
]
url
=
json_data
[
'homepage'
]
url
if
Gitlab
::
UrlSanitizer
.
valid?
(
url
)
end
def
npm_url
...
...
changelogs/unreleased/security-package-json-xss.yml
0 → 100644
View file @
3bd607f2
---
title
:
Fix xss vulnerability sourced from package.json
merge_request
:
author
:
type
:
security
spec/models/blob_viewer/package_json_spec.rb
View file @
3bd607f2
...
...
@@ -40,13 +40,14 @@ describe BlobViewer::PackageJson do
end
context
'when package.json has "private": true'
do
let
(
:homepage
)
{
'http://example.com'
}
let
(
:data
)
do
<<-
SPEC
.
strip_heredoc
{
"name": "module-name",
"version": "10.3.1",
"private": true,
"homepage":
"myawesomepackage.com"
"homepage":
#{
homepage
.
to_json
}
}
SPEC
end
...
...
@@ -54,10 +55,22 @@ describe BlobViewer::PackageJson do
subject
{
described_class
.
new
(
blob
)
}
describe
'#package_url'
do
it
'returns homepage if any'
do
context
'when the homepage has a valid URL'
do
it
'returns homepage URL'
do
expect
(
subject
).
to
receive
(
:prepare!
)
expect
(
subject
.
package_url
).
to
eq
(
'myawesomepackage.com'
)
expect
(
subject
.
package_url
).
to
eq
(
homepage
)
end
end
context
'when the homepage has an invalid URL'
do
let
(
:homepage
)
{
'javascript:alert()'
}
it
'returns nil'
do
expect
(
subject
).
to
receive
(
:prepare!
)
expect
(
subject
.
package_url
).
to
be_nil
end
end
end
...
...
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