asciidoctor / asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!
https://kroki.io/
MIT License
150 stars 51 forks source link

Log an explicit error message when the server returns a 414 URI Too Long status #224

Open ggrossetie opened 3 years ago

ggrossetie commented 3 years ago

Most Web servers have a URI limit to prevent Denial-of-Service or malicious attacks (i.e., buffer overflow/high memory usage...).

According to RFC 2616 (Hypertext Transfer Protocol HTTP/1.1) section 3.2.1, the server should return 414 (Request-URI Too Long) status if a URI is longer than the server can handle.

It's also important to note that browsers also have a URI limit. Having said that, and if we exclude IE, the lowest value is 10240 on Edge 16. This value is relatively high and we should not exceed it. For reference, the current URI limit on https://kroki.io is 4000.

Anyway, if the Kroki server returns a 414 URI Too Long status, we could log an explicit error message to suggest how to resolve this issue. Potential workarounds:

lind commented 3 years ago

Agree it would be fine to have a log message for this @Mogztter

I have tried to find a way of intercepting the 414 response in Vertx but unfortunately haven't found a way so far. The TooLongFrameException from Netty is handled in Http1xServerConnection but I don't find a way to add a interceptor or handler to the Vertx router in any way. Any idea?

ggrossetie commented 3 years ago

I have tried to find a way of intercepting the 414 response in Vertx but unfortunately haven't found a way so far. The TooLongFrameException from Netty is handled in Http1xServerConnection but I don't find a way to add a interceptor or handler to the Vertx router in any way. Any idea?

In my opinion, we don't need to add an interceptor/handler server-side, a 414 status code is already explicit. My idea was to log an explicit message in the Asciidoctor Kroki extension when the status code is 414.

lind commented 3 years ago

In my opinion, we don't need to add an interceptor/handler server-side, a 414 status code is already explicit. My idea was to log an explicit message in the Asciidoctor Kroki extension when the status code is 414.

Of course! Jumped here from https://github.com/yuzutech/kroki/issues/555 so I was still in Kroki server world 😉

Riduidel commented 1 year ago

I thinkit would be nice to have that error reporting done for all errors, since I sometimes have diagrams silently not rendered (see https://github.com/Riduidel/aadarchi/issues/333)