Skip to content

Commit

Permalink
Changed logging routines so that newpw is also blanked in the logging
Browse files Browse the repository at this point in the history
  • Loading branch information
metaregistrar committed Jan 29, 2019
1 parent e858d57 commit dfaa6a9
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions Protocols/EPP/eppConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1061,24 +1061,16 @@ private function showLog() {

protected function writeLog($text,$action) {
if ($this->logging) {
// Hiding userid in the logging
if (($start = strpos($text,'<clID>')) !== false) {
if (($end = strpos($text,'</clID>')) !== false) {
$text = substr($text,0,$start+6).'XXXXXXXXXXXXXXXX'.substr($text,$end,99999);
}
}
// Hiding password in the logging
if (($start = strpos($text,'<pw><![CDATA[')) !== false) {
if (($end = strpos($text,']]></pw>')) !== false) {
$text = substr($text,0,$start+4).'XXXXXXXXXXXXXXXX'.substr($text,$end+3,99999);
}
}
// Hiding password in the logging
if (($start = strpos($text,'<pw>')) !== false) {
if (($end = strpos($text,'</pw>')) !== false) {
$text = substr($text,0,$start+4).'XXXXXXXXXXXXXXXX'.substr($text,$end,99999);
}
}
// Hide userid in the logging
$text = $this->hideTextBetween($text,'<clID>','</clID>');
// Hide password in the logging
$text = $this->hideTextBetween($text,'<pw>','</pw>');
// Hide password in the logging
$text = $this->hideTextBetween($text,'<pw><![CDATA[',']]></pw>');
// Hide new password in the logging
$text = $this->hideTextBetween($text,'<newPW>','</newPW>');
// Hide new password in the logging
$text = $this->hideTextBetween($text,'<newPW><![CDATA[',']]></newPW>');
//echo "-----".date("Y-m-d H:i:s")."-----".$text."-----end-----\n";
$log = "-----" . $action . "-----" . date("Y-m-d H:i:s") . "-----\n" . $text . "\n-----END-----" . date("Y-m-d H:i:s") . "-----\n";
$this->logentries[] = $log;
Expand All @@ -1088,6 +1080,21 @@ protected function writeLog($text,$action) {
}
}

/**
* @param $text
* @param $start
* @param $end
* @return string
*/
protected function hideTextBetween($text, $start, $end) {
if (($startpos = strpos(strtolower($text),strtolower($start))) !== false) {
if (($endpos = strpos(strtolower($text),strtolower($end))) !== false) {
$text = substr($text,0,$startpos+strlen($start)).'XXXXXXXXXXXXXXXX'.substr($text,$endpos,99999);
}
}
return $text;
}

/**
* @param null|string $connectionComment
* @return eppConnection
Expand Down

0 comments on commit dfaa6a9

Please sign in to comment.