diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 01:43:31 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 01:43:31 +0000 |
commit | e20a1cde5d740fbc9f4d033786a8cd5ad7eb8b4d (patch) | |
tree | cf76b0527f1909eaf1ecac057a4ccc7591cce4f6 /lib | |
parent | 5fc725def41e6973e92bc32095774edd60fd154f (diff) | |
download | gitlab-ce-e20a1cde5d740fbc9f4d033786a8cd5ad7eb8b4d.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities/project_import_status.rb | 2 | ||||
-rw-r--r-- | lib/api/internal/base.rb | 16 | ||||
-rw-r--r-- | lib/gitlab/background_migration/update_vulnerabilities_to_dismissed.rb | 13 |
3 files changed, 26 insertions, 5 deletions
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') |