From 80f61b4035607d7cd87de993b8f5e996bde3481f Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 18 Sep 2019 14:02:45 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- lib/api/branches.rb | 2 +- lib/api/entities.rb | 8 +- lib/api/groups.rb | 2 +- lib/api/helpers/internal_helpers.rb | 2 +- lib/api/helpers/projects_helpers.rb | 2 +- lib/api/issues.rb | 6 +- lib/api/merge_requests.rb | 6 +- lib/api/pages_domains.rb | 4 +- lib/api/pipelines.rb | 4 +- lib/api/project_container_repositories.rb | 2 +- lib/api/project_import.rb | 4 +- lib/api/projects.rb | 4 +- lib/api/triggers.rb | 2 +- lib/api/users.rb | 4 +- lib/banzai/filter/relative_link_filter.rb | 2 +- lib/declarative_policy.rb | 2 +- lib/file_size_validator.rb | 2 - .../add_gitlab_instance_administration_project.rb | 14 --- .../background_migration/encrypt_runners_tokens.rb | 2 +- .../fix_user_namespace_names.rb | 2 +- .../fix_user_project_route_names.rb | 2 +- lib/gitlab/checks/diff_check.rb | 2 +- lib/gitlab/ci/config/entry/job.rb | 2 +- lib/gitlab/ci/config/entry/root.rb | 4 +- .../ci/templates/Android-Fastlane.gitlab-ci.yml | 2 +- lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml | 20 +-- .../ci/templates/Security/SAST.gitlab-ci.yml | 138 +++++++++++++++++++-- lib/gitlab/ci/trace.rb | 2 +- lib/gitlab/data_builder/push.rb | 2 +- lib/gitlab/database.rb | 2 +- lib/gitlab/diff/highlight.rb | 2 +- lib/gitlab/ee_compat_check.rb | 4 +- lib/gitlab/etag_caching/router.rb | 4 + lib/gitlab/git/keep_around.rb | 48 +++++++ lib/gitlab/gpg/commit.rb | 2 +- lib/gitlab/graphql/authorize/authorize_resource.rb | 2 +- lib/gitlab/import_export/lfs_restorer.rb | 2 +- lib/gitlab/json_cache.rb | 2 +- lib/gitlab/kubernetes/helm/reset_command.rb | 4 +- lib/gitlab/legacy_github_import/label_formatter.rb | 2 - lib/gitlab/metrics/dashboard/errors.rb | 6 +- lib/gitlab/metrics/dashboard/finder.rb | 4 +- lib/gitlab/metrics/dashboard/processor.rb | 32 +---- lib/gitlab/metrics/dashboard/service_selector.rb | 2 + lib/gitlab/metrics/dashboard/stages/base_stage.rb | 15 +-- .../metrics/dashboard/stages/endpoint_inserter.rb | 8 +- lib/gitlab/middleware/basic_health_check.rb | 2 +- lib/gitlab/multi_collection_paginator.rb | 2 - lib/gitlab/pages_client.rb | 2 +- lib/gitlab/patch/active_record_query_cache.rb | 2 +- .../phabricator_import/issues/task_importer.rb | 2 +- lib/gitlab/request_context.rb | 2 +- lib/gitlab/shell.rb | 2 +- lib/gitlab/tracking.rb | 4 +- lib/gitlab/url_blockers/url_whitelist.rb | 2 +- lib/gitlab/utils/override.rb | 2 +- lib/support/nginx/registry-ssl | 2 +- lib/tasks/downtime_check.rake | 4 +- lib/tasks/gettext.rake | 2 +- lib/tasks/gitlab/dev.rake | 2 +- lib/tasks/gitlab/shell.rake | 2 +- 61 files changed, 276 insertions(+), 149 deletions(-) delete mode 100644 lib/gitlab/background_migration/add_gitlab_instance_administration_project.rb create mode 100644 lib/gitlab/git/keep_around.rb (limited to 'lib') diff --git a/lib/api/branches.rb b/lib/api/branches.rb index c3821630b6b..f8f79ab6f5a 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -32,7 +32,7 @@ module API use :filter_params end get ':id/repository/branches' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42329') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42329') repository = user_project.repository diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 9e820f00c42..89951498489 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -216,7 +216,7 @@ module API # Preloading tags, should be done with using only `:tags`, # as `:tags` are defined as: `has_many :tags, through: :taggings` # N+1 is solved then by using `subject.tags.map(&:name)` - # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20555 + # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20555 projects_relation.preload(:project_feature, :route) .preload(:import_state, :tags) .preload(:auto_devops) @@ -322,7 +322,7 @@ module API # Preloading tags, should be done with using only `:tags`, # as `:tags` are defined as: `has_many :tags, through: :taggings` # N+1 is solved then by using `subject.tags.map(&:name)` - # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20555 + # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20555 super(projects_relation).preload(:group) .preload(:ci_cd_settings) .preload(:auto_devops) @@ -738,7 +738,7 @@ module API # Ideally we should deprecate `MergeRequest#merge_status` exposure and # use `MergeRequest#mergeable?` instead (boolean). - # See https://gitlab.com/gitlab-org/gitlab-ce/issues/42344 for more + # See https://gitlab.com/gitlab-org/gitlab-foss/issues/42344 for more # information. expose :merge_status do |merge_request| merge_request.check_mergeability @@ -980,7 +980,7 @@ module API def todo_target_class(target_type) # false as second argument prevents looking up in module hierarchy - # see also https://gitlab.com/gitlab-org/gitlab-ce/issues/59719 + # see also https://gitlab.com/gitlab-org/gitlab-foss/issues/59719 ::API::Entities.const_get(target_type, false) end end diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 9d1628de7e5..6c88b61eee8 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -187,7 +187,7 @@ module API group = find_group!(params[:id]) authorize! :admin_group, group - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/46285') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/46285') destroy_conditionally!(group) do |group| ::Groups::DestroyService.new(group, current_user).async_execute end diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb index 9a80671f996..4c575381d30 100644 --- a/lib/api/helpers/internal_helpers.rb +++ b/lib/api/helpers/internal_helpers.rb @@ -56,7 +56,7 @@ module API end def process_mr_push_options(push_options, project, user, changes) - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/61359') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/61359') service = ::MergeRequests::PushOptionsHandlerService.new( project, diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb index 07f0386d14d..94619204274 100644 --- a/lib/api/helpers/projects_helpers.rb +++ b/lib/api/helpers/projects_helpers.rb @@ -38,7 +38,7 @@ module API optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed' optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved' optional :tag_list, type: Array[String], desc: 'The list of tags for a project' - # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab-ee/issues/14960 + # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 optional :avatar, type: File, desc: 'Avatar image for project' # rubocop:disable Scalability/FileUploads optional :printing_merge_request_link_enabled, type: Boolean, desc: 'Show link to create/view merge request when pushing from the command line' optional :merge_method, type: String, values: %w(ff rebase_merge merge), desc: 'The merge method used when merging merge requests' diff --git a/lib/api/issues.rb b/lib/api/issues.rb index d06550191ad..de6af980896 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -215,7 +215,7 @@ module API use :issue_params end post ':id/issues' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42320') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42320') authorize! :create_issue, user_project @@ -257,7 +257,7 @@ module API end # rubocop: disable CodeReuse/ActiveRecord put ':id/issues/:issue_iid' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42322') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42322') issue = user_project.issues.find_by!(iid: params.delete(:issue_iid)) authorize! :update_issue, issue @@ -293,7 +293,7 @@ module API end # rubocop: disable CodeReuse/ActiveRecord post ':id/issues/:issue_iid/move' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42323') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42323') issue = user_project.issues.find_by(iid: params[:issue_iid]) not_found!('Issue') unless issue diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index f317ae717bd..1436238c5cf 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -229,7 +229,7 @@ module API use :optional_params end post ":id/merge_requests" do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42316') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42316') authorize! :create_merge_request_from, user_project @@ -353,7 +353,7 @@ module API at_least_one_of(*::API::MergeRequests.update_params_at_least_one_of) end put ':id/merge_requests/:merge_request_iid' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42318') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42318') merge_request = find_merge_request_with_access(params.delete(:merge_request_iid), :update_merge_request) @@ -384,7 +384,7 @@ module API optional :squash, type: Grape::API::Boolean, desc: 'When true, the commits will be squashed into a single commit on merge' end put ':id/merge_requests/:merge_request_iid/merge' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42317') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42317') merge_request = find_project_merge_request(params[:merge_request_iid]) merge_when_pipeline_succeeds = to_boolean(params[:merge_when_pipeline_succeeds]) diff --git a/lib/api/pages_domains.rb b/lib/api/pages_domains.rb index 40b133e8959..ec2fe8270b7 100644 --- a/lib/api/pages_domains.rb +++ b/lib/api/pages_domains.rb @@ -91,7 +91,7 @@ module API params do requires :domain, type: String, desc: 'The domain' # rubocop:disable Scalability/FileUploads - # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab-ee/issues/14960 + # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate', as: :user_provided_certificate optional :key, allow_blank: false, types: [File, String], desc: 'The key', as: :user_provided_key # rubocop:enable Scalability/FileUploads @@ -115,7 +115,7 @@ module API params do requires :domain, type: String, desc: 'The domain' # rubocop:disable Scalability/FileUploads - # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab-ee/issues/14960 + # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate', as: :user_provided_certificate optional :key, allow_blank: false, types: [File, String], desc: 'The key', as: :user_provided_key # rubocop:enable Scalability/FileUploads diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index e09d226a13f..7c87a9878bf 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -46,9 +46,8 @@ module API requires :ref, type: String, desc: 'Reference' optional :variables, Array, desc: 'Array of variables available in the pipeline' end - # rubocop: disable CodeReuse/ActiveRecord post ':id/pipeline' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42124') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42124') authorize! :create_pipeline, user_project @@ -67,7 +66,6 @@ module API render_validation_error!(new_pipeline) end end - # rubocop: enable CodeReuse/ActiveRecord desc 'Gets a the latest pipeline for the project branch' do detail 'This feature was introduced in GitLab 12.3' diff --git a/lib/api/project_container_repositories.rb b/lib/api/project_container_repositories.rb index 6d53abcc500..c10ef96922c 100644 --- a/lib/api/project_container_repositories.rb +++ b/lib/api/project_container_repositories.rb @@ -75,7 +75,7 @@ module API render_api_error!(message, 400) unless obtain_new_cleanup_container_lease CleanupContainerRepositoryWorker.perform_async(current_user.id, repository.id, - declared_params.except(:repository_id)) # rubocop: disable CodeReuse/ActiveRecord + declared_params.except(:repository_id)) status :accepted end diff --git a/lib/api/project_import.rb b/lib/api/project_import.rb index 9b5e0727184..7f1ae5ffbe6 100644 --- a/lib/api/project_import.rb +++ b/lib/api/project_import.rb @@ -27,7 +27,7 @@ module API resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do params do requires :path, type: String, desc: 'The new project path and name' - # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab-ee/issues/14960 + # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 requires :file, type: File, desc: 'The project export file to be imported' # rubocop:disable Scalability/FileUploads optional :namespace, type: String, desc: "The ID or name of the namespace that the project will be imported into. Defaults to the current user's namespace." optional :overwrite, type: Boolean, default: false, desc: 'If there is a project in the same namespace and with the same name overwrite it' @@ -44,7 +44,7 @@ module API post 'import' do validate_file! - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42437') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42437') namespace = if import_params[:namespace] find_namespace!(import_params[:namespace]) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index c28b03ac6c9..d2dacafe7f9 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -249,7 +249,7 @@ module API optional :name, type: String, desc: 'The name that will be assigned to the fork' end post ':id/fork' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42284') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42284') fork_params = declared_params(include_missing: false) namespace_id = fork_params[:namespace] @@ -480,7 +480,7 @@ module API desc 'Upload a file' params do - # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab-ee/issues/14960 + # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 requires :file, type: File, desc: 'The file to be uploaded' # rubocop:disable Scalability/FileUploads end post ":id/uploads" do diff --git a/lib/api/triggers.rb b/lib/api/triggers.rb index eeecc390256..ab83d84284f 100644 --- a/lib/api/triggers.rb +++ b/lib/api/triggers.rb @@ -17,7 +17,7 @@ module API optional :variables, type: Hash, desc: 'The list of variables to be injected into build' end post ":id/(ref/:ref/)trigger/pipeline", requirements: { ref: /.+/ } do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42283') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42283') # validate variables params[:variables] = params[:variables].to_h diff --git a/lib/api/users.rb b/lib/api/users.rb index 99295888c8c..ff8b82e1898 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -50,7 +50,7 @@ module API optional :admin, type: Boolean, desc: 'Flag indicating the user is an administrator' optional :can_create_group, type: Boolean, desc: 'Flag indicating the user can create groups' optional :external, type: Boolean, desc: 'Flag indicating the user is an external user' - # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab-ee/issues/14960 + # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 optional :avatar, type: File, desc: 'Avatar image for user' # rubocop:disable Scalability/FileUploads optional :private_profile, type: Boolean, default: false, desc: 'Flag indicating the user has a private profile' all_or_none_of :extern_uid, :provider @@ -446,7 +446,7 @@ module API end # rubocop: disable CodeReuse/ActiveRecord delete ":id" do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42279') + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42279') authenticated_as_admin! diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb index 2b734db5cfb..e8001889ca3 100644 --- a/lib/banzai/filter/relative_link_filter.rb +++ b/lib/banzai/filter/relative_link_filter.rb @@ -153,7 +153,7 @@ module Banzai end def uri_type(path) - # https://gitlab.com/gitlab-org/gitlab-ce/issues/58657 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/58657 Gitlab::GitalyClient.allow_n_plus_1_calls do @uri_types[path] ||= current_commit.uri_type(path) end diff --git a/lib/declarative_policy.rb b/lib/declarative_policy.rb index 7ba48ae9c79..d99a209dc87 100644 --- a/lib/declarative_policy.rb +++ b/lib/declarative_policy.rb @@ -24,7 +24,7 @@ module DeclarativePolicy cache[key] ||= # to avoid deadlocks in multi-threaded environment when # autoloading is enabled, we allow concurrent loads, - # https://gitlab.com/gitlab-org/gitlab-ce/issues/48263 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/48263 ActiveSupport::Dependencies.interlock.permit_concurrent_loads do class_for(subject).new(user, subject, opts) end diff --git a/lib/file_size_validator.rb b/lib/file_size_validator.rb index 70a145cd5bd..71908d2130f 100644 --- a/lib/file_size_validator.rb +++ b/lib/file_size_validator.rb @@ -34,7 +34,6 @@ class FileSizeValidator < ActiveModel::EachValidator end end - # rubocop: disable CodeReuse/ActiveRecord def validate_each(record, attribute, value) raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.is_a? CarrierWave::Uploader::Base @@ -65,7 +64,6 @@ class FileSizeValidator < ActiveModel::EachValidator record.errors.add(attribute, MESSAGES[key], errors_options) end end - # rubocop: enable CodeReuse/ActiveRecord def help Helper.instance diff --git a/lib/gitlab/background_migration/add_gitlab_instance_administration_project.rb b/lib/gitlab/background_migration/add_gitlab_instance_administration_project.rb deleted file mode 100644 index 730f1acee98..00000000000 --- a/lib/gitlab/background_migration/add_gitlab_instance_administration_project.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true -# rubocop:disable Style/Documentation - -module Gitlab - module BackgroundMigration - class AddGitlabInstanceAdministrationProject - def perform - Rails.logger.info("Creating Gitlab instance administration project") # rubocop:disable Gitlab/RailsLogger - - Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService.new.execute! - end - end - end -end diff --git a/lib/gitlab/background_migration/encrypt_runners_tokens.rb b/lib/gitlab/background_migration/encrypt_runners_tokens.rb index 91e559a8765..ec64a73542e 100644 --- a/lib/gitlab/background_migration/encrypt_runners_tokens.rb +++ b/lib/gitlab/background_migration/encrypt_runners_tokens.rb @@ -13,7 +13,7 @@ module Gitlab # # We can solve this differently, see tech debt issue: # - # https://gitlab.com/gitlab-org/gitlab-ce/issues/54328 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/54328 # class EncryptRunnersTokens < EncryptColumns def perform(model, from, to) diff --git a/lib/gitlab/background_migration/fix_user_namespace_names.rb b/lib/gitlab/background_migration/fix_user_namespace_names.rb index 1a207121be0..d767cbfd8f5 100644 --- a/lib/gitlab/background_migration/fix_user_namespace_names.rb +++ b/lib/gitlab/background_migration/fix_user_namespace_names.rb @@ -5,7 +5,7 @@ module Gitlab # This migration fixes the namespaces.name for all user-namespaces that have names # that aren't equal to the users name. # Then it uses the updated names of the namespaces to update the associated routes - # For more info see https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23272 + # For more info see https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/23272 class FixUserNamespaceNames def perform(from_id, to_id) fix_namespace_names(from_id, to_id) diff --git a/lib/gitlab/background_migration/fix_user_project_route_names.rb b/lib/gitlab/background_migration/fix_user_project_route_names.rb index b84ff32e712..6b99685fd68 100644 --- a/lib/gitlab/background_migration/fix_user_project_route_names.rb +++ b/lib/gitlab/background_migration/fix_user_project_route_names.rb @@ -4,7 +4,7 @@ module Gitlab module BackgroundMigration # This migration fixes the routes.name for all user-projects that have names # that don't start with the users name. - # For more info see https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23272 + # For more info see https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/23272 class FixUserProjectRouteNames def perform(from_id, to_id) ActiveRecord::Base.connection.execute <<~ROUTES_UPDATE diff --git a/lib/gitlab/checks/diff_check.rb b/lib/gitlab/checks/diff_check.rb index 6372d96c07d..5de71addd5f 100644 --- a/lib/gitlab/checks/diff_check.rb +++ b/lib/gitlab/checks/diff_check.rb @@ -62,7 +62,7 @@ module Gitlab def process_commits logger.log_timed(LOG_MESSAGES[:diff_content_check]) do - # n+1: https://gitlab.com/gitlab-org/gitlab-ee/issues/3593 + # n+1: https://gitlab.com/gitlab-org/gitlab/issues/3593 ::Gitlab::GitalyClient.allow_n_plus_1_calls do commits.each do |commit| logger.check_timeout_reached diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb index 5874b01ef2a..07d5be86b1e 100644 --- a/lib/gitlab/ci/config/entry/job.rb +++ b/lib/gitlab/ci/config/entry/job.rb @@ -149,7 +149,7 @@ module Gitlab @entries.delete(:type) # This is something of a hack, see issue for details: - # https://gitlab.com/gitlab-org/gitlab-ce/issues/67150 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/67150 if !only_defined? && has_rules? @entries.delete(:only) @entries.delete(:except) diff --git a/lib/gitlab/ci/config/entry/root.rb b/lib/gitlab/ci/config/entry/root.rb index 0589ad3edf9..07022ff7b54 100644 --- a/lib/gitlab/ci/config/entry/root.rb +++ b/lib/gitlab/ci/config/entry/root.rb @@ -132,12 +132,12 @@ module Gitlab return unless @config.is_a?(Hash) @jobs_config = @config - .except(*self.class.reserved_nodes_names) # rubocop: disable CodeReuse/ActiveRecord + .except(*self.class.reserved_nodes_names) .select do |name, config| Entry::Jobs.find_type(name, config).present? end - @config = @config.except(*@jobs_config.keys) # rubocop: disable CodeReuse/ActiveRecord + @config = @config.except(*@jobs_config.keys) end end end diff --git a/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml b/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml index 2ca6e73a803..be584814271 100644 --- a/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml @@ -37,7 +37,7 @@ ensureContainer: - "mkdir -p ~/.docker && echo '{\"experimental\": \"enabled\"}' > ~/.docker/config.json" - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY # Skip update container `script` if the container already exists - # via https://gitlab.com/gitlab-org/gitlab-ce/issues/26866#note_97609397 -> https://stackoverflow.com/a/52077071/796832 + # via https://gitlab.com/gitlab-org/gitlab-foss/issues/26866#note_97609397 -> https://stackoverflow.com/a/52077071/796832 - docker manifest inspect $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG > /dev/null && exit || true diff --git a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml index f704266b73d..1ad9dd2913e 100644 --- a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml @@ -73,16 +73,16 @@ stages: - cleanup include: - - template: Jobs/Build.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml - - template: Jobs/Test.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Test.gitlab-ci.yml - - template: Jobs/Code-Quality.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml - - template: Jobs/Deploy.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml - - template: Jobs/Browser-Performance-Testing.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Browser-Performance-Testing.gitlab-ci.yml - - template: Security/DAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml - - template: Security/Container-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/Container-Scanning.gitlab-ci.yml - - template: Security/Dependency-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml - - template: Security/License-Management.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/License-Management.gitlab-ci.yml - - template: Security/SAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml + - template: Jobs/Build.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml + - template: Jobs/Test.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Test.gitlab-ci.yml + - template: Jobs/Code-Quality.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml + - template: Jobs/Deploy.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml + - template: Jobs/Browser-Performance-Testing.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Browser-Performance-Testing.gitlab-ci.yml + - template: Security/DAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml + - template: Security/Container-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/Container-Scanning.gitlab-ci.yml + - template: Security/Dependency-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml + - template: Security/License-Management.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/License-Management.gitlab-ci.yml + - template: Security/SAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml # Override DAST job to exclude master branch dast: diff --git a/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml b/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml index a61731a24b7..88f4b72044c 100644 --- a/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml @@ -4,13 +4,28 @@ # List of the variables: https://gitlab.com/gitlab-org/security-products/sast#settings # How to set: https://docs.gitlab.com/ee/ci/yaml/#variables -sast: +.sast: stage: test + allow_failure: true + artifacts: + reports: + sast: gl-sast-report.json + only: + refs: + - branches + variables: + - $GITLAB_FEATURES =~ /\bsast\b/ + +variables: + SAST_ANALYZER_IMAGE_PREFIX: "registry.gitlab.com/gitlab-org/security-products/analyzers" + SAST_DISABLE_DIND: "false" + +sast: + extends: .sast image: docker:stable variables: DOCKER_DRIVER: overlay2 DOCKER_TLS_CERTDIR: "" - allow_failure: true services: - docker:stable-dind script: @@ -63,15 +78,116 @@ sast: --volume "$PWD:/code" \ --volume /var/run/docker.sock:/var/run/docker.sock \ "registry.gitlab.com/gitlab-org/security-products/sast:$SAST_VERSION" /app/bin/run /code - artifacts: - reports: - sast: gl-sast-report.json - dependencies: [] - only: - refs: - - branches - variables: - - $GITLAB_FEATURES =~ /\bsast\b/ except: variables: - $SAST_DISABLED + - $SAST_DISABLE_DIND == 'true' + +.analyzer: + extends: .sast + except: + variables: + - $SAST_DISABLE_DIND == 'false' + script: + - /analyzer run + +bandit-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/bandit" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /python/' + +brakeman-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/brakeman" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /ruby/' + +eslint-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/eslint" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /javascript/' + +flawfinder-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/flawfinder" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\b(c\+\+|c\b)/' + +gosec-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/gosec" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /go/' + +nodejs-scan-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/nodejs-scan" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /javascript/' + +phpcs-security-audit-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/phpcs-security-audit" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /php/' + +pmd-apex-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/pmd-apex" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /apex/' + +secrets-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/secrets" + +security-code-scan-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/security-code-scan" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /c\#/ || $CI_PROJECT_REPOSITORY_LANGUAGES =~ /visual basic/' + +sobelow-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/sobelow" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /elixir/' + +spotbugs-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/spotbugs" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /java\b/' + +tslint-sast: + extends: .analyzer + image: + name: "$SAST_ANALYZER_IMAGE_PREFIX/tslint" + only: + variables: + - '$CI_PROJECT_REPOSITORY_LANGUAGES =~ /typescript/' diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb index 9550bc6d39c..5b8c2d2f7c7 100644 --- a/lib/gitlab/ci/trace.rb +++ b/lib/gitlab/ci/trace.rb @@ -188,7 +188,7 @@ module Gitlab def create_build_trace!(job, path) File.open(path) do |stream| # TODO: Set `file_format: :raw` after we've cleaned up legacy traces migration - # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20307 + # https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20307 job.create_job_artifacts_trace!( project: job.project, file_type: :trace, diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb index 75d9a2d55b9..3460e07fdc5 100644 --- a/lib/gitlab/data_builder/push.rb +++ b/lib/gitlab/data_builder/push.rb @@ -73,7 +73,7 @@ module Gitlab # For performance purposes maximum 20 latest commits # will be passed as post receive hook data. - # n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38259 + # n+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/38259 commit_attrs = Gitlab::GitalyClient.allow_n_plus_1_calls do commits_limited.map do |commit| commit.hook_attrs(with_changed_files: with_changed_files) diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index e4e93b59a36..bea9eb8cb31 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -14,7 +14,7 @@ module Gitlab MAX_TIMESTAMP_VALUE = Time.at((1 << 31) - 1).freeze # The maximum number of characters for text fields, to avoid DoS attacks via parsing huge text fields - # https://gitlab.com/gitlab-org/gitlab-ce/issues/61974 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/61974 MAX_TEXT_SIZE_LIMIT = 1_000_000 # Minimum schema version from which migrations are supported diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb index d2484217ab9..ca7974930af 100644 --- a/lib/gitlab/diff/highlight.rb +++ b/lib/gitlab/diff/highlight.rb @@ -35,7 +35,7 @@ module Gitlab # match the blob, which is a bug. But we shouldn't fail to render # completely in that case, even though we want to report the error. rescue RangeError => e - Gitlab::Sentry.track_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/45441') + Gitlab::Sentry.track_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/45441') end end diff --git a/lib/gitlab/ee_compat_check.rb b/lib/gitlab/ee_compat_check.rb index 5cd90814ca3..707e45dfb71 100644 --- a/lib/gitlab/ee_compat_check.rb +++ b/lib/gitlab/ee_compat_check.rb @@ -4,8 +4,8 @@ module Gitlab # Checks if a set of migrations requires downtime or not. class EeCompatCheck - CANONICAL_CE_PROJECT_URL = 'https://gitlab.com/gitlab-org/gitlab-ce' - CANONICAL_EE_REPO_URL = 'https://gitlab.com/gitlab-org/gitlab-ee.git' + CANONICAL_CE_PROJECT_URL = 'https://gitlab.com/gitlab-org/gitlab-foss' + CANONICAL_EE_REPO_URL = 'https://gitlab.com/gitlab-org/gitlab.git' CHECK_DIR = Rails.root.join('ee_compat_check') IGNORED_FILES_REGEX = /VERSION|CHANGELOG\.md|doc\/.+/i.freeze PLEASE_READ_THIS_BANNER = %Q{ diff --git a/lib/gitlab/etag_caching/router.rb b/lib/gitlab/etag_caching/router.rb index 7b921ab6199..3d14a8dde8d 100644 --- a/lib/gitlab/etag_caching/router.rb +++ b/lib/gitlab/etag_caching/router.rb @@ -52,6 +52,10 @@ module Gitlab %r(#{RESERVED_WORDS_PREFIX}/builds/\d+\.json\z), 'project_build' ), + Gitlab::EtagCaching::Router::Route.new( + %r(#{RESERVED_WORDS_PREFIX}/clusters/\d+/environments\z), + 'cluster_environments' + ), Gitlab::EtagCaching::Router::Route.new( %r(#{RESERVED_WORDS_PREFIX}/environments\.json\z), 'environments' diff --git a/lib/gitlab/git/keep_around.rb b/lib/gitlab/git/keep_around.rb new file mode 100644 index 00000000000..d58f10bdbb7 --- /dev/null +++ b/lib/gitlab/git/keep_around.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +# Makes sure a commit is kept around when Git garbage collection runs. +# Git GC will delete commits from the repository that are no longer in any +# branches or tags, but we want to keep some of these commits around, for +# example if they have comments or CI builds. +# +# For Geo's sake, pass in multiple shas rather than calling it multiple times, +# to avoid unnecessary syncing. +module Gitlab + module Git + class KeepAround + def self.execute(repository, shas) + new(repository).execute(shas) + end + + def initialize(repository) + @repository = repository + end + + def execute(shas) + shas.each do |sha| + next unless sha.present? && commit_by(oid: sha) + + next if kept_around?(sha) + + # This will still fail if the file is corrupted (e.g. 0 bytes) + raw_repository.write_ref(keep_around_ref_name(sha), sha) + rescue Gitlab::Git::CommandError => ex + Rails.logger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}" # rubocop:disable Gitlab/RailsLogger + end + end + + def kept_around?(sha) + ref_exists?(keep_around_ref_name(sha)) + end + + delegate :commit_by, :raw_repository, :ref_exists?, :disk_path, to: :@repository + private :commit_by, :raw_repository, :ref_exists?, :disk_path + + private + + def keep_around_ref_name(sha) + "refs/#{::Repository::REF_KEEP_AROUND}/#{sha}" + end + end + end +end diff --git a/lib/gitlab/gpg/commit.rb b/lib/gitlab/gpg/commit.rb index 1d317c389d2..4b797a0e397 100644 --- a/lib/gitlab/gpg/commit.rb +++ b/lib/gitlab/gpg/commit.rb @@ -80,7 +80,7 @@ module Gitlab def gpgme_signature GPGME::Crypto.new.verify(signature_text, signed_text: signed_text) do |verified_signature| - # Return the first signature for now: https://gitlab.com/gitlab-org/gitlab-ce/issues/54932 + # Return the first signature for now: https://gitlab.com/gitlab-org/gitlab-foss/issues/54932 break verified_signature end rescue GPGME::Error diff --git a/lib/gitlab/graphql/authorize/authorize_resource.rb b/lib/gitlab/graphql/authorize/authorize_resource.rb index 6844367454f..df60b9d8346 100644 --- a/lib/gitlab/graphql/authorize/authorize_resource.rb +++ b/lib/gitlab/graphql/authorize/authorize_resource.rb @@ -46,7 +46,7 @@ module Gitlab # this was named `#authorized?`, however it conflicts with the native # graphql gem version # TODO consider adopting the gem's built in authorization system - # https://gitlab.com/gitlab-org/gitlab-ee/issues/13984 + # https://gitlab.com/gitlab-org/gitlab/issues/13984 def authorized_resource?(object) # Sanity check. We don't want to accidentally allow a developer to authorize # without first adding permissions to authorize against diff --git a/lib/gitlab/import_export/lfs_restorer.rb b/lib/gitlab/import_export/lfs_restorer.rb index 1de8a5bf9ec..ef83cdf24b1 100644 --- a/lib/gitlab/import_export/lfs_restorer.rb +++ b/lib/gitlab/import_export/lfs_restorer.rb @@ -50,7 +50,7 @@ module Gitlab # with a single `lfs_objects_projects` relation. # # This allows us backwards-compatibility without version bumping. - # See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/30830#note_192608870 + # See https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/30830#note_192608870 return ['project'] unless has_lfs_json? lfs_json[oid] diff --git a/lib/gitlab/json_cache.rb b/lib/gitlab/json_cache.rb index 84c6817f3c7..9aa71db6b18 100644 --- a/lib/gitlab/json_cache.rb +++ b/lib/gitlab/json_cache.rb @@ -79,7 +79,7 @@ module Gitlab # is being applied on ActiveRecord::Associations::CollectionAssociation#scope # when the new_record? method incorrectly returns false. # - # See https://gitlab.com/gitlab-org/gitlab-ee/issues/9903#note_145329964 + # See https://gitlab.com/gitlab-org/gitlab/issues/9903#note_145329964 klass .allocate .init_with( diff --git a/lib/gitlab/kubernetes/helm/reset_command.rb b/lib/gitlab/kubernetes/helm/reset_command.rb index a35ffa34c58..c8349639ec3 100644 --- a/lib/gitlab/kubernetes/helm/reset_command.rb +++ b/lib/gitlab/kubernetes/helm/reset_command.rb @@ -33,10 +33,10 @@ module Gitlab private # This method can be delete once we upgrade Helm to > 12.13.0 - # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/27096#note_159695900 + # https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/27096#note_159695900 # # Tracking this method to be removed here: - # https://gitlab.com/gitlab-org/gitlab-ce/issues/52791#note_199374155 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/52791#note_199374155 def delete_tiller_replicaset delete_args = %w[replicaset -n gitlab-managed-apps -l name=tiller] diff --git a/lib/gitlab/legacy_github_import/label_formatter.rb b/lib/gitlab/legacy_github_import/label_formatter.rb index 89200e794d8..0b6e4612843 100644 --- a/lib/gitlab/legacy_github_import/label_formatter.rb +++ b/lib/gitlab/legacy_github_import/label_formatter.rb @@ -15,7 +15,6 @@ module Gitlab :labels end - # rubocop: disable CodeReuse/ActiveRecord def create! params = attributes.except(:project) service = ::Labels::FindOrCreateService.new(nil, project, params) @@ -25,7 +24,6 @@ module Gitlab label end - # rubocop: enable CodeReuse/ActiveRecord private diff --git a/lib/gitlab/metrics/dashboard/errors.rb b/lib/gitlab/metrics/dashboard/errors.rb index 1739a4e6738..d41bd2c43c7 100644 --- a/lib/gitlab/metrics/dashboard/errors.rb +++ b/lib/gitlab/metrics/dashboard/errors.rb @@ -7,14 +7,16 @@ module Gitlab module Metrics module Dashboard module Errors + DashboardProcessingError = Class.new(StandardError) PanelNotFoundError = Class.new(StandardError) + LayoutError = Class.new(DashboardProcessingError) + MissingQueryError = Class.new(DashboardProcessingError) - PROCESSING_ERROR = Gitlab::Metrics::Dashboard::Stages::BaseStage::DashboardProcessingError NOT_FOUND_ERROR = Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError def handle_errors(error) case error - when PROCESSING_ERROR + when DashboardProcessingError error(error.message, :unprocessable_entity) when NOT_FOUND_ERROR error("#{dashboard_path} could not be found.", :not_found) diff --git a/lib/gitlab/metrics/dashboard/finder.rb b/lib/gitlab/metrics/dashboard/finder.rb index 66c4d662a6c..c3169418371 100644 --- a/lib/gitlab/metrics/dashboard/finder.rb +++ b/lib/gitlab/metrics/dashboard/finder.rb @@ -28,9 +28,9 @@ module Gitlab # @param options - y_label [String] Y-Axis label of # a panel. Used by embedded dashboards. # @return [Hash] - def find(project, user, environment, options = {}) + def find(project, user, options = {}) service_for(options) - .new(project, user, options.merge(environment: environment)) + .new(project, user, options) .get_dashboard end diff --git a/lib/gitlab/metrics/dashboard/processor.rb b/lib/gitlab/metrics/dashboard/processor.rb index c0fa3bb2f3a..bfdee76a818 100644 --- a/lib/gitlab/metrics/dashboard/processor.rb +++ b/lib/gitlab/metrics/dashboard/processor.rb @@ -8,43 +8,23 @@ module Gitlab # the UI. These includes shared metric info, custom metrics # info, and alerts (only in EE). class Processor - SYSTEM_SEQUENCE = [ - Stages::CommonMetricsInserter, - Stages::ProjectMetricsInserter, - Stages::EndpointInserter, - Stages::Sorter - ].freeze - - PROJECT_SEQUENCE = [ - Stages::CommonMetricsInserter, - Stages::EndpointInserter, - Stages::Sorter - ].freeze - - def initialize(project, environment, dashboard) + def initialize(project, dashboard, sequence, params) @project = project - @environment = environment @dashboard = dashboard + @sequence = sequence + @params = params end # Returns a new dashboard hash with the results of # running transforms on the dashboard. - def process(insert_project_metrics:) + def process @dashboard.deep_symbolize_keys.tap do |dashboard| - sequence(insert_project_metrics).each do |stage| - stage.new(@project, @environment, dashboard).transform! + @sequence.each do |stage| + stage.new(@project, dashboard, @params).transform! end end end - - private - - def sequence(insert_project_metrics) - insert_project_metrics ? SYSTEM_SEQUENCE : PROJECT_SEQUENCE - end end end end end - -Gitlab::Metrics::Dashboard::Processor.prepend_if_ee('EE::Gitlab::Metrics::Dashboard::Processor') diff --git a/lib/gitlab/metrics/dashboard/service_selector.rb b/lib/gitlab/metrics/dashboard/service_selector.rb index 934ba9145a2..10b686fbb81 100644 --- a/lib/gitlab/metrics/dashboard/service_selector.rb +++ b/lib/gitlab/metrics/dashboard/service_selector.rb @@ -48,3 +48,5 @@ module Gitlab end end end + +Gitlab::Metrics::Dashboard::ServiceSelector.prepend_if_ee('EE::Gitlab::Metrics::Dashboard::ServiceSelector') diff --git a/lib/gitlab/metrics/dashboard/stages/base_stage.rb b/lib/gitlab/metrics/dashboard/stages/base_stage.rb index 514ed50e58d..f9e4ae4b4b5 100644 --- a/lib/gitlab/metrics/dashboard/stages/base_stage.rb +++ b/lib/gitlab/metrics/dashboard/stages/base_stage.rb @@ -7,15 +7,12 @@ module Gitlab class BaseStage include Gitlab::Metrics::Dashboard::Defaults - DashboardProcessingError = Class.new(StandardError) - LayoutError = Class.new(DashboardProcessingError) + attr_reader :project, :dashboard, :params - attr_reader :project, :environment, :dashboard - - def initialize(project, environment, dashboard) + def initialize(project, dashboard, params) @project = project - @environment = environment @dashboard = dashboard + @params = params end # Entry-point to the stage @@ -26,15 +23,15 @@ module Gitlab protected def missing_panel_groups! - raise LayoutError.new('Top-level key :panel_groups must be an array') + raise Errors::LayoutError.new('Top-level key :panel_groups must be an array') end def missing_panels! - raise LayoutError.new('Each "panel_group" must define an array :panels') + raise Errors::LayoutError.new('Each "panel_group" must define an array :panels') end def missing_metrics! - raise LayoutError.new('Each "panel" must define an array :metrics') + raise Errors::LayoutError.new('Each "panel" must define an array :metrics') end def for_metrics diff --git a/lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb b/lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb index 2a959854be0..c00ef208848 100644 --- a/lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb +++ b/lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb @@ -5,9 +5,9 @@ module Gitlab module Dashboard module Stages class EndpointInserter < BaseStage - MissingQueryError = Class.new(DashboardProcessingError) - def transform! + raise Errors::DashboardProcessingError.new('Environment is required for Stages::EndpointInserter') unless params[:environment] + for_metrics do |metric| metric[:prometheus_endpoint_path] = endpoint_for_metric(metric) end @@ -18,7 +18,7 @@ module Gitlab def endpoint_for_metric(metric) Gitlab::Routing.url_helpers.prometheus_api_project_environment_path( project, - environment, + params[:environment], proxy_path: query_type(metric), query: query_for_metric(metric) ) @@ -31,7 +31,7 @@ module Gitlab def query_for_metric(metric) query = metric[query_type(metric)] - raise MissingQueryError.new('Each "metric" must define one of :query or :query_range') unless query + raise Errors::MissingQueryError.new('Each "metric" must define one of :query or :query_range') unless query query end diff --git a/lib/gitlab/middleware/basic_health_check.rb b/lib/gitlab/middleware/basic_health_check.rb index 84e49805428..1f8f87fc33f 100644 --- a/lib/gitlab/middleware/basic_health_check.rb +++ b/lib/gitlab/middleware/basic_health_check.rb @@ -27,7 +27,7 @@ module Gitlab # We should be using ActionDispatch::Request instead of # Rack::Request to be consistent with Rails, but due to a Rails # bug described in - # https://gitlab.com/gitlab-org/gitlab-ce/issues/58573#note_149799010 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/58573#note_149799010 # hosts behind a load balancer will only see 127.0.0.1 for the # load balancer's IP. request = Rack::Request.new(env) diff --git a/lib/gitlab/multi_collection_paginator.rb b/lib/gitlab/multi_collection_paginator.rb index 5375077d7dc..33e0c6aa9b7 100644 --- a/lib/gitlab/multi_collection_paginator.rb +++ b/lib/gitlab/multi_collection_paginator.rb @@ -55,7 +55,6 @@ module Gitlab @first_collection_page_count = first_collection_page.total_pages end - # rubocop: disable CodeReuse/ActiveRecord def first_collection_last_page_size return @first_collection_last_page_size if defined?(@first_collection_last_page_size) @@ -63,6 +62,5 @@ module Gitlab .except(:select) .size end - # rubocop: enable CodeReuse/ActiveRecord end end diff --git a/lib/gitlab/pages_client.rb b/lib/gitlab/pages_client.rb index 281eafb142f..30a1f9ede25 100644 --- a/lib/gitlab/pages_client.rb +++ b/lib/gitlab/pages_client.rb @@ -109,7 +109,7 @@ module Gitlab File.link(f.path, token_path) end rescue Errno::EACCES => ex - # TODO stop rescuing this exception in GitLab 11.0 https://gitlab.com/gitlab-org/gitlab-ce/issues/45672 + # TODO stop rescuing this exception in GitLab 11.0 https://gitlab.com/gitlab-org/gitlab-foss/issues/45672 Rails.logger.error("Could not write pages admin token file: #{ex}") # rubocop:disable Gitlab/RailsLogger rescue Errno::EEXIST # Another process wrote the token file concurrently with us. Use their token, not ours. diff --git a/lib/gitlab/patch/active_record_query_cache.rb b/lib/gitlab/patch/active_record_query_cache.rb index 71d66bdbe02..d6b649cdea7 100644 --- a/lib/gitlab/patch/active_record_query_cache.rb +++ b/lib/gitlab/patch/active_record_query_cache.rb @@ -4,7 +4,7 @@ # ActiveRecord connection used in tests # https://github.com/rails/rails/issues/36587 -# To be removed with https://gitlab.com/gitlab-org/gitlab-ce/issues/64413 +# To be removed with https://gitlab.com/gitlab-org/gitlab-foss/issues/64413 module Gitlab module Patch diff --git a/lib/gitlab/phabricator_import/issues/task_importer.rb b/lib/gitlab/phabricator_import/issues/task_importer.rb index 77ee11c7cdd..c17f3e1729a 100644 --- a/lib/gitlab/phabricator_import/issues/task_importer.rb +++ b/lib/gitlab/phabricator_import/issues/task_importer.rb @@ -12,7 +12,7 @@ module Gitlab # TODO: Reformat the description with attachments, escaping accidental # links and add attachments - # https://gitlab.com/gitlab-org/gitlab-ce/issues/60603 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/60603 issue.assign_attributes(task.issue_attributes) save! diff --git a/lib/gitlab/request_context.rb b/lib/gitlab/request_context.rb index f6d289476c5..ab2549d5e68 100644 --- a/lib/gitlab/request_context.rb +++ b/lib/gitlab/request_context.rb @@ -16,7 +16,7 @@ module Gitlab # We should be using ActionDispatch::Request instead of # Rack::Request to be consistent with Rails, but due to a Rails # bug described in - # https://gitlab.com/gitlab-org/gitlab-ce/issues/58573#note_149799010 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/58573#note_149799010 # hosts behind a load balancer will only see 127.0.0.1 for the # load balancer's IP. req = Rack::Request.new(env) diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index 9e813968093..7dbed591b84 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -232,7 +232,7 @@ module Gitlab # add_namespace("default", "gitlab") # def add_namespace(storage, name) - # https://gitlab.com/gitlab-org/gitlab-ce/issues/58012 + # https://gitlab.com/gitlab-org/gitlab-foss/issues/58012 Gitlab::GitalyClient.allow_n_plus_1_calls do Gitlab::GitalyClient::NamespaceService.new(storage).add(name) end diff --git a/lib/gitlab/tracking.rb b/lib/gitlab/tracking.rb index ef669b03c87..78177c6d306 100644 --- a/lib/gitlab/tracking.rb +++ b/lib/gitlab/tracking.rb @@ -24,8 +24,8 @@ module Gitlab hostname: Gitlab::CurrentSettings.snowplow_collector_hostname, cookie_domain: Gitlab::CurrentSettings.snowplow_cookie_domain, app_id: Gitlab::CurrentSettings.snowplow_site_id, - page_tracking_enabled: additional_features, - activity_tracking_enabled: additional_features + form_tracking: additional_features, + link_click_tracking: additional_features }.transform_keys! { |key| key.to_s.camelize(:lower).to_sym } end diff --git a/lib/gitlab/url_blockers/url_whitelist.rb b/lib/gitlab/url_blockers/url_whitelist.rb index a0cfcbc49a3..7622de4fdbe 100644 --- a/lib/gitlab/url_blockers/url_whitelist.rb +++ b/lib/gitlab/url_blockers/url_whitelist.rb @@ -30,7 +30,7 @@ module Gitlab # Gitlab::CurrentSettings creates an ApplicationSetting which then # calls this method. # - # See https://gitlab.com/gitlab-org/gitlab-ee/issues/9833 + # See https://gitlab.com/gitlab-org/gitlab/issues/9833 def outbound_local_requests_whitelist_arrays return [[], []] unless ApplicationSetting.current diff --git a/lib/gitlab/utils/override.rb b/lib/gitlab/utils/override.rb index f5299439fce..35aea209cb9 100644 --- a/lib/gitlab/utils/override.rb +++ b/lib/gitlab/utils/override.rb @@ -115,7 +115,7 @@ module Gitlab # end # # This would make sure we're overriding something. See: - # https://gitlab.com/gitlab-org/gitlab-ee/issues/1819 + # https://gitlab.com/gitlab-org/gitlab/issues/1819 def override(method_name) return unless ENV['STATIC_VERIFICATION'] diff --git a/lib/support/nginx/registry-ssl b/lib/support/nginx/registry-ssl index 908d26a0da2..df126919866 100644 --- a/lib/support/nginx/registry-ssl +++ b/lib/support/nginx/registry-ssl @@ -16,7 +16,7 @@ server { } server { - # If a different port is specified in https://gitlab.com/gitlab-org/gitlab-ce/blob/8-8-stable/config/gitlab.yml.example#L182, + # If a different port is specified in https://gitlab.com/gitlab-org/gitlab-foss/blob/8-8-stable/config/gitlab.yml.example#L182, # it should be declared here as well listen *:443 ssl http2; server_name registry.gitlab.example.com; diff --git a/lib/tasks/downtime_check.rake b/lib/tasks/downtime_check.rake index 557f4fef10b..ce97ed50fc7 100644 --- a/lib/tasks/downtime_check.rake +++ b/lib/tasks/downtime_check.rake @@ -1,9 +1,9 @@ desc 'Checks if migrations in a branch require downtime' task downtime_check: :environment do repo = if defined?(Gitlab::License) - 'gitlab-ee' + 'gitlab' else - 'gitlab-ce' + 'gitlab-foss' end `git fetch https://gitlab.com/gitlab-org/#{repo}.git --depth 1` diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index 91a52144dd2..dfc0047e753 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -13,7 +13,7 @@ namespace :gettext do end task :compile do - # See: https://gitlab.com/gitlab-org/gitlab-ce/issues/33014#note_31218998 + # See: https://gitlab.com/gitlab-org/gitlab-foss/issues/33014#note_31218998 FileUtils.touch(File.join(Rails.root, 'locale/gitlab.pot')) Rake::Task['gettext:po_to_json'].invoke diff --git a/lib/tasks/gitlab/dev.rake b/lib/tasks/gitlab/dev.rake index 77c28615856..17d3ac74375 100644 --- a/lib/tasks/gitlab/dev.rake +++ b/lib/tasks/gitlab/dev.rake @@ -18,7 +18,7 @@ namespace :gitlab do args end - if File.basename(Rails.root) == 'gitlab-ee' + if File.basename(Rails.root) == 'gitlab' puts "Skipping EE projects" exit 0 elsif Gitlab::EeCompatCheck.new(opts || {}).check diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index 487808a7baa..abd47f018f1 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -135,7 +135,7 @@ namespace :gitlab do then you may have been affected by the 9.3.0 bug in which the new setting was disabled by default. - https://gitlab.com/gitlab-org/gitlab-ee/issues/2738 + https://gitlab.com/gitlab-org/gitlab/issues/2738 It was reverted in 9.3.1 and fixed in 9.3.3, however, if Settings were saved while the setting was unchecked, then it is still disabled. -- cgit v1.2.3