Skip to content

Commit

Permalink
rename variables to better reflect what information they store
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoCaso committed Feb 8, 2023
1 parent be7bada commit e03f436
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/datadog/appsec/contrib/rack/request_body_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def call(env)

request = ::Rack::Request.new(env)

request_return, request_response = Instrumentation.gateway.push('rack.request.body', request) do
request_return, request_action = Instrumentation.gateway.push('rack.request.body', request) do
@app.call(env)
end

if request_response && request_response.any? { |action, _event| action == :block }
if request_action && request_action.any? { |action, _event| action == :block }
request_return = AppSec::Response.negotiate(env).to_rack
end

Expand Down
8 changes: 4 additions & 4 deletions lib/datadog/appsec/contrib/rack/request_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def call(env)

add_appsec_tags(active_trace, active_span, env)

request_return, request_response = Instrumentation.gateway.push('rack.request', request) do
request_return, request_action = Instrumentation.gateway.push('rack.request', request) do
@app.call(env)
end

if request_response && request_response.any? { |action, _event| action == :block }
if request_action && request_action.any? { |action, _event| action == :block }
request_return = AppSec::Response.negotiate(env).to_rack
end

Expand All @@ -48,7 +48,7 @@ def call(env)
@waf_context = context
end

_response_return, response_response = Instrumentation.gateway.push('rack.response', response)
_response_return, response_action = Instrumentation.gateway.push('rack.response', response)

context.events.each do |e|
e[:response] ||= response
Expand All @@ -57,7 +57,7 @@ def call(env)

AppSec::Event.record(*context.events)

if response_response && response_response.any? { |action, _event| action == :block }
if response_action && response_action.any? { |action, _event| action == :block }
request_return = AppSec::Response.negotiate(env).to_rack
end

Expand Down
4 changes: 2 additions & 2 deletions lib/datadog/appsec/contrib/rails/patcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def process_action(*args)

# TODO: handle exceptions, except for super

request_return, request_response = Instrumentation.gateway.push('rails.request.action', request) do
request_return, request_action = Instrumentation.gateway.push('rails.request.action', request) do
super
end

if request_response && request_response.any? { |action, _event| action == :block }
if request_action && request_action.any? { |action, _event| action == :block }
@_response = AppSec::Response.negotiate(env).to_action_dispatch_response
request_return = @_response.body
end
Expand Down
8 changes: 4 additions & 4 deletions lib/datadog/appsec/contrib/sinatra/patcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def dispatch!

# TODO: handle exceptions, except for super

request_return, request_response = Instrumentation.gateway.push('sinatra.request.dispatch', request) do
request_return, request_action = Instrumentation.gateway.push('sinatra.request.dispatch', request) do
# handle process_route interruption
catch(Ext::ROUTE_INTERRUPT) { super }
end

if request_response && request_response.any? { |action, _event| action == :block }
if request_action && request_action.any? { |action, _event| action == :block }
self.response = AppSec::Response.negotiate(env).to_sinatra_response
request_return = nil
end
Expand Down Expand Up @@ -92,9 +92,9 @@ def process_route(*)
# At this point params has both route params and normal params.
route_params = params.each.with_object({}) { |(k, v), h| h[k] = v unless base_params.key?(k) }

_, request_response = Instrumentation.gateway.push('sinatra.request.routed', [request, route_params])
_, request_action = Instrumentation.gateway.push('sinatra.request.routed', [request, route_params])

if request_response && request_response.any? { |action, _event| action == :block }
if request_action && request_action.any? { |action, _event| action == :block }
self.response = AppSec::Response.negotiate(env).to_sinatra_response

# interrupt request and return response to dispatch! for consistency
Expand Down

0 comments on commit e03f436

Please sign in to comment.