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.
Files changed (163) hide show
  1. checksums.yaml +5 -5
  2. data/bin/tcell_agent +26 -14
  3. data/lib/tcell_agent.rb +16 -10
  4. data/lib/tcell_agent/agent.rb +78 -97
  5. data/lib/tcell_agent/agent/route_manager.rb +0 -16
  6. data/lib/tcell_agent/agent/static_agent.rb +9 -30
  7. data/lib/tcell_agent/authlogic.rb +3 -6
  8. data/lib/tcell_agent/config/unknown_options.rb +4 -8
  9. data/lib/tcell_agent/configuration.rb +38 -119
  10. data/lib/tcell_agent/devise.rb +25 -27
  11. data/lib/tcell_agent/hooks/login_fraud.rb +30 -33
  12. data/lib/tcell_agent/instrument_servers.rb +25 -0
  13. data/lib/tcell_agent/instrumentation.rb +12 -10
  14. data/lib/tcell_agent/instrumentation/cmdi.rb +19 -15
  15. data/lib/tcell_agent/instrumentation/lfi.rb +73 -0
  16. data/lib/tcell_agent/instrumentation/monkey_patches/file.rb +25 -0
  17. data/lib/tcell_agent/instrumentation/monkey_patches/io.rb +123 -0
  18. data/lib/tcell_agent/instrumentation/monkey_patches/kernel.rb +159 -0
  19. data/lib/tcell_agent/logger.rb +50 -114
  20. data/lib/tcell_agent/patches.rb +6 -7
  21. data/lib/tcell_agent/policies/appfirewall_policy.rb +26 -0
  22. data/lib/tcell_agent/policies/command_injection_policy.rb +28 -0
  23. data/lib/tcell_agent/policies/dataloss_policy.rb +44 -44
  24. data/lib/tcell_agent/policies/headers_policy.rb +25 -0
  25. data/lib/tcell_agent/policies/http_redirect_policy.rb +13 -79
  26. data/lib/tcell_agent/policies/js_agent_policy.rb +27 -0
  27. data/lib/tcell_agent/policies/local_file_access.rb +28 -0
  28. data/lib/tcell_agent/policies/login_policy.rb +43 -0
  29. data/lib/tcell_agent/policies/patches_policy.rb +27 -0
  30. data/lib/tcell_agent/policies/policies_manager.rb +68 -0
  31. data/lib/tcell_agent/policies/policy_polling.rb +58 -0
  32. data/lib/tcell_agent/policies/policy_types.rb +14 -0
  33. data/lib/tcell_agent/policies/system_enablements.rb +27 -0
  34. data/lib/tcell_agent/rails/auth/authlogic.rb +43 -68
  35. data/lib/tcell_agent/rails/auth/devise.rb +20 -23
  36. data/lib/tcell_agent/rails/auth/doorkeeper.rb +63 -74
  37. data/lib/tcell_agent/rails/csrf_exception.rb +2 -2
  38. data/lib/tcell_agent/rails/dlp.rb +25 -15
  39. data/lib/tcell_agent/rails/dlp_handler.rb +1 -2
  40. data/lib/tcell_agent/rails/js_agent_insert.rb +12 -13
  41. data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +4 -25
  42. data/lib/tcell_agent/rails/middleware/context_middleware.rb +2 -12
  43. data/lib/tcell_agent/rails/middleware/global_middleware.rb +0 -1
  44. data/lib/tcell_agent/rails/middleware/headers_middleware.rb +14 -34
  45. data/lib/tcell_agent/rails/on_start.rb +32 -31
  46. data/lib/tcell_agent/rails/routes.rb +7 -6
  47. data/lib/tcell_agent/rails/routes/grape.rb +1 -3
  48. data/lib/tcell_agent/rails/routes/route_id.rb +3 -1
  49. data/lib/tcell_agent/rails/settings_reporter.rb +23 -36
  50. data/lib/tcell_agent/rails/start_agent_after_initializers.rb +12 -0
  51. data/lib/tcell_agent/rails/tcell_body_proxy.rb +6 -4
  52. data/lib/tcell_agent/rust/agent_config.rb +49 -0
  53. data/lib/tcell_agent/rust/{libtcellagent-alpine-1.3.2.so → libtcellagent-4.14.0.dylib} +0 -0
  54. data/lib/tcell_agent/rust/libtcellagent-4.14.0.so +0 -0
  55. data/lib/tcell_agent/rust/{libtcellagent-1.3.2.so → libtcellagent-alpine-4.14.0.so} +0 -0
  56. data/lib/tcell_agent/rust/models.rb +0 -55
  57. data/lib/tcell_agent/rust/native_agent.rb +531 -0
  58. data/lib/tcell_agent/rust/native_agent_response.rb +42 -0
  59. data/lib/tcell_agent/rust/native_library.rb +68 -0
  60. data/lib/tcell_agent/rust/tcellagent-4.14.0.dll +0 -0
  61. data/lib/tcell_agent/sensor_events/agent_setting_event.rb +12 -0
  62. data/lib/tcell_agent/sensor_events/{app_config.rb → app_config_setting_event.rb} +0 -6
  63. data/lib/tcell_agent/sensor_events/dlp.rb +2 -6
  64. data/lib/tcell_agent/sensor_events/sensor.rb +0 -62
  65. data/lib/tcell_agent/sensor_events/server_agent.rb +13 -18
  66. data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +0 -108
  67. data/lib/tcell_agent/sensor_events/util/utils.rb +0 -2
  68. data/lib/tcell_agent/servers/passenger.rb +1 -28
  69. data/lib/tcell_agent/servers/puma.rb +3 -21
  70. data/lib/tcell_agent/servers/rails_server.rb +1 -1
  71. data/lib/tcell_agent/servers/thin.rb +2 -2
  72. data/lib/tcell_agent/servers/unicorn.rb +19 -80
  73. data/lib/tcell_agent/servers/webrick.rb +1 -1
  74. data/lib/tcell_agent/settings_reporter.rb +24 -24
  75. data/lib/tcell_agent/sinatra.rb +14 -16
  76. data/lib/tcell_agent/tcell_context.rb +40 -14
  77. data/lib/tcell_agent/utils/headers.rb +14 -0
  78. data/lib/tcell_agent/version.rb +1 -1
  79. data/spec/lib/tcell_agent/cmdi_spec.rb +0 -585
  80. data/spec/lib/tcell_agent/config/unknown_options_spec.rb +0 -18
  81. data/spec/lib/tcell_agent/configuration_spec.rb +4 -140
  82. data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +46 -173
  83. data/spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb +504 -0
  84. data/spec/lib/tcell_agent/instrumentation/cmdi/kernel_cmdi_spec.rb +435 -0
  85. data/spec/lib/tcell_agent/instrumentation/lfi/file_lfi_spec.rb +326 -0
  86. data/spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb +556 -0
  87. data/spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb +249 -0
  88. data/spec/lib/tcell_agent/instrumentation/lfi_spec.rb +105 -0
  89. data/spec/lib/tcell_agent/patches_spec.rb +25 -43
  90. data/spec/lib/tcell_agent/policies/appfirewall_policy_spec.rb +183 -0
  91. data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +57 -0
  92. data/spec/lib/tcell_agent/policies/command_injection_policy_spec.rb +84 -773
  93. data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +161 -0
  94. data/spec/lib/tcell_agent/policies/dataloss_policy_spec.rb +9 -9
  95. data/spec/lib/tcell_agent/policies/http_redirect_policy_spec.rb +243 -198
  96. data/spec/lib/tcell_agent/policies/js_agent_policy_spec.rb +75 -0
  97. data/spec/lib/tcell_agent/policies/login_policy_spec.rb +165 -33
  98. data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +84 -277
  99. data/spec/lib/tcell_agent/policies/policies_manager_spec.rb +104 -0
  100. data/spec/lib/tcell_agent/policies/policy_polling_spec.rb +6 -0
  101. data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +56 -0
  102. data/spec/lib/tcell_agent/rails/csrf_exception_spec.rb +9 -18
  103. data/spec/lib/tcell_agent/rails/js_agent_insert_spec.rb +13 -30
  104. data/spec/lib/tcell_agent/rails/logger_spec.rb +27 -7
  105. data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +17 -12
  106. data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +14 -14
  107. data/spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb +0 -35
  108. data/spec/lib/tcell_agent/settings_reporter_spec.rb +127 -153
  109. data/spec/spec_helper.rb +1 -1
  110. data/spec/support/builders.rb +104 -0
  111. data/spec/support/force_logger_mocking.rb +38 -0
  112. data/spec/support/resources/lfi_sample_file.txt +2 -0
  113. data/spec/support/static_agent_overrides.rb +0 -15
  114. metadata +63 -74
  115. data/lib/tcell_agent/agent/event_processor.rb +0 -326
  116. data/lib/tcell_agent/agent/fork_pipe_manager.rb +0 -113
  117. data/lib/tcell_agent/agent/policy_manager.rb +0 -219
  118. data/lib/tcell_agent/agent/policy_types.rb +0 -30
  119. data/lib/tcell_agent/api.rb +0 -91
  120. data/lib/tcell_agent/appsensor/injections_reporter.rb +0 -24
  121. data/lib/tcell_agent/config/child_process_events.rb +0 -8
  122. data/lib/tcell_agent/instrumentation/cmdi/backtick.rb +0 -10
  123. data/lib/tcell_agent/instrumentation/cmdi/exec.rb +0 -14
  124. data/lib/tcell_agent/instrumentation/cmdi/popen.rb +0 -28
  125. data/lib/tcell_agent/instrumentation/cmdi/spawn.rb +0 -11
  126. data/lib/tcell_agent/instrumentation/cmdi/system.rb +0 -11
  127. data/lib/tcell_agent/policies/http_tx_policy.rb +0 -60
  128. data/lib/tcell_agent/policies/login_fraud_policy.rb +0 -45
  129. data/lib/tcell_agent/policies/rust_policies.rb +0 -110
  130. data/lib/tcell_agent/rails.rb +0 -40
  131. data/lib/tcell_agent/rust/libtcellagent-1.3.2.dylib +0 -0
  132. data/lib/tcell_agent/rust/tcellagent-1.3.2.dll +0 -0
  133. data/lib/tcell_agent/rust/whisperer.rb +0 -308
  134. data/lib/tcell_agent/sensor_events/appsensor_event.rb +0 -52
  135. data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +0 -45
  136. data/lib/tcell_agent/sensor_events/command_injection.rb +0 -75
  137. data/lib/tcell_agent/sensor_events/honeytokens.rb +0 -16
  138. data/lib/tcell_agent/sensor_events/login_fraud.rb +0 -60
  139. data/lib/tcell_agent/sensor_events/metrics.rb +0 -123
  140. data/lib/tcell_agent/sensor_events/patches.rb +0 -21
  141. data/lib/tcell_agent/start_background_thread.rb +0 -55
  142. data/lib/tcell_agent/system_info.rb +0 -11
  143. data/lib/tcell_agent/utils/io.rb +0 -38
  144. data/lib/tcell_agent/utils/passwords.rb +0 -28
  145. data/lib/tcell_agent/utils/queue_with_timeout.rb +0 -142
  146. data/spec/lib/tcell_agent/agent/fork_pipe_manager_spec.rb +0 -100
  147. data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +0 -535
  148. data/spec/lib/tcell_agent/agent/static_agent_spec.rb +0 -133
  149. data/spec/lib/tcell_agent/api/api_spec.rb +0 -39
  150. data/spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb +0 -187
  151. data/spec/lib/tcell_agent/instrumentation_spec.rb +0 -225
  152. data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +0 -517
  153. data/spec/lib/tcell_agent/policies/http_tx_policy_spec.rb +0 -22
  154. data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +0 -293
  155. data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +0 -198
  156. data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +0 -180
  157. data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +0 -116
  158. data/spec/lib/tcell_agent/rust/models_spec.rb +0 -120
  159. data/spec/lib/tcell_agent/rust/whisperer_spec.rb +0 -704
  160. data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +0 -45
  161. data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +0 -272
  162. data/spec/lib/tcell_agent/utils/bounded_queue_spec.rb +0 -52
  163. 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', :enabled => true, :should_instrument? => true)
20
+ configuration = double('configuration', :should_instrument? => true)
21
21
 
22
- expect(TCellAgent).to receive(:configuration).and_return(configuration).twice
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', :enabled => true, :should_instrument? => true)
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).twice
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', :enabled => true, :should_instrument? => true)
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).twice
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', :enabled => true, :should_instrument? => true)
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).twice
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', :enabled => true, :should_instrument? => true)
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).twice
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', :enabled => true, :should_instrument? => true)
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).twice
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', :enabled => true, :should_instrument? => true)
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).twice
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
- context 'with send_startup_events=false' do
6
- it 'should not report anything' do
7
- expect(TCellAgent).to_not receive(:configuration)
8
- expect(TCellAgent).to_not receive(:send_event)
9
-
10
- TCellAgent.report_settings(false)
11
- end
12
- end
13
-
14
- context 'with send_startup_events=true' do
15
- context 'should_instrument?=false' do
16
- it 'should not report anything' do
17
- configuration = double('configuration',
18
- :should_instrument? => false)
19
-
20
- expect(TCellAgent).to receive(:configuration).and_return(
21
- configuration
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
- expect(TCellAgent).to receive(:configuration).and_return(
49
- configuration
50
- ).at_least(:once)
51
- expect(TCellAgent).to receive(:logger).and_return(logger).at_least(:once)
52
- expect(Thread).to receive(:new).and_yield
53
- expect(logger).to receive(:debug).with('User unknown')
54
- expect(logger).to receive(:debug).with('Group unknown')
55
- expect(TCellAgent).to receive(:send_event).with(
56
- {
57
- 'event_type' => 'server_agent_details',
58
- 'user' => 'unknown',
59
- 'group' => 'unknown'
60
- }
61
- )
62
- expect(logger).to receive(:debug).with(anything).at_least(:once)
63
- expect(TCellAgent).to receive(:send_event).with(
64
- hash_including('event_type' => 'server_agent_packages')
65
- ) # packages event
66
- expect(TCellAgent).to receive(:send_event).with(
67
- {
68
- 'event_type' => 'app_config_setting',
69
- 'package' => 'tcell',
70
- 'section' => 'config',
71
- 'name' => 'native_lib_loaded',
72
- 'value' => 'true'
73
- }
74
- )
75
- expect(TCellAgent).to receive(:send_event).with(
76
- {
77
- 'event_type' => 'app_config_setting',
78
- 'package' => 'tcell',
79
- 'section' => 'config',
80
- 'name' => 'allow_payloads',
81
- 'value' => 'true'
82
- }
83
- )
84
- expect(TCellAgent).to receive(:send_event).with(
85
- {
86
- 'event_type' => 'app_config_setting',
87
- 'package' => 'tcell',
88
- 'section' => 'config',
89
- 'name' => 'reverse_proxy',
90
- 'value' => 'true'
91
- }
92
- )
93
- expect(TCellAgent).to receive(:send_event).with(
94
- {
95
- 'event_type' => 'app_config_setting',
96
- 'package' => 'tcell',
97
- 'section' => 'config',
98
- 'name' => 'config_filename',
99
- 'value' => 'config-filename'
100
- }
101
- )
102
- expect(TCellAgent).to receive(:send_event).with(
103
- {
104
- 'event_type' => 'app_config_setting',
105
- 'package' => 'tcell',
106
- 'section' => 'config',
107
- 'name' => 'logging_directory',
108
- 'value' => 'agent-log-dir'
109
- }
110
- )
111
- expect(TCellAgent).to receive(:send_event).with(
112
- {
113
- 'event_type' => 'app_config_setting',
114
- 'package' => 'tcell',
115
- 'section' => 'config',
116
- 'name' => 'agent_home_directory',
117
- 'value' => 'agent-home-dir'
118
- }
119
- )
120
- expect(TCellAgent).to receive(:send_event).with(
121
- {
122
- 'event_type' => 'app_config_setting',
123
- 'package' => 'tcell',
124
- 'section' => 'config',
125
- 'name' => 'agent_home_owner',
126
- 'value' => ''
127
- }
128
- )
129
- expect(TCellAgent).to receive(:send_event).with(
130
- {
131
- 'event_type' => 'app_config_setting',
132
- 'package' => 'tcell',
133
- 'section' => 'config',
134
- 'name' => 'logging_enabled',
135
- 'value' => 'true'
136
- }
137
- )
138
- expect(TCellAgent).to receive(:send_event).with(
139
- {
140
- 'event_type' => 'app_config_setting',
141
- 'package' => 'tcell',
142
- 'section' => 'config',
143
- 'name' => 'logging_level',
144
- 'value' => 'INFO'
145
- }
146
- )
147
- expect(TCellAgent).to receive(:send_event).with(
148
- {
149
- 'event_type' => 'app_config_setting',
150
- 'package' => 'tcell',
151
- 'section' => 'config',
152
- 'name' => 'reverse_proxy_ip_address_header',
153
- 'value' => ''
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
- TCellAgent.report_settings(true)
158
- end
159
- end
133
+ TCellAgent.report_settings
160
134
  end
161
135
  end
162
136
  end
@@ -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