diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-28 03:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-28 03:09:24 +0300 |
commit | 63895155f203b6af2df0689474059c1c7dfcfac8 (patch) | |
tree | 301f7d43471cbb7b19bf92561578e6cef8d28b99 /app/models/concerns | |
parent | 936139e69ce259283d02877bcb23ca77f65e2c60 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/ci/maskable.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/app/models/concerns/ci/maskable.rb b/app/models/concerns/ci/maskable.rb index 62be0150ee0..f8f6693c122 100644 --- a/app/models/concerns/ci/maskable.rb +++ b/app/models/concerns/ci/maskable.rb @@ -12,10 +12,30 @@ module Ci # * Characters must be from the Base64 alphabet (RFC4648) with the addition of '@', ':', '.', and '~' # * Absolutely no fun is allowed REGEX = %r{\A[a-zA-Z0-9_+=/@:.~-]{8,}\z}.freeze + # * Single line + # * No spaces + # * Minimal length of 8 characters + # * Some fun is allowed + MASK_AND_RAW_REGEX = %r{\A\S{8,}\z}.freeze included do validates :masked, inclusion: { in: [true, false] } - validates :value, format: { with: REGEX }, if: :masked? + validates :value, format: { with: REGEX }, if: :masked_and_expanded? + validates :value, format: { with: MASK_AND_RAW_REGEX }, if: :masked_and_raw? + end + + def masked_and_raw? + return false unless Feature.enabled?(:ci_remove_character_limitation_raw_masked_var) + return false unless self.class.method_defined?(:raw) + + masked? && raw? + end + + def masked_and_expanded? + return masked? unless Feature.enabled?(:ci_remove_character_limitation_raw_masked_var) + return masked? unless self.class.method_defined?(:raw) + + masked? && !raw? end def to_runner_variable |