Skip to content

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

Closed

Description

@AvinashDalvi89

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

Activity

  1. added
    feature-request
    triage
    on Jan 3, 2025
  2. anafalcao commented on Jan 6, 2025

    @anafalcao
    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 😃

  3. self-assigned this
    on Jan 6, 2025
  4. added
    data-masking
    and removed
    triage
    on Jan 20, 2025
  5. leandrodamascena commented on Jan 20, 2025

    @leandrodamascena
    Contributor

    We are working on this PR #5837

  6. github-actions commented on Feb 11, 2025

    @github-actions
    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.

  7. added
    pending-release
    on Feb 11, 2025
  8. github-actions commented on Feb 11, 2025

    @github-actions
    Contributor

    This is now released under 3.6.0 version!

  9. removed
    pending-release
    on Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

data-maskingfeature-request

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions