tcell_agent 2.1.0 → 2.3.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tcell_agent +42 -146
  3. data/lib/tcell_agent.rb +8 -16
  4. data/lib/tcell_agent/agent.rb +76 -46
  5. data/lib/tcell_agent/config_initializer.rb +66 -0
  6. data/lib/tcell_agent/configuration.rb +72 -267
  7. data/lib/tcell_agent/instrument_servers.rb +14 -18
  8. data/lib/tcell_agent/instrumentation/cmdi.rb +15 -15
  9. data/lib/tcell_agent/instrumentation/lfi.rb +16 -5
  10. data/lib/tcell_agent/instrumentation/monkey_patches/kernel.rb +39 -100
  11. data/lib/tcell_agent/logger.rb +1 -2
  12. data/lib/tcell_agent/rails/auth/authlogic.rb +49 -44
  13. data/lib/tcell_agent/rails/auth/authlogic_helper.rb +20 -0
  14. data/lib/tcell_agent/rails/auth/devise.rb +103 -102
  15. data/lib/tcell_agent/rails/auth/devise_helper.rb +29 -0
  16. data/lib/tcell_agent/rails/auth/doorkeeper.rb +54 -58
  17. data/lib/tcell_agent/{userinfo.rb → rails/auth/userinfo.rb} +0 -0
  18. data/lib/tcell_agent/rails/csrf_exception.rb +0 -8
  19. data/lib/tcell_agent/rails/dlp.rb +0 -4
  20. data/lib/tcell_agent/rails/middleware/global_middleware.rb +4 -1
  21. data/lib/tcell_agent/rails/{on_start.rb → railties/tcell_agent_railties.rb} +9 -16
  22. data/lib/tcell_agent/rails/railties/tcell_agent_unicorn_railties.rb +8 -0
  23. data/lib/tcell_agent/rails/routes.rb +3 -6
  24. data/lib/tcell_agent/rails/routes/grape.rb +4 -12
  25. data/lib/tcell_agent/rails/tcell_body_proxy.rb +0 -1
  26. data/lib/tcell_agent/rust/agent_config.rb +43 -32
  27. data/lib/tcell_agent/rust/{libtcellagent-4.17.1.dylib → libtcellagent-6.2.1.dylib} +0 -0
  28. data/lib/tcell_agent/rust/{libtcellagent-4.17.1.so → libtcellagent-6.2.1.so} +0 -0
  29. data/lib/tcell_agent/rust/{libtcellagent-alpine-4.17.1.so → libtcellagent-alpine-6.2.1.so} +0 -0
  30. data/lib/tcell_agent/rust/models.rb +9 -0
  31. data/lib/tcell_agent/rust/native_agent.rb +18 -0
  32. data/lib/tcell_agent/rust/native_library.rb +2 -1
  33. data/lib/tcell_agent/rust/{tcellagent-4.17.1.dll → tcellagent-6.2.1.dll} +0 -0
  34. data/lib/tcell_agent/servers/puma.rb +7 -7
  35. data/lib/tcell_agent/servers/rack_puma_handler.rb +23 -0
  36. data/lib/tcell_agent/servers/rails_server.rb +4 -4
  37. data/lib/tcell_agent/servers/unicorn.rb +1 -1
  38. data/lib/tcell_agent/servers/webrick.rb +0 -1
  39. data/lib/tcell_agent/settings_reporter.rb +0 -79
  40. data/lib/tcell_agent/tcell_context.rb +1 -1
  41. data/lib/tcell_agent/version.rb +1 -1
  42. data/spec/lib/tcell_agent/configuration_spec.rb +62 -212
  43. data/spec/lib/tcell_agent/instrument_servers_spec.rb +95 -0
  44. data/spec/lib/tcell_agent/instrumentation/cmdi_spec.rb +46 -4
  45. data/spec/lib/tcell_agent/instrumentation/lfi_spec.rb +47 -2
  46. data/spec/lib/tcell_agent/rust/agent_config_spec.rb +27 -0
  47. data/spec/lib/tcell_agent/settings_reporter_spec.rb +0 -73
  48. data/spec/spec_helper.rb +6 -0
  49. data/spec/support/builders.rb +6 -6
  50. data/spec/support/server_mocks/passenger_mock.rb +7 -0
  51. data/spec/support/server_mocks/puma_mock.rb +17 -0
  52. data/spec/support/server_mocks/rails_mock.rb +7 -0
  53. data/spec/support/server_mocks/thin_mock.rb +7 -0
  54. data/spec/support/server_mocks/unicorn_mock.rb +11 -0
  55. metadata +27 -14
  56. data/lib/tcell_agent/authlogic.rb +0 -23
  57. data/lib/tcell_agent/config/unknown_options.rb +0 -119
  58. data/lib/tcell_agent/devise.rb +0 -33
  59. data/lib/tcell_agent/rails/start_agent_after_initializers.rb +0 -12
  60. data/spec/lib/tcell_agent/config/unknown_options_spec.rb +0 -195
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d37df3ff2819b9794d9bde01418437c3efed75358fa58f4f65d80ea4f63e7b8
4
- data.tar.gz: 97efa888f4adf090f13fa5bc0597a91ea981ad299062d3dbd267ed4216b18ba8
3
+ metadata.gz: 15b359f97c96e28cf58ee258ebd6cc0112b31656165271012b8c804a406a2904
4
+ data.tar.gz: cd73c079ce0bd4f063a7c32571ae9e57155bdcd86fa4fd81a9738c97acec3d49
5
5
  SHA512:
6
- metadata.gz: 0f77740a99dd8678ca62a5ccf7e0e69304e680a8fa65258105c101ec360413920afcfea4d6e03237e1c6893198fa6232133ab05111bb2b0341586635db43a9bd
7
- data.tar.gz: c980a3e122b6453e3660358a2ba6a2bbe86179a9f54ca09e34135c8e9f86eb6498ebd8346dbf28b117f2f0b160bc23338b80502dc6c07c28d0b3b03472756a39
6
+ metadata.gz: 7dca586b7699c1bc013b1b5a07034087b8f45322cc30439b3d29e7ab16dfe8b8e85ae07d39738135020628e590bfb1b3a9b154bb6c954c99123102a4df19240a
7
+ data.tar.gz: 937109bc1a6b08d05cd3442e31ed6d4d2d4763ce7954d76cb65c26159c501c0e73fb68a2451c45b1b04e02fd15f3d0ab0564c29c59bf90fa4dc38db1472ea125
@@ -1,25 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # TODO: so a small bit becames something, larger, rewrite as a real cmdline script
4
-
5
- require 'fileutils'
6
- require 'json'
3
+ require 'tcell_agent'
7
4
  require 'optparse'
8
5
 
6
+ CONFIG_DIR = 'config'.freeze
7
+ CONFIG_FILE = 'config/tcell_agent.config'.freeze
9
8
  options = {}
10
-
11
- subtext = <<HELP
12
- Commonly used command are:
13
- setup : Setup new config file
14
- test : Run diagnostics classes and config
15
- loglevel : Set the loglevel of the tcell agent
16
- enable : Enable the agent
17
- disable : Disable the agent
18
-
19
- See 'tcell_agent COMMAND --help' for more information on a specific command.
20
-
21
- HELP
22
-
23
9
  def yesno(default = true)
24
10
  begin
25
11
  system('stty raw -echo')
@@ -34,74 +20,59 @@ def yesno(default = true)
34
20
  default
35
21
  end
36
22
 
37
- CONFIG_DIR = 'config'.freeze
38
- CONFIG_FILE = 'config/tcell_agent.config'.freeze
23
+ subtext = <<HELP
24
+ Commonly used commands are:
25
+ test : Run diagnostics and test event sending
26
+ HELP
39
27
 
40
28
  global = OptionParser.new do |opts|
41
- opts.banner = 'Usage: tcell_agent [options] [subcommand [options]]'
29
+ opts.banner = 'Usage: tcell_agent [options] [subcommand]'
30
+
42
31
  opts.on('--version', 'Print version') do |_v|
43
- require 'tcell_agent/version'
44
- puts "TCell.io Ruby Agent (Version #{TCellAgent::VERSION})"
32
+ puts "tCell Ruby Agent Version #{TCellAgent::VERSION}"
45
33
  Kernel.exit(1)
46
34
  end
47
- opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
48
- options[:verbose] = v
35
+
36
+ opts.on('test', 'Run diagnostics and test event sending') do |_v|
49
37
  end
50
38
  opts.separator ''
51
39
  opts.separator subtext
52
40
  end
53
41
 
54
42
  subcommands = {
55
- 'setup' => OptionParser.new do |opts|
56
- opts.banner = 'Usage: setup'
43
+ 'test' => OptionParser.new do |opts|
44
+ opts.banner = 'Usage: test'
57
45
  end,
58
46
  'loglevel' => OptionParser.new do |opts|
59
47
  opts.banner = 'Usage: loglevel [options] error|warn|info|debug'
60
48
  opts.on('-o', '--off', 'turn logging off ') do |v|
61
49
  options[:off] = v
62
50
  end
63
- end,
64
- 'preload' => OptionParser.new do |opts|
65
- opts.banner = 'Usage: loglevel [options] [preload_filename]'
66
- opts.on('-o', '--off', 'turn preloading filename off ') do |v|
67
- options[:off] = v
68
- end
69
- end,
70
- 'demomode' => OptionParser.new do |opts|
71
- opts.banner = 'Usage: loglevel [options]'
72
- opts.on('-o', '--off', 'turn preloading filename off ') do |v|
73
- options[:off] = v
74
- end
75
- end,
76
- 'enable' => OptionParser.new do |opts|
77
- opts.banner = 'Usage: enable'
78
- end,
79
- 'disable' => OptionParser.new do |opts|
80
- opts.banner = 'Usage: disable'
81
- end,
82
- 'test' => OptionParser.new do |opts|
83
- opts.banner = 'Usage: test'
84
- # opts.on("-q", "--[no-]quiet", "quietly run ") do |v|
85
- # options[:quiet] = v
86
- # end
87
- end
51
+ end
88
52
  }
89
53
 
90
54
  global.order!
91
55
  command = ARGV.shift
92
- if command.nil? || subcommands[command].nil?
56
+ deprecated_commands = %w[setup loglevel preload demomode enable disable]
57
+ if command.nil?
58
+ puts global
59
+ Kernel.exit(1)
60
+ elsif subcommands[command]
61
+ subcommands[command].order!
62
+ elsif !deprecated_commands.include?(command)
93
63
  puts global
94
64
  Kernel.exit(1)
95
65
  end
96
- subcommands[command].order!
97
66
 
98
67
  if command == 'setup'
68
+ puts '[WARN] tcell_agent setup is deprecated and will be removed in the future.'
69
+ puts ' Please download the config file from the tCell dashboard'
99
70
  unless File.directory?(CONFIG_DIR)
100
71
  print "Directory 'config' not found, create? [Y/n]"
101
72
  answer = yesno
102
73
  print "\n"
103
74
  unless answer
104
- puts 'ERROR: Could not create config'
75
+ puts '[ERROR] Could not create config'
105
76
  Kernel.exit(1)
106
77
  end
107
78
  FileUtils.mkdir_p CONFIG_DIR
@@ -132,6 +103,7 @@ if command == 'setup'
132
103
  puts 'done.'
133
104
 
134
105
  elsif command == 'loglevel'
106
+ puts '[WARN] tcell_agent loglevel is deprecated and will be removed in the future.'
135
107
  file = File.read(CONFIG_FILE)
136
108
  config_hash = JSON.parse(file)
137
109
  logging_options = config_hash['applications'][0].fetch('logging_options', {})
@@ -158,6 +130,7 @@ elsif command == 'loglevel'
158
130
  puts 'done.'
159
131
 
160
132
  elsif command == 'preload'
133
+ puts '[WARN] tcell_agent preload is deprecated and will be removed in the future.'
161
134
  file = File.read(CONFIG_FILE)
162
135
  config_hash = JSON.parse(file)
163
136
 
@@ -175,6 +148,7 @@ elsif command == 'preload'
175
148
  puts 'done.'
176
149
 
177
150
  elsif command == 'enable'
151
+ puts '[WARN] tcell_agent enable is deprecated and will be removed in the future.'
178
152
  file = File.read(CONFIG_FILE)
179
153
  config_hash = JSON.parse(file)
180
154
  config_hash['applications'][0].delete('enabled')
@@ -182,6 +156,7 @@ elsif command == 'enable'
182
156
  puts 'Enabled, you will need to restart the server.'
183
157
 
184
158
  elsif command == 'disable'
159
+ puts '[WARN] tcell_agent disable is deprecated and will be removed in the future.'
185
160
  file = File.read(CONFIG_FILE)
186
161
  config_hash = JSON.parse(file)
187
162
  config_hash['applications'][0]['enabled'] = false
@@ -189,6 +164,7 @@ elsif command == 'disable'
189
164
  puts 'Disabled, you will need to restart the server.'
190
165
 
191
166
  elsif command == 'demomode'
167
+ puts '[WARN] tcell_agent demomode is deprecated and will be removed in the future.'
192
168
  file = File.read(CONFIG_FILE)
193
169
  config_hash = JSON.parse(file)
194
170
  if options[:off] == true
@@ -200,104 +176,24 @@ elsif command == 'demomode'
200
176
  puts 'done.'
201
177
 
202
178
  elsif command == 'test'
203
- puts
204
- printf '%-50s', 'Config file exists... '
205
- unless File.exist?(CONFIG_FILE)
206
- puts 'failed'
207
- Kernel.exit(1)
208
- end
209
- puts 'passed'
210
-
211
- printf '%-50s', 'Config valid json... '
212
- file = File.read(CONFIG_FILE)
213
- config_hash = JSON.parse(file)
214
- puts 'passed'
215
-
216
- printf '%-50s', 'Config file has valid version... '
217
- if config_hash.fetch('version') != 1
218
- puts 'failed'
219
- Kernel.exit(1)
220
- end
221
- puts 'passed'
222
-
223
- printf '%-50s', 'Config file has application...'
224
- if config_hash.fetch('applications').empty?
225
- puts 'failed'
226
- Kernel.exit(1)
227
- end
228
- puts 'passed'
229
-
230
- printf '%-50s', 'Application has app_id... '
231
- tcell_application = config_hash.fetch('applications')[0]
232
- if !tcell_application.key?('app_id') && !ENV['TCELL_AGENT_APP_ID']
233
- puts 'failed'
234
- Kernel.exit(1)
235
- end
236
- puts 'passed'
237
-
238
- printf '%-50s', 'Application has api_key... '
239
- tcell_application = config_hash.fetch('applications')[0]
240
- if !tcell_application.key?('api_key') && !ENV['TCELL_AGENT_API_KEY']
241
- puts 'failed'
242
- Kernel.exit(1)
243
- end
244
- puts 'passed'
245
-
246
- printf '%-50s', 'Check for unknown settings... '
247
- require 'tcell_agent/config/unknown_options'
248
- messages = TCellAgent::Config::Validate.get_unknown_options(config_hash)
249
- unless messages.empty?
250
- puts 'failed'
251
- messages.each do |message|
252
- puts message
179
+ Dir[Dir.pwd + '/config/initializers/*.rb'].sort.each do |f|
180
+ begin
181
+ require f
182
+ rescue NameError # rubocop: disable Lint/HandleExceptions
183
+ rescue StandardError => e
184
+ puts "[ERROR] Loading initializers failed. #{e}"
253
185
  end
254
- Kernel.exit(1)
255
186
  end
256
- puts 'passed'
257
-
258
- printf '%-50s', 'Requiring configuration library... '
259
- require 'tcell_agent/configuration'
260
- puts 'passed'
261
187
 
262
- printf '%-50s', 'Loading native library... '
263
188
  require 'tcell_agent/rust/native_library'
264
189
  unless TCellAgent::Rust::NativeLibrary.common_lib_available?
265
- puts 'failed'
266
- Kernel.exit(1)
190
+ puts '[ERROR] Native Library is unavailable'
191
+ return
267
192
  end
268
- puts 'passed'
269
193
 
270
- printf '%-50s', 'Make test API call for policies... '
271
- require 'tcell_agent/rust/native_agent'
272
- errors = TCellAgent::Rust::NativeAgent.test_policies
273
- if !errors.empty?
274
- puts 'failed'
275
- puts errors
276
- Kernel.exit(1)
277
- else
278
- puts 'passed'
279
- end
280
-
281
- printf '%-50s', 'Sending a Test event... '
282
- require 'tcell_agent/logger'
283
- require 'tcell_agent/sensor_events/server_agent'
284
- errors = TCellAgent::Rust::NativeAgent.test_event_sender(
285
- [
286
- TCellAgent::SensorEvents::ServerAgentDetailsLanguageEvent.new(
287
- 'Ruby',
288
- RUBY_VERSION
289
- )
290
- ]
194
+ puts "tCell Ruby Agent Version #{TCellAgent::VERSION}"
195
+ TCellAgent::Rust::NativeAgent.test_agent(
196
+ TCellAgent.initializer_configuration ||
197
+ TCellAgent.configuration
291
198
  )
292
- if !errors.empty?
293
- puts 'failed'
294
- puts errors
295
- Kernel.exit(1)
296
- else
297
- puts 'passed'
298
- end
299
-
300
- puts
301
- puts 'all tests passed, looks good.'
302
- puts 'done.'
303
199
  end
@@ -1,26 +1,18 @@
1
1
  # See the file "LICENSE" for the full license governing this code.
2
-
3
- require 'tcell_agent/logger'
4
- require 'tcell_agent/utils/strings'
5
2
  require 'tcell_agent/configuration'
6
3
 
7
- require 'tcell_agent/agent'
8
-
9
- require 'tcell_agent/sensor_events/util/sanitizer_utilities'
10
-
11
- require 'tcell_agent/instrumentation'
4
+ unless TCellAgent.configuration.disable_all
5
+ require 'tcell_agent/logger'
6
+ require 'tcell_agent/utils/strings'
7
+ require 'tcell_agent/agent'
12
8
 
13
- require 'tcell_agent/instrument_servers'
9
+ require 'tcell_agent/sensor_events/util/sanitizer_utilities'
14
10
 
15
- if !TCellAgent.configuration.disable_all && TCellAgent.configuration.should_instrument?
16
- require 'tcell_agent/instrumentation/cmdi'
17
- require 'tcell_agent/instrumentation/lfi'
18
- require 'tcell_agent/instrumentation/monkey_patches/io'
19
- require 'tcell_agent/instrumentation/monkey_patches/file'
20
- require 'tcell_agent/instrumentation/monkey_patches/kernel'
11
+ require 'tcell_agent/instrumentation'
21
12
 
13
+ require 'tcell_agent/instrument_servers'
22
14
  require 'tcell_agent/hooks/login_fraud'
23
- require 'tcell_agent/rails/on_start' if defined?(Rails)
15
+ require 'tcell_agent/rails/railties/tcell_agent_railties' if defined?(Rails)
24
16
  # sinatra used to be supported, but dropped support due to no customers using it
25
17
  # require 'tcell_agent/sinatra' if defined?(Sinatra)
26
18
  end
@@ -24,75 +24,87 @@ module TCellAgent
24
24
  include TCellAgent::ModuleLoggerAccess
25
25
 
26
26
  attr_accessor :route_table,
27
- :stop_agent,
28
- :safe_to_check_cmdi
27
+ :stop_agent
29
28
 
30
29
  def initialize
31
30
  @stop_agent = false
32
31
  @native_agent = nil
33
32
  @route_table = TCellAgent::Routes::RouteTable.new
34
- @safe_to_check_cmdi = false
35
33
  @policies_manager = PoliciesManager.new(nil)
36
34
  end
37
35
 
38
- def validate_config
39
- if TCellAgent::Utils::Strings.blank?(TCellAgent.configuration.api_key) ||
40
- TCellAgent::Utils::Strings.blank?(TCellAgent.configuration.app_id) ||
41
- TCellAgent::Utils::Strings.blank?(TCellAgent.configuration.tcell_input_url) ||
42
- TCellAgent::Utils::Strings.blank?(TCellAgent.configuration.tcell_api_url)
43
- puts ' ********* ********* ********* *********'
44
- puts '* tCell.io *'
45
- puts '* Configuration info is missing, you may *'
46
- puts '* need to download config file and place *'
47
- puts '* it in the config/ directory *'
48
- puts ' ********* ********* ********* *********'
49
- TCellAgent.configuration.enabled = false
36
+ def instrument_auth_frameworks
37
+ if defined?(Devise) && TCellAgent.configuration.should_instrument?('devise')
38
+ module_logger.info('Instrumenting Devise authentication framework')
39
+ require 'tcell_agent/rails/auth/devise'
40
+ require 'tcell_agent/rails/auth/devise_helper'
41
+ end
42
+
43
+ if defined?(Authlogic) && TCellAgent.configuration.should_instrument?('authlogic')
44
+ module_logger.info('Instrumenting Authlogic authentication framework')
45
+ require 'tcell_agent/rails/auth/authlogic'
46
+ require 'tcell_agent/rails/auth/authlogic_helper'
47
+ end
48
+
49
+ if defined?(Doorkeeper) && TCellAgent.configuration.should_instrument?('doorkeeper') # rubocop:disable Style/GuardClause
50
+ module_logger.info('Instrumenting Doorkeeper authentication framework')
51
+ require 'tcell_agent/rails/auth/doorkeeper'
50
52
  end
51
53
  end
52
54
 
53
- def start(server_name)
54
- TCellAgent.thread_agent.validate_config
55
- return unless TCellAgent.configuration.should_instrument?
55
+ def instrument_built_ins
56
+ require 'tcell_agent/instrumentation/cmdi'
57
+ require 'tcell_agent/instrumentation/lfi'
56
58
 
57
- @native_agent = TCellAgent::Rust::NativeAgent.create_agent(
58
- TCellAgent.configuration
59
- )
60
- if @native_agent.nil?
61
- TCellAgent.configuration.enabled = false
62
- return
59
+ if TCellAgent.configuration.should_instrument?('io')
60
+ module_logger.info('Instrumenting Ruby Class: IO')
61
+ require 'tcell_agent/instrumentation/monkey_patches/io'
62
+ end
63
+
64
+ if TCellAgent.configuration.should_instrument?('file')
65
+ module_logger.info('Instrumenting Ruby Class: File')
66
+ require 'tcell_agent/instrumentation/monkey_patches/file'
67
+ end
68
+
69
+ if TCellAgent.configuration.should_instrument?('kernel') # rubocop:disable Style/GuardClause
70
+ module_logger.info('Instrumenting Ruby Module: Kernel')
71
+ require 'tcell_agent/instrumentation/monkey_patches/kernel'
63
72
  end
73
+ end
64
74
 
65
- TCellAgent.native_agent = @native_agent
75
+ def manage_policies
66
76
  @policies_manager = PoliciesManager.new(@native_agent)
67
- # if preload_policy_filename is used and policy polling is
68
- # disabled, need to call poll policies to make sure
69
- # ruby policies are in sync with native agent enablements
70
- result = @native_agent.poll_new_policies
77
+
78
+ result = {}
79
+ unless TCellAgent.configuration.should_start_policy_poll?
80
+ result = @native_agent.poll_new_policies
81
+ end
82
+
71
83
  policies_and_enablements = result['new_policies_and_enablements'] || {}
84
+
72
85
  @policies_manager.process_policy_json(
73
86
  policies_and_enablements['enablements'],
74
87
  policies_and_enablements['policies']
75
88
  )
76
89
 
77
90
  @policy_polling = PolicyPolling.new(@policies_manager, @native_agent)
91
+ end
78
92
 
79
- module_logger.info("Starting thread agent: #{server_name}")
93
+ def policies
94
+ @policies_manager.policies
95
+ end
80
96
 
81
- @safe_to_check_cmdi = true
97
+ def queue_sensor_event(event)
98
+ return unless @native_agent
82
99
 
83
- TCellAgent.report_settings
84
- TCellAgent::Instrumentation::Rails.send_framework_info
85
- TCellAgent::Instrumentation::Rails.send_settings
100
+ @native_agent.send_sanitized_events(
101
+ [event]
102
+ )
86
103
  rescue StandardError => standard_error
87
- TCellAgent.configuration.enabled = false
88
- module_logger.error("Error starting agent: (#{standard_error.class}) #{standard_error.message}")
104
+ module_logger.error("Error sending event: (#{standard_error.class}) #{standard_error.message}")
89
105
  module_logger.exception(standard_error)
90
106
  end
91
107
 
92
- def policies
93
- @policies_manager.policies
94
- end
95
-
96
108
  def report_metrics(request_time, tcell_context)
97
109
  @native_agent.report_metrics(
98
110
  request_time, tcell_context
@@ -102,14 +114,32 @@ module TCellAgent
102
114
  module_logger.exception(standard_error)
103
115
  end
104
116
 
105
- def queue_sensor_event(event)
106
- return unless @native_agent
107
-
108
- @native_agent.send_sanitized_events(
109
- [event]
117
+ def start(server_name)
118
+ @native_agent = TCellAgent::Rust::NativeAgent.create_agent(
119
+ TCellAgent.initializer_configuration ||
120
+ TCellAgent.configuration
110
121
  )
122
+
123
+ if @native_agent.nil?
124
+ TCellAgent.configuration.enabled = false
125
+ return
126
+ end
127
+
128
+ TCellAgent.native_logger = @native_agent
129
+
130
+ module_logger.info('Rails initializer overriding default agent configuration') unless TCellAgent.initializer_configuration.nil?
131
+
132
+ instrument_auth_frameworks
133
+ instrument_built_ins
134
+ manage_policies
135
+
136
+ module_logger.info("Started thread agent: #{server_name}")
137
+ TCellAgent.report_settings
138
+ TCellAgent::Instrumentation::Rails.send_framework_info
139
+ TCellAgent::Instrumentation::Rails.send_settings
111
140
  rescue StandardError => standard_error
112
- module_logger.error("Error sending event: (#{standard_error.class}) #{standard_error.message}")
141
+ TCellAgent.configuration.enabled = false
142
+ module_logger.error("Error starting agent: (#{standard_error.class}) #{standard_error.message}")
113
143
  module_logger.exception(standard_error)
114
144
  end
115
145
  end