Skip to content
代码片段 群组 项目
未验证 提交 4bed82d5 编辑于 作者: Terri Chu's avatar Terri Chu 提交者: GitLab
浏览文件

Merge branch 'joern-add-path-traversal-check' into 'master'

Add missing path traversal check

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/149717



Merged-by: default avatarTerri Chu <tchu@gitlab.com>
Approved-by: default avatarTerri Chu <tchu@gitlab.com>
Co-authored-by: default avatarTiger <twatson@gitlab.com>
Co-authored-by: default avatarJoern Schneeweisz <jschneeweisz@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -2,7 +2,10 @@
module InProductMarketingHelper
def inline_image_link(image, options)
attachments.inline[image] = File.read(Rails.root.join("app/assets/images", image))
asset_path = Rails.root.join("app/assets/images").to_s
image_path = File.join(asset_path, image)
Gitlab::PathTraversal.check_allowed_absolute_path_and_path_traversal!(image_path, [asset_path])
attachments.inline[image] = File.read(image_path)
image_tag attachments[image].url, **options
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe InProductMarketingHelper, feature_category: :activation do
describe '#inline_image_link' do
let(:image) { 'gitlab_logo.png' }
before do
attachments = instance_double(Mail::AttachmentsList).as_null_object
allow(helper).to receive(:attachments).and_return(attachments)
allow(attachments).to receive(:[]).with(image).and_return(Mail::Part.new)
end
it 'checks for path traversal' do
asset_path = Rails.root.join("app/assets/images").to_s
image_path = File.join(asset_path, image)
expect(Gitlab::PathTraversal).to receive(:check_allowed_absolute_path_and_path_traversal!)
.with(image_path, [asset_path])
helper.inline_image_link(image, {})
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册