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
Jérome Perrin
gitlab-ce
Commits
995e656a
Commit
995e656a
authored
Jun 12, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add path blacklist
parent
8f52501e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
app/models/namespace.rb
app/models/namespace.rb
+1
-0
app/models/project.rb
app/models/project.rb
+2
-9
app/models/user.rb
app/models/user.rb
+1
-0
lib/gitlab/blacklist.rb
lib/gitlab/blacklist.rb
+9
-0
No files found.
app/models/namespace.rb
View file @
995e656a
...
@@ -27,6 +27,7 @@ class Namespace < ActiveRecord::Base
...
@@ -27,6 +27,7 @@ class Namespace < ActiveRecord::Base
message:
"only letters, digits, spaces & '_' '-' '.' allowed."
}
message:
"only letters, digits, spaces & '_' '-' '.' allowed."
}
validates
:description
,
length:
{
within:
0
..
255
}
validates
:description
,
length:
{
within:
0
..
255
}
validates
:path
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
1
..
255
},
validates
:path
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
1
..
255
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
...
...
app/models/project.rb
View file @
995e656a
...
@@ -79,6 +79,7 @@ class Project < ActiveRecord::Base
...
@@ -79,6 +79,7 @@ class Project < ActiveRecord::Base
format:
{
with:
Gitlab
::
Regex
.
project_name_regex
,
format:
{
with:
Gitlab
::
Regex
.
project_name_regex
,
message:
"only letters, digits, spaces & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits, spaces & '_' '-' '.' allowed. Letter should be first"
}
validates
:path
,
presence:
true
,
length:
{
within:
0
..
255
},
validates
:path
,
presence:
true
,
length:
{
within:
0
..
255
},
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
...
@@ -92,7 +93,7 @@ class Project < ActiveRecord::Base
...
@@ -92,7 +93,7 @@ class Project < ActiveRecord::Base
format:
{
with:
URI
::
regexp
(
%w(http https)
),
message:
"should be a valid url"
},
format:
{
with:
URI
::
regexp
(
%w(http https)
),
message:
"should be a valid url"
},
if: :import?
if: :import?
validate
:check_limit
,
:repo_name
validate
:check_limit
# Scopes
# Scopes
scope
:without_user
,
->
(
user
)
{
where
(
"projects.id NOT IN (:ids)"
,
ids:
user
.
authorized_projects
.
map
(
&
:id
)
)
}
scope
:without_user
,
->
(
user
)
{
where
(
"projects.id NOT IN (:ids)"
,
ids:
user
.
authorized_projects
.
map
(
&
:id
)
)
}
...
@@ -166,14 +167,6 @@ class Project < ActiveRecord::Base
...
@@ -166,14 +167,6 @@ class Project < ActiveRecord::Base
errors
[
:base
]
<<
(
"Can't check your ability to create project"
)
errors
[
:base
]
<<
(
"Can't check your ability to create project"
)
end
end
def
repo_name
denied_paths
=
%w(admin dashboard groups help profile projects search)
if
denied_paths
.
include?
(
path
)
errors
.
add
(
:path
,
"like
#{
path
}
is not allowed"
)
end
end
def
to_param
def
to_param
if
namespace
if
namespace
namespace
.
path
+
"/"
+
path
namespace
.
path
+
"/"
+
path
...
...
app/models/user.rb
View file @
995e656a
...
@@ -104,6 +104,7 @@ class User < ActiveRecord::Base
...
@@ -104,6 +104,7 @@ class User < ActiveRecord::Base
validates
:extern_uid
,
allow_blank:
true
,
uniqueness:
{
scope: :provider
}
validates
:extern_uid
,
allow_blank:
true
,
uniqueness:
{
scope: :provider
}
validates
:projects_limit
,
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
validates
:projects_limit
,
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
validates
:username
,
presence:
true
,
uniqueness:
true
,
validates
:username
,
presence:
true
,
uniqueness:
true
,
exclusion:
{
in:
Gitlab
::
Blacklist
.
path
},
format:
{
with:
Gitlab
::
Regex
.
username_regex
,
format:
{
with:
Gitlab
::
Regex
.
username_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
...
...
lib/gitlab/blacklist.rb
0 → 100644
View file @
995e656a
module
Gitlab
module
Blacklist
extend
self
def
path
%w(admin dashboard groups help profile projects search public assets u s teams merge_requests issues users snippets )
end
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