Skip to content

Commit

Permalink
Merge pull request vindi#116 from cedran/master
Browse files Browse the repository at this point in the history
fix: LOGS - aplicacao de mascara no CVV e no registry_code
  • Loading branch information
cedran authored Aug 19, 2024
2 parents fc2091c + 9e02905 commit 4e23cb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Helper/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ private function sanitizeData($data)
'/"expiration_date":\s*"\d{2}\/\d{2}"/',
'/"password":\s*".*?"/',
'/"email":\s*".*?"/',
'/"phone":\s*"\d+"/'
'/"phone":\s*"\d+"/',
'/"card_cvv":\s*"\d+"/',
'/"registry_code":\s*"\d+"/'
];

$replacements = [
Expand All @@ -279,10 +281,11 @@ private function sanitizeData($data)
'"expiration_date": "**/**"',
'"password": "********"',
'"email": "********@****.***"',
'"phone": "**********"'
'"phone": "**********"',
'"card_cvv": "***"',
'"registry_code": "************"'
];

return preg_replace($patterns, $replacements, $data);
}
}

14 changes: 12 additions & 2 deletions Helper/WebhookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ private function logApiRequest($endpoint, $method, $requestBody, $description)
$this->logResource->save($log);
}

/**
* Sanitize sensitive data from the provided input
*
* @param string $data
* @return string
*/
private function sanitizeData($data)
{
$patterns = [
Expand All @@ -141,7 +147,9 @@ private function sanitizeData($data)
'/"expiration_date":\s*"\d{2}\/\d{2}"/',
'/"password":\s*".*?"/',
'/"email":\s*".*?"/',
'/"phone":\s*"\d+"/'
'/"phone":\s*"\d+"/',
'/"card_cvv":\s*"\d+"/',
'/"registry_code":\s*"\d+"/'
];

$replacements = [
Expand All @@ -150,7 +158,9 @@ private function sanitizeData($data)
'"expiration_date": "**/**"',
'"password": "********"',
'"email": "********@****.***"',
'"phone": "**********"'
'"phone": "**********"',
'"card_cvv": "***"',
'"registry_code": "************"'
];

return preg_replace($patterns, $replacements, $data);
Expand Down

0 comments on commit 4e23cb6

Please sign in to comment.