diff options
Diffstat (limited to 'app/models/concerns/ci/maskable.rb')
-rw-r--r-- | app/models/concerns/ci/maskable.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/concerns/ci/maskable.rb b/app/models/concerns/ci/maskable.rb new file mode 100644 index 00000000000..15bc48bf964 --- /dev/null +++ b/app/models/concerns/ci/maskable.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Ci + module Maskable + extend ActiveSupport::Concern + + # * Single line + # * No escape characters + # * No variables + # * No spaces + # * Minimal length of 8 characters + # * Characters must be from the Base64 alphabet (RFC4648) with the addition of @ and : + # * Absolutely no fun is allowed + REGEX = /\A[a-zA-Z0-9_+=\/@:-]{8,}\z/.freeze + + included do + validates :masked, inclusion: { in: [true, false] } + validates :value, format: { with: REGEX }, if: :masked? + end + + def to_runner_variable + super.merge(masked: masked?) + end + end +end |