Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 168d5f2

Browse files
fix: Disable GraphQL introspection in prod (#953)
1 parent f0fcbcc commit 168d5f2

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

codecov/settings_base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292

9393
WSGI_APPLICATION = "codecov.wsgi.application"
9494

95-
9695
# GraphQL
9796

9897
GRAPHQL_QUERY_COST_THRESHOLD = get_config(
@@ -105,6 +104,8 @@
105104

106105
GRAPHQL_RATE_LIMIT_RPM = get_config("setup", "graphql", "rate_limit_rpm", default=300)
107106

107+
GRAPHQL_INTROSPECTION_ENABLED = False
108+
108109
# Database
109110
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
110111

@@ -184,7 +185,6 @@
184185

185186
USE_TZ = True
186187

187-
188188
# Static files (CSS, JavaScript, Images)
189189
# https://docs.djangoproject.com/en/2.1/howto/static-files/
190190

@@ -308,7 +308,6 @@
308308
"gitlab", "bots", "tokenless", "key", default=GITLAB_BOT_KEY
309309
)
310310

311-
312311
GITLAB_ENTERPRISE_CLIENT_ID = get_config("gitlab_enterprise", "client_id")
313312
GITLAB_ENTERPRISE_CLIENT_SECRET = get_config("gitlab_enterprise", "client_secret")
314313
GITLAB_ENTERPRISE_REDIRECT_URI = get_config(
@@ -323,7 +322,6 @@
323322
GITLAB_ENTERPRISE_URL = get_config("gitlab_enterprise", "url")
324323
GITLAB_ENTERPRISE_API_URL = get_config("gitlab_enterprise", "api_url")
325324

326-
327325
CORS_ALLOW_HEADERS = (
328326
list(default_headers)
329327
+ ["token-type"]
@@ -344,7 +342,6 @@
344342
"setup", "http", "file_upload_max_memory_size", default=2621440
345343
)
346344

347-
348345
CORS_ALLOWED_ORIGIN_REGEXES = get_config(
349346
"setup", "api_cors_allowed_origin_regexes", default=[]
350347
)
@@ -362,7 +359,6 @@
362359

363360
HIDE_ALL_CODECOV_TOKENS = get_config("setup", "hide_all_codecov_tokens", default=False)
364361

365-
366362
SENTRY_JWT_SHARED_SECRET = get_config(
367363
"sentry", "jwt_shared_secret", default=None
368364
) or get_config("setup", "sentry", "jwt_shared_secret", default=None)

codecov/settings_dev.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@
5555
# SHELTER_SHARED_SECRET = "test-supertoken"
5656

5757
GUEST_ACCESS = True
58+
59+
GRAPHQL_INTROSPECTION_ENABLED = True

codecov/settings_staging.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@
7575
CSRF_TRUSTED_ORIGINS = [
7676
get_config("setup", "trusted_origin", default="https://*.codecov.dev")
7777
]
78+
79+
GRAPHQL_INTROSPECTION_ENABLED = True

codecov/settings_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
# Mock the Pub/Sub host for testing
1111
# this prevents the pubsub SDK from trying to load credentials
1212
os.environ["PUBSUB_EMULATOR_HOST"] = "localhost"
13+
14+
GRAPHQL_INTROSPECTION_ENABLED = True

graphql_api/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
188188
class AsyncGraphqlView(GraphQLAsyncView):
189189
schema = schema
190190
extensions = [QueryMetricsExtension]
191+
introspection = getattr(settings, "GRAPHQL_INTROSPECTION_ENABLED", False)
191192

192193
def get_validation_rules(
193194
self,

0 commit comments

Comments
 (0)