Forum Discussion

ee's avatar
ee
Icon for Altostratus rankAltostratus
Oct 02, 2024

F5 Data Guard - Expose last 4 digits for Custom Pattern

Hi, as from the screenshot below, we are able to choose to expose the last 4 digits for credit card numbers and U.S. Social Security Numbers. How about if we want to expose the last 4 digits for the custom patterns? It doesn't seem to have this option available. Anyone got idea on how to do so? 

Let's say the phone number or email address are considered as sensitive information and we don't want to mask the entire phone number and email address. 

 

  • Hello,

    I believe that this use case can be done with irules.

    You will need to identify a pattern, search for this pattern in your response page, and then replace the the response with only last for digits.

     

    This irule ma

    when HTTP_RESPONSE {
        set response_data [HTTP::response]
    
        # Regex to match the email pattern
        set pattern {([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})}
        
        # Replace the matched email with asterisks and keep the last four characters of the email
        regsub -all $pattern $response_data {****@\$2} masked_response
        
        # Replace the original response with the masked one
        HTTP::response replace 0 [HTTP::header Content-Length] $masked_response
    }

     

     

    regards