HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/klarna/module-core/Logger/Cleanser.php
<?php
/**
 * This file is part of the Klarna Core module
 *
 * (c) Klarna AB
 *
 * For the full copyright and license information, please view the NOTICE
 * and LICENSE files that were distributed with this source code.
 */

namespace Klarna\Core\Logger;

class Cleanser
{
    /**
     * List of keys that should never be logged
     *
     * @var string[]
     */
    public $privateKeys = [
        'password',
        'shared_secret',
        'secret',
        'secret:Klarna\XMLRPC\Klarna:private',
        '_secret:Klarna_Checkout_BasicConnector:private',
        'date_of_birth',
        '_secret',
        'street',
        'Authorization',
        'given_name',
        'firstname',
        'gender',
        'family_name',
        'lastname',
        'email',
        'street_address',
        'phone',
        'telephone',
        'title'
    ];

    /**
     * Value to be substituted instead of sensitve data
     *
     * @var string
     */
    public $replaceValue = '** REMOVED **';

    /**
     * Search object for sensitive data and replace it if found
     *
     * @param mixed $input
     * @return mixed
     */
    public function checkForSensitiveData($input = null)
    {
        if (is_string($input)) {
            return $input;
        }
        if (null === $input) {
            return $input;
        }
        if ($input instanceof \Exception) {
            $newinput = [
                'message' => $input->getMessage(),
                'trace'   => $input->getTrace()
            ];
            $input = $newinput;
        }
        if (is_object($input)) {
            $input = $this->processObject($input);
        }
        if (is_array($input)) {
            return $this->checkArrayForSensitiveData($input);
        }
        if (($json = json_decode($input, true)) && is_array($json)) {
            $json = $this->checkForSensitiveData($json);
            return json_encode($json);
        }
        return $input;
    }

    /**
     * Convert object to array
     *
     * @param \stdClass $input
     * @return array
     */
    private function processObject($input)
    {
        if (method_exists($input, 'toArray')) {
            return $input->toArray();
        }
        if (method_exists($input, 'getData')) {
            return $input->getData();
        }
        return get_object_vars($input);
    }

    /**
     * Recursively search array for sensitive data and replace it if found
     *
     * @param array $input
     * @return array
     */
    public function checkArrayForSensitiveData($input)
    {
        foreach ($input as $key => $value) {
            if (is_int($key)) {
                continue;
            }
            if (in_array($key, $this->privateKeys)) {
                $input[$key] = $this->replaceValue;
                continue;
            }
            if (!is_array($value)) {
                continue;
            }
            foreach ($value as $k => $v) {
                $input[$key][$k] = $this->checkForSensitiveData($v);
            }
        }
        return $input;
    }
}