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
2fbb28cd
Commit
2fbb28cd
authored
Feb 04, 2021
by
Mehmet Emin INAC
Committed by
Stan Hu
Feb 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable access to projects by instance security dashboard
parent
5a1517a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
ee/app/models/instance_security_dashboard.rb
ee/app/models/instance_security_dashboard.rb
+1
-0
ee/spec/models/instance_security_dashboard_spec.rb
ee/spec/models/instance_security_dashboard_spec.rb
+36
-4
No files found.
ee/app/models/instance_security_dashboard.rb
View file @
2fbb28cd
...
...
@@ -24,6 +24,7 @@ class InstanceSecurityDashboard
def
projects
Project
.
where
(
id:
visible_users_security_dashboard_projects
)
.
with_feature_available_for_user
(
:security_and_compliance
,
user
)
end
def
vulnerabilities
...
...
ee/spec/models/instance_security_dashboard_spec.rb
View file @
2fbb28cd
...
...
@@ -85,8 +85,24 @@ RSpec.describe InstanceSecurityDashboard do
describe
'#projects'
do
context
'when the user cannot read all resources'
do
it
'returns only projects on their dashboard that they can read'
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project1
)
context
'when the `security_and_compliance` is enabled for the project'
do
before
do
ProjectFeature
.
update_all
(
security_and_compliance_access_level:
Featurable
::
ENABLED
)
end
it
'returns only projects on their dashboard that they can read'
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project1
)
end
end
context
'when the `security_and_compliance` is disabled for the project'
do
before
do
project1
.
project_feature
.
update_column
(
:security_and_compliance_access_level
,
Featurable
::
DISABLED
)
end
it
'returns only projects on their dashboard that they can read'
do
expect
(
subject
.
projects
).
to
be_empty
end
end
end
...
...
@@ -94,8 +110,24 @@ RSpec.describe InstanceSecurityDashboard do
let
(
:project_ids
)
{
[
project1
.
id
,
project2
.
id
]
}
let
(
:user
)
{
create
(
:auditor
)
}
it
"returns all projects on the user's dashboard"
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project1
,
project2
,
project3
)
context
'when the `security_and_compliance` is enabled for the project'
do
before
do
ProjectFeature
.
update_all
(
security_and_compliance_access_level:
Featurable
::
ENABLED
)
end
it
"returns all projects on the user's dashboard"
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project1
,
project2
,
project3
)
end
end
context
'when the `security_and_compliance` is disabled for the project'
do
before
do
project1
.
project_feature
.
update_column
(
:security_and_compliance_access_level
,
Featurable
::
DISABLED
)
end
it
"returns only the feature enabled projects on the user's dashboard"
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project2
,
project3
)
end
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