Skip to content

Commit 796bd89

Browse files
committed
change flags name to more intuitive
1 parent d9427f5 commit 796bd89

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

aws_lambda_powertools/utilities/data_masking/base.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def erase(
100100
self,
101101
data: dict,
102102
fields: list[str],
103-
custom_mask: bool | None = None,
104-
mask_pattern: str | None = None,
103+
dynamic_mask: bool | None = None,
104+
custom_mask: str | None = None,
105105
regex_pattern: str | None = None,
106106
mask_format: str | None = None,
107107
) -> dict: ...
@@ -110,8 +110,8 @@ def erase(
110110
self,
111111
data: Sequence | Mapping,
112112
fields: list[str] | None = None,
113-
custom_mask: bool | None = None,
114-
mask_pattern: str | None = None,
113+
dynamic_mask: bool | None = None,
114+
custom_mask: str | None = None,
115115
regex_pattern: str | None = None,
116116
mask_format: str | None = None,
117117
masking_rules: dict | None = None,
@@ -125,8 +125,8 @@ def erase(
125125
data=data,
126126
fields=fields,
127127
action=self.provider.erase,
128+
dynamic_mask=dynamic_mask,
128129
custom_mask=custom_mask,
129-
mask_pattern=mask_pattern,
130130
regex_pattern=regex_pattern,
131131
mask_format=mask_format,
132132
)
@@ -137,8 +137,8 @@ def _apply_action(
137137
fields: list[str] | None,
138138
action: Callable,
139139
provider_options: dict | None = None,
140-
custom_mask: bool | None = None,
141-
mask_pattern: str | None = None,
140+
dynamic_mask: bool | None = None,
141+
custom_mask: str | None = None,
142142
regex_pattern: str | None = None,
143143
mask_format: str | None = None,
144144
**encryption_context: str,
@@ -174,8 +174,8 @@ def _apply_action(
174174
fields=fields,
175175
action=action,
176176
provider_options=provider_options,
177+
dynamic_mask=dynamic_mask,
177178
custom_mask=custom_mask,
178-
mask_pattern=mask_pattern,
179179
regex_pattern=regex_pattern,
180180
mask_format=mask_format,
181181
**encryption_context,
@@ -185,8 +185,8 @@ def _apply_action(
185185
return action(
186186
data=data,
187187
provider_options=provider_options,
188+
dynamic_mask=dynamic_mask,
188189
custom_mask=custom_mask,
189-
mask_pattern=mask_pattern,
190190
regex_pattern=regex_pattern,
191191
mask_format=mask_format,
192192
**encryption_context,
@@ -198,8 +198,8 @@ def _apply_action_to_fields(
198198
fields: list,
199199
action: Callable,
200200
provider_options: dict | None = None,
201-
custom_mask: bool | None = None,
202-
mask_pattern: str | None = None,
201+
dynamic_mask: bool | None = None,
202+
custom_mask: str | None = None,
203203
regex_pattern: str | None = None,
204204
mask_format: str | None = None,
205205
**encryption_context: str,
@@ -260,8 +260,8 @@ def _apply_action_to_fields(
260260
self._call_action,
261261
action=action,
262262
provider_options=provider_options,
263+
dynamic_mask=dynamic_mask,
263264
custom_mask=custom_mask,
264-
mask_pattern=mask_pattern,
265265
regex_pattern=regex_pattern,
266266
mask_format=mask_format,
267267
**encryption_context, # type: ignore[arg-type]
@@ -343,8 +343,8 @@ def _call_action(
343343
field_name: str,
344344
action: Callable,
345345
provider_options: dict[str, Any] | None = None,
346-
custom_mask: bool | None = None,
347-
mask_pattern: str | None = None,
346+
dynamic_mask: bool | None = None,
347+
custom_mask: str | None = None,
348348
regex_pattern: str | None = None,
349349
mask_format: str | None = None,
350350
**encryption_context,
@@ -367,8 +367,8 @@ def _call_action(
367367
fields[field_name] = action(
368368
field_value,
369369
provider_options=provider_options,
370+
dynamic_mask=dynamic_mask,
370371
custom_mask=custom_mask,
371-
mask_pattern=mask_pattern,
372372
regex_pattern=regex_pattern,
373373
mask_format=mask_format,
374374
**encryption_context,

aws_lambda_powertools/utilities/data_masking/provider/base.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def decrypt(self, data, provider_options: dict | None = None, **encryption_conte
7070
def erase(
7171
self,
7272
data,
73-
custom_mask: bool | None = None,
74-
mask_pattern: str | None = None,
73+
dynamic_mask: bool | None = None,
74+
custom_mask: str | None = None,
7575
regex_pattern: str | None = None,
7676
mask_format: str | None = None,
7777
masking_rules: dict | None = None,
@@ -91,22 +91,21 @@ def erase(
9191

9292
if data:
9393
if isinstance(data, str):
94+
if dynamic_mask:
95+
result = self._custom_erase(data, **kwargs)
9496
if custom_mask:
95-
if mask_pattern:
96-
result = self._pattern_mask(data, mask_pattern)
97-
elif regex_pattern and mask_format:
98-
result = self._regex_mask(data, regex_pattern, mask_format)
99-
else:
100-
result = self._custom_erase(data, **kwargs)
97+
result = self._pattern_mask(data, custom_mask)
98+
if regex_pattern and mask_format:
99+
result = self._regex_mask(data, regex_pattern, mask_format)
101100
elif isinstance(data, dict):
102101
if masking_rules:
103102
result = self._apply_masking_rules(data, masking_rules)
104103
elif isinstance(data, (list, tuple, set)):
105104
result = type(data)(
106105
self.erase(
107106
item,
107+
dynamic_mask=dynamic_mask,
108108
custom_mask=custom_mask,
109-
mask_pattern=mask_pattern,
110109
regex_pattern=regex_pattern,
111110
mask_format=mask_format,
112111
masking_rules=masking_rules,

0 commit comments

Comments
 (0)