tcell_agent 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tcell_agent.rb +2 -2
  3. data/lib/tcell_agent/agent/policy_manager.rb +1 -1
  4. data/lib/tcell_agent/api.rb +2 -2
  5. data/lib/tcell_agent/appsensor/rules/appsensor_rule_manager.rb +46 -0
  6. data/lib/tcell_agent/appsensor/rules/appsensor_rule_set.rb +67 -0
  7. data/lib/tcell_agent/appsensor/rules/baserules.json +153 -0
  8. data/lib/tcell_agent/configuration.rb +7 -1
  9. data/lib/tcell_agent/instrumentation.rb +3 -0
  10. data/lib/tcell_agent/logger.rb +25 -3
  11. data/lib/tcell_agent/policies/appsensor/cmdi_sensor.rb +19 -0
  12. data/lib/tcell_agent/policies/appsensor/fpt_sensor.rb +19 -0
  13. data/lib/tcell_agent/policies/appsensor/injection_sensor.rb +136 -0
  14. data/lib/tcell_agent/policies/appsensor/login_sensor.rb +42 -0
  15. data/lib/tcell_agent/policies/appsensor/nullbyte_sensor.rb +22 -0
  16. data/lib/tcell_agent/policies/appsensor/request_size_sensor.rb +21 -0
  17. data/lib/tcell_agent/policies/appsensor/response_codes_sensor.rb +58 -0
  18. data/lib/tcell_agent/policies/appsensor/response_size_sensor.rb +21 -0
  19. data/lib/tcell_agent/policies/appsensor/retr_sensor.rb +18 -0
  20. data/lib/tcell_agent/policies/appsensor/sensor.rb +28 -0
  21. data/lib/tcell_agent/policies/appsensor/size_sensor.rb +43 -0
  22. data/lib/tcell_agent/policies/appsensor/sqli_sensor.rb +25 -0
  23. data/lib/tcell_agent/policies/appsensor/xss_sensor.rb +26 -0
  24. data/lib/tcell_agent/policies/appsensor_policy.rb +198 -67
  25. data/lib/tcell_agent/policies/clickjacking_policy.rb +1 -1
  26. data/lib/tcell_agent/policies/content_security_policy.rb +1 -1
  27. data/lib/tcell_agent/policies/dataloss_policy.rb +1 -1
  28. data/lib/tcell_agent/policies/honeytokens_policy.rb +1 -1
  29. data/lib/tcell_agent/policies/http_redirect_policy.rb +1 -1
  30. data/lib/tcell_agent/policies/http_tx_policy.rb +1 -1
  31. data/lib/tcell_agent/policies/login_fraud_policy.rb +1 -1
  32. data/lib/tcell_agent/policies/secure_headers_policy.rb +1 -1
  33. data/lib/tcell_agent/rails.rb +0 -1
  34. data/lib/tcell_agent/rails/auth/devise.rb +0 -1
  35. data/lib/tcell_agent/rails/dlp.rb +58 -13
  36. data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +0 -1
  37. data/lib/tcell_agent/rails/middleware/context_middleware.rb +0 -1
  38. data/lib/tcell_agent/rails/middleware/global_middleware.rb +0 -1
  39. data/lib/tcell_agent/rails/middleware/headers_middleware.rb +6 -34
  40. data/lib/tcell_agent/sensor_events/appsensor_event.rb +59 -0
  41. data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +95 -0
  42. data/lib/tcell_agent/servers/rails_server.rb +18 -9
  43. data/lib/tcell_agent/utils/params.rb +40 -0
  44. data/lib/tcell_agent/version.rb +1 -1
  45. data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_manager_spec.rb +39 -0
  46. data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_set_spec.rb +152 -0
  47. data/spec/lib/tcell_agent/instrumentation_spec.rb +4 -4
  48. data/spec/lib/tcell_agent/policies/appsensor/cmdi_sensor_spec.rb +128 -0
  49. data/spec/lib/tcell_agent/policies/appsensor/fpt_sensor_spec.rb +128 -0
  50. data/spec/lib/tcell_agent/policies/appsensor/login_sensor_spec.rb +104 -0
  51. data/spec/lib/tcell_agent/policies/appsensor/nullbyte_sensor_spec.rb +132 -0
  52. data/spec/lib/tcell_agent/policies/appsensor/request_size_sensor_spec.rb +164 -0
  53. data/spec/lib/tcell_agent/policies/appsensor/response_codes_sensor_spec.rb +194 -0
  54. data/spec/lib/tcell_agent/policies/appsensor/response_size_sensor_spec.rb +157 -0
  55. data/spec/lib/tcell_agent/policies/appsensor/retr_sensor_spec.rb +128 -0
  56. data/spec/lib/tcell_agent/policies/appsensor/sqli_sensor_spec.rb +151 -0
  57. data/spec/lib/tcell_agent/policies/appsensor/xss_sensor_spec.rb +652 -0
  58. data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +461 -28
  59. data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +4 -4
  60. data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +6 -6
  61. data/spec/lib/tcell_agent/policies/dataloss_policy_spec.rb +10 -10
  62. data/spec/lib/tcell_agent/policies/honeytokens_policy_spec.rb +1 -1
  63. data/spec/lib/tcell_agent/policies/http_redirect_policy_spec.rb +1 -1
  64. data/spec/lib/tcell_agent/policies/http_tx_policy_spec.rb +1 -1
  65. data/spec/lib/tcell_agent/policies/login_policy_spec.rb +2 -2
  66. data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +4 -4
  67. data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +67 -7
  68. data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +80 -0
  69. data/spec/lib/tcell_agent/utils/params_spec.rb +119 -0
  70. data/spec/support/resources/baserules.json +155 -0
  71. metadata +51 -12
  72. data/lib/tcell_agent/appsensor.rb +0 -42
  73. data/lib/tcell_agent/appsensor/cmdi.rb +0 -32
  74. data/lib/tcell_agent/appsensor/path_traversal.rb +0 -33
  75. data/lib/tcell_agent/appsensor/sqli.rb +0 -55
  76. data/lib/tcell_agent/appsensor/xss.rb +0 -40
  77. data/lib/tcell_agent/sensor_events/app_sensor.rb +0 -302
  78. data/spec/lib/tcell_agent/appsensor_spec.rb +0 -65
  79. data/spec/lib/tcell_agent/sensor_events/tcell_app_sensor_event_processor_spec.rb +0 -289
@@ -0,0 +1,164 @@
1
+ require 'spec_helper'
2
+
3
+ module TCellAgent
4
+ module Policies
5
+
6
+ describe RequestSizeSensor do
7
+ context "#initialize" do
8
+ context "default sensor" do
9
+ it "should have properties set to defaults" do
10
+ sensor = RequestSizeSensor.new
11
+ expect(sensor.enabled).to eq(false)
12
+ expect(sensor.limit).to eq(524288)
13
+ expect(sensor.exclude_routes).to eq({})
14
+ expect(sensor.dp_code).to eq(RequestSizeSensor::DP_UNUSUAL_REQUEST_SIZE)
15
+ end
16
+ end
17
+
18
+ context "setting enabled on sensor" do
19
+ it "should have properties set to defaults" do
20
+ sensor = RequestSizeSensor.new({"enabled" => true})
21
+ expect(sensor.enabled).to eq(true)
22
+ expect(sensor.limit).to eq(524288)
23
+ expect(sensor.exclude_routes).to eq({})
24
+ expect(sensor.dp_code).to eq(RequestSizeSensor::DP_UNUSUAL_REQUEST_SIZE)
25
+ end
26
+ end
27
+
28
+ context "setting limit on sensor" do
29
+ it "should have properties set to defaults" do
30
+ sensor = RequestSizeSensor.new({"limit" => 1})
31
+ expect(sensor.enabled).to eq(false)
32
+ expect(sensor.limit).to eq(1)
33
+ expect(sensor.exclude_routes).to eq({})
34
+ expect(sensor.dp_code).to eq(RequestSizeSensor::DP_UNUSUAL_REQUEST_SIZE)
35
+ end
36
+ end
37
+
38
+ context "setting excluded routes on sensor" do
39
+ it "should have properties set to defaults" do
40
+ sensor = RequestSizeSensor.new({"exclude_routes" => ["1", "10", "20"]})
41
+ expect(sensor.enabled).to eq(false)
42
+ expect(sensor.limit).to eq(524288)
43
+ expect(sensor.exclude_routes).to eq({"1"=>true, "10"=>true, "20"=>true})
44
+ expect(sensor.dp_code).to eq(RequestSizeSensor::DP_UNUSUAL_REQUEST_SIZE)
45
+ end
46
+ end
47
+ end
48
+
49
+ context "#check" do
50
+ context "with disabled sensor" do
51
+ it "should not send event" do
52
+ sensor = RequestSizeSensor.new({"enabled" => false})
53
+
54
+ expect(sensor).to_not receive(:send_event)
55
+ sensor.check({}, 10)
56
+ end
57
+ end
58
+
59
+ context "with enabled sensor" do
60
+ context "size is nil" do
61
+ it "should not send event" do
62
+ sensor = RequestSizeSensor.new({
63
+ "enabled" => true,
64
+ "limit" => 2048,
65
+ "exclude_routes" => []
66
+ })
67
+
68
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
69
+ meta.remote_address = "remote_address"
70
+ meta.method = "get"
71
+ meta.location = "location"
72
+ meta.route_id = "route_id"
73
+ meta.session_id = "session_id"
74
+ meta.user_id = "user_id"
75
+ meta.transaction_id = "transaction_id"
76
+
77
+ expect(sensor).to_not receive(:send_event)
78
+ sensor.check(meta, nil)
79
+ end
80
+ end
81
+
82
+ context "size is ok" do
83
+ it "should not send event" do
84
+ sensor = RequestSizeSensor.new({
85
+ "enabled" => true,
86
+ "limit" => 2048,
87
+ "exclude_routes" => []
88
+ })
89
+
90
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
91
+ meta.remote_address = "remote_address"
92
+ meta.method = "get"
93
+ meta.location = "location"
94
+ meta.route_id = "route_id"
95
+ meta.session_id = "session_id"
96
+ meta.user_id = "user_id"
97
+ meta.transaction_id = "transaction_id"
98
+
99
+ expect(sensor).to_not receive(:send_event)
100
+ sensor.check(meta, 1024)
101
+ end
102
+ end
103
+
104
+ context "size is too big" do
105
+ context "route_id is excluded" do
106
+ it "should not send event" do
107
+ sensor = RequestSizeSensor.new({
108
+ "enabled" => true,
109
+ "limit" => 1024,
110
+ "exclude_routes" => ["excluded_route_id"]
111
+ })
112
+
113
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
114
+ meta.remote_address = "remote_address"
115
+ meta.method = "get"
116
+ meta.location = "location"
117
+ meta.route_id = "excluded_route_id"
118
+ meta.session_id = "session_id"
119
+ meta.user_id = "user_id"
120
+ meta.transaction_id = "transaction_id"
121
+
122
+ expect(sensor).to_not receive(:send_event)
123
+ sensor.check(meta, 2048)
124
+ end
125
+ end
126
+
127
+ context "route is not excluded" do
128
+ it "should send event" do
129
+ sensor = RequestSizeSensor.new({
130
+ "enabled" => true,
131
+ "limit" => 1024,
132
+ "exclude_routes" => []
133
+ })
134
+
135
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
136
+ meta.remote_address = "remote_address"
137
+ meta.method = "get"
138
+ meta.location = "location"
139
+ meta.route_id = "excluded_route_id"
140
+ meta.session_id = "session_id"
141
+ meta.user_id = "user_id"
142
+ meta.transaction_id = "transaction_id"
143
+
144
+ expect(TCellAgent).to receive(:send_event).with(
145
+ {
146
+ "event_type" => "as",
147
+ "dp" => RequestSizeSensor::DP_UNUSUAL_REQUEST_SIZE,
148
+ "param" => "2048",
149
+ "remote_addr" => "remote_address",
150
+ "rou" => "excluded_route_id",
151
+ "m" => "get"
152
+ }
153
+ )
154
+ sensor.check(meta, 2048)
155
+ end
156
+ end
157
+ end
158
+
159
+ end
160
+ end
161
+ end
162
+
163
+ end
164
+ end
@@ -0,0 +1,194 @@
1
+ require 'spec_helper'
2
+
3
+ module TCellAgent
4
+ module Policies
5
+
6
+ describe ResponseCodesSensor do
7
+ context "#initialize" do
8
+ context "default sensor" do
9
+ it "should have properties set to defaults" do
10
+ sensor = ResponseCodesSensor.new
11
+ expect(sensor.enabled).to eq(false)
12
+ expect(sensor.series_400_enabled).to eq(false)
13
+ expect(sensor.series_500_enabled).to eq(false)
14
+ end
15
+ end
16
+
17
+ context "setting enabled on sensor" do
18
+ it "should have properties set to defaults" do
19
+ sensor = ResponseCodesSensor.new({"enabled" => true})
20
+ expect(sensor.enabled).to eq(true)
21
+ expect(sensor.series_400_enabled).to eq(false)
22
+ expect(sensor.series_500_enabled).to eq(false)
23
+ end
24
+ end
25
+
26
+ context "setting series_400_enabled on sensor" do
27
+ it "should have properties set to defaults" do
28
+ sensor = ResponseCodesSensor.new({"series_400_enabled" => true})
29
+ expect(sensor.enabled).to eq(false)
30
+ expect(sensor.series_400_enabled).to eq(true)
31
+ expect(sensor.series_500_enabled).to eq(false)
32
+ end
33
+ end
34
+
35
+ context "setting series_500_enabled on sensor" do
36
+ it "should have properties set to defaults" do
37
+ sensor = ResponseCodesSensor.new({"series_500_enabled" => true})
38
+ expect(sensor.enabled).to eq(false)
39
+ expect(sensor.series_400_enabled).to eq(false)
40
+ expect(sensor.series_500_enabled).to eq(true)
41
+ end
42
+ end
43
+ end
44
+
45
+ context "#check" do
46
+ context "with disabled sensor" do
47
+ it "should not send event" do
48
+ sensor = ResponseCodesSensor.new({"enabled" => false})
49
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
50
+ meta.remote_address = "remote_address"
51
+ meta.method = "get"
52
+ meta.location = "location"
53
+ meta.route_id = "route_id"
54
+ meta.session_id = "session_id"
55
+ meta.user_id = "user_id"
56
+ meta.transaction_id = "transaction_id"
57
+
58
+ expect(sensor).to_not receive(:send_event)
59
+ sensor.check(meta, 200)
60
+ end
61
+ end
62
+
63
+ context "with enabled sensor" do
64
+ context "with 200 response code" do
65
+ it "should not send an event" do
66
+ sensor = ResponseCodesSensor.new({"enabled" => true})
67
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
68
+ meta.remote_address = "remote_address"
69
+ meta.method = "get"
70
+ meta.location = "location"
71
+ meta.route_id = "route_id"
72
+ meta.session_id = "session_id"
73
+ meta.user_id = "user_id"
74
+ meta.transaction_id = "transaction_id"
75
+
76
+ expect(sensor).to_not receive(:send_event)
77
+ sensor.check(meta, 200)
78
+ end
79
+ end
80
+
81
+ context "with 300 response code" do
82
+ it "should not send an event" do
83
+ sensor = ResponseCodesSensor.new({"enabled" => true})
84
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
85
+ meta.remote_address = "remote_address"
86
+ meta.method = "get"
87
+ meta.location = "location"
88
+ meta.route_id = "route_id"
89
+ meta.session_id = "session_id"
90
+ meta.user_id = "user_id"
91
+ meta.transaction_id = "transaction_id"
92
+
93
+ expect(sensor).to_not receive(:send_event)
94
+ sensor.check(meta, 300)
95
+ end
96
+ end
97
+
98
+ context "with disabled series_400_enabled" do
99
+ context "with 400 response code" do
100
+ it "should not send an event" do
101
+ sensor = ResponseCodesSensor.new({
102
+ "enabled" => true,
103
+ "series_400_enabled" => false
104
+ })
105
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
106
+ meta.remote_address = "remote_address"
107
+ meta.method = "get"
108
+ meta.location = "location"
109
+ meta.route_id = "route_id"
110
+ meta.session_id = "session_id"
111
+ meta.user_id = "user_id"
112
+ meta.transaction_id = "transaction_id"
113
+
114
+ expect(sensor).to_not receive(:send_event)
115
+ sensor.check(meta, 400)
116
+ end
117
+ end
118
+ end
119
+
120
+ context "with enabled series_400_enabled" do
121
+ context "with 400 response code" do
122
+ it "should send an event" do
123
+ sensor = ResponseCodesSensor.new({
124
+ "enabled" => true,
125
+ "series_400_enabled" => true
126
+ })
127
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
128
+ meta.remote_address = "remote_address"
129
+ meta.method = "get"
130
+ meta.location = "location"
131
+ meta.route_id = "route_id"
132
+ meta.session_id = "session_id"
133
+ meta.user_id = "user_id"
134
+ meta.transaction_id = "transaction_id"
135
+
136
+ expect(sensor).to receive(:send_event).with(
137
+ meta, ResponseCodesSensor::RESPONSE_CODE_DP_DICT[4], "400", nil
138
+ )
139
+ sensor.check(meta, 400)
140
+ end
141
+ end
142
+ end
143
+
144
+ context "with disabled series_500_enabled" do
145
+ context "with 500 response code" do
146
+ it "should not send an event" do
147
+ sensor = ResponseCodesSensor.new({
148
+ "enabled" => true,
149
+ "series_500_enabled" => false
150
+ })
151
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
152
+ meta.remote_address = "remote_address"
153
+ meta.method = "get"
154
+ meta.location = "location"
155
+ meta.route_id = "route_id"
156
+ meta.session_id = "session_id"
157
+ meta.user_id = "user_id"
158
+ meta.transaction_id = "transaction_id"
159
+
160
+ expect(sensor).to_not receive(:send_event)
161
+ sensor.check(meta, 500)
162
+ end
163
+ end
164
+ end
165
+
166
+ context "with enabled series_500_enabled" do
167
+ context "with 500 response code" do
168
+ it "should send an event" do
169
+ sensor = ResponseCodesSensor.new({
170
+ "enabled" => true,
171
+ "series_500_enabled" => true
172
+ })
173
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
174
+ meta.remote_address = "remote_address"
175
+ meta.method = "get"
176
+ meta.location = "location"
177
+ meta.route_id = "route_id"
178
+ meta.session_id = "session_id"
179
+ meta.user_id = "user_id"
180
+ meta.transaction_id = "transaction_id"
181
+
182
+ expect(sensor).to receive(:send_event).with(
183
+ meta, ResponseCodesSensor::RESPONSE_CODE_DP_DICT[500], "500", nil
184
+ )
185
+ sensor.check(meta, 500)
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end
192
+
193
+ end
194
+ end
@@ -0,0 +1,157 @@
1
+ require 'spec_helper'
2
+
3
+ module TCellAgent
4
+ module Policies
5
+
6
+ describe ResponseSizeSensor do
7
+ context "#initialize" do
8
+ context "default sensor" do
9
+ it "should have properties set to defaults" do
10
+ sensor = ResponseSizeSensor.new
11
+ expect(sensor.enabled).to eq(false)
12
+ expect(sensor.limit).to eq(2097152)
13
+ expect(sensor.exclude_routes).to eq({})
14
+ expect(sensor.dp_code).to eq(ResponseSizeSensor::DP_UNUSUAL_RESPONSE_SIZE)
15
+ end
16
+ end
17
+
18
+ context "setting enabled on sensor" do
19
+ it "should have properties set to defaults" do
20
+ sensor = ResponseSizeSensor.new({"enabled" => true})
21
+ expect(sensor.enabled).to eq(true)
22
+ expect(sensor.limit).to eq(2097152)
23
+ expect(sensor.exclude_routes).to eq({})
24
+ expect(sensor.dp_code).to eq(ResponseSizeSensor::DP_UNUSUAL_RESPONSE_SIZE)
25
+ end
26
+ end
27
+
28
+ context "setting limit on sensor" do
29
+ it "should have properties set to defaults" do
30
+ sensor = ResponseSizeSensor.new({"limit" => 1})
31
+ expect(sensor.enabled).to eq(false)
32
+ expect(sensor.limit).to eq(1)
33
+ expect(sensor.exclude_routes).to eq({})
34
+ expect(sensor.dp_code).to eq(ResponseSizeSensor::DP_UNUSUAL_RESPONSE_SIZE)
35
+ end
36
+ end
37
+
38
+ context "setting excluded routes on sensor" do
39
+ it "should have properties set to defaults" do
40
+ sensor = ResponseSizeSensor.new({"exclude_routes" => ["1", "10", "20"]})
41
+ expect(sensor.enabled).to eq(false)
42
+ expect(sensor.limit).to eq(2097152)
43
+ expect(sensor.exclude_routes).to eq({"1"=>true, "10"=>true, "20"=>true})
44
+ expect(sensor.dp_code).to eq(ResponseSizeSensor::DP_UNUSUAL_RESPONSE_SIZE)
45
+ end
46
+ end
47
+ end
48
+
49
+ context "#check" do
50
+ context "with disabled sensor" do
51
+ it "should not send event" do
52
+ sensor = ResponseSizeSensor.new({"enabled" => false})
53
+
54
+ expect(sensor).to_not receive(:send_event)
55
+ sensor.check({}, 10)
56
+ end
57
+ end
58
+
59
+ context "with enabled sensor" do
60
+ context "size is nil" do
61
+ it "should not send event" do
62
+ sensor = ResponseSizeSensor.new({
63
+ "enabled" => true,
64
+ "limit" => 2048,
65
+ "exclude_routes" => []
66
+ })
67
+
68
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
69
+ meta.remote_address = "remote_address"
70
+ meta.method = "get"
71
+ meta.location = "location"
72
+ meta.route_id = "route_id"
73
+ meta.session_id = "session_id"
74
+ meta.user_id = "user_id"
75
+ meta.transaction_id = "transaction_id"
76
+
77
+ expect(sensor).to_not receive(:send_event)
78
+ sensor.check(meta, nil)
79
+ end
80
+ end
81
+
82
+ context "size is ok" do
83
+ it "should not send event" do
84
+ sensor = ResponseSizeSensor.new({
85
+ "enabled" => true,
86
+ "limit" => 2048,
87
+ "exclude_routes" => []
88
+ })
89
+
90
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
91
+ meta.remote_address = "remote_address"
92
+ meta.method = "get"
93
+ meta.location = "location"
94
+ meta.route_id = "route_id"
95
+ meta.session_id = "session_id"
96
+ meta.user_id = "user_id"
97
+ meta.transaction_id = "transaction_id"
98
+
99
+ expect(sensor).to_not receive(:send_event)
100
+ sensor.check(meta, 1024)
101
+ end
102
+ end
103
+
104
+ context "size is too big" do
105
+ context "route_id is excluded" do
106
+ it "should not send event" do
107
+ sensor = ResponseSizeSensor.new({
108
+ "enabled" => true,
109
+ "limit" => 1024,
110
+ "exclude_routes" => ["excluded_route_id"]
111
+ })
112
+
113
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
114
+ meta.remote_address = "remote_address"
115
+ meta.method = "get"
116
+ meta.location = "location"
117
+ meta.route_id = "excluded_route_id"
118
+ meta.session_id = "session_id"
119
+ meta.user_id = "user_id"
120
+ meta.transaction_id = "transaction_id"
121
+
122
+ expect(sensor).to_not receive(:send_event)
123
+ sensor.check(meta, 2048)
124
+ end
125
+ end
126
+
127
+ context "route is not excluded" do
128
+ it "should send event" do
129
+ sensor = ResponseSizeSensor.new({
130
+ "enabled" => true,
131
+ "limit" => 1024,
132
+ "exclude_routes" => []
133
+ })
134
+
135
+ meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
136
+ meta.remote_address = "remote_address"
137
+ meta.method = "get"
138
+ meta.location = "location"
139
+ meta.route_id = "excluded_route_id"
140
+ meta.session_id = "session_id"
141
+ meta.user_id = "user_id"
142
+ meta.transaction_id = "transaction_id"
143
+
144
+ expect(sensor).to receive(:send_event).with(
145
+ meta, ResponseSizeSensor::DP_UNUSUAL_RESPONSE_SIZE, "2048", nil
146
+ )
147
+ sensor.check(meta, 2048)
148
+ end
149
+ end
150
+ end
151
+ end
152
+
153
+ end
154
+ end
155
+
156
+ end
157
+ end