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
bbf010e4
Commit
bbf010e4
authored
May 27, 2020
by
Giorgenes Gelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes pypi XSS
parent
e653b984
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
ee/app/presenters/packages/pypi/package_presenter.rb
ee/app/presenters/packages/pypi/package_presenter.rb
+7
-3
ee/changelogs/unreleased/security-215640-pypi.yml
ee/changelogs/unreleased/security-215640-pypi.yml
+5
-0
ee/spec/presenters/packages/pypi/package_presenter_spec.rb
ee/spec/presenters/packages/pypi/package_presenter_spec.rb
+15
-1
No files found.
ee/app/presenters/packages/pypi/package_presenter.rb
View file @
bbf010e4
...
...
@@ -20,10 +20,10 @@ module Packages
<!DOCTYPE html>
<html>
<head>
<title>Links for
#{
name
}
</title>
<title>Links for
#{
escape
(
name
)
}
</title>
</head>
<body>
<h1>Links for
#{
name
}
</h1>
<h1>Links for
#{
escape
(
name
)
}
</h1>
#{
links
}
</body>
</html>
...
...
@@ -47,7 +47,7 @@ module Packages
end
def
package_link
(
url
,
required_python
,
filename
)
"<a href=
\"
#{
url
}
\"
data-requires-python=
\"
#{
required_python
}
\"
>
#{
filename
}
</a><br>"
"<a href=
\"
#{
url
}
\"
data-requires-python=
\"
#{
escape
(
required_python
)
}
\"
>
#{
filename
}
</a><br>"
end
def
build_pypi_package_path
(
file
)
...
...
@@ -66,6 +66,10 @@ module Packages
def
name
@packages
.
first
.
name
end
def
escape
(
str
)
ERB
::
Util
.
html_escape
(
str
)
end
end
end
end
ee/changelogs/unreleased/security-215640-pypi.yml
0 → 100644
View file @
bbf010e4
---
title
:
Fixed pypi package API XSS
merge_request
:
author
:
type
:
security
ee/spec/presenters/packages/pypi/package_presenter_spec.rb
View file @
bbf010e4
...
...
@@ -19,16 +19,30 @@ describe ::Packages::Pypi::PackagePresenter do
shared_examples_for
"pypi package presenter"
do
let
(
:file
)
{
package
.
package_files
.
first
}
let
(
:filename
)
{
file
.
file_name
}
let
(
:expected_file
)
{
"<a href=
\"
http://localhost/api/v4/projects/
#{
project
.
id
}
/packages/pypi/files/
#{
file
.
file_sha256
}
/
#{
filename
}
#sha256=
#{
file
.
file_sha256
}
\"
data-requires-python=
\"
#{
package
.
pypi_metadatum
.
required_python
}
\"
>
#{
filename
}
</a><br>"
}
let
(
:expected_file
)
{
"<a href=
\"
http://localhost/api/v4/projects/
#{
project
.
id
}
/packages/pypi/files/
#{
file
.
file_sha256
}
/
#{
filename
}
#sha256=
#{
file
.
file_sha256
}
\"
data-requires-python=
\"
#{
expected_python_version
}
\"
>
#{
filename
}
</a><br>"
}
before
do
package
.
pypi_metadatum
.
required_python
=
python_version
end
it
{
is_expected
.
to
include
expected_file
}
end
it_behaves_like
"pypi package presenter"
do
let
(
:python_version
)
{
'>=2.7'
}
let
(
:expected_python_version
)
{
'>=2.7'
}
let
(
:package
)
{
package1
}
end
it_behaves_like
"pypi package presenter"
do
let
(
:python_version
)
{
'"><script>alert(1)</script>'
}
let
(
:expected_python_version
)
{
'"><script>alert(1)</script>'
}
let
(
:package
)
{
package1
}
end
it_behaves_like
"pypi package presenter"
do
let
(
:python_version
)
{
'>=2.7, !=3.0'
}
let
(
:expected_python_version
)
{
'>=2.7, !=3.0'
}
let
(
:package
)
{
package2
}
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