Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Replace client_secret with <redacted> in server logs (#6158)
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Feb 26, 2020
2 parents bebf756 + 0f46bf5 commit d5982cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/6158.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Redact `client_secret` in server logs.
6 changes: 4 additions & 2 deletions synapse/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ def cancelled_to_request_timed_out_error(value, timeout):


ACCESS_TOKEN_RE = re.compile(r"(\?.*access(_|%5[Ff])token=)[^&]*(.*)$")
CLIENT_SECRET_RE = re.compile(r"(\?.*client(_|%5[Ff])secret=)[^&]*(.*)$")


def redact_uri(uri):
"""Strips access tokens from the uri replaces with <redacted>"""
return ACCESS_TOKEN_RE.sub(r"\1<redacted>\3", uri)
"""Strips sensitive information from the uri replaces with <redacted>"""
uri = ACCESS_TOKEN_RE.sub(r"\1<redacted>\3", uri)
return CLIENT_SECRET_RE.sub(r"\1<redacted>\3", uri)


class QuieterFileBodyProducer(FileBodyProducer):
Expand Down

0 comments on commit d5982cd

Please sign in to comment.