Module: Datadog::AppSec::Contrib::Sinatra::Reactive::Routed
- Defined in:
- lib/datadog/appsec/contrib/sinatra/reactive/routed.rb
Overview
Dispatch data from a Sinatra request to the WAF context
Class Method Summary collapse
Class Method Details
.publish(op, data) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/datadog/appsec/contrib/sinatra/reactive/routed.rb', line 15 def self.publish(op, data) _request, route_params = data catch(:block) do op.publish('sinatra.request.route_params', route_params.params) nil end end |
.subscribe(op, waf_context) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/datadog/appsec/contrib/sinatra/reactive/routed.rb', line 25 def self.subscribe(op, waf_context) op.subscribe(*ADDRESSES) do |*values| Datadog.logger.debug { "reacted to #{ADDRESSES.inspect}: #{values.inspect}" } path_params = values[0] persistent_data = { 'server.request.path_params' => path_params, } waf_timeout = Datadog.configuration.appsec.waf_timeout result = waf_context.run(persistent_data, {}, waf_timeout) next if result.status != :match yield result throw(:block, true) unless result.actions.empty? end end |