File tree 1 file changed +21
-0
lines changed
cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/util
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,27 @@ public string MaskSensitiveData(string str)
49
49
{
50
50
foreach ( KeyValuePair < string , string > tag in sensitiveTags )
51
51
{
52
+ //removing the space and hypen from PAN details before masking
53
+ if ( tag . Key . StartsWith ( "\\ \" number\\ \" " ) || tag . Key . StartsWith ( "\\ \" cardNumber\\ \" " ) || tag . Key . StartsWith ( "\\ \" account\\ \" " )
54
+ || tag . Key . StartsWith ( "\\ \" prefix\\ \" " ) || tag . Key . StartsWith ( "\\ \" bin\\ \" " ) )
55
+ {
56
+ string [ ] splittedStr = tag . Key . Split ( ':' ) ;
57
+ string tagName = splittedStr [ 0 ] ;
58
+ string specialPatternForPAN = "(((\\ s*[s/-]*\\ s*)+)\\ p{N}((\\ s*[s/-]*\\ s*)+))+" ;
59
+
60
+ // match the patters for PAN number
61
+ MatchCollection matches = Regex . Matches ( str , $ "{ tagName } :\\ \" { specialPatternForPAN } \\ \" ") ;
62
+
63
+ //remove space and dash from the all matched pattern
64
+ foreach ( Match match in matches )
65
+ {
66
+ String strr = match . ToString ( ) ;
67
+ strr = Regex . Replace ( strr , "\\ s*[s/-]*" , "" ) ;
68
+
69
+ //replace original value in str with match
70
+ str = str . Replace ( match . ToString ( ) , strr ) ;
71
+ }
72
+ }
52
73
str = Regex . Replace ( str , tag . Key , tag . Value ) ;
53
74
}
54
75
}
You can’t perform that action at this time.
0 commit comments