Sha256: c2aac8cd31d37f0af345a28db0060c11344f909bfa43cabfddb2b161c76b87e0

Contents?: true

Size: 1.05 KB

Versions: 35

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Datadog
  module AppSec
    module Contrib
      module Rails
        # Normalized extration of data from ActionDispatch::Request
        module Request
          def self.parsed_body(request)
            # force body parameter parsing, which is done lazily by Rails
            request.parameters

            # 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

35 entries across 35 versions & 2 rubygems

Version Path
datadog-2.9.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.8.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.7.1 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.7.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.6.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.5.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.4.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.3.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.2.0 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.23.3 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.23.2 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.1.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.0.0 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.23.1 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.0.0.beta2 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.22.0 lib/datadog/appsec/contrib/rails/request.rb
datadog-2.0.0.beta1 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.21.1 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.21.0 lib/datadog/appsec/contrib/rails/request.rb
ddtrace-1.20.0 lib/datadog/appsec/contrib/rails/request.rb