Class: Datadog::Lambda::AppSec::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/lambda/appsec/request.rb

Overview

Minimal request object for AppSec event recording.

WARNING: It's a minimal data for interface compliance

See Also:

  • AppSec::Event.record
  • AppSec::Contrib::Rack::Gateway::Request

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_addr:, headers:, request_method:, path:) ⇒ Request

Returns a new instance of Request.



35
36
37
38
39
40
41
42
# File 'lib/datadog/lambda/appsec/request.rb', line 35

def initialize(remote_addr:, headers:, request_method:, path:)
  @headers = headers
  @host = headers['host']
  @user_agent = headers['user-agent']
  @remote_addr = remote_addr
  @request_method = request_method
  @path = path
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



13
14
15
# File 'lib/datadog/lambda/appsec/request.rb', line 13

def headers
  @headers
end

#hostObject (readonly)

Returns the value of attribute host.



13
14
15
# File 'lib/datadog/lambda/appsec/request.rb', line 13

def host
  @host
end

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/datadog/lambda/appsec/request.rb', line 13

def path
  @path
end

#remote_addrObject (readonly)

Returns the value of attribute remote_addr.



13
14
15
# File 'lib/datadog/lambda/appsec/request.rb', line 13

def remote_addr
  @remote_addr
end

#request_methodObject (readonly)

Returns the value of attribute request_method.



13
14
15
# File 'lib/datadog/lambda/appsec/request.rb', line 13

def request_method
  @request_method
end

#user_agentObject (readonly)

Returns the value of attribute user_agent.



13
14
15
# File 'lib/datadog/lambda/appsec/request.rb', line 13

def user_agent
  @user_agent
end

Class Method Details

.from_normalized(event) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/datadog/lambda/appsec/request.rb', line 17

def from_normalized(event)
  new(
    remote_addr: event['source_ip'],
    headers: lowercase_headers(event),
    request_method: event['method'],
    path: event['path']
  )
end