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
82ffa32d
Commit
82ffa32d
authored
Sep 25, 2020
by
Saikat Sarkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tighten the RBAC for GraphQL
parent
6dda0016
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
1 deletion
+74
-1
ee/app/graphql/ee/types/project_type.rb
ee/app/graphql/ee/types/project_type.rb
+2
-0
ee/changelogs/unreleased/security-sast-ci-conf.yml
ee/changelogs/unreleased/security-sast-ci-conf.yml
+5
-0
ee/spec/graphql/types/project_type_spec.rb
ee/spec/graphql/types/project_type_spec.rb
+67
-1
No files found.
ee/app/graphql/ee/types/project_type.rb
View file @
82ffa32d
...
...
@@ -26,6 +26,8 @@ module EE
calls_gitaly:
true
,
description:
'SAST CI configuration for the project'
,
resolve:
->
(
project
,
args
,
ctx
)
do
return
unless
Ability
.
allowed?
(
ctx
[
:current_user
],
:download_code
,
project
)
sast_ci_configuration
(
project
)
end
...
...
ee/changelogs/unreleased/security-sast-ci-conf.yml
0 → 100644
View file @
82ffa32d
---
title
:
Tighten the RBAC for GraphQL in SAST CiConfiguration
merge_request
:
author
:
type
:
security
ee/spec/graphql/types/project_type_spec.rb
View file @
82ffa32d
...
...
@@ -26,7 +26,7 @@ RSpec.describe GitlabSchema.types['Project'] do
describe
'sast_ci_configuration'
do
include_context
'read ci configuration for sast enabled project'
let
_it_be
(
:query
)
do
let
(
:query
)
do
%(
query {
project(fullPath: "#{project.full_path}") {
...
...
@@ -109,6 +109,72 @@ RSpec.describe GitlabSchema.types['Project'] do
expect
(
analyzer
[
'label'
]).
to
eq
(
'Brakeman'
)
expect
(
analyzer
[
'enabled'
]).
to
eq
(
true
)
end
context
"with guest user"
do
before
do
project
.
add_guest
(
user
)
end
context
'when project is private'
do
let
(
:project
)
{
create
(
:project
,
:private
,
:repository
)
}
it
"returns no configuration"
do
secure_analyzers_prefix
=
subject
.
dig
(
'data'
,
'project'
,
'sastCiConfiguration'
)
expect
(
secure_analyzers_prefix
).
to
be_nil
end
end
context
'when project is public'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
context
'when repository is accessible by everyone'
do
it
"returns the project's sast configuration for global variables"
do
secure_analyzers_prefix
=
subject
.
dig
(
'data'
,
'project'
,
'sastCiConfiguration'
,
'global'
,
'nodes'
).
first
expect
(
secure_analyzers_prefix
[
'type'
]).
to
eq
(
'string'
)
expect
(
secure_analyzers_prefix
[
'field'
]).
to
eq
(
'SECURE_ANALYZERS_PREFIX'
)
end
end
end
end
context
"with non-member user"
do
before
do
project
.
team
.
truncate
end
context
'when project is private'
do
let
(
:project
)
{
create
(
:project
,
:private
,
:repository
)
}
it
"returns no configuration"
do
secure_analyzers_prefix
=
subject
.
dig
(
'data'
,
'project'
,
'sastCiConfiguration'
)
expect
(
secure_analyzers_prefix
).
to
be_nil
end
end
context
'when project is public'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
context
'when repository is accessible by everyone'
do
it
"returns the project's sast configuration for global variables"
do
secure_analyzers_prefix
=
subject
.
dig
(
'data'
,
'project'
,
'sastCiConfiguration'
,
'global'
,
'nodes'
).
first
expect
(
secure_analyzers_prefix
[
'type'
]).
to
eq
(
'string'
)
expect
(
secure_analyzers_prefix
[
'field'
]).
to
eq
(
'SECURE_ANALYZERS_PREFIX'
)
end
end
context
'when repository is accessible only by team members'
do
it
"returns no configuration"
do
project
.
project_feature
.
update!
(
merge_requests_access_level:
ProjectFeature
::
DISABLED
,
builds_access_level:
ProjectFeature
::
DISABLED
,
repository_access_level:
ProjectFeature
::
PRIVATE
)
secure_analyzers_prefix
=
subject
.
dig
(
'data'
,
'project'
,
'sastCiConfiguration'
)
expect
(
secure_analyzers_prefix
).
to
be_nil
end
end
end
end
end
describe
'security_scanners'
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