Statement on glibc/iconv Vulnerability

A classe SensitiveParameter

(PHP 8 >= 8.2.0)

Introdução

Esse atributo é usado para marcar um parâmetro que é confidencial e deve ter seu valor ocultado se estiver presente em um stack trace.

Resumo da classe

final class SensitiveParameter {
/* Métodos */
public __construct()
}

Exemplos

<?php

function defaultBehavior(
string $secret,
string $normal
) {
throw new
Exception('Error!');
}

function
sensitiveParametersWithAttribute(
#[
\SensitiveParameter]
string $secret,
string $normal
) {
throw new
Exception('Error!');
}

try {
defaultBehavior('password', 'normal');
} catch (
Exception $e) {
echo
$e, PHP_EOL, PHP_EOL;
}

try {
sensitiveParametersWithAttribute('password', 'normal');
} catch (
Exception $e) {
echo
$e, PHP_EOL, PHP_EOL;
}

?>

A saída do exemplo acima no PHP 8.2 é semelhante a:

Exception: Error! in example.php:7
Stack trace:
#0 example.php(19): defaultBehavior('password', 'normal')
#1 {main}

Exception: Error! in example.php:15
Stack trace:
#0 example.php(25): sensitiveParametersWithAttribute(Object(SensitiveParameterValue), 'normal')
#1 {main}

Índice

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top