BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
16a03038
Commit
16a03038
authored
Jun 27, 2016
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for conflict with wiki projects when creating a new project.
This fix avoids exposing the information from the wiki repository of other project.
parent
f0ed8930
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
CHANGELOG
CHANGELOG
+1
-0
project.rb
app/models/project.rb
+11
-0
project_spec.rb
spec/models/project_spec.rb
+21
-0
No files found.
CHANGELOG
View file @
16a03038
...
...
@@ -10,6 +10,7 @@ v 8.10.0 (unreleased)
- Implement Subresource Integrity for CSS and JavaScript assets. This prevents malicious assets from loading in the case of a CDN compromise.
- Fix changing issue state columns in milestone view
- Fix user creation with stronger minimum password requirements !4054 (nathan-pmt)
- Check for conflicts with existing Project's wiki path when creating a new project.
- Add API endpoint for a group issues !4520 (mahcsig)
v 8.9.1
...
...
app/models/project.rb
View file @
16a03038
...
...
@@ -163,6 +163,7 @@ class Project < ActiveRecord::Base
validates
:avatar
,
file_size:
{
maximum:
200
.
kilobytes
.
to_i
}
validate
:visibility_level_allowed_by_group
validate
:visibility_level_allowed_as_fork
validate
:check_wiki_path_conflict
add_authentication_token_field
:runners_token
before_save
:ensure_runners_token
...
...
@@ -539,6 +540,16 @@ class Project < ActiveRecord::Base
self
.
errors
.
add
(
:visibility_level
,
"
#{
level_name
}
is not allowed since the fork source project has lower visibility."
)
end
def
check_wiki_path_conflict
return
if
path
.
blank?
path_to_check
=
path
.
ends_with?
(
'.wiki'
)
?
path
.
chomp
(
'.wiki'
)
:
"
#{
path
}
.wiki"
if
Project
.
where
(
namespace_id:
namespace_id
,
path:
path_to_check
).
exists?
errors
.
add
(
:name
,
'has already been taken'
)
end
end
def
to_param
path
end
...
...
spec/models/project_spec.rb
View file @
16a03038
...
...
@@ -63,6 +63,27 @@ describe Project, models: true do
expect
(
project2
).
not_to
be_valid
expect
(
project2
.
errors
[
:limit_reached
].
first
).
to
match
(
/Personal project creation is not allowed/
)
end
describe
'wiki path conflict'
do
context
"when the new path has been used by the wiki of other Project"
do
it
'should have an error on the name attribute'
do
new_project
=
build_stubbed
(
:project
,
namespace_id:
project
.
namespace_id
,
path:
"
#{
project
.
path
}
.wiki"
)
expect
(
new_project
).
not_to
be_valid
expect
(
new_project
.
errors
[
:name
].
first
).
to
eq
(
'has already been taken'
)
end
end
context
"when the new wiki path has been used by the path of other Project"
do
it
'should have an error on the name attribute'
do
project_with_wiki_suffix
=
create
(
:project
,
path:
'foo.wiki'
)
new_project
=
build_stubbed
(
:project
,
namespace_id:
project_with_wiki_suffix
.
namespace_id
,
path:
'foo'
)
expect
(
new_project
).
not_to
be_valid
expect
(
new_project
.
errors
[
:name
].
first
).
to
eq
(
'has already been taken'
)
end
end
end
end
describe
'default_scope'
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