Class: TCellAgent::SensorEvents::AppSensorMetaEvent

Inherits:
AppSensor::MetaData show all
Defined in:
lib/tcell_agent/sensor_events/appsensor_meta_event.rb

Instance Attribute Summary collapse

Attributes inherited from AppSensor::MetaData

#body_dict, #cookie_dict, #get_dict, #headers_dict, #location, #method, #path_parameters, #post_dict, #remote_address, #route_id, #session_id, #transaction_id, #user_id

Attributes inherited from TCellSensorEvent

#ensure, #flush, #send

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AppSensor::MetaData

#flattened_body_dict, #flattened_cookie_dict, #flattened_get_dict, #flattened_headers_dict, #flattened_path_parameters, #set_body_dict, #set_headers_dict

Methods inherited from TCellSensorEvent

#bucket_key, #calculateOffset

Constructor Details

#initialize(method, remote_address, route_id, session_id, user_id, transaction_id, location) ⇒ AppSensorMetaEvent



88
89
90
91
92
93
94
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 88

def initialize(method, remote_address, route_id, session_id, user_id, transaction_id, location)
  super(method, remote_address, route_id, session_id, user_id, transaction_id, location)

  @request_content_bytes_len = 0
  @response_content_bytes_len = 0
  @user_agent = nil
end

Instance Attribute Details

#csrf_exception_nameObject

Returns the value of attribute csrf_exception_name.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def csrf_exception_name
  @csrf_exception_name
end

#database_result_sizesObject

Returns the value of attribute database_result_sizes.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def database_result_sizes
  @database_result_sizes
end

#pathObject

Returns the value of attribute path.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def path
  @path
end

#request_content_bytes_lenObject

Returns the value of attribute request_content_bytes_len.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def request_content_bytes_len
  @request_content_bytes_len
end

#response_codeObject

Returns the value of attribute response_code.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def response_code
  @response_code
end

#response_content_bytes_lenObject

Returns the value of attribute response_content_bytes_len.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def response_content_bytes_len
  @response_content_bytes_len
end

#response_headersObject

Returns the value of attribute response_headers.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def response_headers
  @response_headers
end

#sql_exceptionsObject

Returns the value of attribute sql_exceptions.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def sql_exceptions
  @sql_exceptions
end

#user_agentObject

Returns the value of attribute user_agent.



84
85
86
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 84

def user_agent
  @user_agent
end

Class Method Details

.build(request, response_content_length, response_code, response_headers) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 22

def build(request, response_content_length, response_code, response_headers)
  tcell_context = request.env[TCellAgent::Instrumentation::TCELL_ID]
  meta_event = AppSensorMetaEvent.new(
    tcell_context.request_method,
    tcell_context.ip_address,
    tcell_context.route_id,
    tcell_context.hmac_session_id,
    tcell_context.user_id,
    tcell_context.transaction_id,
    tcell_context.uri
  )

  meta_event.csrf_exception_name = tcell_context.csrf_exception_name
  meta_event.user_agent = tcell_context.user_agent
  meta_event.request_content_bytes_len = (request.content_length || 0).to_i
  meta_event.response_content_bytes_len = response_content_length

  meta_event.location = tcell_context.uri
  meta_event.path = tcell_context.path

  meta_event.get_dict = request.GET
  meta_event.cookie_dict = request.cookies
  meta_event.set_headers_dict(request.env)

  # don't enqueue parameter values of unknown type to avoid any serialization issues
  meta_event.post_dict = TCellAgent::Utils::Params.flatten(request.POST)

  meta_event.path_parameters = tcell_context.path_parameters
  meta_event.response_code = response_code
  meta_event.response_headers = response_headers

  meta_event.sql_exceptions = tcell_context.sql_exceptions
  meta_event.database_result_sizes = tcell_context.database_result_sizes

  # Positions strio to the beginning of input, resetting lineno to zero.
  # rails 4.1 seems to read the stringIO directly and so body.gets is empty
  # this is called
  request.body.rewind

  meta_event.set_body_dict(
    meta_event.request_content_bytes_len,
    request.content_type,
    request.body.gets
  )

  meta_event
end

.build_basic(appsensor_meta) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 70

def build_basic(appsensor_meta)
  AppSensorMetaEvent.new(
    appsensor_meta.method,
    appsensor_meta.remote_address,
    appsensor_meta.route_id,
    appsensor_meta.session_id,
    appsensor_meta.user_id,
    appsensor_meta.transaction_id,
    appsensor_meta.location
  )
end

Instance Method Details

#flattened_post_dictObject



103
104
105
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 103

def flattened_post_dict
  @post_dict
end

#post_processObject



96
97
98
99
100
101
# File 'lib/tcell_agent/sensor_events/appsensor_meta_event.rb', line 96

def post_process
  rust_policies = TCellAgent.policy(TCellAgent::PolicyTypes::Rust)
  return unless rust_policies

  rust_policies.check_appfirewall_injections(self)
end