Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-08-30 22:43:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-30 22:43:23 +0300
commitba25c7ef51673db933439a6a2b1503d7c12bec14 (patch)
tree772e1dac7dfa837e6cf990c60887880385e07961 /app
parent01ab84cac0d67be0e81d9c31216408dffc0ce369 (diff)
Add latest changes from gitlab-org/security/gitlab@16-2-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/models/bulk_imports/entity.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/app/models/bulk_imports/entity.rb b/app/models/bulk_imports/entity.rb
index 4f50a112141..644673e249e 100644
--- a/app/models/bulk_imports/entity.rb
+++ b/app/models/bulk_imports/entity.rb
@@ -41,19 +41,15 @@ class BulkImports::Entity < ApplicationRecord
validates :project, absence: true, if: :group
validates :group, absence: true, if: :project
validates :source_type, presence: true
- validates :source_full_path, presence: true, format: {
- with: Gitlab::Regex.bulk_import_source_full_path_regex,
- message: Gitlab::Regex.bulk_import_source_full_path_regex_message
- }
-
+ validates :source_full_path, presence: true
validates :destination_name, presence: true, if: -> { group || project }
validates :destination_namespace, exclusion: [nil], if: :group
validates :destination_namespace, presence: true, if: :project?
validate :validate_parent_is_a_group, if: :parent
validate :validate_imported_entity_type
-
validate :validate_destination_namespace_ascendency, if: :group_entity?
+ validate :validate_source_full_path_format
enum source_type: { group_entity: 0, project_entity: 1 }
@@ -236,4 +232,15 @@ class BulkImports::Entity < ApplicationRecord
)
end
end
+
+ def validate_source_full_path_format
+ validator = group? ? NamespacePathValidator : ProjectPathValidator
+
+ return if validator.valid_path?(source_full_path)
+
+ errors.add(
+ :source_full_path,
+ Gitlab::Regex.bulk_import_source_full_path_regex_message
+ )
+ end
end