tcell_agent 1.1.12 → 2.2.0

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.
Files changed (169) hide show
  1. checksums.yaml +5 -5
  2. data/bin/tcell_agent +45 -137
  3. data/lib/tcell_agent.rb +12 -14
  4. data/lib/tcell_agent/agent.rb +108 -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/config_initializer.rb +66 -0
  8. data/lib/tcell_agent/configuration.rb +69 -345
  9. data/lib/tcell_agent/hooks/login_fraud.rb +30 -33
  10. data/lib/tcell_agent/instrument_servers.rb +23 -0
  11. data/lib/tcell_agent/instrumentation.rb +12 -10
  12. data/lib/tcell_agent/instrumentation/cmdi.rb +29 -25
  13. data/lib/tcell_agent/instrumentation/lfi.rb +84 -0
  14. data/lib/tcell_agent/instrumentation/monkey_patches/file.rb +25 -0
  15. data/lib/tcell_agent/instrumentation/monkey_patches/io.rb +131 -0
  16. data/lib/tcell_agent/instrumentation/monkey_patches/kernel.rb +102 -0
  17. data/lib/tcell_agent/logger.rb +49 -114
  18. data/lib/tcell_agent/patches.rb +6 -7
  19. data/lib/tcell_agent/policies/appfirewall_policy.rb +26 -0
  20. data/lib/tcell_agent/policies/command_injection_policy.rb +28 -0
  21. data/lib/tcell_agent/policies/dataloss_policy.rb +44 -44
  22. data/lib/tcell_agent/policies/headers_policy.rb +25 -0
  23. data/lib/tcell_agent/policies/http_redirect_policy.rb +13 -79
  24. data/lib/tcell_agent/policies/js_agent_policy.rb +27 -0
  25. data/lib/tcell_agent/policies/local_file_access.rb +28 -0
  26. data/lib/tcell_agent/policies/login_policy.rb +43 -0
  27. data/lib/tcell_agent/policies/patches_policy.rb +27 -0
  28. data/lib/tcell_agent/policies/policies_manager.rb +68 -0
  29. data/lib/tcell_agent/policies/policy_polling.rb +58 -0
  30. data/lib/tcell_agent/policies/policy_types.rb +14 -0
  31. data/lib/tcell_agent/policies/system_enablements.rb +27 -0
  32. data/lib/tcell_agent/rails/auth/authlogic.rb +46 -75
  33. data/lib/tcell_agent/rails/auth/authlogic_helper.rb +20 -0
  34. data/lib/tcell_agent/rails/auth/devise.rb +100 -105
  35. data/lib/tcell_agent/rails/auth/devise_helper.rb +29 -0
  36. data/lib/tcell_agent/rails/auth/doorkeeper.rb +62 -76
  37. data/lib/tcell_agent/{userinfo.rb → rails/auth/userinfo.rb} +0 -0
  38. data/lib/tcell_agent/rails/csrf_exception.rb +2 -10
  39. data/lib/tcell_agent/rails/dlp.rb +35 -23
  40. data/lib/tcell_agent/rails/dlp_handler.rb +1 -2
  41. data/lib/tcell_agent/rails/js_agent_insert.rb +12 -13
  42. data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +4 -25
  43. data/lib/tcell_agent/rails/middleware/context_middleware.rb +2 -12
  44. data/lib/tcell_agent/rails/middleware/global_middleware.rb +1 -2
  45. data/lib/tcell_agent/rails/middleware/headers_middleware.rb +14 -34
  46. data/lib/tcell_agent/{rails.rb → rails/railties/tcell_agent_railties.rb} +11 -16
  47. data/lib/tcell_agent/rails/railties/tcell_agent_unicorn_railties.rb +8 -0
  48. data/lib/tcell_agent/rails/routes.rb +10 -12
  49. data/lib/tcell_agent/rails/routes/grape.rb +4 -14
  50. data/lib/tcell_agent/rails/routes/route_id.rb +3 -1
  51. data/lib/tcell_agent/rails/settings_reporter.rb +23 -36
  52. data/lib/tcell_agent/rails/tcell_body_proxy.rb +5 -4
  53. data/lib/tcell_agent/rust/agent_config.rb +60 -0
  54. data/lib/tcell_agent/rust/{libtcellagent-alpine-1.3.2.so → libtcellagent-5.0.2.dylib} +0 -0
  55. data/lib/tcell_agent/rust/{libtcellagent-1.3.2.so → libtcellagent-5.0.2.so} +0 -0
  56. data/lib/tcell_agent/rust/libtcellagent-alpine-5.0.2.so +0 -0
  57. data/lib/tcell_agent/rust/models.rb +6 -52
  58. data/lib/tcell_agent/rust/native_agent.rb +549 -0
  59. data/lib/tcell_agent/rust/native_agent_response.rb +42 -0
  60. data/lib/tcell_agent/rust/native_library.rb +69 -0
  61. data/lib/tcell_agent/rust/tcellagent-5.0.2.dll +0 -0
  62. data/lib/tcell_agent/sensor_events/agent_setting_event.rb +12 -0
  63. data/lib/tcell_agent/sensor_events/{app_config.rb → app_config_setting_event.rb} +0 -6
  64. data/lib/tcell_agent/sensor_events/dlp.rb +2 -6
  65. data/lib/tcell_agent/sensor_events/sensor.rb +0 -62
  66. data/lib/tcell_agent/sensor_events/server_agent.rb +13 -18
  67. data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +0 -108
  68. data/lib/tcell_agent/sensor_events/util/utils.rb +0 -2
  69. data/lib/tcell_agent/servers/passenger.rb +1 -28
  70. data/lib/tcell_agent/servers/puma.rb +3 -21
  71. data/lib/tcell_agent/servers/rails_server.rb +1 -2
  72. data/lib/tcell_agent/servers/thin.rb +2 -2
  73. data/lib/tcell_agent/servers/unicorn.rb +19 -80
  74. data/lib/tcell_agent/servers/webrick.rb +1 -2
  75. data/lib/tcell_agent/settings_reporter.rb +11 -90
  76. data/lib/tcell_agent/sinatra.rb +14 -16
  77. data/lib/tcell_agent/tcell_context.rb +40 -14
  78. data/lib/tcell_agent/utils/headers.rb +14 -0
  79. data/lib/tcell_agent/version.rb +1 -1
  80. data/spec/lib/tcell_agent/configuration_spec.rb +55 -346
  81. data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +46 -173
  82. data/spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb +504 -0
  83. data/spec/lib/tcell_agent/instrumentation/cmdi/kernel_cmdi_spec.rb +435 -0
  84. data/spec/lib/tcell_agent/instrumentation/cmdi_spec.rb +201 -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 +562 -0
  87. data/spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb +264 -0
  88. data/spec/lib/tcell_agent/instrumentation/lfi_spec.rb +150 -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/rust/agent_config_spec.rb +27 -0
  108. data/spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb +0 -35
  109. data/spec/lib/tcell_agent/settings_reporter_spec.rb +56 -155
  110. data/spec/spec_helper.rb +1 -1
  111. data/spec/support/builders.rb +103 -0
  112. data/spec/support/force_logger_mocking.rb +38 -0
  113. data/spec/support/resources/lfi_sample_file.txt +2 -0
  114. data/spec/support/static_agent_overrides.rb +0 -15
  115. metadata +72 -83
  116. data/lib/tcell_agent/agent/event_processor.rb +0 -326
  117. data/lib/tcell_agent/agent/fork_pipe_manager.rb +0 -113
  118. data/lib/tcell_agent/agent/policy_manager.rb +0 -219
  119. data/lib/tcell_agent/agent/policy_types.rb +0 -30
  120. data/lib/tcell_agent/api.rb +0 -91
  121. data/lib/tcell_agent/appsensor/injections_reporter.rb +0 -24
  122. data/lib/tcell_agent/authlogic.rb +0 -26
  123. data/lib/tcell_agent/config/child_process_events.rb +0 -8
  124. data/lib/tcell_agent/config/unknown_options.rb +0 -123
  125. data/lib/tcell_agent/devise.rb +0 -35
  126. data/lib/tcell_agent/instrumentation/cmdi/backtick.rb +0 -10
  127. data/lib/tcell_agent/instrumentation/cmdi/exec.rb +0 -14
  128. data/lib/tcell_agent/instrumentation/cmdi/popen.rb +0 -28
  129. data/lib/tcell_agent/instrumentation/cmdi/spawn.rb +0 -11
  130. data/lib/tcell_agent/instrumentation/cmdi/system.rb +0 -11
  131. data/lib/tcell_agent/policies/http_tx_policy.rb +0 -60
  132. data/lib/tcell_agent/policies/login_fraud_policy.rb +0 -45
  133. data/lib/tcell_agent/policies/rust_policies.rb +0 -110
  134. data/lib/tcell_agent/rails/on_start.rb +0 -41
  135. data/lib/tcell_agent/rust/libtcellagent-1.3.2.dylib +0 -0
  136. data/lib/tcell_agent/rust/tcellagent-1.3.2.dll +0 -0
  137. data/lib/tcell_agent/rust/whisperer.rb +0 -308
  138. data/lib/tcell_agent/sensor_events/appsensor_event.rb +0 -52
  139. data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +0 -45
  140. data/lib/tcell_agent/sensor_events/command_injection.rb +0 -75
  141. data/lib/tcell_agent/sensor_events/honeytokens.rb +0 -16
  142. data/lib/tcell_agent/sensor_events/login_fraud.rb +0 -60
  143. data/lib/tcell_agent/sensor_events/metrics.rb +0 -123
  144. data/lib/tcell_agent/sensor_events/patches.rb +0 -21
  145. data/lib/tcell_agent/start_background_thread.rb +0 -55
  146. data/lib/tcell_agent/system_info.rb +0 -11
  147. data/lib/tcell_agent/utils/io.rb +0 -38
  148. data/lib/tcell_agent/utils/passwords.rb +0 -28
  149. data/lib/tcell_agent/utils/queue_with_timeout.rb +0 -142
  150. data/spec/lib/tcell_agent/agent/fork_pipe_manager_spec.rb +0 -100
  151. data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +0 -535
  152. data/spec/lib/tcell_agent/agent/static_agent_spec.rb +0 -133
  153. data/spec/lib/tcell_agent/api/api_spec.rb +0 -39
  154. data/spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb +0 -187
  155. data/spec/lib/tcell_agent/cmdi_spec.rb +0 -736
  156. data/spec/lib/tcell_agent/config/unknown_options_spec.rb +0 -213
  157. data/spec/lib/tcell_agent/instrumentation_spec.rb +0 -225
  158. data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +0 -517
  159. data/spec/lib/tcell_agent/policies/http_tx_policy_spec.rb +0 -22
  160. data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +0 -293
  161. data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +0 -198
  162. data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +0 -180
  163. data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +0 -116
  164. data/spec/lib/tcell_agent/rust/models_spec.rb +0 -120
  165. data/spec/lib/tcell_agent/rust/whisperer_spec.rb +0 -704
  166. data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +0 -45
  167. data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +0 -272
  168. data/spec/lib/tcell_agent/utils/bounded_queue_spec.rb +0 -52
  169. data/spec/lib/tcell_agent/utils/passwords_spec.rb +0 -143
@@ -0,0 +1,14 @@
1
+
2
+ module TCellAgent
3
+ module Utils
4
+ module Headers
5
+ def self.clean_keys(request_env_or_header_keys)
6
+ if request_env_or_header_keys.is_a?(Hash)
7
+ request_env_or_header_keys.select { |k, _v| k.start_with? 'HTTP_' }.collect { |k, _v| k.sub(/^HTTP_/, '') }
8
+ else
9
+ request_env_or_header_keys.map { |k| k.sub(/^HTTP_/, '') }
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # See the file "LICENSE" for the full license governing this code.
2
2
 
3
3
  module TCellAgent
4
- VERSION = '1.1.12'.freeze
4
+ VERSION = '2.2.0'.freeze
5
5
  end
@@ -2,364 +2,73 @@ require 'spec_helper'
2
2
 
3
3
  module TCellAgent
4
4
  describe Configuration do
5
- describe '#agent_home_dir' do
6
- context 'no TCELL_AGENT_HOME defined' do
7
- it 'should set cache file, config, and log file to defaults' do
8
- configuration = Configuration.new
5
+ describe 'should_instrument?' do
6
+ context 'with the agent disabled' do
7
+ it 'should return false' do
8
+ config = Configuration.new
9
+ config.enabled = false
9
10
 
10
- expect(configuration.cache_filename_with_app_id).to match(
11
- %r{/tcell/cache/tcell_agent.cache}
12
- )
13
- expect(configuration.log_filename).to eq(
14
- File.join(Dir.getwd, 'tcell/logs/tcell_agent.log')
15
- )
16
- expect(configuration.config_filename).to eq(
17
- File.join(Dir.getwd, 'config/tcell_agent.config')
18
- )
11
+ expect(config.should_instrument?).to be_falsey
19
12
  end
20
13
  end
21
-
22
- context 'TCELL_AGENT_HOME defined' do
23
- it 'should set config filename to default, cache file and log file are updated' do
24
- old_tcell_agent_home = ENV['TCELL_AGENT_HOME']
25
-
26
- ENV['TCELL_AGENT_HOME'] = 'spec_tcell_home'
27
-
28
- configuration = Configuration.new
29
-
30
- expect(configuration.cache_filename_with_app_id).to match(
31
- %r{spec_tcell_home/cache/tcell_agent.cache}
32
- )
33
- expect(configuration.log_filename).to eq(
34
- 'spec_tcell_home/logs/tcell_agent.log'
35
- )
36
- expect(configuration.config_filename).to eq(
37
- File.join(Dir.getwd, 'config/tcell_agent.config')
38
- )
39
-
40
- ENV['TCELL_AGENT_HOME'] = old_tcell_agent_home
41
- end
42
- end
43
-
44
- context 'TCELL_AGENT_HOME and TCELL_AGENT_LOG_DIR defined' do
45
- it 'should set config filename to default, cache file and log file are updated' do
46
- old_tcell_agent_home = ENV['TCELL_AGENT_HOME']
47
- old_tcell_agent_log_dir = ENV['TCELL_AGENT_LOG_DIR']
48
-
49
- ENV['TCELL_AGENT_HOME'] = 'spec_tcell_home'
50
- ENV['TCELL_AGENT_LOG_DIR'] = 'spec_tcell_log_dir'
51
-
52
- configuration = Configuration.new
53
-
54
- expect(configuration.cache_filename_with_app_id).to match(
55
- %r{spec_tcell_home/cache/tcell_agent.cache}
56
- )
57
- expect(configuration.log_filename).to eq(
58
- 'spec_tcell_log_dir/tcell_agent.log'
59
- )
60
- expect(configuration.config_filename).to eq(
61
- File.join(Dir.getwd, 'config/tcell_agent.config')
62
- )
63
-
64
- ENV['TCELL_AGENT_HOME'] = old_tcell_agent_home
65
- ENV['TCELL_AGENT_LOG_DIR'] = old_tcell_agent_log_dir
66
- end
67
- end
68
-
69
- context 'TCELL_AGENT_HOME, TCELL_AGENT_LOG_DIR, and TCELL_AGENT_CONFIG defined ' do
70
- it 'should update config filename, cache file, and log file' do
71
- old_tcell_agent_home = ENV['TCELL_AGENT_HOME']
72
- old_tcell_agent_log_dir = ENV['TCELL_AGENT_LOG_DIR']
73
- old_config_filename = ENV['TCELL_AGENT_CONFIG']
74
-
75
- ENV['TCELL_AGENT_HOME'] = 'spec_tcell_home'
76
- ENV['TCELL_AGENT_LOG_DIR'] = 'spec_tcell_log_dir'
77
- ENV['TCELL_AGENT_CONFIG'] = 'spec_config/tcell_agent.config'
78
-
79
- configuration = Configuration.new
80
-
81
- expect(configuration.cache_filename_with_app_id).to match(
82
- %r{spec_tcell_home/cache/tcell_agent.cache}
83
- )
84
- expect(configuration.log_filename).to eq(
85
- 'spec_tcell_log_dir/tcell_agent.log'
86
- )
87
- expect(configuration.config_filename).to eq(
88
- 'spec_config/tcell_agent.config'
89
- )
90
-
91
- ENV['TCELL_AGENT_HOME'] = old_tcell_agent_home
92
- ENV['TCELL_AGENT_LOG_DIR'] = old_tcell_agent_log_dir
93
- ENV['TCELL_AGENT_CONFIG'] = old_config_filename
94
- end
95
- end
96
- end
97
-
98
- describe '#data_exposure' do
99
- context 'no data_exposure defined' do
100
- it 'should set max_data_ex_db_records_per_request to default' do
101
- no_data_ex = double(
102
- 'no_data_ex',
103
- :read => {
104
- :version => 1,
105
- :applications => [
106
- :app_id => 'app_id',
107
- :name => 'test',
108
- :api_key => 'api_key'
109
- ]
110
- }.to_json
111
- )
112
- expect(File).to receive(:file?).with(
113
- File.join(Dir.getwd, 'no_data_ex.config')
114
- ).and_return(true)
115
- expect(File).to receive(:open).with(
116
- File.join(Dir.getwd, 'no_data_ex.config')
117
- ).and_return(no_data_ex)
118
- configuration = Configuration.new('no_data_ex.config')
119
-
120
- expect(configuration.max_data_ex_db_records_per_request).to eq(1000)
121
- end
122
- end
123
-
124
- context 'data_exposure is empty' do
125
- it 'should set max_data_ex_db_records_per_request to default' do
126
- no_data_ex = double(
127
- 'no_data_ex',
128
- :read => {
129
- :version => 1,
130
- :applications => [
131
- :app_id => 'app_id',
132
- :name => 'test',
133
- :api_key => 'api_key',
134
- :data_exposure => {}
135
- ]
136
- }.to_json
137
- )
138
- expect(File).to receive(:file?).with(
139
- File.join(Dir.getwd, 'no_data_ex.config')
140
- ).and_return(true)
141
- expect(File).to receive(:open).with(
142
- File.join(Dir.getwd, 'no_data_ex.config')
143
- ).and_return(no_data_ex)
144
- configuration = Configuration.new('no_data_ex.config')
145
-
146
- expect(configuration.max_data_ex_db_records_per_request).to eq(1000)
147
- end
148
- end
149
-
150
- context 'data_exposure contains an override' do
151
- it 'should set max_data_ex_db_records_per_request to override' do
152
- no_data_ex = double(
153
- 'no_data_ex',
154
- :read => {
155
- :version => 1,
156
- :applications => [
157
- :app_id => 'app_id',
158
- :name => 'test',
159
- :api_key => 'api_key',
160
- :data_exposure => {
161
- :max_data_ex_db_records_per_request => 5000
162
- }
163
- ]
164
- }.to_json
165
- )
166
- expect(File).to receive(:file?).with(
167
- File.join(Dir.getwd, 'no_data_ex.config')
168
- ).and_return(true)
169
- expect(File).to receive(:open).with(
170
- File.join(Dir.getwd, 'no_data_ex.config')
171
- ).and_return(no_data_ex)
172
- configuration = Configuration.new('no_data_ex.config')
173
-
174
- expect(configuration.max_data_ex_db_records_per_request).to eq(5000)
175
- end
176
- end
177
- end
178
-
179
- describe '#allow_payloads' do
180
- context 'setting it via config' do
181
- context 'using allow_unencrypted_appsensor_payloads' do
182
- it 'should be false' do
183
- allow_unencrypted_appfirewall_payloads_enabled = double(
184
- 'no_data_ex',
185
- :read => {
186
- :version => 1,
187
- :applications => [
188
- :app_id => 'app_id',
189
- :api_key => 'api_key',
190
- :allow_unencrypted_appsensor_payloads => false
191
- ]
192
- }.to_json
193
- )
194
- expect(File).to receive(:file?).with(
195
- File.join(Dir.getwd, 'config/tcell_agent.config')
196
- ).and_return(true)
197
- expect(File).to receive(:open).with(
198
- File.join(Dir.getwd, 'config/tcell_agent.config')
199
- ).and_return(allow_unencrypted_appfirewall_payloads_enabled)
200
-
201
- configuration = Configuration.new
202
-
203
- expect(configuration.allow_payloads).to eq(false)
14
+ context 'with the agent enabled' do
15
+ context 'with all instrumentation enabled' do
16
+ context 'with no parameters' do
17
+ it 'should return true' do
18
+ config = Configuration.new
19
+
20
+ expect(config.should_instrument?).to be_truthy
21
+ end
204
22
  end
205
- end
23
+ context 'with parameters' do
24
+ it 'should return true' do
25
+ config = Configuration.new
206
26
 
207
- context 'using allow_unencrypted_appfirewall_payloads' do
208
- it 'should be false' do
209
- allow_unencrypted_appfirewall_payloads_enabled = double(
210
- 'no_data_ex',
211
- :read => {
212
- :version => 1,
213
- :applications => [
214
- :app_id => 'app_id',
215
- :api_key => 'api_key',
216
- :allow_unencrypted_appfirewall_payloads => false
217
- ]
218
- }.to_json
219
- )
220
- expect(File).to receive(:file?).with(
221
- File.join(Dir.getwd, 'config/tcell_agent.config')
222
- ).and_return(true)
223
- expect(File).to receive(:open).with(
224
- File.join(Dir.getwd, 'config/tcell_agent.config')
225
- ).and_return(allow_unencrypted_appfirewall_payloads_enabled)
226
-
227
- configuration = Configuration.new
228
-
229
- expect(configuration.allow_payloads).to eq(false)
27
+ expect(config.should_instrument?('devise')).to be_truthy
28
+ end
230
29
  end
231
30
  end
31
+ context 'with auth frameworks disabled' do
32
+ it 'should return false' do
33
+ config = Configuration.new
34
+ config.disabled_instrumentation = Set.new(%w[authlogic devise doorkeeper])
232
35
 
233
- context 'using allow_payloads' do
234
- it 'should be false' do
235
- allow_unencrypted_appfirewall_payloads_enabled = double(
236
- 'no_data_ex',
237
- :read => {
238
- :version => 1,
239
- :applications => [
240
- :app_id => 'app_id',
241
- :api_key => 'api_key',
242
- :allow_payloads => false
243
- ]
244
- }.to_json
245
- )
246
- expect(File).to receive(:file?).with(
247
- File.join(Dir.getwd, 'config/tcell_agent.config')
248
- ).and_return(true)
249
- expect(File).to receive(:open).with(
250
- File.join(Dir.getwd, 'config/tcell_agent.config')
251
- ).and_return(allow_unencrypted_appfirewall_payloads_enabled)
252
-
253
- configuration = Configuration.new
254
-
255
- expect(configuration.allow_payloads).to eq(false)
36
+ expect(config.should_instrument?('devise')).to be_falsey
256
37
  end
257
38
  end
258
39
  end
259
-
260
- context 'setting it via env var' do
261
- context 'TCELL_AGENT_ALLOW_UNENCRYPTED_APPSENSOR_PAYLOADS overrides config file' do
262
- it 'should be false' do
263
- old_allow_unencrypted_appsensor_payloads = ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPSENSOR_PAYLOADS']
264
-
265
- ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPSENSOR_PAYLOADS'] = 'false'
266
-
267
- allow_unencrypted_appfirewall_payloads_enabled = double(
268
- 'no_data_ex',
269
- :read => {
270
- :version => 1,
271
- :applications => [
272
- :app_id => 'app_id',
273
- :api_key => 'api_key',
274
- :allow_unencrypted_appsensor_payloads => true
275
- ]
276
- }.to_json
277
- )
278
- expect(File).to receive(:file?).with(
279
- File.join(Dir.getwd, 'config/tcell_agent.config')
280
- ).and_return(true)
281
- expect(File).to receive(:open).with(
282
- File.join(Dir.getwd, 'config/tcell_agent.config')
283
- ).and_return(allow_unencrypted_appfirewall_payloads_enabled)
284
-
285
- configuration = Configuration.new
286
-
287
- ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPSENSOR_PAYLOADS'] = old_allow_unencrypted_appsensor_payloads
288
-
289
- expect(configuration.allow_payloads).to eq(false)
290
- end
291
- end
292
-
293
- context 'TCELL_AGENT_ALLOW_UNENCRYPTED_APPFIREWALL_PAYLOADS overrides config file' do
294
- it 'should be false' do
295
- old_allow_unencrypted_appfirewall_payloads = ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPFIREWALL_PAYLOADS']
296
-
297
- ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPFIREWALL_PAYLOADS'] = 'false'
298
-
299
- allow_unencrypted_appfirewall_payloads_enabled = double(
300
- 'no_data_ex',
301
- :read => {
302
- :version => 1,
303
- :applications => [
304
- :app_id => 'app_id',
305
- :api_key => 'api_key',
306
- :allow_unencrypted_appfirewall_payloads => true
307
- ]
308
- }.to_json
309
- )
310
- expect(File).to receive(:file?).with(
311
- File.join(Dir.getwd, 'config/tcell_agent.config')
312
- ).and_return(true)
313
- expect(File).to receive(:open).with(
314
- File.join(Dir.getwd, 'config/tcell_agent.config')
315
- ).and_return(allow_unencrypted_appfirewall_payloads_enabled)
316
-
317
- configuration = Configuration.new
318
-
319
- ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPFIREWALL_PAYLOADS'] = old_allow_unencrypted_appfirewall_payloads
320
-
321
- expect(configuration.allow_payloads).to eq(false)
322
- end
40
+ end
41
+ describe 'populate_configuration' do
42
+ context 'with a poor native_agent_config_response' do
43
+ it 'should not throw an error' do
44
+ native_agent_config_response = {}
45
+
46
+ config = Configuration.new
47
+ expect do
48
+ config.populate_configuration(native_agent_config_response)
49
+ end.not_to raise_error
323
50
  end
324
-
325
- context 'TCELL_AGENT_ALLOW_PAYLOADS overrides everything else' do
326
- it 'should be false' do
327
- old_allow_unencrypted_appsensor_payloads = ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPSENSOR_PAYLOADS']
328
- old_allow_unencrypted_appfirewall_payloads = ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPFIREWALL_PAYLOADS']
329
- old_tcell_agent_allow_payloads = ENV['TCELL_AGENT_ALLOW_PAYLOADS']
330
-
331
- ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPSENSOR_PAYLOADS'] = 'true'
332
- ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPFIREWALL_PAYLOADS'] = 'true'
333
- ENV['TCELL_AGENT_ALLOW_PAYLOADS'] = 'false'
334
-
335
- allow_unencrypted_appfirewall_payloads_enabled = double(
336
- 'no_data_ex',
337
- :read => {
338
- :version => 1,
339
- :applications => [
340
- :app_id => 'app_id',
341
- :api_key => 'api_key',
342
- :allow_unencrypted_appsensor_payloads => true,
343
- :allow_unencrypted_appfirewall_payloads => true,
344
- :allow_payloads => true
345
- ]
346
- }.to_json
347
- )
348
- expect(File).to receive(:file?).with(
349
- File.join(Dir.getwd, 'config/tcell_agent.config')
350
- ).and_return(true)
351
- expect(File).to receive(:open).with(
352
- File.join(Dir.getwd, 'config/tcell_agent.config')
353
- ).and_return(allow_unencrypted_appfirewall_payloads_enabled)
354
-
355
- configuration = Configuration.new
356
-
357
- ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPSENSOR_PAYLOADS'] = old_allow_unencrypted_appsensor_payloads
358
- ENV['TCELL_AGENT_ALLOW_UNENCRYPTED_APPFIREWALL_PAYLOADS'] = old_allow_unencrypted_appfirewall_payloads
359
- ENV['TCELL_AGENT_ALLOW_PAYLOADS'] = old_tcell_agent_allow_payloads
360
-
361
- expect(configuration.allow_payloads).to eq(false)
362
- end
51
+ end
52
+ context 'with an elaborate native_agent_config_response' do
53
+ it 'should set all the correct configurations' do
54
+ native_agent_config_response = { 'enabled' => true,
55
+ 'disabled_instrumentation' => %w[devise doorkeeper],
56
+ 'update_policy' => 'true',
57
+ 'applications' => { 'first' => { 'app_id' => 'app_id_placeholder',
58
+ 'api_key' => 'api_key_paceholder',
59
+ 'hmac_key' => 'hmac_key_placeholder',
60
+ 'password_hmac_key' => 'password_hmac_key_placeholder',
61
+ 'proxy_config' => { 'reverse_proxy' => true,
62
+ 'reverse_proxy_ip_address_header' => 'X-Forwarded-For' } } },
63
+ 'endpoint_config' => { 'api_url' => 'https://us.agent.tcell.insight.rapid7.com/api/v1' },
64
+ 'ruby_config' => { 'enable_policy_polling' => true } }
65
+
66
+ config = Configuration.new
67
+ config.populate_configuration(native_agent_config_response)
68
+
69
+ expect(config.disabled_instrumentation).to be_a(Set)
70
+ expect(config.disabled_instrumentation).to include('devise', 'doorkeeper')
71
+ expect(config.enable_intercept_requests).to be_truthy
363
72
  end
364
73
  end
365
74
  end
@@ -26,56 +26,30 @@ module TCellAgent
26
26
 
27
27
  describe 'manually requiring auth hooks' do
28
28
  before(:all) do
29
- require 'tcell_agent/hooks/login_fraud'
29
+ load 'lib/tcell_agent/hooks/login_fraud.rb'
30
+ load 'spec/support/force_logger_mocking.rb'
30
31
  end
31
32
 
32
33
  describe 'Using generic interface' do
33
34
  context 'with a login failure' do
34
35
  context 'with login_failed_enabled set to true' do
35
36
  it 'should report the login failure' do
36
- login_fraud = double('login_fraud', :enabled => true, :login_failed_enabled => true)
37
-
38
- expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
39
- login_fraud
40
- )
41
- expect(TCellAgent).to receive(:send_event).with(
42
- {
43
- 'event_type' => 'login',
44
- 'header_keys' => %w[USER_AGENT X_FORWARDED_FOR],
45
- 'user_agent' => 'user_agent',
46
- 'referrer' => 'http://tcell.tcell.io/?utm_campaign=',
47
- 'remote_addr' => '1.1.1.1',
48
- 'user_id' => 'user_id',
49
- 'document_uri' => 'http://tcell.tcell.io/login?param_name=',
50
- 'session' => '48c0ce7961d8d5d4bd57bd77976b3d38',
51
- 'event_name' => 'login-failure'
52
- }
53
- )
54
-
37
+ login_fraud = double('login_fraud', :login_failed_enabled => true)
55
38
  status = Hooks::V1::Login::LOGIN_FAILURE
56
39
  header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
57
40
  document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
58
41
  referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
59
42
 
60
- Hooks::V1::Login.register_login_event(
61
- status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
62
- )
63
- end
64
- end
65
-
66
- context 'with login_failed_enabled set to false' do
67
- it 'should NOT report the login failure' do
68
- login_fraud = double('login_fraud', :enabled => true, :login_failed_enabled => false)
69
-
70
- expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
71
- login_fraud
43
+ expect(TCellAgent).to receive(:policy).with(
44
+ TCellAgent::PolicyTypes::LOGINFRAUD
45
+ ).and_return(login_fraud)
46
+ expect(login_fraud).to receive(:report_login_failure).with(
47
+ 'user_id',
48
+ nil,
49
+ header_keys,
50
+ nil,
51
+ anything
72
52
  )
73
- expect(TCellAgent).to_not receive(:send_event)
74
-
75
- status = Hooks::V1::Login::LOGIN_FAILURE
76
- header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
77
- document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
78
- referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
79
53
 
80
54
  Hooks::V1::Login.register_login_event(
81
55
  status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
@@ -87,49 +61,20 @@ module TCellAgent
87
61
  context 'with a login success' do
88
62
  context 'with login_success_enabled set to true' do
89
63
  it 'should report the login success' do
90
- login_fraud = double('login_fraud', :enabled => true, :login_success_enabled => true)
91
-
92
- expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
93
- login_fraud
94
- )
95
- expect(TCellAgent).to receive(:send_event).with(
96
- {
97
- 'event_type' => 'login',
98
- 'header_keys' => %w[USER_AGENT X_FORWARDED_FOR],
99
- 'user_agent' => 'user_agent',
100
- 'referrer' => 'http://tcell.tcell.io/?utm_campaign=',
101
- 'remote_addr' => '1.1.1.1',
102
- 'user_id' => 'user_id',
103
- 'document_uri' => 'http://tcell.tcell.io/login?param_name=',
104
- 'session' => '48c0ce7961d8d5d4bd57bd77976b3d38',
105
- 'event_name' => 'login-success'
106
- }
107
- )
108
-
64
+ login_fraud = double('login_fraud', :login_success_enabled => true)
109
65
  status = Hooks::V1::Login::LOGIN_SUCCESS
110
66
  header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
111
67
  document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
112
68
  referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
113
69
 
114
- Hooks::V1::Login.register_login_event(
115
- status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
116
- )
117
- end
118
- end
119
-
120
- context 'with login_success_enabled set to false' do
121
- it 'should NOT report the login success' do
122
- login_fraud = double('login_fraud', :enabled => true, :login_success_enabled => false)
123
-
124
70
  expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
125
71
  login_fraud
126
72
  )
127
- expect(TCellAgent).to_not receive(:send_event)
128
-
129
- status = Hooks::V1::Login::LOGIN_SUCCESS
130
- header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
131
- document_uri = 'http://tcell.tcell.io/login?param_name=param_value'
132
- referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
73
+ expect(login_fraud).to receive(:report_login_success).with(
74
+ 'user_id',
75
+ header_keys,
76
+ anything
77
+ )
133
78
 
134
79
  Hooks::V1::Login.register_login_event(
135
80
  status, 'session_id', 'user_agent', referrer, '1.1.1.1', header_keys, 'user_id', document_uri
@@ -140,15 +85,17 @@ module TCellAgent
140
85
 
141
86
  context 'with an unknown status' do
142
87
  it 'should log the error' do
143
- login_fraud = double('login_fraud', :enabled => true)
88
+ login_fraud = double('login_fraud')
144
89
  logger = double('logger')
145
90
 
146
- expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
147
- login_fraud
148
- )
91
+ expect(TCellAgent).to receive(:policy).with(
92
+ TCellAgent::PolicyTypes::LOGINFRAUD
93
+ ).and_return(login_fraud)
149
94
  expect(TCellAgent).to_not receive(:send_event)
150
- expect(TCellAgent).to receive(:logger).and_return(logger)
151
- expect(logger).to receive(:error).with('Unkown login status: mumbo-jumbo')
95
+ expect(TCellAgent::Hooks::LoginFraud).to receive(:get_logger).and_return(logger)
96
+ expect(logger).to receive(:error).with(
97
+ 'Unkown login status: mumbo-jumbo'
98
+ )
152
99
 
153
100
  status = 'mumbo-jumbo'
154
101
  header_keys = %w[HTTP_USER_AGENT HTTP_X_FORWARDED_FOR]
@@ -166,12 +113,12 @@ module TCellAgent
166
113
  context 'with a login failure' do
167
114
  context 'with login_failed_enabled set to true' do
168
115
  it 'should report the login failure' do
169
- login_fraud = double('login_fraud', :enabled => true, :login_failed_enabled => true)
116
+ login_fraud = double('login_fraud', :login_failed_enabled => true)
170
117
  rails_request = double('rails_request')
171
118
  tcell_data = TCellAgent::Instrumentation::TCellData.new
172
119
  tcell_data.user_agent = 'user_agent'
173
120
  tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
174
- tcell_data.ip_address = '1.1.1.1'
121
+ tcell_data.remote_address = '1.1.1.1'
175
122
  tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
176
123
  tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
177
124
  request_env = {
@@ -185,18 +132,12 @@ module TCellAgent
185
132
  )
186
133
  expect(rails_request).to receive(:env).and_return(request_env)
187
134
  expect(rails_request).to receive(:env).and_return(request_env)
188
- expect(TCellAgent).to receive(:send_event).with(
189
- {
190
- 'event_type' => 'login',
191
- 'header_keys' => %w[USER_AGENT X_FORWARDED_FOR],
192
- 'user_agent' => 'user_agent',
193
- 'referrer' => 'http://tcell.tcell.io/?utm_campaign=',
194
- 'remote_addr' => '1.1.1.1',
195
- 'user_id' => 'user_id',
196
- 'document_uri' => 'http://tcell.tcell.io/login?param_name=',
197
- 'session' => '48c0ce7961d8d5d4bd57bd77976b3d38',
198
- 'event_name' => 'login-failure'
199
- }
135
+ expect(login_fraud).to receive(:report_login_failure).with(
136
+ 'user_id',
137
+ nil,
138
+ request_env,
139
+ nil,
140
+ anything
200
141
  )
201
142
 
202
143
  status = Hooks::V1::Login::LOGIN_FAILURE
@@ -206,48 +147,17 @@ module TCellAgent
206
147
  )
207
148
  end
208
149
  end
209
-
210
- context 'with login_failed_enabled set to false' do
211
- it 'should NOT report the login failure' do
212
- login_fraud = double('login_fraud', :enabled => true, :login_failed_enabled => false)
213
- rails_request = double('rails_request')
214
- tcell_data = TCellAgent::Instrumentation::TCellData.new
215
- tcell_data.user_agent = 'user_agent'
216
- tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign='
217
- tcell_data.ip_address = '1.1.1.1'
218
- tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
219
- tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
220
- request_env = {
221
- TCellAgent::Instrumentation::TCELL_ID => tcell_data,
222
- 'HTTP_USER_AGENT' => true,
223
- 'HTTP_X_FORWARDED_FOR' => true
224
- }
225
-
226
- expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
227
- login_fraud
228
- )
229
- expect(rails_request).to receive(:env).and_return(request_env)
230
- expect(rails_request).to receive(:env).and_return(request_env)
231
- expect(TCellAgent).to_not receive(:send_event)
232
-
233
- status = Hooks::V1::Login::LOGIN_FAILURE
234
-
235
- Hooks::V1::Frameworks::Rails::Login.register_login_event(
236
- status, rails_request, 'user_id'
237
- )
238
- end
239
- end
240
150
  end
241
151
 
242
152
  context 'with a login success' do
243
153
  context 'with login_success_enabled set to true' do
244
154
  it 'should report the login success' do
245
- login_fraud = double('login_fraud', :enabled => true, :login_success_enabled => true)
155
+ login_fraud = double('login_fraud', :login_success_enabled => true)
246
156
  rails_request = double('rails_request')
247
157
  tcell_data = TCellAgent::Instrumentation::TCellData.new
248
158
  tcell_data.user_agent = 'user_agent'
249
159
  tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
250
- tcell_data.ip_address = '1.1.1.1'
160
+ tcell_data.remote_address = '1.1.1.1'
251
161
  tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
252
162
  tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
253
163
  request_env = {
@@ -261,18 +171,10 @@ module TCellAgent
261
171
  )
262
172
  expect(rails_request).to receive(:env).and_return(request_env)
263
173
  expect(rails_request).to receive(:env).and_return(request_env)
264
- expect(TCellAgent).to receive(:send_event).with(
265
- {
266
- 'event_type' => 'login',
267
- 'header_keys' => %w[USER_AGENT X_FORWARDED_FOR],
268
- 'user_agent' => 'user_agent',
269
- 'referrer' => 'http://tcell.tcell.io/?utm_campaign=',
270
- 'remote_addr' => '1.1.1.1',
271
- 'user_id' => 'user_id',
272
- 'document_uri' => 'http://tcell.tcell.io/login?param_name=',
273
- 'session' => '48c0ce7961d8d5d4bd57bd77976b3d38',
274
- 'event_name' => 'login-success'
275
- }
174
+ expect(login_fraud).to receive(:report_login_success).with(
175
+ 'user_id',
176
+ request_env,
177
+ anything
276
178
  )
277
179
 
278
180
  status = Hooks::V1::Login::LOGIN_SUCCESS
@@ -282,48 +184,17 @@ module TCellAgent
282
184
  )
283
185
  end
284
186
  end
285
-
286
- context 'with login_success_enabled set to false' do
287
- it 'should NOT report the login success' do
288
- login_fraud = double('login_fraud', :enabled => true, :login_success_enabled => false)
289
- rails_request = double('rails_request')
290
- tcell_data = TCellAgent::Instrumentation::TCellData.new
291
- tcell_data.user_agent = 'user_agent'
292
- tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
293
- tcell_data.ip_address = '1.1.1.1'
294
- tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
295
- tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
296
- request_env = {
297
- TCellAgent::Instrumentation::TCELL_ID => tcell_data,
298
- 'HTTP_USER_AGENT' => true,
299
- 'HTTP_X_FORWARDED_FOR' => true
300
- }
301
-
302
- expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LOGINFRAUD).and_return(
303
- login_fraud
304
- )
305
- expect(rails_request).to receive(:env).and_return(request_env)
306
- expect(rails_request).to receive(:env).and_return(request_env)
307
- expect(TCellAgent).to_not receive(:send_event)
308
-
309
- status = Hooks::V1::Login::LOGIN_SUCCESS
310
-
311
- Hooks::V1::Frameworks::Rails::Login.register_login_event(
312
- status, rails_request, 'user_id'
313
- )
314
- end
315
- end
316
187
  end
317
188
 
318
189
  context 'with an unknown status' do
319
190
  it 'should log the error' do
320
- login_fraud = double('login_fraud', :enabled => true, :login_failed_enabled => true)
191
+ login_fraud = double('login_fraud', :login_failed_enabled => true)
321
192
  logger = double('logger')
322
193
  rails_request = double('rails_request')
323
194
  tcell_data = TCellAgent::Instrumentation::TCellData.new
324
195
  tcell_data.user_agent = 'user_agent'
325
196
  tcell_data.referrer = 'http://tcell.tcell.io/?utm_campaign=some-source'
326
- tcell_data.ip_address = '1.1.1.1'
197
+ tcell_data.remote_address = '1.1.1.1'
327
198
  tcell_data.path = 'http://tcell.tcell.io/login?param_name=param_value'
328
199
  tcell_data.hmac_session_id = TCellAgent::SensorEvents::Util.hmac('session_id')
329
200
  request_env = {
@@ -338,8 +209,10 @@ module TCellAgent
338
209
  expect(rails_request).to receive(:env).and_return(request_env)
339
210
  expect(rails_request).to receive(:env).and_return(request_env)
340
211
  expect(TCellAgent).to_not receive(:send_event)
341
- expect(TCellAgent).to receive(:logger).and_return(logger)
342
- expect(logger).to receive(:error).with('Unkown login status: mumbo-jumbo')
212
+ expect(TCellAgent::Hooks::LoginFraud).to receive(:get_logger).and_return(logger)
213
+ expect(logger).to receive(:error).with(
214
+ 'Unkown login status: mumbo-jumbo'
215
+ )
343
216
 
344
217
  status = 'mumbo-jumbo'
345
218