Merge branch 'fix-rdoc-xss' into 'security'
Fix XSS in rdoc and other markups See https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2058
This commit is contained in:
parent
33c8d413d2
commit
7e1f7a02db
3 changed files with 29 additions and 0 deletions
4
changelogs/unreleased/patch-rdoc-xss.yml
Normal file
4
changelogs/unreleased/patch-rdoc-xss.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Patch XSS vulnerability in RDOC support
|
||||
merge_request:
|
||||
author:
|
|
@ -17,6 +17,9 @@ module Gitlab
|
|||
|
||||
html = Banzai.post_process(html, context)
|
||||
|
||||
filter = Banzai::Filter::SanitizationFilter.new(html)
|
||||
html = filter.call.to_s
|
||||
|
||||
html.html_safe
|
||||
end
|
||||
end
|
||||
|
|
22
spec/lib/gitlab/other_markup.rb
Normal file
22
spec/lib/gitlab/other_markup.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::OtherMarkup, lib: true do
|
||||
context "XSS Checks" do
|
||||
links = {
|
||||
'links' => {
|
||||
file: 'file.rdoc',
|
||||
input: 'XSS[JaVaScriPt:alert(1)]',
|
||||
output: '<p><a>XSS</a></p>'
|
||||
}
|
||||
}
|
||||
links.each do |name, data|
|
||||
it "does not convert dangerous #{name} into HTML" do
|
||||
expect(render(data[:file], data[:input], context)).to eql data[:output]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def render(*args)
|
||||
described_class.render(*args)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue