2020-03-18 08:09:13 -04:00
|
|
|
# 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
|
2021-05-13 20:11:05 -04:00
|
|
|
# * Characters must be from the Base64 alphabet (RFC4648) with the addition of '@', ':', '.', and '~'
|
2020-03-18 08:09:13 -04:00
|
|
|
# * Absolutely no fun is allowed
|
2021-07-14 14:08:31 -04:00
|
|
|
REGEX = %r{\A[a-zA-Z0-9_+=/@:.~-]{8,}\z}.freeze
|
2020-03-18 08:09:13 -04:00
|
|
|
|
|
|
|
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
|