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
before_action :authorize_update_build!, only: [:keep]
before_action :extract_ref_name_and_path
before_action :validate_artifacts!
before_action :set_path_and_entry, only: [:file, :raw]
before_action :entry, only: [:file]
def download
if artifacts_file.file_storage?
......@@ -41,7 +41,10 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
def raw
send_artifacts_entry(build, @entry)
path = Gitlab::Ci::Build::Artifacts::Path
.new(params[:path])
send_artifacts_entry(build, path)
end
def keep
......@@ -93,9 +96,8 @@ class Projects::ArtifactsController < Projects::ApplicationController
@artifacts_file ||= build.artifacts_file
end
def set_path_and_entry
@path = params[:path]
@entry = build.artifacts_metadata_entry(@path)
def entry
@entry = build.artifacts_metadata_entry(params[:path])
render_404 unless @entry.exists?
end
......
......@@ -98,10 +98,11 @@ module API
build = get_build!(params[:job_id])
not_found! unless build.artifacts?
entry = build.artifacts_metadata_entry(params[:artifact_path])
not_found! unless entry.exists?
path = Gitlab::Ci::Build::Artifacts::Path
.new(params[:artifact_path])
not_found! unless path.valid?
send_artifacts_entry(build, entry)
send_artifacts_entry(build, path)
end
desc 'Download the artifacts file from a job' do
......
......@@ -220,14 +220,6 @@ describe API::Jobs do
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
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
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