tcell_agent 2.0.0 → 2.5.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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +2 -2
  3. data/bin/tcell_agent +41 -150
  4. data/lib/tcell_agent/agent.rb +87 -52
  5. data/lib/tcell_agent/config_initializer.rb +63 -0
  6. data/lib/tcell_agent/configuration.rb +72 -267
  7. data/lib/tcell_agent/hooks/login_fraud.rb +1 -1
  8. data/lib/tcell_agent/instrument_servers.rb +14 -18
  9. data/lib/tcell_agent/instrumentation/cmdi.rb +47 -15
  10. data/lib/tcell_agent/instrumentation/lfi.rb +72 -15
  11. data/lib/tcell_agent/instrumentation/monkey_patches/ruby_2/file.rb +21 -0
  12. data/lib/tcell_agent/instrumentation/monkey_patches/ruby_2/io.rb +75 -0
  13. data/lib/tcell_agent/instrumentation/monkey_patches/ruby_2/kernel.rb +80 -0
  14. data/lib/tcell_agent/instrumentation/monkey_patches/ruby_3/file.rb +21 -0
  15. data/lib/tcell_agent/instrumentation/monkey_patches/ruby_3/io.rb +75 -0
  16. data/lib/tcell_agent/instrumentation/monkey_patches/ruby_3/kernel.rb +80 -0
  17. data/lib/tcell_agent/instrumentation.rb +14 -6
  18. data/lib/tcell_agent/logger.rb +3 -4
  19. data/lib/tcell_agent/policies/command_injection_policy.rb +1 -1
  20. data/lib/tcell_agent/policies/dataloss_policy.rb +15 -8
  21. data/lib/tcell_agent/policies/headers_policy.rb +2 -2
  22. data/lib/tcell_agent/policies/patches_policy.rb +8 -4
  23. data/lib/tcell_agent/policies/policies_manager.rb +1 -0
  24. data/lib/tcell_agent/policies/policy_polling.rb +4 -3
  25. data/lib/tcell_agent/rails/auth/authlogic.rb +49 -44
  26. data/lib/tcell_agent/rails/auth/authlogic_helper.rb +20 -0
  27. data/lib/tcell_agent/rails/auth/devise.rb +103 -102
  28. data/lib/tcell_agent/rails/auth/devise_helper.rb +29 -0
  29. data/lib/tcell_agent/rails/auth/doorkeeper.rb +54 -57
  30. data/lib/tcell_agent/{userinfo.rb → rails/auth/userinfo.rb} +0 -0
  31. data/lib/tcell_agent/rails/better_ip.rb +7 -19
  32. data/lib/tcell_agent/rails/csrf_exception.rb +0 -8
  33. data/lib/tcell_agent/rails/dlp/process_request.rb +5 -0
  34. data/lib/tcell_agent/rails/dlp.rb +58 -56
  35. data/lib/tcell_agent/rails/dlp_handler.rb +9 -10
  36. data/lib/tcell_agent/rails/js_agent_insert.rb +2 -3
  37. data/lib/tcell_agent/rails/middleware/context_middleware.rb +2 -1
  38. data/lib/tcell_agent/rails/middleware/global_middleware.rb +3 -4
  39. data/lib/tcell_agent/rails/middleware/headers_middleware.rb +1 -0
  40. data/lib/tcell_agent/rails/{on_start.rb → railties/tcell_agent_railties.rb} +9 -16
  41. data/lib/tcell_agent/rails/railties/tcell_agent_unicorn_railties.rb +8 -0
  42. data/lib/tcell_agent/rails/routes/grape.rb +5 -12
  43. data/lib/tcell_agent/rails/routes.rb +6 -9
  44. data/lib/tcell_agent/rails/settings_reporter.rb +3 -6
  45. data/lib/tcell_agent/rails/tcell_body_proxy.rb +4 -7
  46. data/lib/tcell_agent/routes/table.rb +3 -0
  47. data/lib/tcell_agent/rust/agent_config.rb +62 -33
  48. data/lib/tcell_agent/rust/{libtcellagent-4.14.0.so → libtcellagent-alpine.so} +0 -0
  49. data/lib/tcell_agent/rust/{libtcellagent-4.14.0.dylib → libtcellagent-x64.dll} +0 -0
  50. data/lib/tcell_agent/rust/{libtcellagent-alpine-4.14.0.so → libtcellagent.dylib} +0 -0
  51. data/lib/tcell_agent/rust/libtcellagent.so +0 -0
  52. data/lib/tcell_agent/rust/models.rb +9 -0
  53. data/lib/tcell_agent/rust/native_agent.rb +61 -51
  54. data/lib/tcell_agent/rust/native_library.rb +8 -10
  55. data/lib/tcell_agent/sensor_events/server_agent.rb +3 -100
  56. data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +1 -0
  57. data/lib/tcell_agent/servers/puma.rb +30 -13
  58. data/lib/tcell_agent/servers/rack_puma_handler.rb +33 -0
  59. data/lib/tcell_agent/servers/rails_server.rb +4 -4
  60. data/lib/tcell_agent/servers/unicorn.rb +1 -1
  61. data/lib/tcell_agent/servers/webrick.rb +12 -3
  62. data/lib/tcell_agent/settings_reporter.rb +0 -93
  63. data/lib/tcell_agent/sinatra.rb +1 -0
  64. data/lib/tcell_agent/tcell_context.rb +16 -7
  65. data/lib/tcell_agent/utils/headers.rb +0 -1
  66. data/lib/tcell_agent/utils/strings.rb +2 -2
  67. data/lib/tcell_agent/version.rb +1 -1
  68. data/lib/tcell_agent.rb +8 -16
  69. data/spec/cruby_spec_helper.rb +26 -0
  70. data/spec/lib/tcell_agent/configuration_spec.rb +62 -212
  71. data/spec/lib/tcell_agent/instrument_servers_spec.rb +95 -0
  72. data/spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb +2 -2
  73. data/spec/lib/tcell_agent/{cmdi_spec.rb → instrumentation/cmdi_spec.rb} +50 -0
  74. data/spec/lib/tcell_agent/instrumentation/lfi/file_lfi_spec.rb +211 -272
  75. data/spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb +213 -223
  76. data/spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb +95 -61
  77. data/spec/lib/tcell_agent/instrumentation/lfi_spec.rb +120 -2
  78. data/spec/lib/tcell_agent/patches_spec.rb +2 -1
  79. data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +1 -2
  80. data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +5 -6
  81. data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +21 -2
  82. data/spec/lib/tcell_agent/policies/policies_manager_spec.rb +1 -1
  83. data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +13 -8
  84. data/spec/lib/tcell_agent/rails/better_ip_spec.rb +9 -11
  85. data/spec/lib/tcell_agent/rails/csrf_exception_spec.rb +6 -6
  86. data/spec/lib/tcell_agent/rails/dlp_spec.rb +1 -0
  87. data/spec/lib/tcell_agent/rails/js_agent_insert_spec.rb +10 -2
  88. data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +2 -1
  89. data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +4 -4
  90. data/spec/lib/tcell_agent/rust/agent_config_spec.rb +27 -0
  91. data/spec/lib/tcell_agent/settings_reporter_spec.rb +2 -89
  92. data/spec/lib/tcell_agent/tcell_context_spec.rb +6 -5
  93. data/spec/spec_helper.rb +9 -1
  94. data/spec/support/builders.rb +8 -7
  95. data/spec/support/server_mocks/passenger_mock.rb +7 -0
  96. data/spec/support/server_mocks/puma_mock.rb +21 -0
  97. data/spec/support/server_mocks/rails_mock.rb +7 -0
  98. data/spec/support/server_mocks/thin_mock.rb +7 -0
  99. data/spec/support/server_mocks/unicorn_mock.rb +11 -0
  100. data/spec/support/shared_spec.rb +29 -0
  101. data/tcell_agent.gemspec +14 -14
  102. metadata +46 -29
  103. data/Rakefile +0 -18
  104. data/lib/tcell_agent/authlogic.rb +0 -23
  105. data/lib/tcell_agent/config/unknown_options.rb +0 -119
  106. data/lib/tcell_agent/devise.rb +0 -33
  107. data/lib/tcell_agent/instrumentation/monkey_patches/file.rb +0 -25
  108. data/lib/tcell_agent/instrumentation/monkey_patches/io.rb +0 -123
  109. data/lib/tcell_agent/instrumentation/monkey_patches/kernel.rb +0 -159
  110. data/lib/tcell_agent/rails/start_agent_after_initializers.rb +0 -12
  111. data/lib/tcell_agent/rust/tcellagent-4.14.0.dll +0 -0
  112. data/spec/lib/tcell_agent/config/unknown_options_spec.rb +0 -195
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcell_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
- - Rafael
7
+ - Rapid7, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -94,10 +94,8 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: This agent allows users to use the tCell.io service with their Rails
98
- app.
99
- email:
100
- - rafael@tcell.io
97
+ description: This agent allows users to use the tCell service with their Rails app.
98
+ email:
101
99
  executables:
102
100
  - tcell_agent
103
101
  extensions: []
@@ -105,24 +103,24 @@ extra_rdoc_files: []
105
103
  files:
106
104
  - LICENSE
107
105
  - README.md
108
- - Rakefile
109
106
  - bin/tcell_agent
110
107
  - lib/tcell_agent.rb
111
108
  - lib/tcell_agent/agent.rb
112
109
  - lib/tcell_agent/agent/route_manager.rb
113
110
  - lib/tcell_agent/agent/static_agent.rb
114
- - lib/tcell_agent/authlogic.rb
115
- - lib/tcell_agent/config/unknown_options.rb
111
+ - lib/tcell_agent/config_initializer.rb
116
112
  - lib/tcell_agent/configuration.rb
117
- - lib/tcell_agent/devise.rb
118
113
  - lib/tcell_agent/hooks/login_fraud.rb
119
114
  - lib/tcell_agent/instrument_servers.rb
120
115
  - lib/tcell_agent/instrumentation.rb
121
116
  - lib/tcell_agent/instrumentation/cmdi.rb
122
117
  - lib/tcell_agent/instrumentation/lfi.rb
123
- - lib/tcell_agent/instrumentation/monkey_patches/file.rb
124
- - lib/tcell_agent/instrumentation/monkey_patches/io.rb
125
- - lib/tcell_agent/instrumentation/monkey_patches/kernel.rb
118
+ - lib/tcell_agent/instrumentation/monkey_patches/ruby_2/file.rb
119
+ - lib/tcell_agent/instrumentation/monkey_patches/ruby_2/io.rb
120
+ - lib/tcell_agent/instrumentation/monkey_patches/ruby_2/kernel.rb
121
+ - lib/tcell_agent/instrumentation/monkey_patches/ruby_3/file.rb
122
+ - lib/tcell_agent/instrumentation/monkey_patches/ruby_3/io.rb
123
+ - lib/tcell_agent/instrumentation/monkey_patches/ruby_3/kernel.rb
126
124
  - lib/tcell_agent/logger.rb
127
125
  - lib/tcell_agent/patches.rb
128
126
  - lib/tcell_agent/policies/appfirewall_policy.rb
@@ -140,8 +138,11 @@ files:
140
138
  - lib/tcell_agent/policies/policy_types.rb
141
139
  - lib/tcell_agent/policies/system_enablements.rb
142
140
  - lib/tcell_agent/rails/auth/authlogic.rb
141
+ - lib/tcell_agent/rails/auth/authlogic_helper.rb
143
142
  - lib/tcell_agent/rails/auth/devise.rb
143
+ - lib/tcell_agent/rails/auth/devise_helper.rb
144
144
  - lib/tcell_agent/rails/auth/doorkeeper.rb
145
+ - lib/tcell_agent/rails/auth/userinfo.rb
145
146
  - lib/tcell_agent/rails/better_ip.rb
146
147
  - lib/tcell_agent/rails/csrf_exception.rb
147
148
  - lib/tcell_agent/rails/dlp.rb
@@ -152,24 +153,24 @@ files:
152
153
  - lib/tcell_agent/rails/middleware/context_middleware.rb
153
154
  - lib/tcell_agent/rails/middleware/global_middleware.rb
154
155
  - lib/tcell_agent/rails/middleware/headers_middleware.rb
155
- - lib/tcell_agent/rails/on_start.rb
156
+ - lib/tcell_agent/rails/railties/tcell_agent_railties.rb
157
+ - lib/tcell_agent/rails/railties/tcell_agent_unicorn_railties.rb
156
158
  - lib/tcell_agent/rails/responses.rb
157
159
  - lib/tcell_agent/rails/routes.rb
158
160
  - lib/tcell_agent/rails/routes/grape.rb
159
161
  - lib/tcell_agent/rails/routes/route_id.rb
160
162
  - lib/tcell_agent/rails/settings_reporter.rb
161
- - lib/tcell_agent/rails/start_agent_after_initializers.rb
162
163
  - lib/tcell_agent/rails/tcell_body_proxy.rb
163
164
  - lib/tcell_agent/routes/table.rb
164
165
  - lib/tcell_agent/rust/agent_config.rb
165
- - lib/tcell_agent/rust/libtcellagent-4.14.0.dylib
166
- - lib/tcell_agent/rust/libtcellagent-4.14.0.so
167
- - lib/tcell_agent/rust/libtcellagent-alpine-4.14.0.so
166
+ - lib/tcell_agent/rust/libtcellagent-alpine.so
167
+ - lib/tcell_agent/rust/libtcellagent-x64.dll
168
+ - lib/tcell_agent/rust/libtcellagent.dylib
169
+ - lib/tcell_agent/rust/libtcellagent.so
168
170
  - lib/tcell_agent/rust/models.rb
169
171
  - lib/tcell_agent/rust/native_agent.rb
170
172
  - lib/tcell_agent/rust/native_agent_response.rb
171
173
  - lib/tcell_agent/rust/native_library.rb
172
- - lib/tcell_agent/rust/tcellagent-4.14.0.dll
173
174
  - lib/tcell_agent/sensor_events/agent_setting_event.rb
174
175
  - lib/tcell_agent/sensor_events/app_config_setting_event.rb
175
176
  - lib/tcell_agent/sensor_events/discovery.rb
@@ -180,6 +181,7 @@ files:
180
181
  - lib/tcell_agent/sensor_events/util/utils.rb
181
182
  - lib/tcell_agent/servers/passenger.rb
182
183
  - lib/tcell_agent/servers/puma.rb
184
+ - lib/tcell_agent/servers/rack_puma_handler.rb
183
185
  - lib/tcell_agent/servers/rails_server.rb
184
186
  - lib/tcell_agent/servers/thin.rb
185
187
  - lib/tcell_agent/servers/unicorn.rb
@@ -187,17 +189,17 @@ files:
187
189
  - lib/tcell_agent/settings_reporter.rb
188
190
  - lib/tcell_agent/sinatra.rb
189
191
  - lib/tcell_agent/tcell_context.rb
190
- - lib/tcell_agent/userinfo.rb
191
192
  - lib/tcell_agent/utils/headers.rb
192
193
  - lib/tcell_agent/utils/params.rb
193
194
  - lib/tcell_agent/utils/strings.rb
194
195
  - lib/tcell_agent/version.rb
195
- - spec/lib/tcell_agent/cmdi_spec.rb
196
- - spec/lib/tcell_agent/config/unknown_options_spec.rb
196
+ - spec/cruby_spec_helper.rb
197
197
  - spec/lib/tcell_agent/configuration_spec.rb
198
198
  - spec/lib/tcell_agent/hooks/login_fraud_spec.rb
199
+ - spec/lib/tcell_agent/instrument_servers_spec.rb
199
200
  - spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb
200
201
  - spec/lib/tcell_agent/instrumentation/cmdi/kernel_cmdi_spec.rb
202
+ - spec/lib/tcell_agent/instrumentation/cmdi_spec.rb
201
203
  - spec/lib/tcell_agent/instrumentation/lfi/file_lfi_spec.rb
202
204
  - spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb
203
205
  - spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb
@@ -226,6 +228,7 @@ files:
226
228
  - spec/lib/tcell_agent/rails/routes/route_id_spec.rb
227
229
  - spec/lib/tcell_agent/rails/routes/routes_spec.rb
228
230
  - spec/lib/tcell_agent/rails_spec.rb
231
+ - spec/lib/tcell_agent/rust/agent_config_spec.rb
229
232
  - spec/lib/tcell_agent/sensor_events/dlp_spec.rb
230
233
  - spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb
231
234
  - spec/lib/tcell_agent/settings_reporter_spec.rb
@@ -238,11 +241,17 @@ files:
238
241
  - spec/support/middleware_helper.rb
239
242
  - spec/support/resources/lfi_sample_file.txt
240
243
  - spec/support/resources/normal_config.json
244
+ - spec/support/server_mocks/passenger_mock.rb
245
+ - spec/support/server_mocks/puma_mock.rb
246
+ - spec/support/server_mocks/rails_mock.rb
247
+ - spec/support/server_mocks/thin_mock.rb
248
+ - spec/support/server_mocks/unicorn_mock.rb
249
+ - spec/support/shared_spec.rb
241
250
  - spec/support/static_agent_overrides.rb
242
251
  - tcell_agent.gemspec
243
- homepage: https://www.tcell.io
252
+ homepage: https://www.rapid7.com/tcell
244
253
  licenses:
245
- - Copyright (c) 2017 tCell.io (see LICENSE file)
254
+ - Copyright (c) 2020 Rapid7, Inc. (see LICENSE file)
246
255
  metadata: {}
247
256
  post_install_message:
248
257
  rdoc_options: []
@@ -261,17 +270,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
270
  - !ruby/object:Gem::Version
262
271
  version: '0'
263
272
  requirements: []
264
- rubygems_version: 3.0.3
273
+ rubygems_version: 3.2.22
265
274
  signing_key:
266
275
  specification_version: 4
267
- summary: tCell.io Agent for Rails
276
+ summary: tCell Agent for Rails
268
277
  test_files:
269
- - spec/lib/tcell_agent/cmdi_spec.rb
270
- - spec/lib/tcell_agent/config/unknown_options_spec.rb
278
+ - spec/cruby_spec_helper.rb
271
279
  - spec/lib/tcell_agent/configuration_spec.rb
272
280
  - spec/lib/tcell_agent/hooks/login_fraud_spec.rb
281
+ - spec/lib/tcell_agent/instrument_servers_spec.rb
273
282
  - spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb
274
283
  - spec/lib/tcell_agent/instrumentation/cmdi/kernel_cmdi_spec.rb
284
+ - spec/lib/tcell_agent/instrumentation/cmdi_spec.rb
275
285
  - spec/lib/tcell_agent/instrumentation/lfi/file_lfi_spec.rb
276
286
  - spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb
277
287
  - spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb
@@ -300,6 +310,7 @@ test_files:
300
310
  - spec/lib/tcell_agent/rails/routes/route_id_spec.rb
301
311
  - spec/lib/tcell_agent/rails/routes/routes_spec.rb
302
312
  - spec/lib/tcell_agent/rails_spec.rb
313
+ - spec/lib/tcell_agent/rust/agent_config_spec.rb
303
314
  - spec/lib/tcell_agent/sensor_events/dlp_spec.rb
304
315
  - spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb
305
316
  - spec/lib/tcell_agent/settings_reporter_spec.rb
@@ -312,4 +323,10 @@ test_files:
312
323
  - spec/support/middleware_helper.rb
313
324
  - spec/support/resources/lfi_sample_file.txt
314
325
  - spec/support/resources/normal_config.json
326
+ - spec/support/server_mocks/passenger_mock.rb
327
+ - spec/support/server_mocks/puma_mock.rb
328
+ - spec/support/server_mocks/rails_mock.rb
329
+ - spec/support/server_mocks/thin_mock.rb
330
+ - spec/support/server_mocks/unicorn_mock.rb
331
+ - spec/support/shared_spec.rb
315
332
  - spec/support/static_agent_overrides.rb
data/Rakefile DELETED
@@ -1,18 +0,0 @@
1
- require 'rspec/core/rake_task'
2
-
3
- RSpec::Core::RakeTask.new(:spec)
4
-
5
- desc 'Run tests'
6
- task :default => [:spec]
7
- task :test => :spec
8
-
9
- task 'init-integration-tests' do
10
- system('docker-compose run railsintegration224 bundle install')
11
- system('docker-compose run railsintegration224 bundle exec rake db:create db:setup')
12
- system('docker-compose stop')
13
- end
14
-
15
- task 'integration-test' do
16
- system('docker-compose up railsintegration224')
17
- system('docker-compose stop')
18
- end
@@ -1,23 +0,0 @@
1
- if TCellAgent.configuration.should_instrument_authlogic? && defined?(Authlogic)
2
-
3
- require 'tcell_agent/userinfo'
4
-
5
- module TCellAgent
6
- TCellAgent::UserInformation.class_eval do
7
- class << self
8
- alias_method :original_get_user_from_request, :get_user_from_request
9
- def get_user_from_request(request)
10
- orig_user_id = original_get_user_from_request(request)
11
- begin
12
- if request.session && request.session.key?('user_credentials_id')
13
- return request.session['user_credentials_id'].to_s
14
- end
15
- rescue StandardError
16
- return orig_user_id
17
- end
18
- orig_user_id
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,119 +0,0 @@
1
- require 'set'
2
-
3
- module TCellAgent
4
- module Config
5
- module Validate
6
- def self.get_unknown_options(config_json)
7
- messages = []
8
-
9
- known_tcell_env_vars = Set.new(
10
- [
11
- 'TCELL_AGENT_SERVER', # this is only meant for specs
12
- 'TCELL_AGENT_APP_ID',
13
- 'TCELL_AGENT_API_KEY',
14
- 'TCELL_HMAC_KEY',
15
- 'TCELL_PASSWORD_HMAC_KEY',
16
- 'TCELL_AGENT_HOST_IDENTIFIER',
17
- 'TCELL_API_URL',
18
- 'TCELL_INPUT_URL',
19
- 'TCELL_DEMOMODE',
20
- 'TCELL_AGENT_HOME',
21
- 'TCELL_AGENT_LOG_DIR',
22
- 'TCELL_AGENT_CONFIG',
23
- 'TCELL_AGENT_ALLOW_PAYLOADS',
24
- 'TCELL_AGENT_LOG_LEVEL',
25
- 'TCELL_AGENT_LOG_FILENAME',
26
- 'TCELL_AGENT_LOG_ENABLED'
27
- ]
28
- )
29
-
30
- ENV.keys.each do |environment_key|
31
- if environment_key =~ /^TCELL_/ && !known_tcell_env_vars.include?(environment_key)
32
- messages << "Unrecognized environment parameter (TCELL_*) found: #{environment_key}"
33
- end
34
- end
35
-
36
- begin
37
- key_differences = []
38
-
39
- if config_json
40
- first_level_keys = %w[version applications]
41
-
42
- key_differences = config_json.keys - first_level_keys
43
-
44
- applications = config_json.fetch('applications', nil)
45
- if applications
46
-
47
- if applications.size > 1
48
- messages << 'Multiple applications detected in config file'
49
-
50
- elsif applications.size == 1
51
- application = applications[0]
52
-
53
- second_level_keys = %w[
54
- name
55
- app_id
56
- api_key
57
- fetch_policies_from_tcell
58
- preload_policy_filename
59
- log_dir
60
- tcell_api_url
61
- tcell_input_url
62
- host_identifier
63
- hipaaSafeMode
64
- hmac_key
65
- password_hmac_key
66
- js_agent_api_base_url
67
- js_agent_url
68
- max_csp_header_bytes
69
- event_batch_size_limit
70
- allow_payloads
71
- reverse_proxy
72
- reverse_proxy_ip_address_header
73
- demomode
74
- logging_options
75
- data_exposure
76
- disable_all
77
- enabled
78
- enable_event_manager
79
- enable_policy_polling
80
- enable_instrumentation
81
- enable_intercept_requests
82
- instrument_for_events
83
- enabled_instrumentations
84
- stdout_logger
85
- ]
86
-
87
- key_differences += (application.keys - second_level_keys)
88
-
89
- if application.fetch('logging_options', nil)
90
- logging_options = application['logging_options']
91
- key_differences += (logging_options.keys - %w[enabled level filename])
92
- end
93
-
94
- if application.fetch('data_exposure', nil)
95
- data_exposure = application['data_exposure']
96
- key_differences += (data_exposure.keys - ['max_data_ex_db_records_per_request'])
97
- end
98
-
99
- if application.fetch('enabled_instrumentations', nil)
100
- enabled_instrumentations = application['enabled_instrumentations']
101
- key_differences += (enabled_instrumentations.keys - %w[doorkeeper devise authlogic])
102
- end
103
- end
104
- end
105
-
106
- key_differences.each do |key|
107
- messages << "Unrecognized config setting key: #{key}"
108
- end
109
-
110
- end
111
- rescue StandardError => exception
112
- messages << "Something went wrong verifying config file: #{exception}"
113
- end
114
-
115
- messages
116
- end
117
- end
118
- end
119
- end
@@ -1,33 +0,0 @@
1
- if TCellAgent.configuration.should_instrument_devise? && defined?(Devise)
2
- require 'devise'
3
- require 'devise/rails'
4
- require 'devise/strategies/database_authenticatable'
5
- require 'tcell_agent/userinfo'
6
-
7
- module TCellAgent
8
- if defined?(Devise)
9
- TCellAgent::UserInformation.class_eval do
10
- class << self
11
- alias_method :original_get_user_from_request, :get_user_from_request
12
- def get_user_from_request(request)
13
- orig_user_id = original_get_user_from_request(request)
14
- begin
15
- if request.session && request.session.key?('warden.user.user.key')
16
- userkey = request.session['warden.user.user.key']
17
- user_id = if userkey.length == 2
18
- userkey[0][0]
19
- else
20
- userkey[1][0]
21
- end
22
- return user_id.to_s if user_id.is_a? Integer
23
- end
24
- rescue StandardError
25
- return orig_user_id
26
- end
27
- orig_user_id
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,25 +0,0 @@
1
- class File
2
- class << self
3
- alias_method :tcell_original_new, :new
4
- def new(*args, &block)
5
- path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
6
-
7
- if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
8
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
9
- end
10
-
11
- tcell_original_new(*args, &block)
12
- end
13
-
14
- alias_method :tcell_original_open, :open
15
- def open(*args, &block)
16
- path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
17
-
18
- if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
19
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
20
- end
21
-
22
- tcell_original_open(*args, &block)
23
- end
24
- end
25
- end
@@ -1,123 +0,0 @@
1
- class IO
2
- class << self
3
- alias_method :tcell_original_binread, :binread
4
- def binread(*args, &block)
5
- path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
6
-
7
- if path && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
8
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
9
- end
10
- cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
11
- if cmd && TCellAgent::Cmdi.block_command?(cmd)
12
- raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
13
- end
14
-
15
- tcell_original_binread(*args, &block)
16
- end
17
-
18
- alias_method :tcell_original_binwrite, :binwrite
19
- def binwrite(*args, &block)
20
- path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
21
- mode = 'Write'
22
-
23
- if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
24
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
25
- end
26
-
27
- tcell_original_binwrite(*args, &block)
28
- end
29
-
30
- alias_method :tcell_original_foreach, :foreach
31
- def foreach(*args, &block)
32
- path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
33
- mode = 'Read'
34
-
35
- if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
36
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
37
- end
38
-
39
- tcell_original_foreach(*args, &block)
40
- end
41
-
42
- alias_method :tcell_original_popen, :popen
43
- def popen(*args, &block)
44
- unless args.empty?
45
- cmd = ''
46
-
47
- TCellAgent::Instrumentation.safe_block('CMDI Parsing popen *args') do
48
- args_copy = Array.new(args)
49
- args_copy.shift if args_copy.first.is_a?(Hash)
50
- args_copy.pop if args_copy.last.is_a?(Hash)
51
-
52
- cmd = if args_copy.first.is_a?(String)
53
- args_copy.shift
54
- else
55
- TCellAgent::Cmdi.parse_command(*args_copy.shift)
56
- end
57
- end
58
-
59
- if TCellAgent::Cmdi.block_command?(cmd)
60
- raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
61
- end
62
- end
63
-
64
- tcell_original_popen(*args, &block)
65
- end
66
-
67
- alias_method :tcell_original_read, :read
68
- def read(*args, &block)
69
- path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
70
- mode = 'Read'
71
-
72
- if path && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
73
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
74
- end
75
-
76
- cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
77
- if cmd && TCellAgent::Cmdi.block_command?(cmd)
78
- raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
79
- end
80
- tcell_original_read(*args, &block)
81
- end
82
-
83
- alias_method :tcell_original_readlines, :readlines
84
- def readlines(*args, &block)
85
- path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
86
- mode = 'Read'
87
-
88
- if path && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
89
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
90
- end
91
-
92
- cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
93
- if cmd && TCellAgent::Cmdi.block_command?(cmd)
94
- raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
95
- end
96
-
97
- tcell_original_readlines(*args, &block)
98
- end
99
-
100
- alias_method :tcell_original_sysopen, :sysopen
101
- def sysopen(*args, &block)
102
- path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
103
-
104
- if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
105
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
106
- end
107
-
108
- tcell_original_sysopen(*args, &block)
109
- end
110
-
111
- alias_method :tcell_original_write, :write
112
- def write(*args, &block)
113
- path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
114
- mode = 'Write'
115
-
116
- if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
117
- raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
118
- end
119
-
120
- tcell_original_write(*args, &block)
121
- end
122
- end
123
- end