tcell_agent 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -7,7 +7,7 @@ module TCellAgent
|
|
7
7
|
context 'with nil status code' do
|
8
8
|
context 'with empty headers' do
|
9
9
|
it 'should return false' do
|
10
|
-
expect(Rails.empty_content?(nil, {})).to eq(
|
10
|
+
expect(Rails.empty_content?(nil, {})).to eq(nil)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -52,7 +52,7 @@ module TCellAgent
|
|
52
52
|
context 'that contains content' do
|
53
53
|
context 'with empty headers' do
|
54
54
|
it 'should return false' do
|
55
|
-
expect(Rails.empty_content?(200, {})).to eq(
|
55
|
+
expect(Rails.empty_content?(200, {})).to eq(nil)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -197,14 +197,14 @@ module TCellAgent
|
|
197
197
|
describe '.instrument_grape_api' do
|
198
198
|
context 'with nil routes' do
|
199
199
|
it 'should not send any events' do
|
200
|
-
expect(TCellAgent::SensorEvents::Util).to_not receive(:
|
200
|
+
expect(TCellAgent::SensorEvents::Util).to_not receive(:calculate_route_id)
|
201
201
|
TCellAgent::Instrumentation.instrument_grape_api('/api', nil)
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
205
|
context 'with empty routes' do
|
206
206
|
it 'should not send any events' do
|
207
|
-
expect(TCellAgent::SensorEvents::Util).to_not receive(:
|
207
|
+
expect(TCellAgent::SensorEvents::Util).to_not receive(:calculate_route_id)
|
208
208
|
TCellAgent::Instrumentation.instrument_grape_api('/api', [])
|
209
209
|
end
|
210
210
|
end
|
@@ -44,7 +44,7 @@ module TCellAgent
|
|
44
44
|
RouteId.update_context({ TCELL_CONTEXT_KEY => tcell_context }, { :id => 1 }, route)
|
45
45
|
|
46
46
|
expect(tcell_context.route_id).to eq(
|
47
|
-
TCellAgent::SensorEvents::Util.
|
47
|
+
TCellAgent::SensorEvents::Util.calculate_route_id('GET', '/some/regular/path')
|
48
48
|
)
|
49
49
|
expect(tcell_context.grape_mount_endpoint).to eq(nil)
|
50
50
|
expect(tcell_context.path_parameters).to eq({ :id => 1 })
|
@@ -21,7 +21,7 @@ module TCellAgent
|
|
21
21
|
|
22
22
|
expect(TCellAgent).to receive(:configuration).and_return(configuration).twice
|
23
23
|
expect(TCellAgent::Instrumentation).to_not receive(:instrument_grape_api)
|
24
|
-
expect(TCellAgent::SensorEvents::Util).to_not receive(:
|
24
|
+
expect(TCellAgent::SensorEvents::Util).to_not receive(:calculate_route_id)
|
25
25
|
|
26
26
|
Rails.instrument_route(nil)
|
27
27
|
end
|
@@ -69,7 +69,7 @@ module TCellAgent
|
|
69
69
|
|
70
70
|
expect(TCellAgent).to receive(:configuration).and_return(configuration).twice
|
71
71
|
expect(route).to receive(:verb).and_return('GET|POST')
|
72
|
-
expect(TCellAgent::SensorEvents::Util).to_not receive(:
|
72
|
+
expect(TCellAgent::SensorEvents::Util).to_not receive(:calculate_route_id)
|
73
73
|
expect(TCellAgent::Instrumentation).to receive(:instrument_grape_api).with(
|
74
74
|
'/grape', ['/api/grape/route']
|
75
75
|
)
|
@@ -123,7 +123,7 @@ module TCellAgent
|
|
123
123
|
expect(TCellAgent::Instrumentation).to receive(:instrument_grape_api).with(
|
124
124
|
'/grape', ['/api/grape/route']
|
125
125
|
)
|
126
|
-
expect(TCellAgent::SensorEvents::Util).to_not receive(:
|
126
|
+
expect(TCellAgent::SensorEvents::Util).to_not receive(:calculate_route_id)
|
127
127
|
|
128
128
|
Rails.instrument_route(route)
|
129
129
|
end
|
@@ -173,7 +173,7 @@ module TCellAgent
|
|
173
173
|
expect(TCellAgent::Instrumentation).to receive(:instrument_grape_api).with(
|
174
174
|
'/grape', ['/api/grape/route']
|
175
175
|
)
|
176
|
-
expect(TCellAgent::SensorEvents::Util).to_not receive(:
|
176
|
+
expect(TCellAgent::SensorEvents::Util).to_not receive(:calculate_route_id)
|
177
177
|
|
178
178
|
Rails.instrument_route(route)
|
179
179
|
end
|
@@ -5,7 +5,7 @@ module TCellAgent
|
|
5
5
|
module Rust
|
6
6
|
describe '.create_request_response' do
|
7
7
|
it 'should create request response' do
|
8
|
-
|
8
|
+
meta_data = TCellAgent::MetaData.new(
|
9
9
|
'GET',
|
10
10
|
'192.168.1.1',
|
11
11
|
'12345',
|
@@ -14,66 +14,70 @@ module TCellAgent
|
|
14
14
|
'transaction_id',
|
15
15
|
'http://192.168.1.1/some/path?xss_param=<script>'
|
16
16
|
)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
appsensor_meta.set_headers_dict({ 'HTTP_XSS_PARAM' => '<script>' })
|
17
|
+
meta_data.response_code = 200
|
18
|
+
meta_data.user_agent = 'Mozilla'
|
19
|
+
meta_data.path = '/some/path'
|
20
|
+
meta_data.request_content_bytes_len = 1024
|
21
|
+
meta_data.response_content_bytes_len = 2048
|
22
|
+
meta_data.get_dict = { 'user' => { 'xss_param' => '<script>' } }
|
23
|
+
meta_data.sql_exceptions = [{ 'exception_name' => 'OperationalError', 'exception_payload' => 'Developer Error' }]
|
24
|
+
meta_data.csrf_exception_name = 'ActionController::InvalidAuthenticityToken'
|
25
|
+
meta_data.path_parameters = { 'xss_param' => '<script>' }
|
26
|
+
meta_data.post_dict = { 'xss_param' => '<script>' }
|
27
|
+
meta_data.cookie_dict = { 'xss_param' => '<script>' }
|
28
|
+
meta_data.headers_dict = { 'HTTP_XSS_PARAM' => '<script>' }
|
30
29
|
|
31
|
-
|
30
|
+
json_body = { 'xss_param' => '<script>' }.to_json
|
31
|
+
meta_data.set_body_dict(json_body.bytesize, 'application/json', json_body)
|
32
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
|
-
|
69
|
-
|
70
|
-
|
33
|
+
result = Models.create_request_response(meta_data)
|
34
|
+
|
35
|
+
expect(result).to eq(
|
36
|
+
{
|
37
|
+
'method' => 'GET',
|
38
|
+
'status_code' => 200,
|
39
|
+
'route_id' => '12345',
|
40
|
+
'path' => '/some/path',
|
41
|
+
'query_params' => [
|
42
|
+
{ 'name' => 'xss_param', 'value' => '<script>' }
|
43
|
+
],
|
44
|
+
'post_params' => [
|
45
|
+
{ 'name' => 'xss_param', 'value' => '<script>' },
|
46
|
+
{ 'name' => 'xss_param', 'value' => '<script>' }
|
47
|
+
],
|
48
|
+
'headers' => [
|
49
|
+
{ 'name' => 'xss-param', 'value' => '<script>' }
|
50
|
+
],
|
51
|
+
'cookies' => [
|
52
|
+
{ 'name' => 'xss_param', 'value' => '<script>' }
|
53
|
+
],
|
54
|
+
'path_params' => [
|
55
|
+
{ 'name' => 'xss_param', 'value' => '<script>' }
|
56
|
+
],
|
57
|
+
'remote_address' => '192.168.1.1',
|
58
|
+
'full_uri' => 'http://192.168.1.1/some/path?xss_param=<script>',
|
59
|
+
'session_id' => 'session_id',
|
60
|
+
'user_id' => 'user_id',
|
61
|
+
'user_agent' => 'Mozilla',
|
62
|
+
'request_bytes_length' => 1024,
|
63
|
+
'response_bytes_length' => 2048,
|
64
|
+
'csrf_exception' => {
|
65
|
+
'exception_name' => 'ActionController::InvalidAuthenticityToken'
|
66
|
+
},
|
67
|
+
'sql_exceptions' => [
|
68
|
+
{
|
69
|
+
'exception_name' => 'OperationalError',
|
70
|
+
'exception_payload' => 'Developer Error'
|
71
|
+
}
|
72
|
+
]
|
73
|
+
}
|
74
|
+
)
|
71
75
|
end
|
72
76
|
end
|
73
77
|
|
74
78
|
describe '.create_patches_request' do
|
75
79
|
it 'should create patches request' do
|
76
|
-
|
80
|
+
meta_data = TCellAgent::MetaData.new(
|
77
81
|
'GET',
|
78
82
|
'192.168.1.1',
|
79
83
|
'12345',
|
@@ -83,29 +87,33 @@ module TCellAgent
|
|
83
87
|
'http://192.168.1.1/some/path?xss_param=<script>'
|
84
88
|
)
|
85
89
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
appsensor_meta.set_headers_dict({ 'HTTP_XSS_PARAM' => '<script>' })
|
90
|
+
meta_data.path = '/some/path'
|
91
|
+
meta_data.request_content_bytes_len = 1024
|
92
|
+
meta_data.get_dict = { 'user' => { 'xss_param' => '<script>' } }
|
93
|
+
meta_data.post_dict = { 'user' => { 'xss_param' => '<script>' } }
|
94
|
+
meta_data.cookie_dict = { 'xss_param' => '<script>' }
|
95
|
+
meta_data.headers_dict = { 'HTTP_XSS_PARAM' => '<script>' }
|
93
96
|
|
94
|
-
|
97
|
+
json_body = { 'user' => { 'xss_param' => '<script>' } }.to_json
|
98
|
+
meta_data.set_body_dict(json_body.bytesize, 'application/json', json_body)
|
95
99
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
100
|
+
result = Models.create_patches_request(meta_data)
|
101
|
+
|
102
|
+
expect(result).to eq(
|
103
|
+
{
|
104
|
+
'method' => 'GET',
|
105
|
+
'path' => '/some/path',
|
106
|
+
'remote_address' => '192.168.1.1',
|
107
|
+
'request_bytes_length' => 1024,
|
108
|
+
'query_params' => [{ 'name' => 'xss_param', 'value' => '<script>' }],
|
109
|
+
'post_params' => [
|
110
|
+
{ 'name' => 'xss_param', 'value' => '<script>' },
|
111
|
+
{ 'name' => 'xss_param', 'value' => '<script>' }
|
112
|
+
],
|
113
|
+
'headers' => [{ 'name' => 'xss-param', 'value' => '<script>' }],
|
114
|
+
'cookies' => [{ 'name' => 'xss_param', 'value' => '<script>' }]
|
115
|
+
}
|
116
|
+
)
|
109
117
|
end
|
110
118
|
end
|
111
119
|
end
|
@@ -602,7 +602,7 @@ module TCellAgent
|
|
602
602
|
end
|
603
603
|
|
604
604
|
it 'should return appfirewall injections' do
|
605
|
-
|
605
|
+
meta_data = TCellAgent::MetaData.new(
|
606
606
|
'GET',
|
607
607
|
'192.168.1.1',
|
608
608
|
'12345',
|
@@ -611,22 +611,22 @@ module TCellAgent
|
|
611
611
|
'transaction_id',
|
612
612
|
'http://192.168.1.1/some/path?xss_param=<script>'
|
613
613
|
)
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
614
|
+
meta_data.path = '/some/path'
|
615
|
+
meta_data.request_content_bytes_len = 1024
|
616
|
+
meta_data.response_content_bytes_len = 2048
|
617
|
+
meta_data.get_dict = { 'xss_param' => '<script>' }
|
618
|
+
meta_data.user_agent = 'Mozilla'
|
619
|
+
meta_data.sql_exceptions = [
|
620
620
|
{
|
621
621
|
'exception_name' => 'OperationalError',
|
622
622
|
'exception_payload' => 'Developer Error'
|
623
623
|
}
|
624
624
|
]
|
625
|
-
|
625
|
+
meta_data.csrf_exception_name = 'ActionController::InvalidAuthenticityToken'
|
626
626
|
|
627
627
|
whisper = Whisperer.apply_appfirewall(
|
628
628
|
@agent_ptr,
|
629
|
-
|
629
|
+
meta_data
|
630
630
|
)
|
631
631
|
expect(whisper).to eq(
|
632
632
|
{
|
@@ -669,7 +669,7 @@ module TCellAgent
|
|
669
669
|
end
|
670
670
|
|
671
671
|
it 'should return patches blocking' do
|
672
|
-
|
672
|
+
meta_data = TCellAgent::MetaData.new(
|
673
673
|
'GET',
|
674
674
|
'192.168.1.1',
|
675
675
|
'12345',
|
@@ -678,12 +678,12 @@ module TCellAgent
|
|
678
678
|
'transaction_id',
|
679
679
|
'http://192.168.1.1/some/path?xss_param=<script>'
|
680
680
|
)
|
681
|
-
|
682
|
-
|
683
|
-
|
681
|
+
meta_data.path = '/some/path'
|
682
|
+
meta_data.request_content_bytes_len = 1024
|
683
|
+
meta_data.get_dict = { 'xss_param' => '<script>' }
|
684
684
|
whisper = Whisperer.apply_patches(
|
685
685
|
@agent_ptr,
|
686
|
-
|
686
|
+
meta_data
|
687
687
|
)
|
688
688
|
expect(whisper).to eq(
|
689
689
|
{
|
@@ -3,9 +3,9 @@ require 'spec_helper'
|
|
3
3
|
module TCellAgent
|
4
4
|
module SensorEvents
|
5
5
|
describe AppSensorMetaEvent do
|
6
|
-
describe '#
|
6
|
+
describe '#post_process' do
|
7
7
|
before(:each) do
|
8
|
-
@
|
8
|
+
@meta_data = TCellAgent::MetaData.new(
|
9
9
|
'get',
|
10
10
|
'remote_address',
|
11
11
|
'route_id',
|
@@ -14,80 +14,29 @@ module TCellAgent
|
|
14
14
|
'transaction_id',
|
15
15
|
'http://test.com'
|
16
16
|
)
|
17
|
+
@appsensor_meta_event = AppSensorMetaEvent.new(@meta_data)
|
17
18
|
end
|
18
19
|
|
19
|
-
context '
|
20
|
-
it 'should
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
{
|
25
|
-
:username => 'tester',
|
26
|
-
:password => 'pass'
|
27
|
-
}.to_json
|
28
|
-
)
|
20
|
+
context 'empty rust policies' do
|
21
|
+
it 'should not process anything' do
|
22
|
+
expect(TCellAgent).to receive(:policy).with(
|
23
|
+
TCellAgent::PolicyTypes::RUST
|
24
|
+
).and_return(nil)
|
29
25
|
|
30
|
-
|
26
|
+
@appsensor_meta_event.post_process
|
31
27
|
end
|
32
28
|
end
|
29
|
+
context 'rust policies available' do
|
30
|
+
it 'should call rust policies for processing' do
|
31
|
+
rust_policies = double('rust_policies')
|
32
|
+
expect(TCellAgent).to receive(:policy).with(
|
33
|
+
TCellAgent::PolicyTypes::RUST
|
34
|
+
).and_return(rust_policies)
|
35
|
+
expect(rust_policies).to receive(:check_appfirewall_injections).with(
|
36
|
+
@appsensor_meta_event.meta_data
|
37
|
+
)
|
33
38
|
|
34
|
-
|
35
|
-
context 'with empty request body' do
|
36
|
-
it 'should set the body params to empty' do
|
37
|
-
@appsensor_meta.set_body_dict(
|
38
|
-
67,
|
39
|
-
'application/json',
|
40
|
-
nil
|
41
|
-
)
|
42
|
-
|
43
|
-
expect(@appsensor_meta.body_dict).to eq({})
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with bad json in the body' do
|
48
|
-
it 'should set the body params to empty' do
|
49
|
-
@appsensor_meta.set_body_dict(
|
50
|
-
67,
|
51
|
-
'application/json',
|
52
|
-
'{"username":"tester""password":"pass"}'
|
53
|
-
)
|
54
|
-
|
55
|
-
expect(@appsensor_meta.body_dict).to eq({})
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'with valid json in the body' do
|
60
|
-
it 'should set the body params' do
|
61
|
-
@appsensor_meta.set_body_dict(
|
62
|
-
67,
|
63
|
-
'application/json',
|
64
|
-
{
|
65
|
-
:username => 'tester',
|
66
|
-
:password => 'pass'
|
67
|
-
}.to_json
|
68
|
-
)
|
69
|
-
|
70
|
-
expect(@appsensor_meta.body_dict).to eq(
|
71
|
-
{
|
72
|
-
['username'] => 'tester',
|
73
|
-
['password'] => 'pass'
|
74
|
-
}
|
75
|
-
)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'with a json body that is too big' do
|
80
|
-
it 'should set the body params to empty' do
|
81
|
-
@appsensor_meta.set_body_dict(
|
82
|
-
20_000_000,
|
83
|
-
'application/json',
|
84
|
-
{
|
85
|
-
:username => 'tester',
|
86
|
-
:password => 'pass'
|
87
|
-
}.to_json
|
88
|
-
)
|
89
|
-
expect(@appsensor_meta.body_dict).to eq({})
|
90
|
-
end
|
39
|
+
@appsensor_meta_event.post_process
|
91
40
|
end
|
92
41
|
end
|
93
42
|
end
|
@@ -19,7 +19,7 @@ module TCellAgent
|
|
19
19
|
sessions_metric = SessionsMetric.new
|
20
20
|
sessions_metric.add_session_info('hmac_session_id', 'user_id', '127.0.0.1', 'user_agent')
|
21
21
|
|
22
|
-
expect(sessions_metric.
|
22
|
+
expect(sessions_metric.sessions?).to eq(true)
|
23
23
|
expect(sessions_metric).to eq(
|
24
24
|
{
|
25
25
|
'event_type' => 'metrics',
|