From 5c6ee6415245650016558e8ce89e2add03c4771c Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Tue, 30 Apr 2024 20:43:12 +0200 Subject: [PATCH] Don't scrub 'author' (#55) --- logfire/_internal/scrubbing.py | 2 +- tests/test_secret_scrubbing.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/logfire/_internal/scrubbing.py b/logfire/_internal/scrubbing.py index 7bc7f90b..096b315f 100644 --- a/logfire/_internal/scrubbing.py +++ b/logfire/_internal/scrubbing.py @@ -31,7 +31,7 @@ 'passwd', 'mysql_pwd', 'secret', - 'auth', + r'auth(?!ors?\b)', 'credential', 'private[._ -]?key', 'api[._ -]?key', diff --git a/tests/test_secret_scrubbing.py b/tests/test_secret_scrubbing.py index 1725e069..f2d3c8b4 100644 --- a/tests/test_secret_scrubbing.py +++ b/tests/test_secret_scrubbing.py @@ -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 @@ -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":{}}}', }, } ]