diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-04 14:00:49 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 12:48:15 +0100 |
commit | a5e1905d28e490fb4734bff0e02a1ecff4c7c029 (patch) | |
tree | 65af43af6432d72048fbf18789b8f8bff858615f | |
parent | f948c00757ca9529817c7368610b0c0d6734d48f (diff) | |
download | gitlab-ce-a5e1905d28e490fb4734bff0e02a1ecff4c7c029.tar.gz |
Render 404 when artifacts path is invalid
-rw-r--r-- | app/controllers/projects/artifacts_controller.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/build/artifacts/metadata.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb | 6 |
3 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index ee1b1f375dc..d11ae5bd52d 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -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 diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb index 5313182d55f..d5c3cd10e48 100644 --- a/lib/gitlab/ci/build/artifacts/metadata.rb +++ b/lib/gitlab/ci/build/artifacts/metadata.rb @@ -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) diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb index 8c648be5f02..62c86a60ac4 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb @@ -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 @@ -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 |