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:
Diffstat (limited to 'lib/gitlab/untrusted_regexp/ruby_syntax.rb')
-rw-r--r--lib/gitlab/untrusted_regexp/ruby_syntax.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/gitlab/untrusted_regexp/ruby_syntax.rb b/lib/gitlab/untrusted_regexp/ruby_syntax.rb
index 6adf119aa75..010214cf295 100644
--- a/lib/gitlab/untrusted_regexp/ruby_syntax.rb
+++ b/lib/gitlab/untrusted_regexp/ruby_syntax.rb
@@ -20,13 +20,13 @@ module Gitlab
!!self.fabricate(pattern, fallback: fallback)
end
- def self.fabricate(pattern, fallback: false)
- self.fabricate!(pattern, fallback: fallback)
+ def self.fabricate(pattern, fallback: false, project: nil)
+ self.fabricate!(pattern, fallback: fallback, project: project)
rescue RegexpError
nil
end
- def self.fabricate!(pattern, fallback: false)
+ def self.fabricate!(pattern, fallback: false, project: nil)
raise RegexpError, 'Pattern is not string!' unless pattern.is_a?(String)
matches = pattern.match(PATTERN)
@@ -38,6 +38,16 @@ module Gitlab
raise unless fallback &&
Feature.enabled?(:allow_unsafe_ruby_regexp, default_enabled: false)
+ if Feature.enabled?(:ci_unsafe_regexp_logger, type: :ops, default_enabled: :yaml)
+ Gitlab::AppJsonLogger.info(
+ class: self.class.name,
+ regexp: pattern.to_s,
+ fabricated: 'unsafe ruby regexp',
+ project_id: project&.id,
+ project_path: project&.full_path
+ )
+ end
+
create_ruby_regexp(matches[:regexp], matches[:flags])
end
end