dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

Implement blocking servlet/tomcat/jetty

Open cataphract opened this issue 2 years ago • 3 comments

Implements blocking behavior for servlet/tomcat/jetty. Blocking means a fixed error response is send and request handling is skipped.

cataphract avatar Aug 04 '22 14:08 cataphract

Can only be merged after changes in the WAF/default AppSec configuration. Right now, the system tests cannot pass because the WAF returns a blocking instruction and the system tests expect no blocking.

cataphract avatar Aug 12 '22 13:08 cataphract

I can see usage of span.markForBlocking() in case of:

  • reading/parsing URL
  • reading http headers
  • reading socket address

but I can't see such blocking ability for:

  • http response (we have few rules that check server.response.status)
  • parsing request body

Was it skipped intentionally?

ValentinZakharov avatar Aug 15 '22 15:08 ValentinZakharov

I can see usage of IGSpanInfo.isToBeBlocked() as a blocking indicator for Servlet/Tomcat/Undertow, but not for Jetty. I don't really understand how is Jetty aware about blocking?

ValentinZakharov avatar Aug 15 '22 15:08 ValentinZakharov

I can see usage of span.markForBlocking() in case of:

  • reading/parsing URL
  • reading http headers
  • reading socket address

but I can't see such blocking ability for:

  • http response (we have few rules that check server.response.status)
  • parsing request body

Was it skipped intentionally?

Yes, it was skipped intentionally. IIRC, the plan is to first only block on ip addresses, and then only on users.

cataphract avatar Aug 17 '22 10:08 cataphract

I can see usage of IGSpanInfo.isToBeBlocked() as a blocking indicator for Servlet/Tomcat/Undertow, but not for Jetty. I don't really understand how is Jetty aware about blocking?

It is used for Jetty. See https://github.com/DataDog/dd-trace-java/pull/3701/files#diff-8d4f557f90cc211125aed1eaf1c1232fec4a1b9be60e96959e77098f08add2a9R76-R81

cataphract avatar Aug 17 '22 14:08 cataphract