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/ci/config/interpolation/inputs/string_input.rb')
-rw-r--r--lib/gitlab/ci/config/interpolation/inputs/string_input.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab/ci/config/interpolation/inputs/string_input.rb b/lib/gitlab/ci/config/interpolation/inputs/string_input.rb
index 39870582d0c..3f40e851f11 100644
--- a/lib/gitlab/ci/config/interpolation/inputs/string_input.rb
+++ b/lib/gitlab/ci/config/interpolation/inputs/string_input.rb
@@ -25,6 +25,24 @@ module Gitlab
def valid_value?(value)
value.nil? || value.is_a?(String)
end
+
+ private
+
+ def validate_regex!
+ return unless spec.key?(:regex)
+
+ safe_regex = ::Gitlab::UntrustedRegexp.new(spec[:regex])
+
+ return if safe_regex.match?(actual_value)
+
+ if value.nil?
+ error('default value does not match required RegEx pattern')
+ else
+ error('provided value does not match required RegEx pattern')
+ end
+ rescue RegexpError
+ error('invalid regular expression')
+ end
end
end
end