75613[TASK] Directly respond to invalid HTTP server requests
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 2
Review log 3236
Show 1011 earlier messages
-
Oliver Hader uploaded patch set 1 09/06/22, 09:51
-
Oliver Hader commented on patch set 1 09/06/22, 09:53
This change is ready for review. -
Oliver Hader commented on patch set 1 09/06/22, 09:54
I'm not really happy yet with the new static map - using another exception instead (which would be capable of transporting the status-code) might be an alternative as well, e.g. `InvalidServerRequestException`... Looking forward to receiving your feedback/tests on this one. -
core-ci voted on patch set 1 V +1 09/06/22, 09:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30645
-
Andreas Kienast commented on patch set 1 09/06/22, 10:30
I kinda dislike the suggestedReply
"InvalidServerRequestException" doesn't sound correct for status codes >= 500, IMO. In Symfony, there's a generic HttpException, where most error codes have their own respective exception class, maybe it's worth a look for inspiration. -
Andreas Kienast commented on patch set 1 09/06/22, 10:30
Reply
aaaargh, Gerrit... -
Oliver Klee commented on patch set 1 09/06/22, 11:45
ServerRequestFactory.php:35/** * @var array<positive-int, positive-int> */ServerRequestFactory.php:35From the naming, it's not directly clear that these are HTTP status codes. Proposed name: EXCEPTION_CODES_TO_HTTP_STATUS_CODES (which also makes clear that this is a mapping)ServerRequestFactory.php:36For the HTTP status codes, do we have some names constants we can use? -
Stephan Großberndt commented on patch set 1 09/06/22, 11:50
exception -
Susi Moog commented on patch set 1 09/06/22, 15:24
Reply
Yep, I like the symfony solution (which is afaics also used by laravel btw) - https://github.com/symfony/symfony/tree/6.2/src/Symfony/Component/HttpKernel/Exception providing both a generic HttpException and "speaking" ones, which would also have the advantage that the calling method could denote its' intention better (so Request::validateMethod could throw a NotImplementedHttpException) -
Oliver Hader commented on patch set 1 09/06/22, 18:56
Thanks for your feedback. For a bugfix that can be back-ported to TYPO3 v10 I tried to avoid introducing new transport exceptions and was aiming for a simple mapping instead. However, it seems that a general `HttpException` (which still extends `\InvalidArgumentException`, for BW-compatibility) would be the way to go. This still can be extended with meaningful exception names. -
Oliver Hader commented on patch set 1 09/06/22, 19:59
Reply
DoneServerRequestFactory.php:35ReplyObsoleteServerRequestFactory.php:35ReplyObsoleteServerRequestFactory.php:36Reply
-
Oliver Hader uploaded patch set 2 09/06/22, 20:01
-
Oliver Klee voted on patch set 2 CR +1 09/06/22, 20:06
-
core-ci voted on patch set 2 V -1 09/06/22, 20:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30683
-
Oliver Hader commented on patch set 2 CR -1 09/07/22, 07:52
HttpException.php:23wrong -
Oliver Hader uploaded patch set 3 09/07/22, 07:58
-
core-ci voted on patch set 3 V +1 09/07/22, 08:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30705
-
Susi Moog voted on patch set 3 V +1 CR +1 09/07/22, 08:36
-
Susi Moog commented on patch set 3 09/07/22, 08:37
HttpException.php:23ReplyDone -
Markus Klein voted on patch set 3 CR +1 09/07/22, 11:04
-
Markus Klein commented on patch set 3 09/07/22, 11:08
HttpException.php:35UnresolvedIMO this is not neededRequest.php:234Unresolved@throws? -
Benjamin Franzke commented on patch set 3 CR -1 09/08/22, 16:36
So this is basically like ImmediateResponseException (or the older ImmediateResponseException), both which are there for cases where current API doesn't allow to directly return responses. So we could rather create responses and use PropagateResponseException without intdroducing new API. Also: The same remarks as with ImmediateResponseException vs ImmediateResponseException would apply here: HttpException bypasses the middleware stack, that's not good and it would be better (for proper cleanup) to walk through the middleware stack. For those two reasons: Please use PropagateResponseException instead. -
Benjamin Franzke commented on patch set 3 09/08/22, 16:37
Reply
I meant "like PropagateResponseException (or the older ImmediateResponseException". -
Benjamin Franzke commented on patch set 3 CR 0 09/08/22, 16:48
Hm.. and an additional note:Reply
Well, ok, I understand that PropagateResponseException is no option, as we're inside our PSR-7 implementation in here and PSR-7 requires thrown exceptions to be \InvalidArgumentException. Taking my CR-1 away, as I don't really seem to understand the reasoning of this change. But it looks like we're doing implicit client input validation/refusal here, which should be out-of-scope for the PSR-7 implementation. -
Benjamin Franzke commented on patch set 3 09/08/22, 16:51
Reply Unresolved
replied too early: Question was: Is the exception message excluded from the response on (security) purpose? -
Benjamin Franzke commented on patch set 3 CR -1 09/08/22, 16:55
Reply
Sorry for the back and forth. Readding CR-1. Mixing 400er and 500er codes makes no sense, as it implies from which context (user input or server-side generate subrequest) the methods are used. That's out of scope for PSR-7 and should be handled by the usages of the respective methods (catching \InvalidArgumentException). -
Oliver Hader commented on patch set 3 V -1 12/06/22, 14:21
Reply Unresolved
Ack & thanks for the explanation. Invocation context is missing here... -
Oliver Hader marked it work in progress 12/06/22, 14:22
-
Oliver Hader commented on patch set 3 06/26/23, 09:01
Just stumbled over this again... since the HTTP status code in the response depends on the context, it only would be possible to implement an "interpretation" of the exception codes and map it to corresponding HTTP status codes in `AbstractApplication` (`CommandApplication` for CLI of course should not used HTTP responses). -
Oliver Hader uploaded patch set 4
CR +1V +106/26/23, 09:39 -
Oliver Hader commented on patch set 4 06/26/23, 09:41
Without the patch: ``` curl -Ik -XWRONG https://ip12.anyhost.it/ HTTP/1.1 500 Internal Server Error Date: Mon, 26 Jun 2023 09:40:51 GMT Server: Apache/2.4.57 (Unix) OpenSSL/3.1.1 mod_fcgid/2.3.9 X-Powered-By: PHP/8.1.18 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 ``` With the patch: ``` curl -Ik https://ip12.anyhost.it/ -XWRONG HTTP/1.1 400 Bad Request Date: Mon, 26 Jun 2023 09:38:49 GMT Server: Apache/2.4.57 (Unix) OpenSSL/3.1.1 mod_fcgid/2.3.9 X-Powered-By: PHP/8.1.18 Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8 ``` -
core-ci voted on patch set 4 V +1 06/26/23, 09:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/42982
-
Markus Klein voted on patch set 4 CR +1 06/26/23, 11:41
-
Markus Klein commented on patch set 4 10/04/24, 09:45
According to https://forge.typo3.org/issues/98264#note-7 this should be fixed. So we can abandon this one? -
Oliver Hader commented on patch set 4 10/04/24, 10:55
Reply
It still responds with an HTTP 500 exception, but is not logged anymore. Let's close this one here... -
Oliver Hader abandoned the change 10/04/24, 10:55