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
Boxiang Sun
gitlab-ce
Commits
70194cfc
Commit
70194cfc
authored
Dec 01, 2017
by
Christiaan Van den Poel
Committed by
Grzegorz Bizon
Dec 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds validation for Project#ci_config_path not to contain leading slash
parent
3e78b5ae
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
5 deletions
+12
-5
app/models/project.rb
app/models/project.rb
+3
-3
changelogs/unreleased/add_project_ci_config_path_leading_slash_validation.yml
...d/add_project_ci_config_path_leading_slash_validation.yml
+6
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+3
-2
No files found.
app/models/project.rb
View file @
70194cfc
...
@@ -234,8 +234,8 @@ class Project < ActiveRecord::Base
...
@@ -234,8 +234,8 @@ class Project < ActiveRecord::Base
validates
:creator
,
presence:
true
,
on: :create
validates
:creator
,
presence:
true
,
on: :create
validates
:description
,
length:
{
maximum:
2000
},
allow_blank:
true
validates
:description
,
length:
{
maximum:
2000
},
allow_blank:
true
validates
:ci_config_path
,
validates
:ci_config_path
,
format:
{
without:
/
\.{2}
/
,
format:
{
without:
/
(\.{2}|\A\/)
/
,
message:
'cannot include directory traversal.'
},
message:
'cannot include
leading slash or
directory traversal.'
},
length:
{
maximum:
255
},
length:
{
maximum:
255
},
allow_blank:
true
allow_blank:
true
validates
:name
,
validates
:name
,
...
@@ -599,7 +599,7 @@ class Project < ActiveRecord::Base
...
@@ -599,7 +599,7 @@ class Project < ActiveRecord::Base
def
ci_config_path
=
(
value
)
def
ci_config_path
=
(
value
)
# Strip all leading slashes so that //foo -> foo
# Strip all leading slashes so that //foo -> foo
super
(
value
&
.
sub
(
%r{
\A
/+}
,
''
)
&
.
delete
(
"
\0
"
))
super
(
value
&
.
delete
(
"
\0
"
))
end
end
def
import_url
=
(
value
)
def
import_url
=
(
value
)
...
...
changelogs/unreleased/add_project_ci_config_path_leading_slash_validation.yml
0 → 100644
View file @
70194cfc
---
title
:
Prefer ci_config_path validation for leading slashes instead of sanitizing
the input
merge_request
:
15672
author
:
Christiaan Van den Poel
type
:
other
spec/models/project_spec.rb
View file @
70194cfc
...
@@ -138,6 +138,7 @@ describe Project do
...
@@ -138,6 +138,7 @@ describe Project do
it
{
is_expected
.
to
validate_length_of
(
:ci_config_path
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
validate_length_of
(
:ci_config_path
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
allow_value
(
''
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
to
allow_value
(
''
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
not_to
allow_value
(
'test/../foo'
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
not_to
allow_value
(
'test/../foo'
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
not_to
allow_value
(
'/test/foo'
).
for
(
:ci_config_path
)
}
it
{
is_expected
.
to
validate_presence_of
(
:creator
)
}
it
{
is_expected
.
to
validate_presence_of
(
:creator
)
}
...
@@ -1548,8 +1549,8 @@ describe Project do
...
@@ -1548,8 +1549,8 @@ describe Project do
expect
(
project
.
ci_config_path
).
to
eq
(
'foo/.gitlab_ci.yml'
)
expect
(
project
.
ci_config_path
).
to
eq
(
'foo/.gitlab_ci.yml'
)
end
end
it
'sets a string but removes all
leading slashes and
null characters'
do
it
'sets a string but removes all null characters'
do
project
.
update!
(
ci_config_path:
"
///
f
\0
oo/
\0
/.gitlab_ci.yml"
)
project
.
update!
(
ci_config_path:
"f
\0
oo/
\0
/.gitlab_ci.yml"
)
expect
(
project
.
ci_config_path
).
to
eq
(
'foo//.gitlab_ci.yml'
)
expect
(
project
.
ci_config_path
).
to
eq
(
'foo//.gitlab_ci.yml'
)
end
end
...
...
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