From e20a1cde5d740fbc9f4d033786a8cd5ad7eb8b4d Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 24 Apr 2020 01:43:31 +0000 Subject: Add latest changes from gitlab-org/gitlab@12-10-stable-ee --- lib/api/entities/project_import_status.rb | 2 +- lib/api/internal/base.rb | 16 ++++++++++++---- .../update_vulnerabilities_to_dismissed.rb | 13 +++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 lib/gitlab/background_migration/update_vulnerabilities_to_dismissed.rb (limited to 'lib') diff --git a/lib/api/entities/project_import_status.rb b/lib/api/entities/project_import_status.rb index 5ef5600259f..f92593da3fa 100644 --- a/lib/api/entities/project_import_status.rb +++ b/lib/api/entities/project_import_status.rb @@ -9,7 +9,7 @@ module API end expose :failed_relations, using: Entities::ProjectImportFailedRelation do |project, _options| - project.import_state.relation_hard_failures(limit: 100) + project.import_state&.relation_hard_failures(limit: 100) || [] end # TODO: Use `expose_nil` once we upgrade the grape-entity gem diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb index f1e33b27d2b..0d50a310b37 100644 --- a/lib/api/internal/base.rb +++ b/lib/api/internal/base.rb @@ -43,12 +43,9 @@ module API Gitlab::Git::HookEnv.set(gl_repository, env) if container actor.update_last_used_at! - access_checker = access_checker_for(actor, params[:protocol]) check_result = begin - result = access_checker.check(params[:action], params[:changes]) - @project ||= access_checker.project - result + access_check!(actor, params) rescue Gitlab::GitAccess::ForbiddenError => e # The return code needs to be 401. If we return 403 # the custom message we return won't be shown to the user @@ -92,6 +89,17 @@ module API response_with_status(code: 500, success: false, message: UNKNOWN_CHECK_RESULT_ERROR) end end + + def access_check!(actor, params) + access_checker = access_checker_for(actor, params[:protocol]) + access_checker.check(params[:action], params[:changes]).tap do |result| + break result if @project || !repo_type.project? + + # If we have created a project directly from a git push + # we have to assign its value to both @project and @container + @project = @container = access_checker.project + end + end end namespace 'internal' do diff --git a/lib/gitlab/background_migration/update_vulnerabilities_to_dismissed.rb b/lib/gitlab/background_migration/update_vulnerabilities_to_dismissed.rb new file mode 100644 index 00000000000..a2940cba6fa --- /dev/null +++ b/lib/gitlab/background_migration/update_vulnerabilities_to_dismissed.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop: disable Style/Documentation + class UpdateVulnerabilitiesToDismissed + def perform(project_id) + end + end + end +end + +Gitlab::BackgroundMigration::UpdateVulnerabilitiesToDismissed.prepend_if_ee('EE::Gitlab::BackgroundMigration::UpdateVulnerabilitiesToDismissed') -- cgit v1.2.3