Sha256: fc9b28e6f4e944df7a3f817c9b145e163ca085ee50b86964935d5e063b470754
Contents?: true
Size: 1.55 KB
Versions: 5
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true require_relative '../request' module Datadog module AppSec module Contrib module Rails module Reactive # Dispatch data from a Rails request to the WAF context module Action ADDRESSES = [ 'rails.request.body', 'rails.request.route_params', ].freeze private_constant :ADDRESSES def self.publish(op, gateway_request) catch(:block) do # params have been parsed from the request body op.publish('rails.request.body', gateway_request.parsed_body) op.publish('rails.request.route_params', gateway_request.route_params) nil end end def self.subscribe(op, waf_context) op.subscribe(*ADDRESSES) do |*values| Datadog.logger.debug { "reacted to #{ADDRESSES.inspect}: #{values.inspect}" } body = values[0] path_params = values[1] persistent_data = { 'server.request.body' => body, '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 end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems