Skip to content

Commit 7e4a21c

Browse files
committed
Enhancing regex to include single one
1 parent d4370ab commit 7e4a21c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/AuthenticationSDK/logging/sensitive_logging.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class SensitiveDataConfigType
1616
def initialize
1717
@sensitiveTags = Array.new([
1818
SensitiveTag.new("securityCode", "[0-9]{3,4}", "XXX", false),
19-
SensitiveTag.new("number", "(\\p{N}+)(\\p{N}{4})", "XXXX-\\2", false),
20-
SensitiveTag.new("cardNumber", "(\\p{N}+)(\\p{N}{4})", "XXXX-\\2", false),
19+
SensitiveTag.new("number", "(\\s*\\p{N}\\s*)+(\\p{N}{4})(\\s*)", "XXXX-\\2", false),
20+
SensitiveTag.new("cardNumber", "(\\s*\\p{N}\\s*)+(\\p{N}{4})(\\s*)", "XXXX-\\2", false),
2121
SensitiveTag.new("expirationMonth", "[0-1][0-9]", "XXXX", false),
2222
SensitiveTag.new("expirationYear", "2[0-9][0-9][0-9]", "XXXX", false),
23-
SensitiveTag.new("account", "(\\p{N}+)(\\p{N}{4})", "XXXX-\\2", false),
23+
SensitiveTag.new("account", "(\\s*\\p{N}\\s*)+(\\p{N}{4})(\\s*)", "XXXX-\\2", false),
2424
SensitiveTag.new("routingNumber", "[0-9]+", "XXXXX", false),
2525
SensitiveTag.new("email", "[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", "XXXXX", false),
2626
SensitiveTag.new("firstName", "([a-zA-Z]+( )?[a-zA-Z]*'?-?[a-zA-Z]*( )?([a-zA-Z]*)?)", "xxxxx", false),
@@ -30,9 +30,8 @@ def initialize
3030
SensitiveTag.new("token", "[-.A-Za-z0-9 ]+", "xxxxx", false),
3131
SensitiveTag.new("signature", "[-.A-Za-z0-9 ]+", "xxxxx", false),
3232
SensitiveTag.new("prefix", "(\\p{N}{6})(\\p{N}*)", "\\2-XXXXX", false),
33-
SensitiveTag.new("prefix", "(\\d{4})\s?(\\d{4})", "\\1-XXXX", false),
34-
SensitiveTag.new("bin", "(\\p{N}{4})(\\p{N}*)", "\\1-XXXX", false),
35-
SensitiveTag.new("bin", "(\\d{4})\s?(\\d{4})", "\\1-XXXX", false)
33+
SensitiveTag.new("prefix", "(\\s*)(\\p{N}{4})(\\s*)(\\p{N}{2})(\\s*\\p{N}*\\s*)", "\\2-XXXX", false),
34+
SensitiveTag.new("bin", "(\\s*)(\\p{N}{4})(\\s*)(\\p{N}{2})(\\s*\\p{N}*\\s*)", "\\2-XXXX", false)
3635
]).freeze
3736

3837
@sensitiveStringRegexes = [

0 commit comments

Comments
 (0)