trait RedactsSensitiveData

Constants

protected REDACTED

protected UNSERIALIZABLE

protected URL_HEADERS

The headers whose value is a URL, so their sensitive query parameters are redacted.

Methods

array
redact(array $data, array $keys)

Redact the values of the given keys throughout the data.

array
redactSensitiveStoragePayload(array $payload)

Final storage pass for entry payloads. Earlier builders redact known request surfaces, but this keeps persisted entries private if a future collector path adds sensitive data before save.

array
redactRecursive(array $data, array $loweredKeys)

Redact the values of the given lowercase keys at every depth.

array
redactHeaders(array $headers)

Flatten the given headers, redacting the sensitive ones and the sensitive query parameters of URL headers.

array
normalizeSensitiveKeys(array $keys)

Normalize the configured sensitive keys to unique lowercase strings.

array
redactUrls(array $data, array $keys)

Redact sensitive query parameters from the URLs in the data.

string
redactUrl(string $url, array $keys)

Redact the values of sensitive query parameters. A parameter matches when its decoded name or any of its bracketed segments (e.g. filter[secret]) is a sensitive key. The query is not parsed and rebuilt, so every other byte of the URL is kept as recorded, and relative or malformed URLs are redacted the same way.

array
sanitizeForJsonEncoding(array $data)

Replace leaf values that cannot be stored as JSON with a marker.

bool
isJsonEncodable(mixed $value)

Determine if the value can be stored as JSON.

Details

at line 27
protected array redact(array $data, array $keys)

Redact the values of the given keys throughout the data.

Parameters

array $data
array $keys

Return Value

array

at line 46
protected array redactSensitiveStoragePayload(array $payload)

Final storage pass for entry payloads. Earlier builders redact known request surfaces, but this keeps persisted entries private if a future collector path adds sensitive data before save.

Parameters

array $payload

Return Value

array

at line 81
protected array redactRecursive(array $data, array $loweredKeys)

Redact the values of the given lowercase keys at every depth.

Parameters

array $data
array $loweredKeys

Return Value

array

at line 101
protected array redactHeaders(array $headers)

Flatten the given headers, redacting the sensitive ones and the sensitive query parameters of URL headers.

Parameters

array $headers

Return Value

array

at line 127
protected array normalizeSensitiveKeys(array $keys)

Normalize the configured sensitive keys to unique lowercase strings.

Parameters

array $keys

Return Value

array

at line 149
protected array redactUrls(array $data, array $keys)

Redact sensitive query parameters from the URLs in the data.

Parameters

array $data
array $keys

Return Value

array

at line 181
protected string redactUrl(string $url, array $keys)

Redact the values of sensitive query parameters. A parameter matches when its decoded name or any of its bracketed segments (e.g. filter[secret]) is a sensitive key. The query is not parsed and rebuilt, so every other byte of the URL is kept as recorded, and relative or malformed URLs are redacted the same way.

Parameters

string $url
array $keys

Return Value

string

at line 210
protected array sanitizeForJsonEncoding(array $data)

Replace leaf values that cannot be stored as JSON with a marker.

Parameters

array $data

Return Value

array

at line 226
protected bool isJsonEncodable(mixed $value)

Determine if the value can be stored as JSON.

Parameters

mixed $value

Return Value

bool