ES: Project members with guest role can't access confidential issues

parent 26909fe4
......@@ -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) } }
]
}
}
......
......@@ -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) } }
]
}
}
......
......@@ -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')
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment