Skip to content

Commit

Permalink
Disable introspection on prod sizing (#1704)
Browse files Browse the repository at this point in the history
<!-- please choose -->
-

- Disable introspection on `prod_sizing`

- <URL or Ticket>

Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
  • Loading branch information
noah-paige authored and dlpzx committed Dec 5, 2024
1 parent aedaa29 commit 5c71242
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion backend/api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dataall.base.db import get_engine
from dataall.base.loader import load_modules, ImportMode

from graphql.pyutils import did_you_mean

logger = logging.getLogger()
logger.setLevel(os.environ.get('LOG_LEVEL', 'INFO'))
Expand All @@ -32,6 +33,11 @@
for name in ['boto3', 's3transfer', 'botocore', 'boto']:
logging.getLogger(name).setLevel(logging.ERROR)

ALLOW_INTROSPECTION = True if os.getenv('ALLOW_INTROSPECTION') == 'True' else False

if not ALLOW_INTROSPECTION:
did_you_mean.__globals__['MAX_LENGTH'] = 0

load_modules(modes={ImportMode.API})
SCHEMA = bootstrap_schema()
TYPE_DEFS = gql(SCHEMA.gql(with_directives=False))
Expand Down Expand Up @@ -137,7 +143,9 @@ def handler(event, context):
else:
raise Exception(f'Could not initialize user context from event {event}')

success, response = graphql_sync(schema=executable_schema, data=query, context_value=app_context)
success, response = graphql_sync(
schema=executable_schema, data=query, context_value=app_context, introspection=ALLOW_INTROSPECTION
)

dispose_context()
response = json.dumps(response)
Expand Down
7 changes: 6 additions & 1 deletion deploy/stacks/lambda_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ def __init__(

self.api_handler_dlq = self.set_dlq(f'{resource_prefix}-{envname}-graphql-dlq')
api_handler_sg = self.create_lambda_sgs(envname, 'apihandler', resource_prefix, vpc)
api_handler_env = {'envname': envname, 'LOG_LEVEL': log_level, 'REAUTH_TTL': str(reauth_ttl)}
api_handler_env = {
'envname': envname,
'LOG_LEVEL': log_level,
'REAUTH_TTL': str(reauth_ttl),
'ALLOW_INTROSPECTION': str(not prod_sizing),
}
# Check if custom domain exists and if it exists email notifications could be enabled. Create a env variable which stores the domain url. This is used for sending data.all share weblinks in the email notifications.
if custom_domain and custom_domain.get('hosted_zone_name', None):
api_handler_env['frontend_domain_url'] = f'https://{custom_domain.get("hosted_zone_name", None)}'
Expand Down

0 comments on commit 5c71242

Please sign in to comment.