tcell_agent 0.2.21 → 0.2.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tcell_agent.rb +1 -0
- data/lib/tcell_agent/api.rb +3 -2
- data/lib/tcell_agent/appsensor/injections_matcher.rb +137 -0
- data/lib/tcell_agent/appsensor/injections_reporter.rb +67 -0
- data/lib/tcell_agent/appsensor/meta_data.rb +71 -0
- data/lib/tcell_agent/appsensor/rules/appsensor_rule_manager.rb +5 -2
- data/lib/tcell_agent/appsensor/rules/appsensor_rule_set.rb +1 -1
- data/lib/tcell_agent/appsensor/sensor.rb +48 -0
- data/lib/tcell_agent/configuration.rb +15 -2
- data/lib/tcell_agent/instrumentation.rb +3 -2
- data/lib/tcell_agent/logger.rb +19 -3
- data/lib/tcell_agent/patches.rb +26 -0
- data/lib/tcell_agent/patches/block_rule.rb +58 -0
- data/lib/tcell_agent/patches/meta_data.rb +54 -0
- data/lib/tcell_agent/patches/sensors_matcher.rb +30 -0
- data/lib/tcell_agent/policies/appsensor/cmdi_sensor.rb +4 -0
- data/lib/tcell_agent/policies/appsensor/database_sensor.rb +7 -3
- data/lib/tcell_agent/policies/appsensor/fpt_sensor.rb +4 -0
- data/lib/tcell_agent/policies/appsensor/injection_sensor.rb +32 -38
- data/lib/tcell_agent/policies/appsensor/misc_sensor.rb +4 -4
- data/lib/tcell_agent/policies/appsensor/nullbyte_sensor.rb +4 -0
- data/lib/tcell_agent/policies/appsensor/payloads_policy.rb +3 -1
- data/lib/tcell_agent/policies/appsensor/response_codes_sensor.rb +3 -3
- data/lib/tcell_agent/policies/appsensor/retr_sensor.rb +4 -0
- data/lib/tcell_agent/policies/appsensor/size_sensor.rb +9 -3
- data/lib/tcell_agent/policies/appsensor/user_agent_sensor.rb +3 -3
- data/lib/tcell_agent/policies/appsensor_policy.rb +55 -131
- data/lib/tcell_agent/policies/content_security_policy.rb +148 -137
- data/lib/tcell_agent/policies/patches_policy.rb +41 -13
- data/lib/tcell_agent/rails.rb +11 -109
- data/lib/tcell_agent/rails/auth/devise.rb +5 -1
- data/lib/tcell_agent/rails/dlp.rb +5 -2
- data/lib/tcell_agent/rails/dlp/process_request.rb +88 -0
- data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +1 -1
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +3 -13
- data/lib/tcell_agent/rails/on_start.rb +5 -101
- data/lib/tcell_agent/rails/routes.rb +240 -81
- data/lib/tcell_agent/rails/routes/grape.rb +113 -0
- data/lib/tcell_agent/rails/routes/route_id.rb +29 -0
- data/lib/tcell_agent/sensor_events/app_config.rb +21 -13
- data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +7 -26
- data/lib/tcell_agent/servers/passenger.rb +10 -0
- data/lib/tcell_agent/start_background_thread.rb +82 -0
- data/lib/tcell_agent/utils/params.rb +1 -1
- data/lib/tcell_agent/version.rb +1 -1
- data/spec/lib/tcell_agent/appsensor/injections_matcher_spec.rb +504 -0
- data/spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb +222 -0
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_manager_spec.rb +7 -13
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_set_spec.rb +18 -18
- data/spec/lib/tcell_agent/patches/block_rule_spec.rb +381 -0
- data/spec/lib/tcell_agent/patches/sensors_matcher_spec.rb +35 -0
- data/spec/lib/tcell_agent/patches_spec.rb +156 -0
- data/spec/lib/tcell_agent/policies/appsensor/cmdi_sensor_spec.rb +21 -10
- data/spec/lib/tcell_agent/policies/appsensor/fpt_sensor_spec.rb +20 -9
- data/spec/lib/tcell_agent/policies/appsensor/nullbyte_sensor_spec.rb +44 -9
- data/spec/lib/tcell_agent/policies/appsensor/request_size_sensor_spec.rb +4 -4
- data/spec/lib/tcell_agent/policies/appsensor/response_codes_sensor_spec.rb +13 -13
- data/spec/lib/tcell_agent/policies/appsensor/response_size_sensor_spec.rb +5 -5
- data/spec/lib/tcell_agent/policies/appsensor/retr_sensor_spec.rb +20 -9
- data/spec/lib/tcell_agent/policies/appsensor/sqli_sensor_spec.rb +24 -14
- data/spec/lib/tcell_agent/policies/appsensor/xss_sensor_spec.rb +243 -241
- data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +128 -200
- data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +126 -55
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +485 -24
- data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +5 -0
- data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +4 -2
- data/spec/lib/tcell_agent/rails/routes/grape_spec.rb +294 -0
- data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +80 -0
- data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +182 -0
- metadata +30 -7
- data/lib/tcell_agent/policies/appsensor/login_sensor.rb +0 -39
- data/lib/tcell_agent/policies/appsensor/sensor.rb +0 -46
- data/lib/tcell_agent/rails/path_parameters_setter.rb +0 -43
- data/spec/lib/tcell_agent/policies/appsensor/login_sensor_spec.rb +0 -104
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tcell_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garrett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -142,19 +142,26 @@ files:
|
|
142
142
|
- lib/tcell_agent/agent/static_agent.rb
|
143
143
|
- lib/tcell_agent/agent.rb
|
144
144
|
- lib/tcell_agent/api.rb
|
145
|
+
- lib/tcell_agent/appsensor/injections_matcher.rb
|
146
|
+
- lib/tcell_agent/appsensor/injections_reporter.rb
|
147
|
+
- lib/tcell_agent/appsensor/meta_data.rb
|
145
148
|
- lib/tcell_agent/appsensor/rules/appsensor_rule_manager.rb
|
146
149
|
- lib/tcell_agent/appsensor/rules/appsensor_rule_set.rb
|
147
150
|
- lib/tcell_agent/appsensor/rules/baserules.json
|
151
|
+
- lib/tcell_agent/appsensor/sensor.rb
|
148
152
|
- lib/tcell_agent/authlogic.rb
|
149
153
|
- lib/tcell_agent/configuration.rb
|
150
154
|
- lib/tcell_agent/devise.rb
|
151
155
|
- lib/tcell_agent/instrumentation.rb
|
152
156
|
- lib/tcell_agent/logger.rb
|
157
|
+
- lib/tcell_agent/patches/block_rule.rb
|
158
|
+
- lib/tcell_agent/patches/meta_data.rb
|
159
|
+
- lib/tcell_agent/patches/sensors_matcher.rb
|
160
|
+
- lib/tcell_agent/patches.rb
|
153
161
|
- lib/tcell_agent/policies/appsensor/cmdi_sensor.rb
|
154
162
|
- lib/tcell_agent/policies/appsensor/database_sensor.rb
|
155
163
|
- lib/tcell_agent/policies/appsensor/fpt_sensor.rb
|
156
164
|
- lib/tcell_agent/policies/appsensor/injection_sensor.rb
|
157
|
-
- lib/tcell_agent/policies/appsensor/login_sensor.rb
|
158
165
|
- lib/tcell_agent/policies/appsensor/misc_sensor.rb
|
159
166
|
- lib/tcell_agent/policies/appsensor/nullbyte_sensor.rb
|
160
167
|
- lib/tcell_agent/policies/appsensor/payloads_policy.rb
|
@@ -162,7 +169,6 @@ files:
|
|
162
169
|
- lib/tcell_agent/policies/appsensor/response_codes_sensor.rb
|
163
170
|
- lib/tcell_agent/policies/appsensor/response_size_sensor.rb
|
164
171
|
- lib/tcell_agent/policies/appsensor/retr_sensor.rb
|
165
|
-
- lib/tcell_agent/policies/appsensor/sensor.rb
|
166
172
|
- lib/tcell_agent/policies/appsensor/size_sensor.rb
|
167
173
|
- lib/tcell_agent/policies/appsensor/sqli_sensor.rb
|
168
174
|
- lib/tcell_agent/policies/appsensor/user_agent_sensor.rb
|
@@ -181,13 +187,15 @@ files:
|
|
181
187
|
- lib/tcell_agent/rails/auth/devise.rb
|
182
188
|
- lib/tcell_agent/rails/better_ip.rb
|
183
189
|
- lib/tcell_agent/rails/csrf_exception.rb
|
190
|
+
- lib/tcell_agent/rails/dlp/process_request.rb
|
184
191
|
- lib/tcell_agent/rails/dlp.rb
|
185
192
|
- lib/tcell_agent/rails/middleware/body_filter_middleware.rb
|
186
193
|
- lib/tcell_agent/rails/middleware/context_middleware.rb
|
187
194
|
- lib/tcell_agent/rails/middleware/global_middleware.rb
|
188
195
|
- lib/tcell_agent/rails/middleware/headers_middleware.rb
|
189
196
|
- lib/tcell_agent/rails/on_start.rb
|
190
|
-
- lib/tcell_agent/rails/
|
197
|
+
- lib/tcell_agent/rails/routes/grape.rb
|
198
|
+
- lib/tcell_agent/rails/routes/route_id.rb
|
191
199
|
- lib/tcell_agent/rails/routes.rb
|
192
200
|
- lib/tcell_agent/rails/settings_reporter.rb
|
193
201
|
- lib/tcell_agent/rails.rb
|
@@ -205,6 +213,7 @@ files:
|
|
205
213
|
- lib/tcell_agent/sensor_events/util/redirect_utils.rb
|
206
214
|
- lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb
|
207
215
|
- lib/tcell_agent/sensor_events/util/utils.rb
|
216
|
+
- lib/tcell_agent/servers/passenger.rb
|
208
217
|
- lib/tcell_agent/servers/puma.rb
|
209
218
|
- lib/tcell_agent/servers/rails_server.rb
|
210
219
|
- lib/tcell_agent/servers/thin.rb
|
@@ -268,14 +277,18 @@ files:
|
|
268
277
|
- spec/lib/tcell_agent/agent/policy_manager_spec.rb
|
269
278
|
- spec/lib/tcell_agent/agent/static_agent_spec.rb
|
270
279
|
- spec/lib/tcell_agent/api/api_spec.rb
|
280
|
+
- spec/lib/tcell_agent/appsensor/injections_matcher_spec.rb
|
281
|
+
- spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb
|
271
282
|
- spec/lib/tcell_agent/appsensor/rules/appsensor_rule_manager_spec.rb
|
272
283
|
- spec/lib/tcell_agent/appsensor/rules/appsensor_rule_set_spec.rb
|
273
284
|
- spec/lib/tcell_agent/configuration_spec.rb
|
274
285
|
- spec/lib/tcell_agent/instrumentation_spec.rb
|
286
|
+
- spec/lib/tcell_agent/patches/block_rule_spec.rb
|
287
|
+
- spec/lib/tcell_agent/patches/sensors_matcher_spec.rb
|
288
|
+
- spec/lib/tcell_agent/patches_spec.rb
|
275
289
|
- spec/lib/tcell_agent/policies/appsensor/cmdi_sensor_spec.rb
|
276
290
|
- spec/lib/tcell_agent/policies/appsensor/database_sensor_spec.rb
|
277
291
|
- spec/lib/tcell_agent/policies/appsensor/fpt_sensor_spec.rb
|
278
|
-
- spec/lib/tcell_agent/policies/appsensor/login_sensor_spec.rb
|
279
292
|
- spec/lib/tcell_agent/policies/appsensor/misc_sensor_spec.rb
|
280
293
|
- spec/lib/tcell_agent/policies/appsensor/nullbyte_sensor_spec.rb
|
281
294
|
- spec/lib/tcell_agent/policies/appsensor/payloads_policy_apply_spec.rb
|
@@ -304,6 +317,9 @@ files:
|
|
304
317
|
- spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb
|
305
318
|
- spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb
|
306
319
|
- spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb
|
320
|
+
- spec/lib/tcell_agent/rails/routes/grape_spec.rb
|
321
|
+
- spec/lib/tcell_agent/rails/routes/route_id_spec.rb
|
322
|
+
- spec/lib/tcell_agent/rails/routes/routes_spec.rb
|
307
323
|
- spec/lib/tcell_agent/rails_spec.rb
|
308
324
|
- spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb
|
309
325
|
- spec/lib/tcell_agent/sensor_events/dlp_spec.rb
|
@@ -410,14 +426,18 @@ test_files:
|
|
410
426
|
- spec/lib/tcell_agent/agent/policy_manager_spec.rb
|
411
427
|
- spec/lib/tcell_agent/agent/static_agent_spec.rb
|
412
428
|
- spec/lib/tcell_agent/api/api_spec.rb
|
429
|
+
- spec/lib/tcell_agent/appsensor/injections_matcher_spec.rb
|
430
|
+
- spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb
|
413
431
|
- spec/lib/tcell_agent/appsensor/rules/appsensor_rule_manager_spec.rb
|
414
432
|
- spec/lib/tcell_agent/appsensor/rules/appsensor_rule_set_spec.rb
|
415
433
|
- spec/lib/tcell_agent/configuration_spec.rb
|
416
434
|
- spec/lib/tcell_agent/instrumentation_spec.rb
|
435
|
+
- spec/lib/tcell_agent/patches/block_rule_spec.rb
|
436
|
+
- spec/lib/tcell_agent/patches/sensors_matcher_spec.rb
|
437
|
+
- spec/lib/tcell_agent/patches_spec.rb
|
417
438
|
- spec/lib/tcell_agent/policies/appsensor/cmdi_sensor_spec.rb
|
418
439
|
- spec/lib/tcell_agent/policies/appsensor/database_sensor_spec.rb
|
419
440
|
- spec/lib/tcell_agent/policies/appsensor/fpt_sensor_spec.rb
|
420
|
-
- spec/lib/tcell_agent/policies/appsensor/login_sensor_spec.rb
|
421
441
|
- spec/lib/tcell_agent/policies/appsensor/misc_sensor_spec.rb
|
422
442
|
- spec/lib/tcell_agent/policies/appsensor/nullbyte_sensor_spec.rb
|
423
443
|
- spec/lib/tcell_agent/policies/appsensor/payloads_policy_apply_spec.rb
|
@@ -446,6 +466,9 @@ test_files:
|
|
446
466
|
- spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb
|
447
467
|
- spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb
|
448
468
|
- spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb
|
469
|
+
- spec/lib/tcell_agent/rails/routes/grape_spec.rb
|
470
|
+
- spec/lib/tcell_agent/rails/routes/route_id_spec.rb
|
471
|
+
- spec/lib/tcell_agent/rails/routes/routes_spec.rb
|
449
472
|
- spec/lib/tcell_agent/rails_spec.rb
|
450
473
|
- spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb
|
451
474
|
- spec/lib/tcell_agent/sensor_events/dlp_spec.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'tcell_agent/policies/appsensor/size_sensor'
|
2
|
-
require 'tcell_agent/sensor_events/util/utils'
|
3
|
-
|
4
|
-
|
5
|
-
module TCellAgent
|
6
|
-
module Policies
|
7
|
-
|
8
|
-
class LoginSensor < Sensor
|
9
|
-
LOGIN_FAILURE_DP = "lgnFlr"
|
10
|
-
|
11
|
-
attr_accessor :enabled
|
12
|
-
|
13
|
-
def initialize(policy_json=nil)
|
14
|
-
@enabled = false
|
15
|
-
|
16
|
-
if policy_json
|
17
|
-
@enabled = policy_json.fetch("enabled", false)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def check(appsensor_meta, username)
|
23
|
-
return unless self.enabled
|
24
|
-
|
25
|
-
if username
|
26
|
-
username = TCellAgent::SensorEvents::Util.hmac(username)
|
27
|
-
end
|
28
|
-
|
29
|
-
send_event(appsensor_meta, LOGIN_FAILURE_DP, username, nil)
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_s
|
33
|
-
"<#{self.class.name} enabled: #{@enabled}>"
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'tcell_agent/sensor_events/appsensor_event'
|
2
|
-
|
3
|
-
module TCellAgent
|
4
|
-
module Policies
|
5
|
-
|
6
|
-
class Sensor
|
7
|
-
def send_event(appsensor_meta, detection_point, parameter, meta, payload, pattern)
|
8
|
-
event = TCellAgent::SensorEvents::TCellAppSensorEvent.new(
|
9
|
-
appsensor_meta.location,
|
10
|
-
detection_point,
|
11
|
-
appsensor_meta.method,
|
12
|
-
appsensor_meta.remote_address,
|
13
|
-
parameter,
|
14
|
-
appsensor_meta.route_id,
|
15
|
-
meta,
|
16
|
-
appsensor_meta.session_id,
|
17
|
-
appsensor_meta.user_id,
|
18
|
-
payload,
|
19
|
-
pattern
|
20
|
-
)
|
21
|
-
|
22
|
-
TCellAgent.send_event(event)
|
23
|
-
end
|
24
|
-
|
25
|
-
def send_event_from_tcell_data(tcell_data, detection_point, parameter, meta)
|
26
|
-
payload = pattern = nil
|
27
|
-
event = TCellAgent::SensorEvents::TCellAppSensorEvent.new(
|
28
|
-
tcell_data.uri,
|
29
|
-
detection_point,
|
30
|
-
tcell_data.request_method,
|
31
|
-
tcell_data.ip_address,
|
32
|
-
parameter,
|
33
|
-
tcell_data.route_id,
|
34
|
-
meta,
|
35
|
-
tcell_data.hmac_session_id,
|
36
|
-
tcell_data.user_id,
|
37
|
-
payload,
|
38
|
-
pattern
|
39
|
-
)
|
40
|
-
|
41
|
-
TCellAgent.send_event(event)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
@@ -1,43 +0,0 @@
|
|
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
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TCellAgent
|
4
|
-
module Policies
|
5
|
-
|
6
|
-
describe LoginSensor do
|
7
|
-
describe "#initialize" do
|
8
|
-
context "default sensor" do
|
9
|
-
it "should have properties set to defaults" do
|
10
|
-
sensor = LoginSensor.new
|
11
|
-
expect(sensor.enabled).to eq(false)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "setting enabled on sensor" do
|
16
|
-
it "should have properties set to defaults" do
|
17
|
-
sensor = LoginSensor.new({"enabled" => true})
|
18
|
-
expect(sensor.enabled).to eq(true)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#check" do
|
25
|
-
context "with disabled sensor" do
|
26
|
-
context "with empty username" do
|
27
|
-
it "should not send an event" do
|
28
|
-
sensor = LoginSensor.new({"enabled" => false})
|
29
|
-
meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
|
30
|
-
meta.remote_address = "remote_address"
|
31
|
-
meta.method = "get"
|
32
|
-
meta.location = "location"
|
33
|
-
meta.route_id = "route_id"
|
34
|
-
meta.session_id = "session_id"
|
35
|
-
meta.user_id = "user_id"
|
36
|
-
meta.transaction_id = "transaction_id"
|
37
|
-
|
38
|
-
expect(sensor).to_not receive(:send_event)
|
39
|
-
sensor.check(meta, nil)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "with username present" do
|
44
|
-
it "should not send an event" do
|
45
|
-
sensor = LoginSensor.new({"enabled" => false})
|
46
|
-
meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
|
47
|
-
meta.remote_address = "remote_address"
|
48
|
-
meta.method = "get"
|
49
|
-
meta.location = "location"
|
50
|
-
meta.route_id = "route_id"
|
51
|
-
meta.session_id = "session_id"
|
52
|
-
meta.user_id = "user_id"
|
53
|
-
meta.transaction_id = "transaction_id"
|
54
|
-
|
55
|
-
expect(sensor).to_not receive(:send_event)
|
56
|
-
sensor.check(meta, "username")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "with enabled sensor" do
|
62
|
-
context "with empty username" do
|
63
|
-
it "should send an event" do
|
64
|
-
sensor = LoginSensor.new({"enabled" => true})
|
65
|
-
meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
|
66
|
-
meta.remote_address = "remote_address"
|
67
|
-
meta.method = "get"
|
68
|
-
meta.location = "location"
|
69
|
-
meta.route_id = "route_id"
|
70
|
-
meta.session_id = "session_id"
|
71
|
-
meta.user_id = "user_id"
|
72
|
-
meta.transaction_id = "transaction_id"
|
73
|
-
|
74
|
-
expect(sensor).to receive(:send_event).with(
|
75
|
-
meta, LoginSensor::LOGIN_FAILURE_DP, nil, nil
|
76
|
-
)
|
77
|
-
sensor.check(meta, nil)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "with username present" do
|
82
|
-
it "should send an event" do
|
83
|
-
sensor = LoginSensor.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 receive(:send_event).with(
|
94
|
-
meta, LoginSensor::LOGIN_FAILURE_DP, anything(), nil
|
95
|
-
)
|
96
|
-
sensor.check(meta, "username")
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
end
|