Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datadog_lambda/tag_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ def _should_try_string(obj):

def _redact_val(k, v):
split_key = k.split(".").pop() or k
if split_key in redactable_keys:
if split_key.lower() in redactable_keys:
return "redacted"
return v
17 changes: 16 additions & 1 deletion tests/test_tag_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ def test_tag_object_max_depth_0(self):
"vals": [{"thingOne": 1}, {"thingTwo": 2}],
}
spanMock = MagicMock()
expected_value = str(payload)

tag_object(spanMock, "function.request", payload)
spanMock.set_tag.assert_has_calls(
[
call(
"function.request",
"{'hello': 'world', 'level1': {'level2_dict': {'level3': 3}, 'level2_list': [None, True, 'nice', {'l3': 'v3'}], 'level2_bool': True, 'level2_int': 2}, 'vals': [{'thingOne': 1}, {'thingTwo': 2}]}",
expected_value,
),
],
True,
Expand All @@ -105,6 +106,20 @@ def test_redacted_tag_object(self):
True,
)

def test_redacted_tag_object_case_insensitive(self):
payload = {
"Authorization": "secret",
"headers": {"X-AUTHORIZATION": "another"},
}
spanMock = MagicMock()
tag_object(spanMock, "function.request", payload)
spanMock.set_tag.assert_any_call(
"function.request.Authorization", "redacted"
)
spanMock.set_tag.assert_any_call(
"function.request.headers.X-AUTHORIZATION", "redacted"
)

def test_json_tag_object(self):
payload = {
"token": "world",
Expand Down
Loading