tcell_agent 1.1.3 → 1.1.4
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.
- checksums.yaml +4 -4
- data/bin/tcell_agent +10 -2
- data/lib/tcell_agent.rb +3 -3
- data/lib/tcell_agent/agent.rb +42 -52
- data/lib/tcell_agent/agent/event_processor.rb +129 -162
- data/lib/tcell_agent/agent/fork_pipe_manager.rb +57 -62
- data/lib/tcell_agent/agent/policy_manager.rb +83 -104
- data/lib/tcell_agent/agent/policy_types.rb +24 -29
- data/lib/tcell_agent/agent/route_manager.rb +36 -46
- data/lib/tcell_agent/agent/static_agent.rb +19 -21
- data/lib/tcell_agent/api.rb +23 -28
- data/lib/tcell_agent/appsensor/injections_reporter.rb +7 -11
- data/lib/tcell_agent/authlogic.rb +7 -7
- data/lib/tcell_agent/cmdi.rb +22 -23
- data/lib/tcell_agent/config/unknown_options.rb +71 -69
- data/lib/tcell_agent/configuration.rb +187 -191
- data/lib/tcell_agent/devise.rb +13 -15
- data/lib/tcell_agent/hooks/login_fraud.rb +1 -1
- data/lib/tcell_agent/instrumentation.rb +120 -124
- data/lib/tcell_agent/logger.rb +29 -45
- data/lib/tcell_agent/patches.rb +5 -5
- data/lib/tcell_agent/policies/dataloss_policy.rb +263 -288
- data/lib/tcell_agent/policies/http_redirect_policy.rb +25 -37
- data/lib/tcell_agent/policies/http_tx_policy.rb +48 -52
- data/lib/tcell_agent/policies/login_fraud_policy.rb +15 -20
- data/lib/tcell_agent/policies/policy.rb +0 -2
- data/lib/tcell_agent/policies/rust_policies.rb +24 -29
- data/lib/tcell_agent/rails.rb +2 -3
- data/lib/tcell_agent/rails/auth/authlogic.rb +2 -2
- data/lib/tcell_agent/rails/auth/devise.rb +2 -2
- data/lib/tcell_agent/rails/auth/doorkeeper.rb +2 -2
- data/lib/tcell_agent/rails/better_ip.rb +12 -16
- data/lib/tcell_agent/rails/csrf_exception.rb +4 -7
- data/lib/tcell_agent/rails/dlp.rb +208 -107
- data/lib/tcell_agent/rails/dlp/process_request.rb +37 -47
- data/lib/tcell_agent/rails/dlp_handler.rb +9 -11
- data/lib/tcell_agent/rails/js_agent_insert.rb +11 -14
- data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +8 -7
- data/lib/tcell_agent/rails/middleware/context_middleware.rb +4 -5
- data/lib/tcell_agent/rails/middleware/global_middleware.rb +5 -8
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +24 -27
- data/lib/tcell_agent/rails/on_start.rb +5 -5
- data/lib/tcell_agent/rails/responses.rb +7 -9
- data/lib/tcell_agent/rails/routes.rb +62 -81
- data/lib/tcell_agent/rails/routes/grape.rb +25 -30
- data/lib/tcell_agent/rails/routes/route_id.rb +9 -14
- data/lib/tcell_agent/rails/settings_reporter.rb +44 -33
- data/lib/tcell_agent/rails/tcell_body_proxy.rb +15 -18
- data/lib/tcell_agent/routes/table.rb +31 -33
- data/lib/tcell_agent/rust/{libtcellagent-1.3.0.dylib → libtcellagent-1.3.1.dylib} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-1.3.0.so → libtcellagent-1.3.1.so} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-alpine-1.3.0.so → libtcellagent-alpine-1.3.1.so} +0 -0
- data/lib/tcell_agent/rust/models.rb +32 -37
- data/lib/tcell_agent/rust/tcellagent-1.3.1.dll +0 -0
- data/lib/tcell_agent/rust/whisperer.rb +101 -104
- data/lib/tcell_agent/sensor_events/app_config.rb +7 -7
- data/lib/tcell_agent/sensor_events/appsensor_event.rb +26 -27
- data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +20 -88
- data/lib/tcell_agent/sensor_events/command_injection.rb +52 -80
- data/lib/tcell_agent/sensor_events/discovery.rb +27 -27
- data/lib/tcell_agent/sensor_events/dlp.rb +50 -56
- data/lib/tcell_agent/sensor_events/honeytokens.rb +9 -9
- data/lib/tcell_agent/sensor_events/metrics.rb +20 -21
- data/lib/tcell_agent/sensor_events/patches.rb +10 -12
- data/lib/tcell_agent/sensor_events/sensor.rb +32 -36
- data/lib/tcell_agent/sensor_events/server_agent.rb +130 -127
- data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +60 -80
- data/lib/tcell_agent/sensor_events/util/utils.rb +3 -5
- data/lib/tcell_agent/servers/passenger.rb +5 -9
- data/lib/tcell_agent/servers/puma.rb +18 -27
- data/lib/tcell_agent/servers/rails_server.rb +5 -9
- data/lib/tcell_agent/servers/thin.rb +2 -4
- data/lib/tcell_agent/servers/unicorn.rb +18 -27
- data/lib/tcell_agent/servers/webrick.rb +2 -4
- data/lib/tcell_agent/settings_reporter.rb +126 -0
- data/lib/tcell_agent/sinatra.rb +24 -26
- data/lib/tcell_agent/start_background_thread.rb +21 -142
- data/lib/tcell_agent/system_info.rb +4 -3
- data/lib/tcell_agent/tcell_context.rb +150 -0
- data/lib/tcell_agent/userinfo.rb +3 -3
- data/lib/tcell_agent/utils/io.rb +19 -24
- data/lib/tcell_agent/utils/params.rb +9 -15
- data/lib/tcell_agent/utils/queue_with_timeout.rb +26 -32
- data/lib/tcell_agent/utils/strings.rb +4 -6
- data/lib/tcell_agent/version.rb +1 -1
- data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +5 -5
- data/spec/lib/tcell_agent/agent/static_agent_spec.rb +7 -7
- data/spec/lib/tcell_agent/cmdi_spec.rb +21 -21
- data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +29 -24
- data/spec/lib/tcell_agent/instrumentation_spec.rb +4 -4
- data/spec/lib/tcell_agent/patches_spec.rb +8 -8
- data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +23 -23
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +2 -2
- data/spec/lib/tcell_agent/rails/csrf_exception_spec.rb +69 -0
- data/spec/lib/tcell_agent/rails/dlp_spec.rb +1039 -0
- data/spec/lib/tcell_agent/rails/js_agent_insert_spec.rb +271 -0
- data/spec/lib/tcell_agent/rails/logger_spec.rb +5 -5
- data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +3 -3
- data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +4 -4
- data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +5 -5
- data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +1 -1
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +11 -8
- data/spec/lib/tcell_agent/rails/responses_spec.rb +2 -2
- data/spec/lib/tcell_agent/rails/routes/grape_spec.rb +2 -2
- data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +1 -1
- data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +4 -4
- data/spec/lib/tcell_agent/rust/models_spec.rb +83 -75
- data/spec/lib/tcell_agent/rust/whisperer_spec.rb +14 -14
- data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +19 -70
- data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +1 -1
- data/spec/lib/tcell_agent/settings_reporter_spec.rb +162 -0
- data/spec/lib/tcell_agent/tcell_context_spec.rb +154 -0
- data/spec/spec_helper.rb +5 -0
- metadata +18 -10
- data/lib/tcell_agent/appsensor/meta_data.rb +0 -132
- data/lib/tcell_agent/patches/meta_data.rb +0 -59
- data/lib/tcell_agent/rust/tcellagent-1.3.0.dll +0 -0
- data/spec/lib/tcell_agent/appsensor/meta_data_spec.rb +0 -71
@@ -35,7 +35,7 @@ module TCellAgent
|
|
35
35
|
it 'should report the login failure' do
|
36
36
|
login_fraud = double('login_fraud', :enabled => true, :login_failed_enabled => true)
|
37
37
|
|
38
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
38
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
39
39
|
login_fraud
|
40
40
|
)
|
41
41
|
expect(TCellAgent).to receive(:send_event).with(
|
@@ -43,7 +43,7 @@ module TCellAgent
|
|
43
43
|
'event_type' => 'login',
|
44
44
|
'header_keys' => %w[USER_AGENT X_FORWARDED_FOR],
|
45
45
|
'user_agent' => 'user_agent',
|
46
|
-
'referrer' => '
|
46
|
+
'referrer' => 'http://tcell.tcell.io/?utm_campaign=',
|
47
47
|
'remote_addr' => '1.1.1.1',
|
48
48
|
'user_id' => 'user_id',
|
49
49
|
'document_uri' => 'http://tcell.tcell.io/login?param_name=',
|
@@ -55,9 +55,10 @@ module TCellAgent
|
|
55
55
|
status = Hooks::V1::Login::LOGIN_FAILURE
|
56
56
|
header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
|
57
57
|
document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
|
58
|
+
referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
58
59
|
|
59
60
|
Hooks::V1::Login.register_login_event(
|
60
|
-
status, 'session_id', 'user_agent',
|
61
|
+
status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
|
61
62
|
)
|
62
63
|
end
|
63
64
|
end
|
@@ -66,7 +67,7 @@ module TCellAgent
|
|
66
67
|
it 'should NOT report the login failure' do
|
67
68
|
login_fraud = double('login_fraud', :enabled => true, :login_failed_enabled => false)
|
68
69
|
|
69
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
70
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
70
71
|
login_fraud
|
71
72
|
)
|
72
73
|
expect(TCellAgent).to_not receive(:send_event)
|
@@ -74,9 +75,10 @@ module TCellAgent
|
|
74
75
|
status = Hooks::V1::Login::LOGIN_FAILURE
|
75
76
|
header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
|
76
77
|
document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
|
78
|
+
referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
77
79
|
|
78
80
|
Hooks::V1::Login.register_login_event(
|
79
|
-
status, 'session_id', 'user_agent',
|
81
|
+
status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
|
80
82
|
)
|
81
83
|
end
|
82
84
|
end
|
@@ -87,7 +89,7 @@ module TCellAgent
|
|
87
89
|
it 'should report the login success' do
|
88
90
|
login_fraud = double('login_fraud', :enabled => true, :login_success_enabled => true)
|
89
91
|
|
90
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
92
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
91
93
|
login_fraud
|
92
94
|
)
|
93
95
|
expect(TCellAgent).to receive(:send_event).with(
|
@@ -95,7 +97,7 @@ module TCellAgent
|
|
95
97
|
'event_type' => 'login',
|
96
98
|
'header_keys' => %w[USER_AGENT X_FORWARDED_FOR],
|
97
99
|
'user_agent' => 'user_agent',
|
98
|
-
'referrer' => '
|
100
|
+
'referrer' => 'http://tcell.tcell.io/?utm_campaign=',
|
99
101
|
'remote_addr' => '1.1.1.1',
|
100
102
|
'user_id' => 'user_id',
|
101
103
|
'document_uri' => 'http://tcell.tcell.io/login?param_name=',
|
@@ -107,9 +109,10 @@ module TCellAgent
|
|
107
109
|
status = Hooks::V1::Login::LOGIN_SUCCESS
|
108
110
|
header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
|
109
111
|
document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
|
112
|
+
referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
110
113
|
|
111
114
|
Hooks::V1::Login.register_login_event(
|
112
|
-
status, 'session_id', 'user_agent',
|
115
|
+
status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
|
113
116
|
)
|
114
117
|
end
|
115
118
|
end
|
@@ -118,7 +121,7 @@ module TCellAgent
|
|
118
121
|
it 'should NOT report the login success' do
|
119
122
|
login_fraud = double('login_fraud', :enabled => true, :login_success_enabled => false)
|
120
123
|
|
121
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
124
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
122
125
|
login_fraud
|
123
126
|
)
|
124
127
|
expect(TCellAgent).to_not receive(:send_event)
|
@@ -126,9 +129,10 @@ module TCellAgent
|
|
126
129
|
status = Hooks::V1::Login::LOGIN_SUCCESS
|
127
130
|
header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
|
128
131
|
document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
|
132
|
+
referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
129
133
|
|
130
134
|
Hooks::V1::Login.register_login_event(
|
131
|
-
status, 'session_id', 'user_agent',
|
135
|
+
status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
|
132
136
|
)
|
133
137
|
end
|
134
138
|
end
|
@@ -139,7 +143,7 @@ module TCellAgent
|
|
139
143
|
login_fraud = double('login_fraud', :enabled => true)
|
140
144
|
logger = double('logger')
|
141
145
|
|
142
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
146
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
143
147
|
login_fraud
|
144
148
|
)
|
145
149
|
expect(TCellAgent).to_not receive(:send_event)
|
@@ -149,9 +153,10 @@ module TCellAgent
|
|
149
153
|
status = 'mumbo-jumbo'
|
150
154
|
header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
|
151
155
|
document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
|
156
|
+
referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
152
157
|
|
153
158
|
Hooks::V1::Login.register_login_event(
|
154
|
-
status, 'session_id', 'user_agent',
|
159
|
+
status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
|
155
160
|
)
|
156
161
|
end
|
157
162
|
end
|
@@ -165,7 +170,7 @@ module TCellAgent
|
|
165
170
|
rails_request = double('rails_request')
|
166
171
|
tcell_data = TCellAgent::Instrumentation::TCellData.new
|
167
172
|
tcell_data.user_agent = 'user_agent'
|
168
|
-
tcell_data.referrer = '
|
173
|
+
tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
169
174
|
tcell_data.ip_address = '1.1.1.1'
|
170
175
|
tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
|
171
176
|
tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
|
@@ -175,7 +180,7 @@ module TCellAgent
|
|
175
180
|
'HTTP_X_FORWARDED_FOR' => true
|
176
181
|
}
|
177
182
|
|
178
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
183
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
179
184
|
login_fraud
|
180
185
|
)
|
181
186
|
expect(rails_request).to receive(:env).and_return(request_env)
|
@@ -185,7 +190,7 @@ module TCellAgent
|
|
185
190
|
'event_type' => 'login',
|
186
191
|
'header_keys' => %w[USER_AGENT X_FORWARDED_FOR],
|
187
192
|
'user_agent' => 'user_agent',
|
188
|
-
'referrer' => '
|
193
|
+
'referrer' => 'http://tcell.tcell.io/?utm_campaign=',
|
189
194
|
'remote_addr' => '1.1.1.1',
|
190
195
|
'user_id' => 'user_id',
|
191
196
|
'document_uri' => 'http://tcell.tcell.io/login?param_name=',
|
@@ -208,7 +213,7 @@ module TCellAgent
|
|
208
213
|
rails_request = double('rails_request')
|
209
214
|
tcell_data = TCellAgent::Instrumentation::TCellData.new
|
210
215
|
tcell_data.user_agent = 'user_agent'
|
211
|
-
tcell_data.referrer = '
|
216
|
+
tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign='
|
212
217
|
tcell_data.ip_address = '1.1.1.1'
|
213
218
|
tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
|
214
219
|
tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
|
@@ -218,7 +223,7 @@ module TCellAgent
|
|
218
223
|
'HTTP_X_FORWARDED_FOR' => true
|
219
224
|
}
|
220
225
|
|
221
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
226
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
222
227
|
login_fraud
|
223
228
|
)
|
224
229
|
expect(rails_request).to receive(:env).and_return(request_env)
|
@@ -241,7 +246,7 @@ module TCellAgent
|
|
241
246
|
rails_request = double('rails_request')
|
242
247
|
tcell_data = TCellAgent::Instrumentation::TCellData.new
|
243
248
|
tcell_data.user_agent = 'user_agent'
|
244
|
-
tcell_data.referrer = '
|
249
|
+
tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
245
250
|
tcell_data.ip_address = '1.1.1.1'
|
246
251
|
tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
|
247
252
|
tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
|
@@ -251,7 +256,7 @@ module TCellAgent
|
|
251
256
|
'HTTP_X_FORWARDED_FOR' => true
|
252
257
|
}
|
253
258
|
|
254
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
259
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
255
260
|
login_fraud
|
256
261
|
)
|
257
262
|
expect(rails_request).to receive(:env).and_return(request_env)
|
@@ -261,7 +266,7 @@ module TCellAgent
|
|
261
266
|
'event_type' => 'login',
|
262
267
|
'header_keys' => %w[USER_AGENT X_FORWARDED_FOR],
|
263
268
|
'user_agent' => 'user_agent',
|
264
|
-
'referrer' => '
|
269
|
+
'referrer' => 'http://tcell.tcell.io/?utm_campaign=',
|
265
270
|
'remote_addr' => '1.1.1.1',
|
266
271
|
'user_id' => 'user_id',
|
267
272
|
'document_uri' => 'http://tcell.tcell.io/login?param_name=',
|
@@ -284,7 +289,7 @@ module TCellAgent
|
|
284
289
|
rails_request = double('rails_request')
|
285
290
|
tcell_data = TCellAgent::Instrumentation::TCellData.new
|
286
291
|
tcell_data.user_agent = 'user_agent'
|
287
|
-
tcell_data.referrer = '
|
292
|
+
tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
288
293
|
tcell_data.ip_address = '1.1.1.1'
|
289
294
|
tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
|
290
295
|
tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
|
@@ -294,7 +299,7 @@ module TCellAgent
|
|
294
299
|
'HTTP_X_FORWARDED_FOR' => true
|
295
300
|
}
|
296
301
|
|
297
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
302
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
298
303
|
login_fraud
|
299
304
|
)
|
300
305
|
expect(rails_request).to receive(:env).and_return(request_env)
|
@@ -317,7 +322,7 @@ module TCellAgent
|
|
317
322
|
rails_request = double('rails_request')
|
318
323
|
tcell_data = TCellAgent::Instrumentation::TCellData.new
|
319
324
|
tcell_data.user_agent = 'user_agent'
|
320
|
-
tcell_data.referrer = '
|
325
|
+
tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
|
321
326
|
tcell_data.ip_address = '1.1.1.1'
|
322
327
|
tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
|
323
328
|
tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
|
@@ -327,7 +332,7 @@ module TCellAgent
|
|
327
332
|
'HTTP_X_FORWARDED_FOR' => true
|
328
333
|
}
|
329
334
|
|
330
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::
|
335
|
+
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
|
331
336
|
login_fraud
|
332
337
|
)
|
333
338
|
expect(rails_request).to receive(:env).and_return(request_env)
|
@@ -41,7 +41,7 @@ module TCellAgent
|
|
41
41
|
}
|
42
42
|
session_id_policy = TCellAgent::Policies::DataLossPolicy.from_json(policy_json_two)
|
43
43
|
mock_agent = MockAgent.new(-1)
|
44
|
-
mock_agent.policies[TCellAgent::PolicyTypes::
|
44
|
+
mock_agent.policies[TCellAgent::PolicyTypes::DATALOSS] = session_id_policy
|
45
45
|
TCellAgent.set_thread_agent(mock_agent)
|
46
46
|
|
47
47
|
context = TCellData.new
|
@@ -66,7 +66,7 @@ module TCellAgent
|
|
66
66
|
}
|
67
67
|
session_id_policy = TCellAgent::Policies::DataLossPolicy.from_json(policy_json_two)
|
68
68
|
mock_agent = MockAgent.new(-1)
|
69
|
-
mock_agent.policies[TCellAgent::PolicyTypes::
|
69
|
+
mock_agent.policies[TCellAgent::PolicyTypes::DATALOSS] = session_id_policy
|
70
70
|
TCellAgent.set_thread_agent(mock_agent)
|
71
71
|
|
72
72
|
context = TCellData.new
|
@@ -93,7 +93,7 @@ module TCellAgent
|
|
93
93
|
}
|
94
94
|
session_id_policy = TCellAgent::Policies::DataLossPolicy.from_json(policy_json_two)
|
95
95
|
mock_agent = MockAgent.new(-1)
|
96
|
-
mock_agent.policies[TCellAgent::PolicyTypes::
|
96
|
+
mock_agent.policies[TCellAgent::PolicyTypes::DATALOSS] = session_id_policy
|
97
97
|
TCellAgent.set_thread_agent(mock_agent)
|
98
98
|
|
99
99
|
context = TCellData.new
|
@@ -118,7 +118,7 @@ module TCellAgent
|
|
118
118
|
}
|
119
119
|
session_id_policy = TCellAgent::Policies::DataLossPolicy.from_json(policy_json_two)
|
120
120
|
mock_agent = MockAgent.new(-1)
|
121
|
-
mock_agent.policies[TCellAgent::PolicyTypes::
|
121
|
+
mock_agent.policies[TCellAgent::PolicyTypes::DATALOSS] = session_id_policy
|
122
122
|
TCellAgent.set_thread_agent(mock_agent)
|
123
123
|
|
124
124
|
context = TCellData.new
|
@@ -24,9 +24,9 @@ module TCellAgent
|
|
24
24
|
logger = double('logger')
|
25
25
|
request = double('request')
|
26
26
|
expect(TCellAgent).to receive(:policy).with(
|
27
|
-
TCellAgent::PolicyTypes::
|
27
|
+
TCellAgent::PolicyTypes::RUST
|
28
28
|
).and_raise(StandardError.new('UNEXPECTED'))
|
29
|
-
expect(TCellAgent::
|
29
|
+
expect(TCellAgent::MetaData).to_not receive(:from_request)
|
30
30
|
expect(TCellAgent).to receive(:logger).and_return(logger).twice
|
31
31
|
expect(logger).to receive(:debug).with(
|
32
32
|
'Exception in safe_block Checking patches blocking: StandardError happened, message is UNEXPECTED'
|
@@ -41,7 +41,7 @@ module TCellAgent
|
|
41
41
|
it 'should return false' do
|
42
42
|
request = double('request')
|
43
43
|
expect(TCellAgent).to receive(:policy).and_return(nil)
|
44
|
-
expect(TCellAgent::
|
44
|
+
expect(TCellAgent::MetaData).to_not receive(:from_request)
|
45
45
|
|
46
46
|
expect(Patches.block?(request)).to eq(false)
|
47
47
|
end
|
@@ -53,7 +53,7 @@ module TCellAgent
|
|
53
53
|
expect(@rust_policies.patches_enabled).to eq(false)
|
54
54
|
|
55
55
|
expect(TCellAgent).to receive(:policy).and_return(@rust_policies)
|
56
|
-
expect(TCellAgent::
|
56
|
+
expect(TCellAgent::MetaData).to_not receive(:from_request)
|
57
57
|
|
58
58
|
expect(Patches.block?(request)).to eq(false)
|
59
59
|
end
|
@@ -73,7 +73,7 @@ module TCellAgent
|
|
73
73
|
TCellAgent::Instrumentation::TCELL_ID => tcell_context
|
74
74
|
}
|
75
75
|
)
|
76
|
-
expect(TCellAgent::
|
76
|
+
expect(TCellAgent::MetaData).to receive(:from_request).and_return(
|
77
77
|
meta_data
|
78
78
|
)
|
79
79
|
|
@@ -92,7 +92,7 @@ module TCellAgent
|
|
92
92
|
expect(TCellAgent).to receive(:policy).and_return(@rust_policies)
|
93
93
|
expect(@rust_policies).to receive(:patches_enabled).and_return(true)
|
94
94
|
expect(@rust_policies).to receive(:block_request?).and_return(true)
|
95
|
-
expect(TCellAgent::
|
95
|
+
expect(TCellAgent::MetaData).to receive(:from_request).and_return(
|
96
96
|
meta_data
|
97
97
|
)
|
98
98
|
expect(request).to receive(:env).and_return({ TCellAgent::Instrumentation::TCELL_ID => tcell_context })
|
@@ -105,7 +105,7 @@ module TCellAgent
|
|
105
105
|
context "and that's complex" do
|
106
106
|
it 'should return a response' do
|
107
107
|
request = double('request')
|
108
|
-
meta_data = TCellAgent::
|
108
|
+
meta_data = TCellAgent::MetaData.new(
|
109
109
|
'get',
|
110
110
|
'2.3.4.5',
|
111
111
|
'route_id',
|
@@ -122,7 +122,7 @@ module TCellAgent
|
|
122
122
|
expect(TCellAgent).to receive(:policy).and_return(@rust_policies)
|
123
123
|
expect(@rust_policies).to receive(:patches_enabled).and_return(true)
|
124
124
|
expect(@rust_policies).to receive(:block_request?).and_return(true)
|
125
|
-
expect(TCellAgent::
|
125
|
+
expect(TCellAgent::MetaData).to receive(:from_request).and_return(
|
126
126
|
meta_data
|
127
127
|
)
|
128
128
|
expect(request).to receive(:env).and_return({ TCellAgent::Instrumentation::TCELL_ID => tcell_context })
|
@@ -266,7 +266,7 @@ module TCellAgent
|
|
266
266
|
expect(TCellAgent).to receive(:configuration).and_return(configuration).at_least(:once)
|
267
267
|
@rust_policies = RustPolicies.new
|
268
268
|
@rust_policies.update_policies(everything_enabled_policy_json)
|
269
|
-
@
|
269
|
+
@meta_data = TCellAgent::MetaData.new(
|
270
270
|
'GET',
|
271
271
|
'192.168.1.1',
|
272
272
|
'12345',
|
@@ -275,8 +275,8 @@ module TCellAgent
|
|
275
275
|
'transaction_id',
|
276
276
|
'http://test.com/?some_param=present'
|
277
277
|
)
|
278
|
-
@
|
279
|
-
@
|
278
|
+
@meta_data.user_agent = 'Mozilla'
|
279
|
+
@meta_data.response_code = 200
|
280
280
|
end
|
281
281
|
|
282
282
|
context 'csrf exception' do
|
@@ -284,9 +284,9 @@ module TCellAgent
|
|
284
284
|
it 'should not send an event' do
|
285
285
|
expect(TCellAgent).to_not receive(:send_event)
|
286
286
|
|
287
|
-
@
|
287
|
+
@meta_data.csrf_exception_name = nil
|
288
288
|
@rust_policies.check_appfirewall_injections(
|
289
|
-
@
|
289
|
+
@meta_data
|
290
290
|
)
|
291
291
|
end
|
292
292
|
end
|
@@ -295,9 +295,9 @@ module TCellAgent
|
|
295
295
|
it 'should not send an event' do
|
296
296
|
expect(TCellAgent).to_not receive(:send_event)
|
297
297
|
|
298
|
-
@
|
298
|
+
@meta_data.csrf_exception_name = ''
|
299
299
|
@rust_policies.check_appfirewall_injections(
|
300
|
-
@
|
300
|
+
@meta_data
|
301
301
|
)
|
302
302
|
end
|
303
303
|
end
|
@@ -319,9 +319,9 @@ module TCellAgent
|
|
319
319
|
}
|
320
320
|
)
|
321
321
|
|
322
|
-
@
|
322
|
+
@meta_data.csrf_exception_name = 'ActionController::InvalidAuthenticityToken'
|
323
323
|
@rust_policies.check_appfirewall_injections(
|
324
|
-
@
|
324
|
+
@meta_data
|
325
325
|
)
|
326
326
|
end
|
327
327
|
end
|
@@ -332,9 +332,9 @@ module TCellAgent
|
|
332
332
|
it 'should not send an event' do
|
333
333
|
expect(TCellAgent).to_not receive(:send_event)
|
334
334
|
|
335
|
-
@
|
335
|
+
@meta_data.sql_exceptions = []
|
336
336
|
@rust_policies.check_appfirewall_injections(
|
337
|
-
@
|
337
|
+
@meta_data
|
338
338
|
)
|
339
339
|
end
|
340
340
|
end
|
@@ -361,12 +361,12 @@ module TCellAgent
|
|
361
361
|
}
|
362
362
|
)
|
363
363
|
|
364
|
-
@
|
364
|
+
@meta_data.sql_exceptions = [{
|
365
365
|
'exception_name' => 'ActiveRecord::StatementInvalid',
|
366
366
|
'exception_payload' => 'exception message goes here'
|
367
367
|
}]
|
368
368
|
@rust_policies.check_appfirewall_injections(
|
369
|
-
@
|
369
|
+
@meta_data
|
370
370
|
)
|
371
371
|
end
|
372
372
|
end
|
@@ -408,7 +408,7 @@ module TCellAgent
|
|
408
408
|
}
|
409
409
|
)
|
410
410
|
|
411
|
-
@
|
411
|
+
@meta_data.sql_exceptions = [
|
412
412
|
{
|
413
413
|
'exception_name' => 'ActiveRecord::StatementInvalid',
|
414
414
|
'exception_payload' => 'exception message goes here'
|
@@ -419,7 +419,7 @@ module TCellAgent
|
|
419
419
|
}
|
420
420
|
]
|
421
421
|
@rust_policies.check_appfirewall_injections(
|
422
|
-
@
|
422
|
+
@meta_data
|
423
423
|
)
|
424
424
|
end
|
425
425
|
end
|
@@ -430,9 +430,9 @@ module TCellAgent
|
|
430
430
|
it 'should not send an event' do
|
431
431
|
expect(TCellAgent).to_not receive(:send_event)
|
432
432
|
|
433
|
-
@
|
433
|
+
@meta_data.database_result_sizes = nil
|
434
434
|
@rust_policies.check_appfirewall_injections(
|
435
|
-
@
|
435
|
+
@meta_data
|
436
436
|
)
|
437
437
|
end
|
438
438
|
end
|
@@ -441,9 +441,9 @@ module TCellAgent
|
|
441
441
|
it 'should not send an event' do
|
442
442
|
expect(TCellAgent).to_not receive(:send_event)
|
443
443
|
|
444
|
-
@
|
444
|
+
@meta_data.database_result_sizes = []
|
445
445
|
@rust_policies.check_appfirewall_injections(
|
446
|
-
@
|
446
|
+
@meta_data
|
447
447
|
)
|
448
448
|
end
|
449
449
|
end
|
@@ -465,9 +465,9 @@ module TCellAgent
|
|
465
465
|
}
|
466
466
|
)
|
467
467
|
|
468
|
-
@
|
468
|
+
@meta_data.database_result_sizes = [1001]
|
469
469
|
@rust_policies.check_appfirewall_injections(
|
470
|
-
@
|
470
|
+
@meta_data
|
471
471
|
)
|
472
472
|
end
|
473
473
|
end
|
@@ -503,9 +503,9 @@ module TCellAgent
|
|
503
503
|
}
|
504
504
|
)
|
505
505
|
|
506
|
-
@
|
506
|
+
@meta_data.database_result_sizes = [1001, 1002]
|
507
507
|
@rust_policies.check_appfirewall_injections(
|
508
|
-
@
|
508
|
+
@meta_data
|
509
509
|
)
|
510
510
|
end
|
511
511
|
end
|