Valinor/docs/pages
Romain Canon 6ce1a439ad feat!: filter userland exceptions to hide potential sensible data
/!\ This change fixes a security issue.

Userland exception thrown in a constructor will not be automatically
caught by the mapper anymore. This prevents messages with sensible
information from reaching the final user — for instance an SQL exception
showing a part of a query.

To allow exceptions to be considered as safe, the new method
`MapperBuilder::filterExceptions()` must be used, with caution.

```php
final class SomeClass
{
    public function __construct(private string $value)
    {
        \Webmozart\Assert\Assert::startsWith($value, 'foo_');
    }
}

try {
    (new \CuyZ\Valinor\MapperBuilder())
        ->filterExceptions(function (Throwable $exception) {
            if ($exception instanceof \Webmozart\Assert\InvalidArgumentException) {
                return \CuyZ\Valinor\Mapper\Tree\Message\ThrowableMessage::from($exception);
            }

            // If the exception should not be caught by this library, it
            // must be thrown again.
            throw $exception;
        })
        ->mapper()
        ->map(SomeClass::class, 'bar_baz');
} catch (\CuyZ\Valinor\Mapper\MappingError $exception) {
    // Should print something similar to:
    // > Expected a value to start with "foo_". Got: "bar_baz"
    echo $exception->node()->messages()[0];
}
```
2022-07-08 13:58:48 +02:00
..
img doc: add Open Graph meta tags 2022-06-12 16:37:58 +02:00
mapping feat!: make mapper more strict and allow flexible mode 2022-06-23 10:30:36 +02:00
other doc: introduce mkdocs as a static documentation generator 2022-06-10 17:32:07 +02:00
stylesheets doc: change some settings and adjust logos 2022-06-10 23:33:28 +02:00
changelog.md release: version 0.11.0 2022-06-23 11:17:11 +02:00
credits.md doc: introduce mkdocs as a static documentation generator 2022-06-10 17:32:07 +02:00
getting-started.md doc: introduce mkdocs as a static documentation generator 2022-06-10 17:32:07 +02:00
index.md doc: remove badges from documentation index 2022-06-11 12:48:35 +02:00
message-customization.md feat!: filter userland exceptions to hide potential sensible data 2022-07-08 13:58:48 +02:00
robots.txt doc: improve documentation building process 2022-06-22 11:15:26 +02:00
source.md doc: introduce mkdocs as a static documentation generator 2022-06-10 17:32:07 +02:00
validation.md feat!: filter userland exceptions to hide potential sensible data 2022-07-08 13:58:48 +02:00