Skip to content

Bug: $sensitiveDataInTrace does not work #7708

@kenjis

Description

@kenjis

PHP Version

8.1

CodeIgniter4 Version

4.3.6 and develop

CodeIgniter4 Installation Method

Git

Which operating systems have you tested for this bug?

macOS

Which server did you use?

cli-server (PHP built-in webserver)

Database

n/a

What happened?

1. APPPATH/Controllers/Home.php : 15   —  App\Controllers\Home->f ( arguments )                          

$obj     stdClass Object 
         (     
              [password] => ****************** 
         )

$array   Array 
         (     
              [password] => secret2 
         )

Steps to Reproduce

--- a/app/Config/Exceptions.php
+++ b/app/Config/Exceptions.php
@@ -49,7 +49,7 @@ class Exceptions extends BaseConfig
      * In order to specify 2 levels, use "/" to separate.
      * ex. ['server', 'setup/password', 'secret_token']
      */
-    public array $sensitiveDataInTrace = [];
+    public array $sensitiveDataInTrace = ['password'];
 
     /**
      * --------------------------------------------------------------------------
<?php

namespace App\Controllers;

class Home extends BaseController
{
    public function index()
    {
        $obj = (object) [
            'password' => 'secret1',
        ];

        $array = ['password' => 'secret2'];

        $this->f($obj, $array);
    }

    private function f($obj, $array)
    {
        foo($obj, $array);
    }
}

Expected Output

The array's password value should also be ******************.

Anything else?

If I set $sensitiveDataInTrace = ['file'], I get the following error:

Fatal error: Uncaught TypeError: Cannot assign string to property Config\Cache::$file of type array in .../CodeIgniter4/system/Debug/Exceptions.php on line 325

Ref #4550

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions