From 4860f5e5c907bea5696d908f0a9544ef2b85b666 Mon Sep 17 00:00:00 2001 From: Alex Rapatij <109154287+AlexRapatij@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:45:47 +0100 Subject: [PATCH 1/2] Don't logging not encrypted types values --- Plugin/LogDecrypts.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Plugin/LogDecrypts.php b/Plugin/LogDecrypts.php index 7dea075..1a58d0f 100644 --- a/Plugin/LogDecrypts.php +++ b/Plugin/LogDecrypts.php @@ -5,6 +5,7 @@ use Psr\Log\LoggerInterface; use Magento\Framework\Encryption\Encryptor; use Magento\Framework\App\DeploymentConfig; +use Gene\EncryptionKeyManager\Model\EncodingHelper; class LogDecrypts { @@ -27,7 +28,8 @@ class LogDecrypts public function __construct( Encryptor $encryptor, DeploymentConfig $deploymentConfig, - private readonly LoggerInterface $logger + private readonly LoggerInterface $logger, + private readonly EncodingHelper $encodingHelper ) { $this->keyCount = count(explode(PHP_EOL, $encryptor->exportKeys())) - 1; @@ -65,6 +67,11 @@ public function afterDecrypt(Encryptor $subject, $result, $data) return $result; } + // don't logging values don't like as an encrypted value + if (!$this->encodingHelper->isEncryptedValue()) { + return $result; + } + $exception = new \Exception(); /** From aa4bab61458751910f1988179088ad2d9bff0a50 Mon Sep 17 00:00:00 2001 From: Alex Rapatij <109154287+AlexRapatij@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:59:35 +0100 Subject: [PATCH 2/2] Update Plugin/LogDecrypts.php Co-authored-by: Luke Rodgers --- Plugin/LogDecrypts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugin/LogDecrypts.php b/Plugin/LogDecrypts.php index 1a58d0f..8d80c6b 100644 --- a/Plugin/LogDecrypts.php +++ b/Plugin/LogDecrypts.php @@ -68,7 +68,7 @@ public function afterDecrypt(Encryptor $subject, $result, $data) } // don't logging values don't like as an encrypted value - if (!$this->encodingHelper->isEncryptedValue()) { + if (!$this->encodingHelper->isEncryptedValue($data)) { return $result; }