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
2f4afe45
Commit
2f4afe45
authored
Oct 12, 2018
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix XSS in MR source branch name
parent
1103f589
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
9 deletions
+17
-9
app/presenters/merge_request_presenter.rb
app/presenters/merge_request_presenter.rb
+3
-9
changelogs/unreleased/51527-xss-in-mr-source-branch.yml
changelogs/unreleased/51527-xss-in-mr-source-branch.yml
+5
-0
spec/presenters/merge_request_presenter_spec.rb
spec/presenters/merge_request_presenter_spec.rb
+9
-0
No files found.
app/presenters/merge_request_presenter.rb
View file @
2f4afe45
...
@@ -108,16 +108,10 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
...
@@ -108,16 +108,10 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
namespace
=
source_project_namespace
namespace
=
source_project_namespace
branch
=
source_branch
branch
=
source_branch
if
source_branch_exists?
namespace_link
=
source_branch_exists?
?
link_to
(
namespace
,
project_path
(
source_project
))
:
ERB
::
Util
.
html_escape
(
namespace
)
namespace
=
link_to
(
namespace
,
project_path
(
source_project
))
branch_link
=
source_branch_exists?
?
link_to
(
branch
,
project_tree_path
(
source_project
,
source_branch
))
:
ERB
::
Util
.
html_escape
(
branch
)
branch
=
link_to
(
branch
,
project_tree_path
(
source_project
,
source_branch
))
end
if
for_fork?
for_fork?
?
"
#{
namespace_link
}
:
#{
branch_link
}
"
:
branch_link
namespace
+
":"
+
branch
else
branch
end
end
end
def
closing_issues_links
def
closing_issues_links
...
...
changelogs/unreleased/51527-xss-in-mr-source-branch.yml
0 → 100644
View file @
2f4afe45
---
title
:
Fix XSS in merge request source branch name
merge_request
:
author
:
type
:
security
spec/presenters/merge_request_presenter_spec.rb
View file @
2f4afe45
...
@@ -403,6 +403,15 @@ describe MergeRequestPresenter do
...
@@ -403,6 +403,15 @@ describe MergeRequestPresenter do
is_expected
is_expected
.
to
eq
(
"<a href=
\"
/
#{
resource
.
source_project
.
full_path
}
/tree/
#{
resource
.
source_branch
}
\"
>
#{
resource
.
source_branch
}
</a>"
)
.
to
eq
(
"<a href=
\"
/
#{
resource
.
source_project
.
full_path
}
/tree/
#{
resource
.
source_branch
}
\"
>
#{
resource
.
source_branch
}
</a>"
)
end
end
it
'escapes html, when source_branch does not exist'
do
xss_attempt
=
"<img src='x' onerror=alert('bad stuff') />"
allow
(
resource
).
to
receive
(
:source_branch
)
{
xss_attempt
}
allow
(
resource
).
to
receive
(
:source_branch_exists?
)
{
false
}
is_expected
.
to
eq
(
ERB
::
Util
.
html_escape
(
xss_attempt
))
end
end
end
describe
'#rebase_path'
do
describe
'#rebase_path'
do
...
...
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