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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-18 15:09:13 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-18 15:09:13 +0300
commit1363ca12f1f07c634647cf55c4c16b7401098673 (patch)
treed932caf09c8148322edb51ae954ed159ff7d00f8 /app/models/concerns/ci/maskable.rb
parent6763d2787670bc03a36a8eb601703e88fc70dece (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns/ci/maskable.rb')
-rw-r--r--app/models/concerns/ci/maskable.rb25
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