Commit 3b874414 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not use artifacts metadata to access single artifact

parent 52e52f4a
...@@ -7,7 +7,7 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -7,7 +7,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
before_action :authorize_update_build!, only: [:keep] before_action :authorize_update_build!, only: [:keep]
before_action :extract_ref_name_and_path before_action :extract_ref_name_and_path
before_action :validate_artifacts! before_action :validate_artifacts!
before_action :set_path_and_entry, only: [:file, :raw] before_action :entry, only: [:file]
def download def download
if artifacts_file.file_storage? if artifacts_file.file_storage?
...@@ -41,7 +41,10 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -41,7 +41,10 @@ class Projects::ArtifactsController < Projects::ApplicationController
end end
def raw def raw
send_artifacts_entry(build, @entry) path = Gitlab::Ci::Build::Artifacts::Path
.new(params[:path])
send_artifacts_entry(build, path)
end end
def keep def keep
...@@ -93,9 +96,8 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -93,9 +96,8 @@ class Projects::ArtifactsController < Projects::ApplicationController
@artifacts_file ||= build.artifacts_file @artifacts_file ||= build.artifacts_file
end end
def set_path_and_entry def entry
@path = params[:path] @entry = build.artifacts_metadata_entry(params[:path])
@entry = build.artifacts_metadata_entry(@path)
render_404 unless @entry.exists? render_404 unless @entry.exists?
end end
......
...@@ -98,10 +98,11 @@ module API ...@@ -98,10 +98,11 @@ module API
build = get_build!(params[:job_id]) build = get_build!(params[:job_id])
not_found! unless build.artifacts? not_found! unless build.artifacts?
entry = build.artifacts_metadata_entry(params[:artifact_path]) path = Gitlab::Ci::Build::Artifacts::Path
not_found! unless entry.exists? .new(params[:artifact_path])
not_found! unless path.valid?
send_artifacts_entry(build, entry) send_artifacts_entry(build, path)
end end
desc 'Download the artifacts file from a job' do desc 'Download the artifacts file from a job' do
......
...@@ -220,14 +220,6 @@ describe API::Jobs do ...@@ -220,14 +220,6 @@ describe API::Jobs do
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
end end
end end
context 'when request path is invalid' do
it 'does not find artifact file' do
get_artifact_file('invalid/path')
expect(response).to have_http_status(404)
end
end
end end
context 'when job does not have artifacts' do context 'when job does not have artifacts' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment