tcell_agent 1.1.12 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/tcell_agent +26 -14
- data/lib/tcell_agent.rb +16 -10
- data/lib/tcell_agent/agent.rb +78 -97
- data/lib/tcell_agent/agent/route_manager.rb +0 -16
- data/lib/tcell_agent/agent/static_agent.rb +9 -30
- data/lib/tcell_agent/authlogic.rb +3 -6
- data/lib/tcell_agent/config/unknown_options.rb +4 -8
- data/lib/tcell_agent/configuration.rb +38 -119
- data/lib/tcell_agent/devise.rb +25 -27
- data/lib/tcell_agent/hooks/login_fraud.rb +30 -33
- data/lib/tcell_agent/instrument_servers.rb +25 -0
- data/lib/tcell_agent/instrumentation.rb +12 -10
- data/lib/tcell_agent/instrumentation/cmdi.rb +19 -15
- data/lib/tcell_agent/instrumentation/lfi.rb +73 -0
- data/lib/tcell_agent/instrumentation/monkey_patches/file.rb +25 -0
- data/lib/tcell_agent/instrumentation/monkey_patches/io.rb +123 -0
- data/lib/tcell_agent/instrumentation/monkey_patches/kernel.rb +159 -0
- data/lib/tcell_agent/logger.rb +50 -114
- data/lib/tcell_agent/patches.rb +6 -7
- data/lib/tcell_agent/policies/appfirewall_policy.rb +26 -0
- data/lib/tcell_agent/policies/command_injection_policy.rb +28 -0
- data/lib/tcell_agent/policies/dataloss_policy.rb +44 -44
- data/lib/tcell_agent/policies/headers_policy.rb +25 -0
- data/lib/tcell_agent/policies/http_redirect_policy.rb +13 -79
- data/lib/tcell_agent/policies/js_agent_policy.rb +27 -0
- data/lib/tcell_agent/policies/local_file_access.rb +28 -0
- data/lib/tcell_agent/policies/login_policy.rb +43 -0
- data/lib/tcell_agent/policies/patches_policy.rb +27 -0
- data/lib/tcell_agent/policies/policies_manager.rb +68 -0
- data/lib/tcell_agent/policies/policy_polling.rb +58 -0
- data/lib/tcell_agent/policies/policy_types.rb +14 -0
- data/lib/tcell_agent/policies/system_enablements.rb +27 -0
- data/lib/tcell_agent/rails/auth/authlogic.rb +43 -68
- data/lib/tcell_agent/rails/auth/devise.rb +20 -23
- data/lib/tcell_agent/rails/auth/doorkeeper.rb +63 -74
- data/lib/tcell_agent/rails/csrf_exception.rb +2 -2
- data/lib/tcell_agent/rails/dlp.rb +25 -15
- data/lib/tcell_agent/rails/dlp_handler.rb +1 -2
- data/lib/tcell_agent/rails/js_agent_insert.rb +12 -13
- data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +4 -25
- data/lib/tcell_agent/rails/middleware/context_middleware.rb +2 -12
- data/lib/tcell_agent/rails/middleware/global_middleware.rb +0 -1
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +14 -34
- data/lib/tcell_agent/rails/on_start.rb +32 -31
- data/lib/tcell_agent/rails/routes.rb +7 -6
- data/lib/tcell_agent/rails/routes/grape.rb +1 -3
- data/lib/tcell_agent/rails/routes/route_id.rb +3 -1
- data/lib/tcell_agent/rails/settings_reporter.rb +23 -36
- data/lib/tcell_agent/rails/start_agent_after_initializers.rb +12 -0
- data/lib/tcell_agent/rails/tcell_body_proxy.rb +6 -4
- data/lib/tcell_agent/rust/agent_config.rb +49 -0
- data/lib/tcell_agent/rust/{libtcellagent-alpine-1.3.2.so → libtcellagent-4.14.0.dylib} +0 -0
- data/lib/tcell_agent/rust/libtcellagent-4.14.0.so +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-1.3.2.so → libtcellagent-alpine-4.14.0.so} +0 -0
- data/lib/tcell_agent/rust/models.rb +0 -55
- data/lib/tcell_agent/rust/native_agent.rb +531 -0
- data/lib/tcell_agent/rust/native_agent_response.rb +42 -0
- data/lib/tcell_agent/rust/native_library.rb +68 -0
- data/lib/tcell_agent/rust/tcellagent-4.14.0.dll +0 -0
- data/lib/tcell_agent/sensor_events/agent_setting_event.rb +12 -0
- data/lib/tcell_agent/sensor_events/{app_config.rb → app_config_setting_event.rb} +0 -6
- data/lib/tcell_agent/sensor_events/dlp.rb +2 -6
- data/lib/tcell_agent/sensor_events/sensor.rb +0 -62
- data/lib/tcell_agent/sensor_events/server_agent.rb +13 -18
- data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +0 -108
- data/lib/tcell_agent/sensor_events/util/utils.rb +0 -2
- data/lib/tcell_agent/servers/passenger.rb +1 -28
- data/lib/tcell_agent/servers/puma.rb +3 -21
- data/lib/tcell_agent/servers/rails_server.rb +1 -1
- data/lib/tcell_agent/servers/thin.rb +2 -2
- data/lib/tcell_agent/servers/unicorn.rb +19 -80
- data/lib/tcell_agent/servers/webrick.rb +1 -1
- data/lib/tcell_agent/settings_reporter.rb +24 -24
- data/lib/tcell_agent/sinatra.rb +14 -16
- data/lib/tcell_agent/tcell_context.rb +40 -14
- data/lib/tcell_agent/utils/headers.rb +14 -0
- data/lib/tcell_agent/version.rb +1 -1
- data/spec/lib/tcell_agent/cmdi_spec.rb +0 -585
- data/spec/lib/tcell_agent/config/unknown_options_spec.rb +0 -18
- data/spec/lib/tcell_agent/configuration_spec.rb +4 -140
- data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +46 -173
- data/spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb +504 -0
- data/spec/lib/tcell_agent/instrumentation/cmdi/kernel_cmdi_spec.rb +435 -0
- data/spec/lib/tcell_agent/instrumentation/lfi/file_lfi_spec.rb +326 -0
- data/spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb +556 -0
- data/spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb +249 -0
- data/spec/lib/tcell_agent/instrumentation/lfi_spec.rb +105 -0
- data/spec/lib/tcell_agent/patches_spec.rb +25 -43
- data/spec/lib/tcell_agent/policies/appfirewall_policy_spec.rb +183 -0
- data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +57 -0
- data/spec/lib/tcell_agent/policies/command_injection_policy_spec.rb +84 -773
- data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +161 -0
- data/spec/lib/tcell_agent/policies/dataloss_policy_spec.rb +9 -9
- data/spec/lib/tcell_agent/policies/http_redirect_policy_spec.rb +243 -198
- data/spec/lib/tcell_agent/policies/js_agent_policy_spec.rb +75 -0
- data/spec/lib/tcell_agent/policies/login_policy_spec.rb +165 -33
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +84 -277
- data/spec/lib/tcell_agent/policies/policies_manager_spec.rb +104 -0
- data/spec/lib/tcell_agent/policies/policy_polling_spec.rb +6 -0
- data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +56 -0
- data/spec/lib/tcell_agent/rails/csrf_exception_spec.rb +9 -18
- data/spec/lib/tcell_agent/rails/js_agent_insert_spec.rb +13 -30
- data/spec/lib/tcell_agent/rails/logger_spec.rb +27 -7
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +17 -12
- data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +14 -14
- data/spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb +0 -35
- data/spec/lib/tcell_agent/settings_reporter_spec.rb +127 -153
- data/spec/spec_helper.rb +1 -1
- data/spec/support/builders.rb +104 -0
- data/spec/support/force_logger_mocking.rb +38 -0
- data/spec/support/resources/lfi_sample_file.txt +2 -0
- data/spec/support/static_agent_overrides.rb +0 -15
- metadata +63 -74
- data/lib/tcell_agent/agent/event_processor.rb +0 -326
- data/lib/tcell_agent/agent/fork_pipe_manager.rb +0 -113
- data/lib/tcell_agent/agent/policy_manager.rb +0 -219
- data/lib/tcell_agent/agent/policy_types.rb +0 -30
- data/lib/tcell_agent/api.rb +0 -91
- data/lib/tcell_agent/appsensor/injections_reporter.rb +0 -24
- data/lib/tcell_agent/config/child_process_events.rb +0 -8
- data/lib/tcell_agent/instrumentation/cmdi/backtick.rb +0 -10
- data/lib/tcell_agent/instrumentation/cmdi/exec.rb +0 -14
- data/lib/tcell_agent/instrumentation/cmdi/popen.rb +0 -28
- data/lib/tcell_agent/instrumentation/cmdi/spawn.rb +0 -11
- data/lib/tcell_agent/instrumentation/cmdi/system.rb +0 -11
- data/lib/tcell_agent/policies/http_tx_policy.rb +0 -60
- data/lib/tcell_agent/policies/login_fraud_policy.rb +0 -45
- data/lib/tcell_agent/policies/rust_policies.rb +0 -110
- data/lib/tcell_agent/rails.rb +0 -40
- data/lib/tcell_agent/rust/libtcellagent-1.3.2.dylib +0 -0
- data/lib/tcell_agent/rust/tcellagent-1.3.2.dll +0 -0
- data/lib/tcell_agent/rust/whisperer.rb +0 -308
- data/lib/tcell_agent/sensor_events/appsensor_event.rb +0 -52
- data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +0 -45
- data/lib/tcell_agent/sensor_events/command_injection.rb +0 -75
- data/lib/tcell_agent/sensor_events/honeytokens.rb +0 -16
- data/lib/tcell_agent/sensor_events/login_fraud.rb +0 -60
- data/lib/tcell_agent/sensor_events/metrics.rb +0 -123
- data/lib/tcell_agent/sensor_events/patches.rb +0 -21
- data/lib/tcell_agent/start_background_thread.rb +0 -55
- data/lib/tcell_agent/system_info.rb +0 -11
- data/lib/tcell_agent/utils/io.rb +0 -38
- data/lib/tcell_agent/utils/passwords.rb +0 -28
- data/lib/tcell_agent/utils/queue_with_timeout.rb +0 -142
- data/spec/lib/tcell_agent/agent/fork_pipe_manager_spec.rb +0 -100
- data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +0 -535
- data/spec/lib/tcell_agent/agent/static_agent_spec.rb +0 -133
- data/spec/lib/tcell_agent/api/api_spec.rb +0 -39
- data/spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb +0 -187
- data/spec/lib/tcell_agent/instrumentation_spec.rb +0 -225
- data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +0 -517
- data/spec/lib/tcell_agent/policies/http_tx_policy_spec.rb +0 -22
- data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +0 -293
- data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +0 -198
- data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +0 -180
- data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +0 -116
- data/spec/lib/tcell_agent/rust/models_spec.rb +0 -120
- data/spec/lib/tcell_agent/rust/whisperer_spec.rb +0 -704
- data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +0 -45
- data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +0 -272
- data/spec/lib/tcell_agent/utils/bounded_queue_spec.rb +0 -52
- data/spec/lib/tcell_agent/utils/passwords_spec.rb +0 -143
@@ -17,9 +17,9 @@ module TCellAgent
|
|
17
17
|
describe '.instrument_route' do
|
18
18
|
context 'with a nil route' do
|
19
19
|
it "shouldn't be reported" do
|
20
|
-
configuration = double('configuration', :
|
20
|
+
configuration = double('configuration', :should_instrument? => true)
|
21
21
|
|
22
|
-
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
22
|
+
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
23
23
|
expect(TCellAgent::Instrumentation).to_not receive(:instrument_grape_api)
|
24
24
|
expect(TCellAgent::SensorEvents::Util).to_not receive(:calculate_route_id)
|
25
25
|
|
@@ -33,7 +33,7 @@ module TCellAgent
|
|
33
33
|
stub_const('::Rails::VERSION::MAJOR', 5)
|
34
34
|
stub_const('::Rails::VERSION::MINOR', 0)
|
35
35
|
|
36
|
-
configuration = double('configuration', :
|
36
|
+
configuration = double('configuration', :should_instrument? => true)
|
37
37
|
route = double(
|
38
38
|
'route',
|
39
39
|
:path => double('path', :spec => '/regular/route'),
|
@@ -41,7 +41,7 @@ module TCellAgent
|
|
41
41
|
:app => double('app', :app => 'some_app')
|
42
42
|
)
|
43
43
|
|
44
|
-
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
44
|
+
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
45
45
|
expect(route).to receive(:verb).and_return('GET|POST').twice
|
46
46
|
expect(TCellAgent::SensorEvents::AppRoutesSensorEvent).to receive(:new).with(
|
47
47
|
'/regular/route', 'GET', '-1187510355', nil, '{}'
|
@@ -59,7 +59,7 @@ module TCellAgent
|
|
59
59
|
stub_const('::Rails::VERSION::MAJOR', 5)
|
60
60
|
stub_const('::Rails::VERSION::MINOR', 0)
|
61
61
|
|
62
|
-
configuration = double('configuration', :
|
62
|
+
configuration = double('configuration', :should_instrument? => true)
|
63
63
|
route = double(
|
64
64
|
'route',
|
65
65
|
:path => double('path', :spec => '/grape'),
|
@@ -67,7 +67,7 @@ module TCellAgent
|
|
67
67
|
:app => double('app', :app => GrapeRoute)
|
68
68
|
)
|
69
69
|
|
70
|
-
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
70
|
+
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
71
71
|
expect(route).to receive(:verb).and_return('GET|POST')
|
72
72
|
expect(TCellAgent::SensorEvents::Util).to_not receive(:calculate_route_id)
|
73
73
|
expect(TCellAgent::Instrumentation).to receive(:instrument_grape_api).with(
|
@@ -85,7 +85,7 @@ module TCellAgent
|
|
85
85
|
stub_const('::Rails::VERSION::MAJOR', 4)
|
86
86
|
stub_const('::Rails::VERSION::MINOR', 2)
|
87
87
|
|
88
|
-
configuration = double('configuration', :
|
88
|
+
configuration = double('configuration', :should_instrument? => true)
|
89
89
|
route = double(
|
90
90
|
'route',
|
91
91
|
:path => double('path', :spec => '/regular/route'),
|
@@ -94,7 +94,7 @@ module TCellAgent
|
|
94
94
|
:app => double('app', :app => 'some_app')
|
95
95
|
)
|
96
96
|
|
97
|
-
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
97
|
+
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
98
98
|
expect(TCellAgent::Instrumentation).to_not receive(:instrument_grape_api)
|
99
99
|
expect(route).to receive(:verb).and_return(/DELETE/).at_least(9)
|
100
100
|
expect(TCellAgent::SensorEvents::AppRoutesSensorEvent).to receive(:new).with(
|
@@ -110,7 +110,7 @@ module TCellAgent
|
|
110
110
|
stub_const('::Rails::VERSION::MAJOR', 4)
|
111
111
|
stub_const('::Rails::VERSION::MINOR', 2)
|
112
112
|
|
113
|
-
configuration = double('configuration', :
|
113
|
+
configuration = double('configuration', :should_instrument? => true)
|
114
114
|
route = double(
|
115
115
|
'route',
|
116
116
|
:path => double('path', :spec => '/grape'),
|
@@ -119,7 +119,7 @@ module TCellAgent
|
|
119
119
|
:app => double('app', :app => GrapeRoute)
|
120
120
|
)
|
121
121
|
|
122
|
-
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
122
|
+
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
123
123
|
expect(TCellAgent::Instrumentation).to receive(:instrument_grape_api).with(
|
124
124
|
'/grape', ['/api/grape/route']
|
125
125
|
)
|
@@ -136,7 +136,7 @@ module TCellAgent
|
|
136
136
|
stub_const('::Rails::VERSION::MAJOR', 4)
|
137
137
|
stub_const('::Rails::VERSION::MINOR', 1)
|
138
138
|
|
139
|
-
configuration = double('configuration', :
|
139
|
+
configuration = double('configuration', :should_instrument? => true)
|
140
140
|
route = double(
|
141
141
|
'route',
|
142
142
|
:path => double('path', :spec => '/regular/route'),
|
@@ -145,7 +145,7 @@ module TCellAgent
|
|
145
145
|
:app => 'some_app'
|
146
146
|
)
|
147
147
|
|
148
|
-
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
148
|
+
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
149
149
|
expect(TCellAgent::Instrumentation).to_not receive(:instrument_grape_api)
|
150
150
|
expect(route).to receive(:verb).and_return(/PUT/).at_least(9)
|
151
151
|
expect(TCellAgent::SensorEvents::AppRoutesSensorEvent).to receive(:new).with(
|
@@ -160,7 +160,7 @@ module TCellAgent
|
|
160
160
|
it 'should instrument the grape endpoint' do
|
161
161
|
stub_const('::Rails::VERSION::MAJOR', 4)
|
162
162
|
stub_const('::Rails::VERSION::MINOR', 1)
|
163
|
-
configuration = double('configuration', :
|
163
|
+
configuration = double('configuration', :should_instrument? => true)
|
164
164
|
route = double(
|
165
165
|
'route',
|
166
166
|
:path => double('path', :spec => '/grape'),
|
@@ -169,7 +169,7 @@ module TCellAgent
|
|
169
169
|
:app => GrapeRoute
|
170
170
|
)
|
171
171
|
|
172
|
-
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
172
|
+
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
173
173
|
expect(TCellAgent::Instrumentation).to receive(:instrument_grape_api).with(
|
174
174
|
'/grape', ['/api/grape/route']
|
175
175
|
)
|
@@ -17,41 +17,6 @@ module TCellAgent
|
|
17
17
|
TCellAgent.configuration.hmac_key = old_hmac
|
18
18
|
end
|
19
19
|
end
|
20
|
-
context 'Parsing request cookies and replacing values' do
|
21
|
-
it 'Parsing regular uri without params' do
|
22
|
-
TCellAgent.configuration.app_id = nil
|
23
|
-
original_uri = 'http://foo.com/posts'
|
24
|
-
expect_santized_uri = 'http://foo.com/posts'
|
25
|
-
expect(Util.sanitize_uri(original_uri)).to eq(expect_santized_uri)
|
26
|
-
end
|
27
|
-
it 'Parsing regular uri with regular query string' do
|
28
|
-
TCellAgent.configuration.app_id = nil
|
29
|
-
original_uri = 'http://foo.com/posts?abcd'
|
30
|
-
expect_santized_uri = 'http://foo.com/posts?abcd='
|
31
|
-
expect(Util.sanitize_uri(original_uri)).to eq(expect_santized_uri)
|
32
|
-
end
|
33
|
-
it 'Parsing uri' do
|
34
|
-
TCellAgent.configuration.app_id = nil
|
35
|
-
original_uri = 'http://foo.com/posts?id=30&limit=5#time=1305298413'
|
36
|
-
expect_santized_uri = 'http://foo.com/posts?id=61aa3630ced0e67b63a1c61e3b86f4d3&limit=89abb06a7bf0401b5911e61b68660c24#time=1305298413'
|
37
|
-
expect(Util.sanitize_uri(original_uri)).to eq(expect_santized_uri)
|
38
|
-
end
|
39
|
-
it 'returns an empty set' do
|
40
|
-
TCellAgent.configuration.app_id = nil
|
41
|
-
expect(Util.santize_request_cookie_string('ABC')).to eq('')
|
42
|
-
expect(Util.santize_request_cookie_string('abcd=')).to match('')
|
43
|
-
end
|
44
|
-
it 'parses a cookie' do
|
45
|
-
TCellAgent.configuration.app_id = nil
|
46
|
-
expect(Util.santize_request_cookie_string('x=y;z=a')).to eq('x=97cb9e2aa3ec93888b356dbcf13b280e;z=566c1a1c12ad909d628d4537e10773bf')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
context 'Parsing a response set-cookie and replacing values' do
|
50
|
-
it 'sanitize a typical response set-cookie value' do
|
51
|
-
santized_string = Util.santize_response_cookie_string('name=Nicholas; expires=Sat, 02 May 2009 23:38:25 GMT; httponly')
|
52
|
-
expect(santized_string).to eq('name=beb56c04cdd764f6b7cbe6c078236aeb=; expires=Sat, 02 May 2009 23:38:25 GMT=; httponly=')
|
53
|
-
end
|
54
|
-
end
|
55
20
|
end
|
56
21
|
end
|
57
22
|
end
|
@@ -1,162 +1,136 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
module TCellAgent
|
2
4
|
describe '.report_settings' do
|
3
5
|
require 'tcell_agent/settings_reporter'
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
expect(TCellAgent).to_not receive(:send_event)
|
24
|
-
|
25
|
-
TCellAgent.report_settings(true)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'should_instrument?=true' do
|
30
|
-
it 'should not report all the settings' do
|
31
|
-
logger = double('logger')
|
32
|
-
configuration = double('configuration',
|
33
|
-
:enabled => true,
|
34
|
-
:should_instrument? => true,
|
35
|
-
:logger => logger,
|
36
|
-
:allow_payloads => true,
|
37
|
-
:reverse_proxy => true,
|
38
|
-
:reverse_proxy_ip_address_header => nil,
|
39
|
-
:log_filename => 'log-filename',
|
40
|
-
:config_filename => 'config-filename',
|
41
|
-
:agent_log_dir => 'agent-log-dir',
|
42
|
-
:agent_home_dir => 'agent-home-dir',
|
43
|
-
:agent_home_owner => nil,
|
44
|
-
:logging_options => {
|
45
|
-
},
|
46
|
-
:hmac_key => nil)
|
7
|
+
it 'should not report all the settings' do
|
8
|
+
logger = double('logger')
|
9
|
+
configuration = double('configuration',
|
10
|
+
:enabled => true,
|
11
|
+
:should_instrument? => true,
|
12
|
+
:logger => logger,
|
13
|
+
:allow_payloads => true,
|
14
|
+
:reverse_proxy => true,
|
15
|
+
:reverse_proxy_ip_address_header => nil,
|
16
|
+
:log_filename => 'log-filename',
|
17
|
+
:config_filename => 'config-filename',
|
18
|
+
:agent_log_dir => 'agent-log-dir',
|
19
|
+
:agent_home_dir => 'agent-home-dir',
|
20
|
+
:agent_home_owner => nil,
|
21
|
+
:log_tag => nil,
|
22
|
+
:logging_options => {
|
23
|
+
},
|
24
|
+
:hmac_key => nil)
|
47
25
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
}
|
155
|
-
)
|
26
|
+
expect(TCellAgent).to receive(:configuration).and_return(
|
27
|
+
configuration
|
28
|
+
).at_least(:once)
|
29
|
+
expect(TCellAgent).to receive(:logger).and_return(logger).at_least(:once)
|
30
|
+
expect(Thread).to receive(:new).and_yield
|
31
|
+
expect(logger).to receive(:debug).with('TCellAgent::SensorEvents::ServerAgentDetailsSensorEvent', 'User unknown')
|
32
|
+
expect(logger).to receive(:debug).with('TCellAgent::SensorEvents::ServerAgentDetailsSensorEvent', 'Group unknown')
|
33
|
+
expect(TCellAgent).to receive(:send_event).with(
|
34
|
+
{
|
35
|
+
'event_type' => 'server_agent_details',
|
36
|
+
'user' => 'unknown',
|
37
|
+
'group' => 'unknown'
|
38
|
+
}
|
39
|
+
)
|
40
|
+
expect(logger).to receive(:debug).with(anything, anything).at_least(:once)
|
41
|
+
expect(TCellAgent).to receive(:send_event).with(
|
42
|
+
hash_including('event_type' => 'server_agent_packages')
|
43
|
+
) # packages event
|
44
|
+
expect(TCellAgent).to receive(:send_event).with(
|
45
|
+
{
|
46
|
+
'event_type' => 'server_agent_details',
|
47
|
+
'language' => 'Ruby',
|
48
|
+
'language_version' => RUBY_VERSION
|
49
|
+
}
|
50
|
+
)
|
51
|
+
expect(TCellAgent).to receive(:send_event).with(
|
52
|
+
{
|
53
|
+
'event_type' => 'app_config_setting',
|
54
|
+
'package' => 'tcell',
|
55
|
+
'section' => 'config',
|
56
|
+
'name' => 'native_lib_loaded',
|
57
|
+
'value' => 'true'
|
58
|
+
}
|
59
|
+
)
|
60
|
+
expect(TCellAgent).to receive(:send_event).with(
|
61
|
+
{
|
62
|
+
'event_type' => 'app_config_setting',
|
63
|
+
'package' => 'tcell',
|
64
|
+
'section' => 'config',
|
65
|
+
'name' => 'allow_payloads',
|
66
|
+
'value' => 'true'
|
67
|
+
}
|
68
|
+
)
|
69
|
+
expect(TCellAgent).to receive(:send_event).with(
|
70
|
+
{
|
71
|
+
'event_type' => 'app_config_setting',
|
72
|
+
'package' => 'tcell',
|
73
|
+
'section' => 'config',
|
74
|
+
'name' => 'reverse_proxy',
|
75
|
+
'value' => 'true'
|
76
|
+
}
|
77
|
+
)
|
78
|
+
expect(TCellAgent).to receive(:send_event).with(
|
79
|
+
{
|
80
|
+
'event_type' => 'app_config_setting',
|
81
|
+
'package' => 'tcell',
|
82
|
+
'section' => 'config',
|
83
|
+
'name' => 'config_filename',
|
84
|
+
'value' => 'config-filename'
|
85
|
+
}
|
86
|
+
)
|
87
|
+
expect(TCellAgent).to receive(:send_event).with(
|
88
|
+
{
|
89
|
+
'event_type' => 'app_config_setting',
|
90
|
+
'package' => 'tcell',
|
91
|
+
'section' => 'config',
|
92
|
+
'name' => 'logging_directory',
|
93
|
+
'value' => 'agent-log-dir'
|
94
|
+
}
|
95
|
+
)
|
96
|
+
expect(TCellAgent).to receive(:send_event).with(
|
97
|
+
{
|
98
|
+
'event_type' => 'app_config_setting',
|
99
|
+
'package' => 'tcell',
|
100
|
+
'section' => 'config',
|
101
|
+
'name' => 'agent_home_directory',
|
102
|
+
'value' => 'agent-home-dir'
|
103
|
+
}
|
104
|
+
)
|
105
|
+
expect(TCellAgent).to receive(:send_event).with(
|
106
|
+
{
|
107
|
+
'event_type' => 'app_config_setting',
|
108
|
+
'package' => 'tcell',
|
109
|
+
'section' => 'config',
|
110
|
+
'name' => 'logging_enabled',
|
111
|
+
'value' => 'true'
|
112
|
+
}
|
113
|
+
)
|
114
|
+
expect(TCellAgent).to receive(:send_event).with(
|
115
|
+
{
|
116
|
+
'event_type' => 'app_config_setting',
|
117
|
+
'package' => 'tcell',
|
118
|
+
'section' => 'config',
|
119
|
+
'name' => 'logging_level',
|
120
|
+
'value' => 'INFO'
|
121
|
+
}
|
122
|
+
)
|
123
|
+
expect(TCellAgent).to receive(:send_event).with(
|
124
|
+
{
|
125
|
+
'event_type' => 'app_config_setting',
|
126
|
+
'package' => 'tcell',
|
127
|
+
'section' => 'config',
|
128
|
+
'name' => 'reverse_proxy_ip_address_header',
|
129
|
+
'value' => ''
|
130
|
+
}
|
131
|
+
)
|
156
132
|
|
157
|
-
|
158
|
-
end
|
159
|
-
end
|
133
|
+
TCellAgent.report_settings
|
160
134
|
end
|
161
135
|
end
|
162
136
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rspec'
|
|
2
2
|
require 'rails'
|
3
3
|
require 'webmock/rspec'
|
4
4
|
require 'fork_break'
|
5
|
+
require 'rack/request'
|
5
6
|
|
6
7
|
if ENV['COVERAGE']
|
7
8
|
require 'simplecov'
|
@@ -10,7 +11,6 @@ end
|
|
10
11
|
|
11
12
|
ENV['TCELL_AGENT_SERVER'] = 'mock'
|
12
13
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'tcell_agent')
|
13
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'tcell_agent', 'rails') if defined?(Rails)
|
14
14
|
|
15
15
|
Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each { |f| require f }
|
16
16
|
|