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
8b931410
Commit
8b931410
authored
Jun 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ES: Project members with guest role can't access confidential issues
parent
26909fe4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
2 deletions
+48
-2
app/models/concerns/elastic/issues_search.rb
app/models/concerns/elastic/issues_search.rb
+1
-1
app/models/concerns/elastic/notes_search.rb
app/models/concerns/elastic/notes_search.rb
+1
-1
spec/lib/gitlab/elastic/project_search_results_spec.rb
spec/lib/gitlab/elastic/project_search_results_spec.rb
+12
-0
spec/models/concerns/elastic/note_spec.rb
spec/models/concerns/elastic/note_spec.rb
+34
-0
No files found.
app/models/concerns/elastic/issues_search.rb
View file @
8b931410
...
...
@@ -69,7 +69,7 @@ module Elastic
should:
[
{
term:
{
author_id:
current_user
.
id
}
},
{
term:
{
assignee_id:
current_user
.
id
}
},
{
terms:
{
project_id:
current_user
.
authorized_projects
.
pluck
(
:id
)
}
}
{
terms:
{
project_id:
current_user
.
authorized_projects
(
Gitlab
::
Access
::
REPORTER
)
.
pluck
(
:id
)
}
}
]
}
}
...
...
app/models/concerns/elastic/notes_search.rb
View file @
8b931410
...
...
@@ -92,7 +92,7 @@ module Elastic
should:
[
{
term:
{
"issue.author_id"
=>
current_user
.
id
}
},
{
term:
{
"issue.assignee_id"
=>
current_user
.
id
}
},
{
terms:
{
"
issue.project_id"
=>
current_user
.
authorized_projects
.
pluck
(
:id
)
}
}
{
terms:
{
"
project_id"
=>
current_user
.
authorized_projects
(
Gitlab
::
Access
::
REPORTER
)
.
pluck
(
:id
)
}
}
]
}
}
...
...
spec/lib/gitlab/elastic/project_search_results_spec.rb
View file @
8b931410
...
...
@@ -122,6 +122,18 @@ describe Gitlab::Elastic::ProjectSearchResults, lib: true do
expect
(
results
.
issues_count
).
to
eq
3
end
it
'should not list project confidential issues for project members with guest role'
do
project
.
team
<<
[
member
,
:guest
]
results
=
described_class
.
new
(
member
,
project
.
id
,
query
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
include
issue
expect
(
issues
).
not_to
include
security_issue_1
expect
(
issues
).
not_to
include
security_issue_2
expect
(
results
.
issues_count
).
to
eq
1
end
it
'should list all project issues for admin'
do
results
=
described_class
.
new
(
admin
,
project
.
id
,
query
)
issues
=
results
.
objects
(
'issues'
)
...
...
spec/models/concerns/elastic/note_spec.rb
View file @
8b931410
...
...
@@ -78,5 +78,39 @@ describe Note, elastic: true do
expect
(
Note
.
elastic_search
(
'term'
,
options:
options
).
total_count
).
to
eq
(
1
)
end
it
"return notes with matching content for project members"
do
user
=
create
:user
issue
=
create
:issue
,
:confidential
,
author:
user
member
=
create
(
:user
)
issue
.
project
.
team
<<
[
member
,
:developer
]
create
:note
,
note:
'bla-bla term'
,
project:
issue
.
project
,
noteable:
issue
create
:note
,
project:
issue
.
project
,
noteable:
issue
Note
.
__elasticsearch__
.
refresh_index!
options
=
{
project_ids:
[
issue
.
project
.
id
],
current_user:
member
}
expect
(
Note
.
elastic_search
(
'term'
,
options:
options
).
total_count
).
to
eq
(
1
)
end
it
"does not return notes with matching content for project members with guest role"
do
user
=
create
:user
issue
=
create
:issue
,
:confidential
,
author:
user
member
=
create
(
:user
)
issue
.
project
.
team
<<
[
member
,
:guest
]
create
:note
,
note:
'bla-bla term'
,
project:
issue
.
project
,
noteable:
issue
create
:note
,
project:
issue
.
project
,
noteable:
issue
Note
.
__elasticsearch__
.
refresh_index!
options
=
{
project_ids:
[
issue
.
project
.
id
],
current_user:
member
}
expect
(
Note
.
elastic_search
(
'term'
,
options:
options
).
total_count
).
to
eq
(
0
)
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