Skip to content

Commit ebe6f2a

Browse files
sentrivanaclaude
andauthored
ref: Expand scrubbing (#6161)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a8a4992 commit ebe6f2a

5 files changed

Lines changed: 24 additions & 3 deletions

File tree

sentry_sdk/integrations/_wsgi_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"HTTP_SET_COOKIE",
3232
"HTTP_COOKIE",
3333
"HTTP_AUTHORIZATION",
34+
"HTTP_PROXY_AUTHORIZATION",
3435
"HTTP_X_API_KEY",
3536
"HTTP_X_FORWARDED_FOR",
3637
"HTTP_X_REAL_IP",

sentry_sdk/scrubber.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"set_cookie",
3535
"cookie",
3636
"authorization",
37+
"proxy-authorization",
3738
"x_api_key",
3839
# other common names used in the wild
3940
"aiohttp_session", # aiohttp

tests/integrations/fastapi/test_fastapi.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ async def test_original_request_not_scrubbed(
403403
async def _error(request: Request):
404404
logging.critical("Oh no!")
405405
assert request.headers["Authorization"] == "Bearer ohno"
406+
assert request.headers["Proxy-Authorization"] == "Basic ohno"
406407
assert await request.json() == {"password": "secret"}
407408

408409
return {"error": "Oh no!"}
@@ -411,12 +412,18 @@ async def _error(request: Request):
411412

412413
client = TestClient(app)
413414
client.post(
414-
"/error", json={"password": "secret"}, headers={"Authorization": "Bearer ohno"}
415+
"/error",
416+
json={"password": "secret"},
417+
headers={
418+
"Authorization": "Bearer ohno",
419+
"Proxy-Authorization": "Basic ohno",
420+
},
415421
)
416422

417423
event = events[0]
418424
assert event["request"]["data"] == {"password": "[Filtered]"}
419425
assert event["request"]["headers"]["authorization"] == "[Filtered]"
426+
assert event["request"]["headers"]["proxy-authorization"] == "[Filtered]"
420427

421428

422429
def test_response_status_code_ok_in_transaction_context(sentry_init, capture_envelopes):

tests/integrations/flask/test_flask.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,19 +903,26 @@ def index():
903903
logging.critical("oops")
904904
assert request.get_json() == {"password": "ohno"}
905905
assert request.headers["Authorization"] == "Bearer ohno"
906+
assert request.headers["Proxy-Authorization"] == "Basic ohno"
906907
return "ok"
907908

908909
events = capture_events()
909910

910911
client = app.test_client()
911912
client.post(
912-
"/", json={"password": "ohno"}, headers={"Authorization": "Bearer ohno"}
913+
"/",
914+
json={"password": "ohno"},
915+
headers={
916+
"Authorization": "Bearer ohno",
917+
"Proxy-Authorization": "Basic ohno",
918+
},
913919
)
914920

915921
(event,) = events
916922

917923
assert event["request"]["data"]["password"] == "[Filtered]"
918924
assert event["request"]["headers"]["Authorization"] == "[Filtered]"
925+
assert event["request"]["headers"]["Proxy-Authorization"] == "[Filtered]"
919926

920927

921928
def test_response_status_code_ok_in_transaction_context(

tests/integrations/starlette/test_starlette.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,7 @@ def test_original_request_not_scrubbed(sentry_init, capture_events):
11931193
async def _error(request):
11941194
logging.critical("Oh no!")
11951195
assert request.headers["Authorization"] == "Bearer ohno"
1196+
assert request.headers["Proxy-Authorization"] == "Basic ohno"
11961197
assert await request.json() == {"password": "ohno"}
11971198
return starlette.responses.JSONResponse({"status": "Oh no!"})
11981199

@@ -1206,12 +1207,16 @@ async def _error(request):
12061207
client.post(
12071208
"/error",
12081209
json={"password": "ohno"},
1209-
headers={"Authorization": "Bearer ohno"},
1210+
headers={
1211+
"Authorization": "Bearer ohno",
1212+
"Proxy-Authorization": "Basic ohno",
1213+
},
12101214
)
12111215

12121216
event = events[0]
12131217
assert event["request"]["data"] == {"password": "[Filtered]"}
12141218
assert event["request"]["headers"]["authorization"] == "[Filtered]"
1219+
assert event["request"]["headers"]["proxy-authorization"] == "[Filtered]"
12151220

12161221

12171222
@pytest.mark.skipif(STARLETTE_VERSION < (0, 24), reason="Requires Starlette >= 0.24")

0 commit comments

Comments
 (0)