Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[ErrorRenderer] Security fix: hide sensitive error messages #34158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ public function testDefaultJsonLoginBadRequest()

$this->assertSame(400, $response->getStatusCode());
$this->assertSame('application/json', $response->headers->get('Content-Type'));
$this->assertSame(['title' => 'Bad Request', 'status' => 400, 'detail' => 'Invalid JSON.'], json_decode($response->getContent(), true));
$this->assertSame(['title' => 'Bad Request', 'status' => 400], json_decode($response->getContent(), true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function render(FlattenException $exception): string
$content = [
'title' => $exception->getTitle(),
'status' => $exception->getStatusCode(),
'detail' => $exception->getMessage(),
];
if ($debug) {
$content['detail'] = $exception->getMessage();
$content['exceptions'] = $exception->toArray();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ public function render(FlattenException $exception): string
$debug = $this->debug && ($exception->getHeaders()['X-Debug'] ?? true);
$content = sprintf("[title] %s\n", $exception->getTitle());
$content .= sprintf("[status] %s\n", $exception->getStatusCode());
$content .= sprintf("[detail] %s\n", $exception->getMessage());

if ($debug) {
$content .= sprintf("[detail] %s\n", $exception->getMessage());

foreach ($exception->toArray() as $i => $e) {
$content .= sprintf("[%d] %s: %s\n", $i + 1, $e['class'], $e['message']);
foreach ($e['trace'] as $trace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ public function render(FlattenException $exception): string
{
$debug = $this->debug && ($exception->getHeaders()['X-Debug'] ?? true);
$title = $this->escapeXml($exception->getTitle());
$message = $this->escapeXml($exception->getMessage());
$statusCode = $this->escapeXml($exception->getStatusCode());
$charset = $this->escapeXml($this->charset);

$exceptions = '';
$message = '';
if ($debug) {
$message = '<detail>'.$this->escapeXml($exception->getMessage()).'</detail>';

$exceptions .= '<exceptions>';
foreach ($exception->toArray() as $e) {
$exceptions .= sprintf('<exception class="%s" message="%s"><traces>', $e['class'], $this->escapeXml($e['message']));
Expand All @@ -71,7 +73,7 @@ public function render(FlattenException $exception): string
<problem xmlns="urn:ietf:rfc:7807">
<title>{$title}</title>
<status>{$statusCode}</status>
<detail>{$message}</detail>
{$message}
{$exceptions}
</problem>
EOF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public function testFormatArgument()
$this->assertSame(<<<TXT
{
"title": "Internal Server Error",
"status": 500,
"detail": "This is a sample exception."
"status": 500
}

TXT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public function getRenderData(): iterable
$expectedNonDebug = <<<JSON
{
"title": "Internal Server Error",
"status": 500,
"detail": "Foo"
"status": 500
}
JSON;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function getRenderData(): iterable
$expectedNonDebug = <<<TXT
[title] Internal Server Error
[status] 500
[detail] Foo
TXT;

yield '->render() returns the TXT content WITH stack traces in debug mode' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getRenderData(): iterable
<problem xmlns="urn:ietf:rfc:7807">
<title>Internal Server Error</title>
<status>500</status>
<detail>Foo</detail>


</problem>
XML;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getInvokeControllerDataProvider()
$request,
FlattenException::createFromThrowable(new \Exception('foo')),
500,
'{"title": "Internal Server Error","status": 500,"detail": "foo"}',
'{"title": "Internal Server Error","status": 500}',
];

$request = new Request();
Expand All @@ -70,7 +70,7 @@ public function getInvokeControllerDataProvider()
$request,
FlattenException::createFromThrowable(new HttpException(405, 'Invalid request.')),
405,
'{"title": "Method Not Allowed","status": 405,"detail": "Invalid request."}',
'{"title": "Method Not Allowed","status": 405}',
];

$request = new Request();
Expand All @@ -79,7 +79,7 @@ public function getInvokeControllerDataProvider()
$request,
FlattenException::createFromThrowable(new HttpException(405, 'Invalid request.')),
405,
'{"title": "Method Not Allowed","status": 405,"detail": "Invalid request."}',
'{"title": "Method Not Allowed","status": 405}',
];

$request = new Request();
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.