summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-29 08:18:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-29 08:18:14 +0000
commitdeb2f3a60831afda2ad7ec144eb58aaf269abe58 (patch)
tree66c001da2aeba9b3e0204af1407c91994057f403 /app/controllers
parent88da5554d9626377fe7868e956a47a0498e04eb5 (diff)
downloadgitlab-ce-deb2f3a60831afda2ad7ec144eb58aaf269abe58.tar.gz
Add latest changes from gitlab-org/security/gitlab@14-10-stable-ee
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/application_controller.rb15
-rw-r--r--app/controllers/projects/artifacts_controller.rb7
-rw-r--r--app/controllers/projects/jobs_controller.rb12
3 files changed, 23 insertions, 11 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index 62233c8c3c9..028b7af02c9 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -32,6 +32,21 @@ class Projects::ApplicationController < ApplicationController
->(project) { !project.pending_delete? }
end
+ def authorize_read_build_trace!
+ return if can?(current_user, :read_build_trace, build)
+
+ if build.debug_mode?
+ access_denied!(
+ _('You must have developer or higher permissions in the associated project to view job logs when debug trace ' \
+ "is enabled. To disable debug trace, set the 'CI_DEBUG_TRACE' variable to 'false' in your pipeline " \
+ 'configuration or CI/CD settings. If you need to view this job log, a project maintainer must add you to ' \
+ 'the project with developer permissions or higher.')
+ )
+ else
+ access_denied!(_('The current user is not authorized to access the job log.'))
+ end
+ end
+
def build_canonical_path(project)
params[:namespace_id] = project.namespace.to_param
params[:project_id] = project.to_param
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index feed94708f6..997d321ac24 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -9,6 +9,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
layout 'project'
before_action :authorize_read_build!
+ before_action :authorize_read_build_trace!, only: [:download]
before_action :authorize_update_build!, only: [:keep]
before_action :authorize_destroy_artifacts!, only: [:destroy]
before_action :extract_ref_name_and_path
@@ -164,4 +165,10 @@ class Projects::ArtifactsController < Projects::ApplicationController
render_404 unless @entry.exists?
end
+
+ def authorize_read_build_trace!
+ return unless params[:file_type] == 'trace'
+
+ super
+ end
end
diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb
index 4189419c3ba..0f6cf97d69d 100644
--- a/app/controllers/projects/jobs_controller.rb
+++ b/app/controllers/projects/jobs_controller.rb
@@ -177,17 +177,7 @@ class Projects::JobsController < Projects::ApplicationController
private
- def authorize_read_build_trace!
- return if can?(current_user, :read_build_trace, @build)
-
- msg = _(
- "You must have developer or higher permissions in the associated project to view job logs when debug trace is enabled. To disable debug trace, set the 'CI_DEBUG_TRACE' variable to 'false' in your pipeline configuration or CI/CD settings. " \
- "If you need to view this job log, a project maintainer must add you to the project with developer permissions or higher."
- )
- return access_denied!(msg) if @build.debug_mode?
-
- access_denied!(_('The current user is not authorized to access the job log.'))
- end
+ attr_reader :build
def authorize_update_build!
return access_denied! unless can?(current_user, :update_build, @build)