Skip to content

Commit

Permalink
Don't scrub 'author' (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmojaki authored Apr 30, 2024
1 parent 375318d commit 5c6ee64
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion logfire/_internal/scrubbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'passwd',
'mysql_pwd',
'secret',
'auth',
r'auth(?!ors?\b)',
'credential',
'private[._ -]?key',
'api[._ -]?key',
Expand Down
19 changes: 17 additions & 2 deletions tests/test_secret_scrubbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@


def test_scrub_attribute(exporter: TestExporter):
logfire.info('Password: {user_password}', user_password=['hunter2'], mode='password', modes='passwords')
logfire.info(
'Password: {user_password}',
user_password=['hunter2'],
mode='password',
modes='passwords',
Author='Alice1',
authors='Alice2',
authr='Alice3',
authorization='Alice4',
)
# We redact:
# - The `user_password` attribute.
# - The `modes` attribute.
# - `authr` and `authorization` because they contain 'auth' but don't look like 'author(s)'.
# Things intentionally not redacted even though they contain "password":
# - The `mode` attribute, because the value 'password' is a full match.
# - 'Author' and 'authors': special cases in the regex that looks for 'auth'.
# - logfire.msg_template
# - The span name, which is the same as msg_template and shouldn't contain data.
# - logfire.json_schema
Expand All @@ -42,7 +53,11 @@ def test_scrub_attribute(exporter: TestExporter):
'user_password': "[Redacted due to 'password']",
'mode': 'password',
'modes': "[Redacted due to 'password']",
'logfire.json_schema': '{"type":"object","properties":{"user_password":{"type":"array"},"mode":{},"modes":{}}}',
'Author': 'Alice1',
'authors': 'Alice2',
'authr': "[Redacted due to 'auth']",
'authorization': "[Redacted due to 'auth']",
'logfire.json_schema': '{"type":"object","properties":{"user_password":{"type":"array"},"mode":{},"modes":{},"Author":{},"authors":{},"authr":{},"authorization":{}}}',
},
}
]
Expand Down

0 comments on commit 5c6ee64

Please sign in to comment.