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
90554e6e
Commit
90554e6e
authored
Dec 20, 2019
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GraphQL: Add timeout to all queries
parent
981c7ed7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
changelogs/unreleased/security-11-graphql-timeout.yml
changelogs/unreleased/security-11-graphql-timeout.yml
+5
-0
config/initializers/graphql.rb
config/initializers/graphql.rb
+4
-0
spec/requests/api/graphql/gitlab_schema_spec.rb
spec/requests/api/graphql/gitlab_schema_spec.rb
+12
-0
No files found.
changelogs/unreleased/security-11-graphql-timeout.yml
0 → 100644
View file @
90554e6e
---
title
:
'
GraphQL:
Add
timeout
to
all
queries'
merge_request
:
author
:
type
:
security
config/initializers/graphql.rb
View file @
90554e6e
...
...
@@ -5,3 +5,7 @@ GraphQL::Field.accepts_definitions(authorize: GraphQL::Define.assign_metadata_ke
GraphQL
::
Schema
::
Object
.
accepts_definition
(
:authorize
)
GraphQL
::
Schema
::
Field
.
accepts_definition
(
:authorize
)
GitlabSchema
.
middleware
<<
GraphQL
::
Schema
::
TimeoutMiddleware
.
new
(
max_seconds:
ENV
.
fetch
(
'GITLAB_RAILS_GRAPHQL_TIMEOUT'
,
30
).
to_i
)
do
|
timeout_error
,
query
|
Gitlab
::
GraphqlLogger
.
error
(
message:
timeout_error
.
to_s
,
query:
query
.
query_string
,
query_variables:
query
.
provided_variables
)
end
spec/requests/api/graphql/gitlab_schema_spec.rb
View file @
90554e6e
...
...
@@ -8,6 +8,18 @@ describe 'GitlabSchema configurations' do
set
(
:project
)
{
create
(
:project
)
}
shared_examples
'imposing query limits'
do
describe
'timeouts'
do
context
'when timeout is reached'
do
it
'shows an error'
do
Timecop
.
scale
(
50000000
)
do
# ludicrously large number because the timeout has to happen before the query even begins
subject
expect_graphql_errors_to_include
/Timeout/
end
end
end
end
describe
'#max_complexity'
do
context
'when complexity is too high'
do
it
'shows an error'
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