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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-11-14 11:41:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-11-14 11:41:52 +0300
commit585826cb22ecea5998a2c2a4675735c94bdeedac (patch)
tree5b05f0b30d33cef48963609e8a18a4dff260eab3 /lib/gitlab/regex
parentdf221d036e5d0c6c0ee4d55b9c97f481ee05dee8 (diff)
Add latest changes from gitlab-org/gitlab@16-6-stable-eev16.6.0-rc42
Diffstat (limited to 'lib/gitlab/regex')
-rw-r--r--lib/gitlab/regex/packages.rb8
-rw-r--r--lib/gitlab/regex/packages/protection/rules.rb15
2 files changed, 21 insertions, 2 deletions
diff --git a/lib/gitlab/regex/packages.rb b/lib/gitlab/regex/packages.rb
index 6b178933a25..a0038d39318 100644
--- a/lib/gitlab/regex/packages.rb
+++ b/lib/gitlab/regex/packages.rb
@@ -3,6 +3,8 @@
module Gitlab
module Regex
module Packages
+ include ::Gitlab::Utils::StrongMemoize
+
CONAN_RECIPE_FILES = %w[conanfile.py conanmanifest.txt conan_sources.tgz conan_export.tgz].freeze
CONAN_PACKAGE_FILES = %w[conaninfo.txt conanmanifest.txt conan_package.tgz].freeze
@@ -74,8 +76,10 @@ module Gitlab
maven_app_name_regex
end
- def npm_package_name_regex
- @npm_package_name_regex ||= %r{\A(?:@(#{Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX})/)?[-+\.\_a-zA-Z0-9]+\z}o
+ def npm_package_name_regex(other_accepted_chars = nil)
+ strong_memoize_with(:npm_package_name_regex, other_accepted_chars) do
+ %r{\A(?:@(#{Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX})/)?[-+\.\_a-zA-Z0-9#{other_accepted_chars}]+\z}
+ end
end
def npm_package_name_regex_message
diff --git a/lib/gitlab/regex/packages/protection/rules.rb b/lib/gitlab/regex/packages/protection/rules.rb
new file mode 100644
index 00000000000..383f26fe92d
--- /dev/null
+++ b/lib/gitlab/regex/packages/protection/rules.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Regex
+ module Packages
+ module Protection
+ module Rules
+ def protection_rules_npm_package_name_pattern_regex
+ @protection_rules_npm_package_name_pattern_regex ||= npm_package_name_regex('*')
+ end
+ end
+ end
+ end
+ end
+end