Skip to content

[Proposal]: Flow\Bridge\Monolog\Http\PSR7Processor - data masking #1698

@norberttech

Description

@norberttech

Describe the Proposal

PSR7Processor purpose is iterate through the log record context and normalize requests/responses based on Request/Response Configs.

This works great but there are cases where we should mask the parts of requests/response during normalization.

API Adjustments

Expand RequestConfig and ResponseConfig by adding $maskFields

/** 
 * @var array<string, Sanitizer>
 */ 
$maskFields = ['access_token' => mask('#'), 'key' => mask(), 'credentials' => mask('*')]; 

The idea is that processor after normalization of request/response should iterate recursively through the context and apply mask.

To achieve that we need to implement Sanitizer interface and we can start with a single implementation:

final class Mask implements Sanitizer
{
    /**
     *  @param int $offset - start masking values from this offset 
     */
    public function __construct(string $mask = '*', int $offset = 0)

    public function sanitize(string $value) : string; 
}

So mask() is just a DSL function that should live in:

src/bridge/monolog/http/src/Flow/Bridge/Monolog/Http/DSL/functions.php

Are you intenting to also work on proposed change?

Yes

Are you interested in sponsoring this change?

None

Integration & Dependencies

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions