From 993abdde843ead67080f3288beb3e92f52c6a6d0 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Tue, 27 Feb 2024 14:11:22 +0100 Subject: [PATCH 1/3] ref: Rename `scrub_list` to `_scrub_list_recursive` The new name indicates that the method is private API and that it is intended to only be called in the recursive scrubbing case --- sentry_sdk/scrubber.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/scrubber.py b/sentry_sdk/scrubber.py index 312f042c44..8636bd75d4 100644 --- a/sentry_sdk/scrubber.py +++ b/sentry_sdk/scrubber.py @@ -65,7 +65,7 @@ def __init__(self, denylist=None, recursive=False): self.denylist = [x.lower() for x in self.denylist] self.recursive = recursive - def scrub_list(self, lst): + def _scrub_list_recursively(self, lst): # type: (List[Any]) -> None if not isinstance(lst, list): return @@ -74,7 +74,7 @@ def scrub_list(self, lst): if isinstance(v, dict): self.scrub_dict(v) elif isinstance(v, list): - self.scrub_list(v) + self._scrub_list_recursively(v) def scrub_dict(self, d): # type: (Dict[str, Any]) -> None @@ -88,7 +88,7 @@ def scrub_dict(self, d): if isinstance(v, dict): self.scrub_dict(v) elif isinstance(v, list): - self.scrub_list(v) + self._scrub_list_recursively(v) def scrub_request(self, event): # type: (Event) -> None From 9fc6e8791e504d63361ffa96c0de5f3988f426bf Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Tue, 27 Feb 2024 14:32:19 +0100 Subject: [PATCH 2/3] Make `scrub_list_recursively` public --- sentry_sdk/scrubber.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/scrubber.py b/sentry_sdk/scrubber.py index 8636bd75d4..8afd5946fe 100644 --- a/sentry_sdk/scrubber.py +++ b/sentry_sdk/scrubber.py @@ -65,7 +65,7 @@ def __init__(self, denylist=None, recursive=False): self.denylist = [x.lower() for x in self.denylist] self.recursive = recursive - def _scrub_list_recursively(self, lst): + def scrub_list_recursively(self, lst): # type: (List[Any]) -> None if not isinstance(lst, list): return @@ -74,7 +74,7 @@ def _scrub_list_recursively(self, lst): if isinstance(v, dict): self.scrub_dict(v) elif isinstance(v, list): - self._scrub_list_recursively(v) + self.scrub_list_recursively(v) def scrub_dict(self, d): # type: (Dict[str, Any]) -> None @@ -88,7 +88,7 @@ def scrub_dict(self, d): if isinstance(v, dict): self.scrub_dict(v) elif isinstance(v, list): - self._scrub_list_recursively(v) + self.scrub_list_recursively(v) def scrub_request(self, event): # type: (Event) -> None From aa93df53a3bd9259be67164390620dd21e9385b3 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Tue, 27 Feb 2024 14:49:01 +0100 Subject: [PATCH 3/3] Rename back to `scrub_list` and add doc comment --- sentry_sdk/scrubber.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/scrubber.py b/sentry_sdk/scrubber.py index 8afd5946fe..a6c55af4fd 100644 --- a/sentry_sdk/scrubber.py +++ b/sentry_sdk/scrubber.py @@ -65,8 +65,14 @@ def __init__(self, denylist=None, recursive=False): self.denylist = [x.lower() for x in self.denylist] self.recursive = recursive - def scrub_list_recursively(self, lst): + def scrub_list(self, lst): # type: (List[Any]) -> None + """ + If a list is passed to this method, the method recursively searches the list and any + nested lists for any dictionaries. The method calls scrub_dict on all dictionaries + it finds. + If the parameter passed to this method is not a list, the method does nothing. + """ if not isinstance(lst, list): return @@ -74,7 +80,7 @@ def scrub_list_recursively(self, lst): if isinstance(v, dict): self.scrub_dict(v) elif isinstance(v, list): - self.scrub_list_recursively(v) + self.scrub_list(v) def scrub_dict(self, d): # type: (Dict[str, Any]) -> None @@ -88,7 +94,7 @@ def scrub_dict(self, d): if isinstance(v, dict): self.scrub_dict(v) elif isinstance(v, list): - self.scrub_list_recursively(v) + self.scrub_list(v) def scrub_request(self, event): # type: (Event) -> None