-
Notifications
You must be signed in to change notification settings - Fork 643
feat(integrations): Gate user info behind data_collection config #6876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6e3c9ca
64e29e9
f409f02
11fb505
d28ee71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Need to add some ignore rules in this directory, because the unit tests will add the Sentry SDK and its dependencies | ||
| # into this directory to create a Lambda function package that contains everything needed to instrument a Lambda function using Sentry. | ||
|
|
||
| # Ignore everything | ||
| * | ||
|
|
||
| # But not index.py | ||
| !index.py | ||
|
|
||
| # And not .gitignore itself | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import os | ||
|
|
||
| import sentry_sdk | ||
| from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration | ||
|
|
||
| sentry_sdk.init( | ||
| dsn=os.environ.get("SENTRY_DSN"), | ||
| traces_sample_rate=1.0, | ||
| integrations=[AwsLambdaIntegration()], | ||
| _experiments={ | ||
| "data_collection": { | ||
| "user_info": False, | ||
| } | ||
| }, | ||
| ) | ||
|
|
||
|
|
||
| def handler(event, context): | ||
| return {"event": event} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Need to add some ignore rules in this directory, because the unit tests will add the Sentry SDK and its dependencies | ||
| # into this directory to create a Lambda function package that contains everything needed to instrument a Lambda function using Sentry. | ||
|
|
||
| # Ignore everything | ||
| * | ||
|
|
||
| # But not index.py | ||
| !index.py | ||
|
|
||
| # And not .gitignore itself | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import os | ||
|
|
||
| import sentry_sdk | ||
| from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration | ||
|
|
||
| sentry_sdk.init( | ||
| dsn=os.environ.get("SENTRY_DSN"), | ||
| traces_sample_rate=1.0, | ||
| integrations=[AwsLambdaIntegration()], | ||
| _experiments={ | ||
| "data_collection": { | ||
| "user_info": True, | ||
| } | ||
| }, | ||
| ) | ||
|
|
||
|
|
||
| def handler(event, context): | ||
| return {"event": event} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -427,11 +427,9 @@ | |
| }, | ||
| "pathParameters": null, | ||
| "stageVariables": null, | ||
| "requestContext": { | ||
| "identity": { | ||
| "sourceIp": "213.47.147.207", | ||
| "userArn": "42" | ||
| } | ||
| "identity": { | ||
| "sourceIp": "213.47.147.207", | ||
| "userArn": "42" | ||
|
Check warning on line 432 in tests/integrations/aws_lambda/test_aws_lambda.py
|
||
|
Comment on lines
+430
to
+432
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AWS Lambda user-info tests use non-standard event structure The test payload changed from standard Evidence
Identified by Warden · code-review · RCQ-XUC |
||
| }, | ||
| "body": null, | ||
| "isBase64Encoded": false | ||
|
|
@@ -464,6 +462,64 @@ | |
| "data": None, | ||
| } | ||
|
|
||
| # Legacy send_default_pii=True attaches the user identity. | ||
| assert transaction_event["user"] == { | ||
| "id": "42", | ||
| "ip_address": "213.47.147.207", | ||
| } | ||
|
|
||
|
|
||
| USER_INFO_PAYLOAD = b""" | ||
| { | ||
| "resource": "/asd", | ||
| "path": "/asd", | ||
| "httpMethod": "GET", | ||
| "headers": { | ||
| "Host": "iwsz2c7uwi.execute-api.us-east-1.amazonaws.com", | ||
| "User-Agent": "custom", | ||
| "X-Forwarded-Proto": "https" | ||
| }, | ||
| "queryStringParameters": { | ||
| "bonkers": "true" | ||
| }, | ||
| "pathParameters": null, | ||
| "stageVariables": null, | ||
| "identity": { | ||
| "sourceIp": "213.47.147.207", | ||
| "userArn": "42" | ||
| }, | ||
| "body": null, | ||
| "isBase64Encoded": false | ||
| } | ||
| """ | ||
|
|
||
|
|
||
| def test_user_info_with_data_collection_user_info_on(lambda_client, test_environment): | ||
| lambda_client.invoke( | ||
| FunctionName="BasicOkDataCollectionUserInfoOn", | ||
| Payload=USER_INFO_PAYLOAD, | ||
| ) | ||
| envelopes = test_environment["server"].envelopes | ||
|
|
||
| (transaction_event,) = envelopes | ||
|
|
||
| assert transaction_event["user"] == { | ||
| "id": "42", | ||
| "ip_address": "213.47.147.207", | ||
| } | ||
|
|
||
|
|
||
| def test_user_info_with_data_collection_user_info_off(lambda_client, test_environment): | ||
| lambda_client.invoke( | ||
| FunctionName="BasicOkDataCollectionUserInfoOff", | ||
| Payload=USER_INFO_PAYLOAD, | ||
| ) | ||
| envelopes = test_environment["server"].envelopes | ||
|
|
||
| (transaction_event,) = envelopes | ||
|
|
||
| assert "user" not in transaction_event | ||
|
|
||
|
|
||
| def test_request_data_with_data_collection_allowlist(lambda_client, test_environment): | ||
| payload = b""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWS Lambda body handling skipped when data_collection is enabled
When
has_data_collection_enabledis true, theelif should_send_default_pii()branch is skipped, so request body is neither collected nor redacted.Evidence
has_data_collection_enabledreturns true whendata_collectionis configured in_experiments.if has_data_collection_enabledbranch at line 441 skips theelif should_send_default_pii()branch at line 456.request["data"] = aws_event.get("body", "")) and redaction (AnnotatedValue.removed_because_raw_data()) live exclusively inside the skippedelif/elsebranches.data_collection.pyline 178 documents that bodies are collected regardless of PII settings by default.data_collectiontest payloads use"body": null, so this regression is not exercised.Identified by Warden · code-review · GGF-TPP