55
66class ANetSensitiveFields
77{
8- private static $ sensitiveTags = NULL ;
8+ private static $ applySensitiveTags = NULL ;
99 private static $ sensitiveStringRegexes = NULL ;
1010
1111 private static function fetchFromConfigFiles (){
@@ -15,7 +15,7 @@ private static function fetchFromConfigFiles(){
1515 if ($ presentUserConfigFile ) { //client config for tags
1616 //read list of tags(and associate regex-patterns and replacements) from .json file
1717 $ jsonFileObejct = json_decode (file_get_contents ($ userConfigFile ));
18- self :: $ sensitiveTags = $ jsonFileObejct ->sensitiveTags ;
18+ $ sensitiveTags = $ jsonFileObejct ->sensitiveTags ;
1919 self ::$ sensitiveStringRegexes = $ jsonFileObejct ->sensitiveStringRegexes ;
2020 if (json_last_error () === JSON_ERROR_NONE ) {// JSON is valid
2121 }
@@ -29,14 +29,24 @@ private static function fetchFromConfigFiles(){
2929 exit ("ERROR: No config file: " . $ configFilePath );
3030 }
3131 $ jsonFileObejct = json_decode (file_get_contents ($ configFilePath ));
32- self :: $ sensitiveTags = $ jsonFileObejct ->sensitiveTags ;
32+ $ sensitiveTags = $ jsonFileObejct ->sensitiveTags ;
3333 self ::$ sensitiveStringRegexes = $ jsonFileObejct ->sensitiveStringRegexes ;
3434 if (json_last_error () === JSON_ERROR_NONE ) {
3535 }
3636 else {
3737 exit ("ERROR: Invalid json in: " . $ configFilePath . " json_last_error_msg : " . json_last_error_msg ());
3838 }
3939 }
40+ //Check for disableMask flag in case of client json.
41+ self ::$ applySensitiveTags = array ();
42+ foreach ($ sensitiveTags as $ sensitiveTag ){
43+ if ($ sensitiveTag ->disableMask ){
44+ //skip masking continue;
45+ }
46+ else {
47+ array_push (self ::$ applySensitiveTags ,$ sensitiveTag );
48+ }
49+ }
4050 }
4151 public static function getSensitiveStringRegexes (){
4252 if (NULL == self ::$ sensitiveStringRegexes ) {
@@ -45,9 +55,9 @@ public static function getSensitiveStringRegexes(){
4555 return self ::$ sensitiveStringRegexes ;
4656 }
4757 public static function getSensitiveXmlTags (){
48- if (NULL == self ::$ sensitiveTags ) {
58+ if (NULL == self ::$ applySensitiveTags ) {
4959 self ::fetchFromConfigFiles ();
5060 }
51- return self ::$ sensitiveTags ;
61+ return self ::$ applySensitiveTags ;
5262 }
5363}
0 commit comments