diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /lib/gitlab/untrusted_regexp | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'lib/gitlab/untrusted_regexp')
-rw-r--r-- | lib/gitlab/untrusted_regexp/ruby_syntax.rb | 16 |
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 |