Skip to content
Snippets Groups Projects
Commit a5e1905d authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Render 404 when artifacts path is invalid

parent f948c007
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -17,6 +17,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def browse
return render_404 unless build.artifacts?
@path = build.artifacts_metadata_string_path(params[:path] || './')
return render_404 if @path.universe.empty?
end
 
private
Loading
Loading
Loading
Loading
@@ -22,7 +22,7 @@ module Gitlab
paths, metadata = [], []
 
each do |line|
next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]+/?\s}
next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]*/?\s}
 
path, meta = line.split(' ')
paths.push(path)
Loading
Loading
Loading
Loading
@@ -38,7 +38,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
 
it 'matches correct paths' do
expect(subject.first).
to contain_exactly 'other_artifacts_0.1.2/doc_sample.txt',
to contain_exactly 'other_artifacts_0.1.2/',
'other_artifacts_0.1.2/doc_sample.txt',
'other_artifacts_0.1.2/another-subdirectory/'
end
end
Loading
Loading
@@ -48,7 +49,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
 
it 'matches correct paths' do
expect(subject.first).
to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/',
'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment