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

Closed
2 tasks done
AvinashDalvi89 opened this issue Jan 3, 2025 · 4 comments · Fixed by #5837
Closed
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
Contributor

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

@dreamorosi dreamorosi linked a pull request Jan 27, 2025 that will close this issue
7 tasks
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Feb 11, 2025
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Feb 11, 2025
Copy link
Contributor

This is now released under 3.6.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Feb 11, 2025
@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Feb 11, 2025
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: Shipped
Development

Successfully merging a pull request may close this issue.

3 participants