Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0f036967
Commit
0f036967
authored
Mar 16, 2020
by
Fabio Pitino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Maskable concern to Ci namespace
The concern is only used by CI variables
parent
93fa7a0e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
30 deletions
+32
-30
app/helpers/ci_variables_helper.rb
app/helpers/ci_variables_helper.rb
+1
-1
app/models/ci/group_variable.rb
app/models/ci/group_variable.rb
+1
-1
app/models/ci/variable.rb
app/models/ci/variable.rb
+1
-1
app/models/concerns/ci/maskable.rb
app/models/concerns/ci/maskable.rb
+25
-0
app/models/concerns/maskable.rb
app/models/concerns/maskable.rb
+0
-23
spec/models/ci/group_variable_spec.rb
spec/models/ci/group_variable_spec.rb
+1
-1
spec/models/ci/variable_spec.rb
spec/models/ci/variable_spec.rb
+1
-1
spec/models/concerns/ci/maskable_spec.rb
spec/models/concerns/ci/maskable_spec.rb
+2
-2
No files found.
app/helpers/ci_variables_helper.rb
View file @
0f036967
...
...
@@ -45,6 +45,6 @@ module CiVariablesHelper
end
def
ci_variable_maskable_regex
Maskable
::
REGEX
.
inspect
.
sub
(
'\\A'
,
'^'
).
sub
(
'\\z'
,
'$'
).
sub
(
/^\//
,
''
).
sub
(
/\/[a-z]*$/
,
''
).
gsub
(
'\/'
,
'/'
)
Ci
::
Maskable
::
REGEX
.
inspect
.
sub
(
'\\A'
,
'^'
).
sub
(
'\\z'
,
'$'
).
sub
(
/^\//
,
''
).
sub
(
/\/[a-z]*$/
,
''
).
gsub
(
'\/'
,
'/'
)
end
end
app/models/ci/group_variable.rb
View file @
0f036967
...
...
@@ -5,7 +5,7 @@ module Ci
extend
Gitlab
::
Ci
::
Model
include
HasVariable
include
Presentable
include
Maskable
include
Ci
::
Maskable
belongs_to
:group
,
class_name:
"::Group"
...
...
app/models/ci/variable.rb
View file @
0f036967
...
...
@@ -5,7 +5,7 @@ module Ci
extend
Gitlab
::
Ci
::
Model
include
HasVariable
include
Presentable
include
Maskable
include
Ci
::
Maskable
prepend
HasEnvironmentScope
belongs_to
:project
...
...
app/models/concerns/ci/maskable.rb
0 → 100644
View file @
0f036967
# 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
app/models/concerns/maskable.rb
deleted
100644 → 0
View file @
93fa7a0e
# frozen_string_literal: true
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
spec/models/ci/group_variable_spec.rb
View file @
0f036967
...
...
@@ -8,7 +8,7 @@ describe Ci::GroupVariable do
it_behaves_like
"CI variable"
it
{
is_expected
.
to
include_module
(
Presentable
)
}
it
{
is_expected
.
to
include_module
(
Maskable
)
}
it
{
is_expected
.
to
include_module
(
Ci
::
Maskable
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:key
).
scoped_to
(
:group_id
).
with_message
(
/\(\w+\) has already been taken/
)
}
describe
'.unprotected'
do
...
...
spec/models/ci/variable_spec.rb
View file @
0f036967
...
...
@@ -9,7 +9,7 @@ describe Ci::Variable do
describe
'validations'
do
it
{
is_expected
.
to
include_module
(
Presentable
)
}
it
{
is_expected
.
to
include_module
(
Maskable
)
}
it
{
is_expected
.
to
include_module
(
Ci
::
Maskable
)
}
it
{
is_expected
.
to
include_module
(
HasEnvironmentScope
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:key
).
scoped_to
(
:project_id
,
:environment_scope
).
with_message
(
/\(\w+\) has already been taken/
)
}
end
...
...
spec/models/concerns/maskable_spec.rb
→
spec/models/concerns/
ci/
maskable_spec.rb
View file @
0f036967
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
describe
Maskable
do
describe
Ci
::
Maskable
do
let
(
:variable
)
{
build
(
:ci_variable
)
}
describe
'masked value validations'
do
...
...
@@ -34,7 +34,7 @@ describe Maskable do
end
describe
'REGEX'
do
subject
{
Maskable
::
REGEX
}
subject
{
Ci
::
Maskable
::
REGEX
}
it
'does not match strings shorter than 8 letters'
do
expect
(
subject
.
match?
(
'hello'
)).
to
eq
(
false
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment