Sha256: 2125a5be0db1abd71d57c32fbf82559bd439169639c2d6bed3bbd2c84feb33d3

Contents?: true

Size: 954 Bytes

Versions: 7

Compression:

Stored size: 954 Bytes

Contents

# typed: true

module Datadog
  module AppSec
    module Contrib
      module Rails
        # Normalized extration of data from ActionDispatch::Request
        module Request
          def self.parsed_body(request)
            # usually Hash<String,String> but can be a more complex
            # Hash<String,String||Array||Hash> when e.g coming from JSON or
            # with Rails advanced param square bracket parsing
            body = request.env['action_dispatch.request.request_parameters']

            return if body.nil?

            body.reject do |k, _v|
              request.env['action_dispatch.request.path_parameters'].key?(k)
            end
          end

          def self.route_params(request)
            excluded = [:controller, :action]

            request.env['action_dispatch.request.path_parameters'].reject do |k, _v|
              excluded.include?(k)
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-1.5.0 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.4.2 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.4.1 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.4.0 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.3.0 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.2.0 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.1.0 lib/datadog/appsec/contrib/rails/request.rb