Skip to content

An ability to have wildcards in yii\log\Target::$maskVars array #20295

Closed
@xcopy

Description

@xcopy

Let's assume that I have the following configuration:

// config/components/log.php
return [
    'targets' => [
        [
            'class' => 'yii\log\FileTarget',
            'levels' => ['error', 'warning'],
            'maskVars' => [
                '_SERVER.AUTH_GOOGLE_TOKEN',
                '_SERVER.AUTH_FACEBOOK_TOKEN',
                '_SERVER.AUTH_TWITTER_TOKEN',
                '_SERVER.AUTH_GITHUB_TOKEN',
                '_SERVER.AUTH_APPLE_TOKEN',
                '_SERVER.AUTH_MICROSOFT_TOKEN',
                '_SERVER.AUTH_MICROSOFT_TOKEN',
                // ...

                '_POST.LoginForm.password',
                '_POST.ChangePassword.password',
                '_POST.ResetPasswordForm.password',
                '_POST.ResetPasswordForm.password_repeat',
                // ...
            ]
        ]
    ]
]

And the context information to be logged respectively:

$_SERVER = [
    'AUTH_GOOGLE_TOKEN' => '***',
    'AUTH_FACEBOOK_TOKEN' => '***',
    'AUTH_TWITTER_TOKEN' => '***',
    'AUTH_GITHUB_TOKEN' => '***',
    'AUTH_APPLE_TOKEN' => '***',
    'AUTH_MICROSOFT_TOKEN' => '***',
    'AUTH_MICROSOFT_TOKEN' => '***',
]

$_POST = [
    'LoginForm' => [
        'password' => '***',
    ],
    'ResetPasswordForm' => [
        'password' => '***',
        'password_repeat' => '***',
    ]
]

But what if instead of tens (or hundreds) predefined variables we will only have a few entries, e.g.

'maskVars' => [
    '_SERVER.*TOKEN',
    '_POST.*.password',
]

Is it worth it? Would be convenient, huh?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions