Statement on glibc/iconv Vulnerability

Класс SensitiveParameter

(PHP 8 >= 8.2.0)

Введение

Атрибутом размечают параметр с чувствительным значением, которое PHP отредактирует, когда значение пападёт в трассировку стека.

Обзор классов

final class SensitiveParameter {
/* Методы */
public __construct()
}

Примеры

<?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;
}

?>

Результат выполнения приведённого примера в PHP 8.2 аналогичен:

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}

Содержание

add a note

User Contributed Notes

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