Skip to content

Commit 555f839

Browse files
fix(security): fix encryption_context handling in data masking operations (#6074)
Enforcing encryption context
1 parent 02d9921 commit 555f839

File tree

1 file changed

+16
-11
lines changed
  • aws_lambda_powertools/utilities/data_masking

1 file changed

+16
-11
lines changed

Diff for: aws_lambda_powertools/utilities/data_masking/base.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _apply_action(
207207
custom_mask: str | None = None,
208208
regex_pattern: str | None = None,
209209
mask_format: str | None = None,
210-
**kwargs: Any,
210+
**encryption_context: Any,
211211
) -> Any:
212212
"""
213213
Helper method to determine whether to apply a given action to the entire input data
@@ -242,19 +242,24 @@ def _apply_action(
242242
custom_mask=custom_mask,
243243
regex_pattern=regex_pattern,
244244
mask_format=mask_format,
245-
**kwargs,
246245
)
247246
else:
248247
logger.debug(f"Running action {action.__name__} with the entire data")
249-
return action(
250-
data=data,
251-
provider_options=provider_options,
252-
dynamic_mask=dynamic_mask,
253-
custom_mask=custom_mask,
254-
regex_pattern=regex_pattern,
255-
mask_format=mask_format,
256-
**kwargs,
257-
)
248+
if action.__name__ == "erase":
249+
return action(
250+
data=data,
251+
provider_options=provider_options,
252+
dynamic_mask=dynamic_mask,
253+
custom_mask=custom_mask,
254+
regex_pattern=regex_pattern,
255+
mask_format=mask_format,
256+
)
257+
else:
258+
return action(
259+
data=data,
260+
provider_options=provider_options,
261+
**encryption_context,
262+
)
258263

259264
def _apply_action_to_fields(
260265
self,

0 commit comments

Comments
 (0)