Skip to content

Commit b7ab904

Browse files
committed
feat: wip
1 parent 4590fe8 commit b7ab904

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

posthog/test/test_exception_capture.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ def trigger_error():
6464
"password": "secret123", # key matches pattern -> should be masked
6565
"other_key": "contains_password_here", # value matches pattern -> should be masked
6666
}}
67+
my_nested_dict = {{
68+
"level1": {{
69+
"level2": {{
70+
"api_key": "nested_secret", # deeply nested key matches
71+
"data": "contains_token_here", # deeply nested value matches
72+
"safe": "visible",
73+
}}
74+
}}
75+
}}
76+
my_list = ["safe_item", "has_password_inside", "another_safe"]
77+
my_tuple = ("tuple_safe", "secret_in_value", "tuple_also_safe")
78+
my_list_of_dicts = [
79+
{{"id": 1, "password": "list_dict_secret"}},
80+
{{"id": 2, "value": "safe_value"}},
81+
]
6782
my_obj = UnserializableObject()
6883
my_password = "secret123" # Should be masked by default (name matches)
6984
my_innocent_var = "contains_password_here" # Should be masked by default (value matches)
@@ -102,10 +117,11 @@ def process_data():
102117
assert b"'my_number': 42" in output
103118
assert b"'my_bool': 'True'" in output
104119
assert b'"my_dict": "{\\"name\\": \\"test\\", \\"value\\": 123}"' in output
105-
# Dict with sensitive keys/values should have those masked
106-
assert b'"safe_key": "safe_value"' in output
107-
assert b'"password": "$$_posthog_redacted_based_on_masking_rules_$$"' in output
108-
assert b'"other_key": "$$_posthog_redacted_based_on_masking_rules_$$"' in output
120+
assert b'{\\"safe_key\\": \\"safe_value\\", \\"password\\": \\"$$_posthog_redacted_based_on_masking_rules_$$\\", \\"other_key\\": \\"$$_posthog_redacted_based_on_masking_rules_$$\\"}' in output
121+
assert b'{\\"level1\\": {\\"level2\\": {\\"api_key\\": \\"$$_posthog_redacted_based_on_masking_rules_$$\\", \\"data\\": \\"$$_posthog_redacted_based_on_masking_rules_$$\\", \\"safe\\": \\"visible\\"}}}' in output
122+
assert b'[\\"safe_item\\", \\"$$_posthog_redacted_based_on_masking_rules_$$\\", \\"another_safe\\"]' in output
123+
assert b'[\\"tuple_safe\\", \\"$$_posthog_redacted_based_on_masking_rules_$$\\", \\"tuple_also_safe\\"]' in output
124+
assert b'[{\\"id\\": 1, \\"password\\": \\"$$_posthog_redacted_based_on_masking_rules_$$\\"}, {\\"id\\": 2, \\"value\\": \\"safe_value\\"}]' in output
109125
assert b"<__main__.UnserializableObject object at" in output
110126
assert b"'my_password': '$$_posthog_redacted_based_on_masking_rules_$$'" in output
111127
assert (

0 commit comments

Comments
 (0)