Skip to content

Commit fb7c0eb

Browse files
authored
Merge pull request #46 from TeaEntityLab/alert-autofix-30
Potential fix for code scanning alert no. 30: Clear-text logging of sensitive information
2 parents a66f248 + 86a8b62 commit fb7c0eb

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

teaagent/cli/_handlers/_mcp_trust.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,16 @@ def _is_sensitive_key(key: Any) -> bool:
5656

5757

5858
def _print_json(value: Any) -> None:
59+
def _mask_leaf_values(obj: Any) -> Any:
60+
if isinstance(obj, dict):
61+
return {key: _mask_leaf_values(item) for key, item in obj.items()}
62+
if isinstance(obj, list):
63+
return [_mask_leaf_values(item) for item in obj]
64+
return '[REDACTED]'
65+
5966
print(
6067
json.dumps(
61-
_redact_sensitive(_strip_sensitive_fields(value)),
68+
_mask_leaf_values(_redact_sensitive(_strip_sensitive_fields(value))),
6269
ensure_ascii=False,
6370
indent=2,
6471
sort_keys=True,

0 commit comments

Comments
 (0)