BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
4acab552
Commit
4acab552
authored
Sep 04, 2017
by
Douwe Maan
Committed by
Robert Speicher
Sep 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'fix-escape-commit-block' into 'security-9-5'
[9.5] Prevent a persistent XSS in the commit author block See merge request gitlab/gitlabhq!2180
parent
941a2d27
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
+30
-3
commits_helper.rb
app/helpers/commits_helper.rb
+3
-3
fix-escape-commit-block.yml
changelogs/unreleased/fix-escape-commit-block.yml
+5
-0
commits_helper_spec.rb
spec/helpers/commits_helper_spec.rb
+22
-0
No files found.
app/helpers/commits_helper.rb
View file @
4acab552
...
...
@@ -137,7 +137,7 @@ module CommitsHelper
text
=
if
options
[
:avatar
]
%Q{<span class="commit-
#{
options
[
:source
]
}
-name">
#{
person_name
}
</span>}
content_tag
(
:span
,
person_name
,
class:
"commit-
#{
options
[
:source
]
}
-name"
)
else
person_name
end
...
...
@@ -148,9 +148,9 @@ module CommitsHelper
}
if
user
.
nil?
mail_to
(
source_email
,
text
.
html_safe
,
options
)
mail_to
(
source_email
,
text
,
options
)
else
link_to
(
text
.
html_safe
,
user_path
(
user
),
options
)
link_to
(
text
,
user_path
(
user
),
options
)
end
end
...
...
changelogs/unreleased/fix-escape-commit-block.yml
0 → 100644
View file @
4acab552
---
title
:
Prevent a persistent XSS in the commit author block
merge_request
:
author
:
type
:
security
spec/helpers/commits_helper_spec.rb
View file @
4acab552
...
...
@@ -12,6 +12,17 @@ describe CommitsHelper do
expect
(
helper
.
commit_author_link
(
commit
))
.
not_to
include
(
'onmouseover="alert(1)"'
)
end
it
'escapes the author name'
do
user
=
build_stubbed
(
:user
,
name:
'Foo <script>alert("XSS")</script>'
)
commit
=
double
(
author:
user
,
author_name:
''
,
author_email:
''
)
expect
(
helper
.
commit_author_link
(
commit
))
.
to
include
(
'Foo <script>'
)
expect
(
helper
.
commit_author_link
(
commit
,
avatar:
true
))
.
to
include
(
'commit-author-name'
,
'Foo <script>'
)
end
end
describe
'commit_committer_link'
do
...
...
@@ -25,6 +36,17 @@ describe CommitsHelper do
expect
(
helper
.
commit_committer_link
(
commit
))
.
not_to
include
(
'onmouseover="alert(1)"'
)
end
it
'escapes the commiter name'
do
user
=
build_stubbed
(
:user
,
name:
'Foo <script>alert("XSS")</script>'
)
commit
=
double
(
committer:
user
,
committer_name:
''
,
committer_email:
''
)
expect
(
helper
.
commit_committer_link
(
commit
))
.
to
include
(
'Foo <script>'
)
expect
(
helper
.
commit_committer_link
(
commit
,
avatar:
true
))
.
to
include
(
'commit-committer-name'
,
'Foo <script>'
)
end
end
describe
'#view_on_environment_button'
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