tcell_agent 0.2.18 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +11 -0
  3. data/lib/tcell_agent/configuration.rb +8 -1
  4. data/lib/tcell_agent/instrumentation.rb +14 -10
  5. data/lib/tcell_agent/logger.rb +23 -23
  6. data/lib/tcell_agent/policies/appsensor/database_sensor.rb +61 -0
  7. data/lib/tcell_agent/policies/appsensor/injection_sensor.rb +10 -2
  8. data/lib/tcell_agent/policies/appsensor/misc_sensor.rb +66 -0
  9. data/lib/tcell_agent/policies/appsensor/response_codes_sensor.rb +11 -3
  10. data/lib/tcell_agent/policies/appsensor/size_sensor.rb +6 -5
  11. data/lib/tcell_agent/policies/appsensor/user_agent_sensor.rb +47 -0
  12. data/lib/tcell_agent/policies/appsensor_policy.rb +68 -5
  13. data/lib/tcell_agent/policies/patches_policy.rb +2 -2
  14. data/lib/tcell_agent/rails.rb +3 -0
  15. data/lib/tcell_agent/rails/auth/authlogic.rb +2 -2
  16. data/lib/tcell_agent/rails/auth/devise.rb +4 -4
  17. data/lib/tcell_agent/rails/better_ip.rb +36 -0
  18. data/lib/tcell_agent/rails/csrf_exception.rb +30 -0
  19. data/lib/tcell_agent/rails/dlp.rb +38 -76
  20. data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +5 -5
  21. data/lib/tcell_agent/rails/middleware/context_middleware.rb +6 -4
  22. data/lib/tcell_agent/rails/middleware/global_middleware.rb +7 -7
  23. data/lib/tcell_agent/rails/middleware/headers_middleware.rb +15 -15
  24. data/lib/tcell_agent/rails/path_parameters_setter.rb +43 -0
  25. data/lib/tcell_agent/rails/routes.rb +4 -4
  26. data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +11 -6
  27. data/lib/tcell_agent/version.rb +1 -1
  28. data/spec/lib/tcell_agent/policies/appsensor/database_sensor_spec.rb +165 -0
  29. data/spec/lib/tcell_agent/policies/appsensor/misc_sensor_spec.rb +432 -0
  30. data/spec/lib/tcell_agent/policies/appsensor/request_size_sensor_spec.rb +4 -4
  31. data/spec/lib/tcell_agent/policies/appsensor/response_codes_sensor_spec.rb +99 -24
  32. data/spec/lib/tcell_agent/policies/appsensor/response_size_sensor_spec.rb +4 -4
  33. data/spec/lib/tcell_agent/policies/appsensor/user_agent_sensor_spec.rb +156 -0
  34. data/spec/lib/tcell_agent/policies/appsensor/xss_sensor_spec.rb +175 -0
  35. data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +79 -0
  36. data/spec/lib/tcell_agent/rails/better_ip_spec.rb +76 -0
  37. metadata +16 -2
@@ -30,7 +30,7 @@ module TCellAgent
30
30
  if TCellAgent.configuration.should_intercept_requests?
31
31
  response_time = (Time.now.to_f * 1000).to_i - orig
32
32
  TCellAgent::Instrumentation.safe_block("Handling Route Time") {
33
- route_id = env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].route_id
33
+ route_id = env[TCellAgent::Instrumentation::TCELL_ID].route_id
34
34
  if route_id
35
35
  TCellAgent.increment_route(route_id, response_time)
36
36
  else
@@ -40,14 +40,14 @@ module TCellAgent
40
40
  TCellAgent::Instrumentation.safe_block("Handling Sessions Info") {
41
41
  login_fraud_policy = TCellAgent.policy(TCellAgent::PolicyTypes::LoginFraud)
42
42
  if (login_fraud_policy && login_fraud_policy.session_hijacking_metrics)
43
- hmac_session_id = env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].hmac_session_id
44
- user_id = env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].user_id
43
+ hmac_session_id = env[TCellAgent::Instrumentation::TCELL_ID].hmac_session_id
44
+ user_id = env[TCellAgent::Instrumentation::TCELL_ID].user_id
45
45
  if user_id && hmac_session_id
46
46
  TCellAgent.increment_session_info(
47
47
  hmac_session_id,
48
48
  user_id,
49
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].ip_address,
50
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].user_agent,
49
+ env[TCellAgent::Instrumentation::TCELL_ID].ip_address,
50
+ env[TCellAgent::Instrumentation::TCELL_ID].user_agent,
51
51
  )
52
52
  end
53
53
  end
@@ -20,7 +20,6 @@ module TCellAgent
20
20
  module Instrumentation
21
21
  module Rails
22
22
  module Middleware
23
- TCELL_ID = "tcell.request_data"
24
23
 
25
24
  class ContextMiddleware
26
25
  THREADS = {}
@@ -30,11 +29,14 @@ module TCellAgent
30
29
 
31
30
  def call(env)
32
31
  if TCellAgent.configuration.should_intercept_requests?
33
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID] = TCellAgent::Instrumentation::TCellData.new
32
+ env[TCellAgent::Instrumentation::TCELL_ID] = TCellAgent::Instrumentation::TCellData.new
34
33
  TCellAgent::Instrumentation.safe_block("Setting transaction_id") {
35
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].transaction_id = SecureRandom.uuid
34
+ env[TCellAgent::Instrumentation::TCELL_ID].transaction_id = SecureRandom.uuid
36
35
  request = Rack::Request.new(env)
37
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].uri = request.fullpath
36
+ env[TCellAgent::Instrumentation::TCELL_ID].uri = request.fullpath
37
+ if request.request_method
38
+ env[TCellAgent::Instrumentation::TCELL_ID].request_method = request.request_method.downcase
39
+ end
38
40
  }
39
41
  env["filter_body_set"] = Set.new
40
42
  ContextMiddleware::THREADS[Thread.current.object_id] = env
@@ -30,24 +30,24 @@ module TCellAgent
30
30
  request = Rack::Request.new(env)
31
31
  TCellAgent::Instrumentation.safe_block("Setting session_id & user_id") {
32
32
  if request.session
33
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].session_id =
33
+ env[TCellAgent::Instrumentation::TCELL_ID].session_id =
34
34
  request.session["session_id"]
35
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].user_id =
35
+ env[TCellAgent::Instrumentation::TCELL_ID].user_id =
36
36
  TCellAgent::UserInformation.getUserFromRequest(request)
37
37
  end
38
38
  }
39
39
 
40
40
  TCellAgent::Instrumentation.safe_block("Setting hmac_session_id") {
41
41
  hmac_key = TCellAgent::SensorEvents::Util.getHmacKey()
42
- if request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].session_id
43
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].hmac_session_id =
44
- TCellAgent::SensorEvents::Util.hmac(request.env["tcell.request_data"].session_id, hmac_key)
42
+ if request.env[TCellAgent::Instrumentation::TCELL_ID].session_id
43
+ env[TCellAgent::Instrumentation::TCELL_ID].hmac_session_id =
44
+ TCellAgent::SensorEvents::Util.hmac(request.env[TCellAgent::Instrumentation::TCELL_ID].session_id, hmac_key)
45
45
  end
46
46
  }
47
47
 
48
48
  TCellAgent::Instrumentation.safe_block("Setting and ip address user agent") {
49
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].ip_address = request.ip
50
- env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID].user_agent = request.user_agent
49
+ env[TCellAgent::Instrumentation::TCELL_ID].ip_address = TCellAgent::Utils::Rails.better_ip(request)
50
+ env[TCellAgent::Instrumentation::TCELL_ID].user_agent = request.user_agent
51
51
  }
52
52
  end
53
53
 
@@ -33,7 +33,7 @@ module TCellAgent
33
33
  TCellAgent::Instrumentation.safe_block("Checking for blocked ips") do
34
34
  patches_policy = TCellAgent.policy(TCellAgent::PolicyTypes::Patches)
35
35
  if patches_policy
36
- if patches_policy.block_ip?(request)
36
+ if patches_policy.block_ip?(TCellAgent::Utils::Rails.better_ip(request))
37
37
  return [403, {"Content-Type" => "text/plain"}, ["Forbidden based on referer"]]
38
38
  end
39
39
  end
@@ -66,10 +66,10 @@ module TCellAgent
66
66
 
67
67
  if content_security_policy
68
68
  content_security_policy.each(
69
- request.env["tcell.request_data"].transaction_id,
70
- request.env["tcell.request_data"].route_id,
71
- request.env["tcell.request_data"].hmac_session_id,
72
- request.env["tcell.request_data"].user_id) do | header_pair |
69
+ request.env[TCellAgent::Instrumentation::TCELL_ID].transaction_id,
70
+ request.env[TCellAgent::Instrumentation::TCELL_ID].route_id,
71
+ request.env[TCellAgent::Instrumentation::TCELL_ID].hmac_session_id,
72
+ request.env[TCellAgent::Instrumentation::TCELL_ID].user_id) do | header_pair |
73
73
  headers[header_pair["name"]] = header_pair["value"]
74
74
  end
75
75
  end
@@ -85,9 +85,9 @@ module TCellAgent
85
85
 
86
86
  if clickjacking_policy
87
87
  clickjacking_policy.each(
88
- request.env["tcell.request_data"].transaction_id,
89
- request.env["tcell.request_data"].hmac_session_id,
90
- request.env["tcell.request_data"].user_id) do | header_pair |
88
+ request.env[TCellAgent::Instrumentation::TCELL_ID].transaction_id,
89
+ request.env[TCellAgent::Instrumentation::TCELL_ID].hmac_session_id,
90
+ request.env[TCellAgent::Instrumentation::TCELL_ID].user_id) do | header_pair |
91
91
  header_name = header_pair["name"]
92
92
  header_value = header_pair["value"]
93
93
  if (headers.has_key?header_name)
@@ -124,16 +124,16 @@ module TCellAgent
124
124
  http_redirect_policy = TCellAgent.policy(TCellAgent::PolicyTypes::HttpRedirect)
125
125
  if http_redirect_policy && headers.has_key?("Location")
126
126
  local_uri = URI.parse(request.url)
127
- route_id = request.env["tcell.request_data"].route_id
128
- session_id = request.env["tcell.request_data"].session_id
127
+ route_id = request.env[TCellAgent::Instrumentation::TCELL_ID].route_id
128
+ session_id = request.env[TCellAgent::Instrumentation::TCELL_ID].session_id
129
129
  new_location = http_redirect_policy.enforce(
130
- headers["Location"],
131
- local_uri.host,
132
- request.fullpath,
130
+ headers["Location"],
131
+ local_uri.host,
132
+ request.fullpath,
133
133
  request.request_method,
134
134
  route_id,
135
- status,
136
- request.ip,
135
+ status,
136
+ TCellAgent::Utils::Rails.better_ip(request),
137
137
  session_id)
138
138
  # Enforcement
139
139
  if (new_location)
@@ -0,0 +1,43 @@
1
+ module TCellAgent
2
+
3
+ ActionDispatch::Routing::RouteSet::Dispatcher.class_eval do
4
+ if (::Rails::VERSION::MAJOR == 3)
5
+ alias_method :tcell_dispatch, :dispatch
6
+ def dispatch(controller, action, env)
7
+ result = tcell_dispatch(controller, action, env)
8
+
9
+ TCellAgent::Instrumentation.safe_block("Set path_parameters in TCellData") do
10
+ if TCellAgent.configuration.should_intercept_requests?
11
+ request_env = TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware::THREADS.fetch(Thread.current.object_id, {})
12
+ tcell_data = request_env[TCellAgent::Instrumentation::TCELL_ID]
13
+ if tcell_data
14
+ tcell_data.path_parameters = env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
15
+ end
16
+ end
17
+ end
18
+
19
+ result
20
+ end
21
+ end
22
+
23
+ if (::Rails::VERSION::MAJOR == 4)
24
+ alias_method :tcell_serve, :serve
25
+ def serve(req)
26
+ result = tcell_serve(req)
27
+
28
+ TCellAgent::Instrumentation.safe_block("Set path_parameters in TCellData") do
29
+ if TCellAgent.configuration.should_intercept_requests?
30
+ request_env = TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware::THREADS.fetch(Thread.current.object_id, {})
31
+ tcell_data = request_env[TCellAgent::Instrumentation::TCELL_ID]
32
+ if tcell_data
33
+ tcell_data.path_parameters = req.path_parameters
34
+ end
35
+ end
36
+ end
37
+
38
+ result
39
+ end
40
+ end
41
+ end
42
+
43
+ end
@@ -26,7 +26,7 @@ module TCellAgent
26
26
  end
27
27
  def self._handle_dataexpsure_forms(request)
28
28
  dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
29
- tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
29
+ tcell_context = request.env[TCellAgent::Instrumentation::TCELL_ID]
30
30
  if tcell_context && dataex_policy && dataex_policy.has_actions_for_form_parameter?
31
31
  for_params(request) { |method, param_name, param_value|
32
32
  actions = dataex_policy.get_actions_for_form_parameter(param_name, tcell_context.route_id)
@@ -43,7 +43,7 @@ module TCellAgent
43
43
  }
44
44
  def self._handle_dataexpsure_headers(request)
45
45
  dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
46
- tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
46
+ tcell_context = request.env[TCellAgent::Instrumentation::TCELL_ID]
47
47
  if tcell_context && dataex_policy && dataex_policy.has_actions_for_headers?
48
48
  headers = request.env.select {|k,v| k.start_with? 'HTTP_'}
49
49
  headers.each { |header_name, header_value|
@@ -62,7 +62,7 @@ module TCellAgent
62
62
  }
63
63
  def self._handler_dataexposure_cookies(request)
64
64
  dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
65
- tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
65
+ tcell_context = request.env[TCellAgent::Instrumentation::TCELL_ID]
66
66
  if tcell_context && dataex_policy && dataex_policy.has_actions_for_cookie?
67
67
  request.cookies.each { |cookie_name, cookie_value|
68
68
  actions = dataex_policy.get_actions_for_cookie(cookie_name)
@@ -92,7 +92,7 @@ module TCellAgent
92
92
  route = Rails.application.routes.router.recognize(request) { |r, _| r }.first
93
93
  if route
94
94
  route_path = route[2].path.spec
95
- tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
95
+ tcell_context = request.env[TCellAgent::Instrumentation::TCELL_ID]
96
96
  if tcell_context
97
97
  tcell_context.route_id = TCellAgent::SensorEvents::Util.calculateRouteId(request.method.downcase, route_path)
98
98
  end
@@ -20,10 +20,11 @@ module TCellAgent
20
20
  def build(request, rack_response, response_code, response_headers)
21
21
  meta_event = AppSensorMetaEvent.new
22
22
 
23
- meta_event.remote_address = request.ip
23
+ meta_event.remote_address = TCellAgent::Utils::Rails.better_ip(request)
24
24
  meta_event.method = request.request_method
25
25
  meta_event.location = "#{request.base_url}#{request.fullpath}"
26
26
  meta_event.request_headers = request.env
27
+ meta_event.user_agent = request.env['HTTP_USER_AGENT']
27
28
  meta_event.request_content_len = (request.content_length || "0").to_i
28
29
  meta_event.response_content_len = (rack_response.length || "0").to_i
29
30
  meta_event.get_dict = request.GET
@@ -33,10 +34,11 @@ module TCellAgent
33
34
  meta_event.response_code = response_code
34
35
  meta_event.response_headers = response_headers
35
36
 
36
- meta_event.route_id = request.env["tcell.request_data"].route_id
37
- meta_event.transaction_id = request.env["tcell.request_data"].transaction_id
38
- meta_event.session_id = request.env["tcell.request_data"].hmac_session_id
39
- meta_event.user_id = request.env["tcell.request_data"].user_id
37
+ meta_event.path_parameters = request.env[TCellAgent::Instrumentation::TCELL_ID].path_parameters
38
+ meta_event.route_id = request.env[TCellAgent::Instrumentation::TCELL_ID].route_id
39
+ meta_event.transaction_id = request.env[TCellAgent::Instrumentation::TCELL_ID].transaction_id
40
+ meta_event.session_id = request.env[TCellAgent::Instrumentation::TCELL_ID].hmac_session_id
41
+ meta_event.user_id = request.env[TCellAgent::Instrumentation::TCELL_ID].user_id
40
42
 
41
43
  meta_event.set_body_dict(
42
44
  meta_event.request_content_len,
@@ -50,7 +52,8 @@ module TCellAgent
50
52
 
51
53
 
52
54
  attr_accessor :remote_address, :method, :location, :route_id, :session_id, :user_id, :transaction_id,
53
- :request_content_len, :get_dict, :post_dict, :body_dict, :cookie_dict, :response_content_len, :response_code
55
+ :request_content_len, :get_dict, :post_dict, :body_dict, :cookie_dict, :response_content_len, :response_code,
56
+ :user_agent, :path_parameters
54
57
 
55
58
  attr_accessor :request_headers, :response_headers
56
59
 
@@ -62,6 +65,8 @@ module TCellAgent
62
65
  @get_dict = {}
63
66
  @post_dict = {}
64
67
  @cookie_dict = {}
68
+ @user_agent = nil
69
+ @path_parameters = {}
65
70
  end
66
71
 
67
72
  def set_body_dict(request_content_len, request_content_type, request_body)
@@ -1,5 +1,5 @@
1
1
  # See the file "LICENSE" for the full license governing this code.
2
2
 
3
3
  module TCellAgent
4
- VERSION = "0.2.18"
4
+ VERSION = "0.2.19"
5
5
  end
@@ -0,0 +1,165 @@
1
+ require 'spec_helper'
2
+
3
+ module TCellAgent
4
+ module Policies
5
+
6
+ describe DatabaseSensor do
7
+
8
+ context "#initialize" do
9
+ context "default sensor" do
10
+ it "should have properties set to defaults" do
11
+ sensor = DatabaseSensor.new
12
+ expect(sensor.enabled).to eq(false)
13
+ expect(sensor.max_rows).to eq(1001)
14
+ expect(sensor.excluded_route_ids).to eq({})
15
+ end
16
+ end
17
+
18
+ context "setting enabled on sensor" do
19
+ it "should have properties set to defaults" do
20
+ sensor = DatabaseSensor.new({"enabled" => true})
21
+ expect(sensor.enabled).to eq(true)
22
+ expect(sensor.max_rows).to eq(1001)
23
+ expect(sensor.excluded_route_ids).to eq({})
24
+ end
25
+ end
26
+
27
+ context "setting max_rows on sensor" do
28
+ it "should have properties set to defaults" do
29
+ sensor = DatabaseSensor.new({"large_result" => {"limit" => 1}})
30
+ expect(sensor.enabled).to eq(false)
31
+ expect(sensor.max_rows).to eq(1)
32
+ expect(sensor.excluded_route_ids).to eq({})
33
+ end
34
+ end
35
+
36
+ context "setting excluded routes on sensor" do
37
+ it "should have properties set to defaults" do
38
+ sensor = DatabaseSensor.new({"exclude_routes" => ["1", "10", "20"]})
39
+ expect(sensor.enabled).to eq(false)
40
+ expect(sensor.max_rows).to eq(1001)
41
+ expect(sensor.excluded_route_ids).to eq({"1"=>true, "10"=>true, "20"=>true})
42
+ end
43
+ end
44
+ end
45
+
46
+ context "#check" do
47
+ context "with disabled sensor" do
48
+ it "should not send event" do
49
+ sensor = DatabaseSensor.new({"enabled" => false})
50
+
51
+ expect(TCellAgent).to_not receive(:send_event)
52
+ sensor.check({}, 10)
53
+ end
54
+ end
55
+
56
+ context "with enabled sensor" do
57
+ context "records is less than limit" do
58
+ it "should not send event" do
59
+ sensor = RequestSizeSensor.new({
60
+ "enabled" => true,
61
+ "large_result" => { "limit" => 10},
62
+ "exclude_routes" => []
63
+ })
64
+
65
+ tcell_data = TCellAgent::Instrumentation::TCellData.new
66
+
67
+ expect(TCellAgent).to_not receive(:send_event)
68
+ sensor.check(tcell_data, 1)
69
+ end
70
+ end
71
+
72
+ context "records are more than limit" do
73
+ it "should send event" do
74
+ sensor = DatabaseSensor.new({
75
+ "enabled" => true,
76
+ "large_result" => { "limit" => 10},
77
+ "exclude_routes" => []
78
+ })
79
+
80
+ tcell_data = TCellAgent::Instrumentation::TCellData.new
81
+ tcell_data.ip_address = "ip_address"
82
+ tcell_data.request_method = "get"
83
+ tcell_data.uri = "location"
84
+ tcell_data.route_id = "route_id"
85
+ tcell_data.session_id = "session_id"
86
+ tcell_data.user_id = "user_id"
87
+ tcell_data.transaction_id = "transaction_id"
88
+
89
+ expect(TCellAgent).to receive(:send_event).with(
90
+ {
91
+ "event_type" => "as",
92
+ "dp" => DatabaseSensor::DP_CODE,
93
+ "param" => nil,
94
+ "remote_addr" => "ip_address",
95
+ "rou" => "route_id",
96
+ "m" => "get"
97
+ }
98
+ )
99
+ sensor.check(tcell_data, 11)
100
+ end
101
+ end
102
+
103
+ context "records are more than limit" do
104
+ context "route_id is excluded" do
105
+ it "should not send event" do
106
+ sensor = DatabaseSensor.new({
107
+ "enabled" => true,
108
+ "large_result" => { "limit" => 10},
109
+ "exclude_routes" => ["route_id"]
110
+ })
111
+
112
+ tcell_data = TCellAgent::Instrumentation::TCellData.new
113
+ tcell_data.ip_address = "ip_address"
114
+ tcell_data.request_method = "get"
115
+ tcell_data.uri = "location"
116
+ tcell_data.route_id = "route_id"
117
+ tcell_data.session_id = "session_id"
118
+ tcell_data.user_id = "user_id"
119
+ tcell_data.transaction_id = "transaction_id"
120
+
121
+ expect(TCellAgent).to_not receive(:send_event)
122
+
123
+ sensor.check(tcell_data, 11)
124
+ end
125
+ end
126
+
127
+ context "route is not excluded" do
128
+ it "should send event" do
129
+ sensor = DatabaseSensor.new({
130
+ "enabled" => true,
131
+ "large_result" => { "limit" => 10},
132
+ "exclude_routes" => ["nonmatching_route_id"]
133
+ })
134
+
135
+ tcell_data = TCellAgent::Instrumentation::TCellData.new
136
+ tcell_data.ip_address = "ip_address"
137
+ tcell_data.request_method = "get"
138
+ tcell_data.uri = "location"
139
+ tcell_data.route_id = "route_id"
140
+ tcell_data.session_id = "session_id"
141
+ tcell_data.user_id = "user_id"
142
+ tcell_data.transaction_id = "transaction_id"
143
+
144
+ expect(TCellAgent).to receive(:send_event).with(
145
+ {
146
+ "event_type" => "as",
147
+ "dp" => DatabaseSensor::DP_CODE,
148
+ "param" => nil,
149
+ "remote_addr" => "ip_address",
150
+ "rou" => "route_id",
151
+ "m" => "get"
152
+ }
153
+ )
154
+ sensor.check(tcell_data, 11)
155
+ end
156
+ end
157
+ end
158
+
159
+ end
160
+ end
161
+
162
+ end
163
+
164
+ end
165
+ end