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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
06c111ca
Commit
06c111ca
authored
Nov 19, 2017
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure users can't create environments with leading or trailing slashes (Fixes #39885)
parent
498ade48
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
changelogs/unreleased/issue-39885.yml
changelogs/unreleased/issue-39885.yml
+5
-0
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+6
-2
spec/lib/gitlab/regex_spec.rb
spec/lib/gitlab/regex_spec.rb
+5
-0
No files found.
changelogs/unreleased/issue-39885.yml
0 → 100644
View file @
06c111ca
---
title
:
'
Ensure
users
cannot
create
environments
with
leading
or
trailing
slashes
(Fixes
#39885)'
merge_request
:
!15273
author
:
Dylan Griffith
type
:
fixed
lib/gitlab/regex.rb
View file @
06c111ca
...
...
@@ -40,12 +40,16 @@ module Gitlab
'a-zA-Z0-9_/\\$\\{\\}\\. \\-'
end
def
environment_name_regex_chars_without_slash
'a-zA-Z0-9_\\$\\{\\}\\. -'
end
def
environment_name_regex
@environment_name_regex
||=
/\A[
#{
environment_name_regex_chars
}
]+
\z/
.
freeze
@environment_name_regex
||=
/\A[
#{
environment_name_regex_chars
_without_slash
}
]([
#{
environment_name_regex_chars
}
]*[
#{
environment_name_regex_chars_without_slash
}
])?
\z/
.
freeze
end
def
environment_name_regex_message
"can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', and spaces"
"can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', and spaces
, but it cannot start or end with '/'
"
end
def
kubernetes_namespace_regex
...
...
spec/lib/gitlab/regex_spec.rb
View file @
06c111ca
...
...
@@ -18,6 +18,7 @@ describe Gitlab::Regex do
subject
{
described_class
.
environment_name_regex
}
it
{
is_expected
.
to
match
(
'foo'
)
}
it
{
is_expected
.
to
match
(
'a'
)
}
it
{
is_expected
.
to
match
(
'foo-1'
)
}
it
{
is_expected
.
to
match
(
'FOO'
)
}
it
{
is_expected
.
to
match
(
'foo/1'
)
}
...
...
@@ -25,6 +26,10 @@ describe Gitlab::Regex do
it
{
is_expected
.
not_to
match
(
'9&foo'
)
}
it
{
is_expected
.
not_to
match
(
'foo-^'
)
}
it
{
is_expected
.
not_to
match
(
'!!()()'
)
}
it
{
is_expected
.
not_to
match
(
'/foo'
)
}
it
{
is_expected
.
not_to
match
(
'foo/'
)
}
it
{
is_expected
.
not_to
match
(
'/foo/'
)
}
it
{
is_expected
.
not_to
match
(
'/'
)
}
end
describe
'.environment_slug_regex'
do
...
...
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