Skip to content

Commit ff00f01

Browse files
committed
Added logging for arrays.
1 parent 4f71788 commit ff00f01

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

lib/net/authorize/util/Log.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private function getPropertiesInclBase($reflClass)
115115
}
116116

117117
/**
118-
* private function checkAndMask($prop, $obj).
118+
* private function checkPropertyAndMask($prop, $obj).
119119
*
120120
* Receives a ReflectionProperty and an object, and returns a masked object if the ReflectionProperty corresponds to a sensitive field, else returns false.
121121
*
@@ -124,22 +124,22 @@ private function getPropertiesInclBase($reflClass)
124124
*
125125
* @return string|bool
126126
*/
127-
private function checkAndMask($prop, $obj){
128-
foreach($this->sensitiveXmlTags as $i => $sensitiveTag)
127+
private function checkPropertyAndMask($prop, $obj){
128+
foreach($this->sensitiveXmlTags as $i => $sensitiveField)
129129
{
130130
$inputPattern = "(.+)";
131131
$inputReplacement = "xxxx";
132132

133-
if(trim($sensitiveTag->pattern)) {
134-
$inputPattern = $sensitiveTag->pattern;
133+
if(trim($sensitiveField->pattern)) {
134+
$inputPattern = $sensitiveField->pattern;
135135
}
136136
$inputPattern='/'.$inputPattern.'/';
137137

138-
if(trim($sensitiveTag->replacement)) {
139-
$inputReplacement = $sensitiveTag->replacement;
138+
if(trim($sensitiveField->replacement)) {
139+
$inputReplacement = $sensitiveField->replacement;
140140
}
141141

142-
if(strcmp($prop->getName(),$sensitiveTag->tagName)==0)
142+
if(strcmp($prop->getName(),$sensitiveField->tagName)==0)
143143
{
144144
$prop->setValue($obj,preg_replace($inputPattern,$inputReplacement,$prop->getValue($obj)));
145145
return $prop->getValue($obj);
@@ -179,7 +179,7 @@ private function maskSensitiveProperties ($obj)
179179
}
180180
// else check if the property represents a sensitive field. If so, mask.
181181
else{
182-
$res=$this->checkAndMask($prop, $obj);
182+
$res=$this->checkPropertyAndMask($prop, $obj);
183183
if($res)
184184
$prop->setValue($obj, $res);
185185
}
@@ -205,15 +205,27 @@ private function getMasked($raw)
205205
{ //always returns string
206206
$messageType = gettype($raw);
207207
$message="";
208-
if ($messageType == "string") {
209-
$maskedXml = $this->maskSensitiveXmlString($raw);
210-
//mask credit card numbers
211-
$message = $this->maskCreditCards($maskedXml);
212-
}
213-
else if($messageType == "object"){
208+
if($messageType == "object"){
214209
$obj = unserialize(serialize($raw)); // deep copying the object
215210
$message = print_r($this->maskSensitiveProperties($obj), true); //object to string
216211
}
212+
else if($messageType == "array"){
213+
$copyArray = unserialize(serialize($raw));
214+
foreach($copyArray as $i => $element){
215+
$copyArray[$i] = $this->getMasked($element);
216+
}
217+
$message = print_r($copyArray, true); // returns string
218+
}
219+
else { //$messageType == "string")
220+
$primtiveTypeAsString = strval($raw);
221+
222+
$maskedXml = $primtiveTypeAsString;
223+
if($messageType == "string") {
224+
$maskedXml = $this->maskSensitiveXmlString($primtiveTypeAsString);
225+
}
226+
//mask credit card numbers
227+
$message = $this->maskCreditCards($maskedXml);
228+
}
217229
return $message;
218230
}
219231

0 commit comments

Comments
 (0)