Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support for custom masking with regx pattern or custom masking chars #5826

Open
2 tasks done
AvinashDalvi89 opened this issue Jan 3, 2025 · 2 comments
Open
2 tasks done
Assignees
Labels
data-masking Sensitive Data Masking feature feature-request feature request

Comments

@AvinashDalvi89
Copy link

Use case

In some of case I would like to custom masking like example Aadhar number or SSN number is 1111-1111-1111 then masking should be done like ****-****-6789 or ****-****-**** or regex pattern.

Solution/User Experience

currently erase, encrypt and decrypt is supported. Similarly can be introduce mask or custom_mask method which accept parameter s like masking_chars
This is just an example to explain how it can worked this can move to prebuild function mask or custom_mask

from aws_lambda_powertools import Logger
import re

# Initialize logger with custom masking
logger = Logger()

def mask_sensitive_data(value):
    """Custom function to mask sensitive data"""
    return re.sub(r'\d{4}-\d{4}-\d{4}-(\d{4})', '****-****-****-****', value)

user_data = {
    "username": "john_doe",
    "card_number": "4111-1111-1111-1111"
}

# Apply custom masking
masked_card_number = mask_sensitive_data(user_data["card_number"])
logger.info("Processing payment", extra={"card_number": masked_card_number})

Alternative solutions

Acknowledgment

@anafalcao
Copy link
Collaborator

Hey @AvinashDalvi89 !
Thank you for submitting this feature request. We believe this will be a valuable addition to the Data Masking functionality.
I'll be working on creating this PR soon 😃

@anafalcao anafalcao self-assigned this Jan 6, 2025
@leandrodamascena leandrodamascena moved this from Triage to Working on it in Powertools for AWS Lambda (Python) Jan 20, 2025
@leandrodamascena leandrodamascena added data-masking Sensitive Data Masking feature and removed triage Pending triage from maintainers labels Jan 20, 2025
@leandrodamascena
Copy link
Contributor

We are working on this PR #5837

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data-masking Sensitive Data Masking feature feature-request feature request
Projects
Status: Working on it
Development

No branches or pull requests

3 participants