tcell_agent 2.2.1 → 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.
- checksums.yaml +4 -4
- data/LICENSE +2 -2
- data/bin/tcell_agent +6 -11
- data/lib/tcell_agent/agent.rb +18 -13
- data/lib/tcell_agent/config_initializer.rb +2 -5
- data/lib/tcell_agent/configuration.rb +6 -6
- data/lib/tcell_agent/hooks/login_fraud.rb +1 -1
- data/lib/tcell_agent/instrumentation/cmdi.rb +32 -0
- data/lib/tcell_agent/instrumentation/lfi.rb +55 -9
- data/lib/tcell_agent/instrumentation/monkey_patches/ruby_2/file.rb +21 -0
- data/lib/tcell_agent/instrumentation/monkey_patches/ruby_2/io.rb +75 -0
- data/lib/tcell_agent/instrumentation/monkey_patches/ruby_2/kernel.rb +80 -0
- data/lib/tcell_agent/instrumentation/monkey_patches/ruby_3/file.rb +21 -0
- data/lib/tcell_agent/instrumentation/monkey_patches/ruby_3/io.rb +75 -0
- data/lib/tcell_agent/instrumentation/monkey_patches/ruby_3/kernel.rb +80 -0
- data/lib/tcell_agent/instrumentation.rb +14 -6
- data/lib/tcell_agent/logger.rb +2 -2
- data/lib/tcell_agent/policies/dataloss_policy.rb +15 -8
- data/lib/tcell_agent/policies/headers_policy.rb +2 -2
- data/lib/tcell_agent/policies/patches_policy.rb +8 -4
- data/lib/tcell_agent/policies/policies_manager.rb +1 -0
- data/lib/tcell_agent/policies/policy_polling.rb +4 -3
- data/lib/tcell_agent/rails/auth/doorkeeper.rb +1 -0
- data/lib/tcell_agent/rails/better_ip.rb +7 -19
- data/lib/tcell_agent/rails/dlp/process_request.rb +5 -0
- data/lib/tcell_agent/rails/dlp.rb +48 -48
- data/lib/tcell_agent/rails/dlp_handler.rb +9 -10
- data/lib/tcell_agent/rails/js_agent_insert.rb +2 -3
- data/lib/tcell_agent/rails/middleware/context_middleware.rb +2 -1
- data/lib/tcell_agent/rails/middleware/global_middleware.rb +1 -5
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +1 -0
- data/lib/tcell_agent/rails/routes/grape.rb +2 -1
- data/lib/tcell_agent/rails/settings_reporter.rb +3 -6
- data/lib/tcell_agent/rails/tcell_body_proxy.rb +4 -6
- data/lib/tcell_agent/routes/table.rb +3 -0
- data/lib/tcell_agent/rust/agent_config.rb +20 -2
- data/lib/tcell_agent/rust/{libtcellagent-5.0.2.so → libtcellagent-alpine.so} +0 -0
- data/lib/tcell_agent/rust/{tcellagent-5.0.2.dll → libtcellagent-x64.dll} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-5.0.2.dylib → libtcellagent.dylib} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-alpine-5.0.2.so → libtcellagent.so} +0 -0
- data/lib/tcell_agent/rust/native_agent.rb +51 -59
- data/lib/tcell_agent/rust/native_library.rb +7 -10
- data/lib/tcell_agent/sensor_events/server_agent.rb +3 -100
- data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +1 -0
- data/lib/tcell_agent/servers/puma.rb +25 -8
- data/lib/tcell_agent/servers/rack_puma_handler.rb +13 -3
- data/lib/tcell_agent/servers/webrick.rb +13 -3
- data/lib/tcell_agent/settings_reporter.rb +0 -14
- data/lib/tcell_agent/sinatra.rb +1 -0
- data/lib/tcell_agent/tcell_context.rb +15 -6
- data/lib/tcell_agent/utils/headers.rb +0 -1
- data/lib/tcell_agent/utils/strings.rb +2 -2
- data/lib/tcell_agent/version.rb +1 -1
- data/spec/cruby_spec_helper.rb +26 -0
- data/spec/lib/tcell_agent/instrument_servers_spec.rb +1 -1
- data/spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb +2 -2
- data/spec/lib/tcell_agent/instrumentation/lfi/file_lfi_spec.rb +211 -272
- data/spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb +207 -223
- data/spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb +89 -70
- data/spec/lib/tcell_agent/instrumentation/lfi_spec.rb +73 -0
- data/spec/lib/tcell_agent/patches_spec.rb +2 -1
- data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +1 -2
- data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +5 -6
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +21 -2
- data/spec/lib/tcell_agent/policies/policies_manager_spec.rb +1 -1
- data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +13 -8
- data/spec/lib/tcell_agent/rails/better_ip_spec.rb +9 -11
- data/spec/lib/tcell_agent/rails/csrf_exception_spec.rb +6 -6
- data/spec/lib/tcell_agent/rails/dlp_spec.rb +1 -0
- data/spec/lib/tcell_agent/rails/js_agent_insert_spec.rb +10 -2
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +2 -1
- data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +4 -4
- data/spec/lib/tcell_agent/settings_reporter_spec.rb +2 -16
- data/spec/lib/tcell_agent/tcell_context_spec.rb +6 -5
- data/spec/spec_helper.rb +3 -1
- data/spec/support/builders.rb +2 -1
- data/spec/support/server_mocks/puma_mock.rb +4 -0
- data/spec/support/shared_spec.rb +29 -0
- data/tcell_agent.gemspec +14 -14
- metadata +23 -19
- data/Rakefile +0 -18
- data/lib/tcell_agent/instrumentation/monkey_patches/file.rb +0 -25
- data/lib/tcell_agent/instrumentation/monkey_patches/io.rb +0 -131
- data/lib/tcell_agent/instrumentation/monkey_patches/kernel.rb +0 -102
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4460b2fd01c8b788c8139cbeb2cee7f8a2505e4cc365c279a518778766d9cdb0
|
|
4
|
+
data.tar.gz: 18dfdd5e944e91155d6b58fa22262b027292038192fac0b6afd4693314f74fd8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2404786f0663783fd45194043c4a12efda21db0e933c14aca5f2d4532e900aac3b3f700ca8282b1995b38c718b6e0eade2a2b1ffbc9df467bf8ab5b4f144b18
|
|
7
|
+
data.tar.gz: 5021cff2601b66fd94a41b710ab0ab0211be35b2bd442afc0ca992ce4236d6c65e3ef69e14cd2ca9455fb4282d8affa1ba3e7aa3f05c75e4285ff6b5ab77e871
|
data/LICENSE
CHANGED
data/bin/tcell_agent
CHANGED
|
@@ -9,7 +9,7 @@ options = {}
|
|
|
9
9
|
def yesno(default = true)
|
|
10
10
|
begin
|
|
11
11
|
system('stty raw -echo')
|
|
12
|
-
str =
|
|
12
|
+
str = $stdin.getc
|
|
13
13
|
ensure
|
|
14
14
|
system('stty -raw echo')
|
|
15
15
|
end
|
|
@@ -33,8 +33,6 @@ global = OptionParser.new do |opts|
|
|
|
33
33
|
Kernel.exit(1)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
opts.on('test', 'Run diagnostics and test event sending') do |_v|
|
|
37
|
-
end
|
|
38
36
|
opts.separator ''
|
|
39
37
|
opts.separator subtext
|
|
40
38
|
end
|
|
@@ -53,15 +51,11 @@ subcommands = {
|
|
|
53
51
|
|
|
54
52
|
global.order!
|
|
55
53
|
command = ARGV.shift
|
|
56
|
-
deprecated_commands = %w[setup loglevel preload demomode enable disable]
|
|
57
54
|
if command.nil?
|
|
58
55
|
puts global
|
|
59
56
|
Kernel.exit(1)
|
|
60
57
|
elsif subcommands[command]
|
|
61
58
|
subcommands[command].order!
|
|
62
|
-
elsif !deprecated_commands.include?(command)
|
|
63
|
-
puts global
|
|
64
|
-
Kernel.exit(1)
|
|
65
59
|
end
|
|
66
60
|
|
|
67
61
|
if command == 'setup'
|
|
@@ -87,9 +81,9 @@ if command == 'setup'
|
|
|
87
81
|
end
|
|
88
82
|
end
|
|
89
83
|
print 'Enter your API Key (ie gAABAAAA...): '
|
|
90
|
-
api_key =
|
|
84
|
+
api_key = $stdin.gets.chomp
|
|
91
85
|
print 'Enter your App ID (ie MyApp-Fdk4j): '
|
|
92
|
-
app_id =
|
|
86
|
+
app_id = $stdin.gets.chomp
|
|
93
87
|
config_hash = {
|
|
94
88
|
'version' => 1,
|
|
95
89
|
'applications' => [
|
|
@@ -176,10 +170,11 @@ elsif command == 'demomode'
|
|
|
176
170
|
puts 'done.'
|
|
177
171
|
|
|
178
172
|
elsif command == 'test'
|
|
179
|
-
Dir[Dir.pwd
|
|
173
|
+
Dir["#{Dir.pwd}/config/initializers/*.rb"].sort.each do |f|
|
|
180
174
|
begin
|
|
181
175
|
require f
|
|
182
|
-
rescue NameError
|
|
176
|
+
rescue NameError
|
|
177
|
+
# do nothing
|
|
183
178
|
rescue StandardError => e
|
|
184
179
|
puts "[ERROR] Loading initializers failed. #{e}"
|
|
185
180
|
end
|
data/lib/tcell_agent/agent.rb
CHANGED
|
@@ -56,19 +56,25 @@ module TCellAgent
|
|
|
56
56
|
require 'tcell_agent/instrumentation/cmdi'
|
|
57
57
|
require 'tcell_agent/instrumentation/lfi'
|
|
58
58
|
|
|
59
|
+
variant = if RUBY_VERSION.start_with?('3')
|
|
60
|
+
'ruby_3'
|
|
61
|
+
else
|
|
62
|
+
'ruby_2'
|
|
63
|
+
end
|
|
64
|
+
|
|
59
65
|
if TCellAgent.configuration.should_instrument?('io')
|
|
60
66
|
module_logger.info('Instrumenting Ruby Class: IO')
|
|
61
|
-
require
|
|
67
|
+
require "tcell_agent/instrumentation/monkey_patches/#{variant}/io"
|
|
62
68
|
end
|
|
63
69
|
|
|
64
70
|
if TCellAgent.configuration.should_instrument?('file')
|
|
65
71
|
module_logger.info('Instrumenting Ruby Class: File')
|
|
66
|
-
require
|
|
72
|
+
require "tcell_agent/instrumentation/monkey_patches/#{variant}/file"
|
|
67
73
|
end
|
|
68
74
|
|
|
69
75
|
if TCellAgent.configuration.should_instrument?('kernel') # rubocop:disable Style/GuardClause
|
|
70
76
|
module_logger.info('Instrumenting Ruby Module: Kernel')
|
|
71
|
-
require
|
|
77
|
+
require "tcell_agent/instrumentation/monkey_patches/#{variant}/kernel"
|
|
72
78
|
end
|
|
73
79
|
end
|
|
74
80
|
|
|
@@ -100,18 +106,18 @@ module TCellAgent
|
|
|
100
106
|
@native_agent.send_sanitized_events(
|
|
101
107
|
[event]
|
|
102
108
|
)
|
|
103
|
-
rescue StandardError =>
|
|
104
|
-
module_logger.error("Error sending event: (#{
|
|
105
|
-
module_logger.exception(
|
|
109
|
+
rescue StandardError => e
|
|
110
|
+
module_logger.error("Error sending event: (#{e.class}) #{e.message}")
|
|
111
|
+
module_logger.exception(e)
|
|
106
112
|
end
|
|
107
113
|
|
|
108
114
|
def report_metrics(request_time, tcell_context)
|
|
109
115
|
@native_agent.report_metrics(
|
|
110
116
|
request_time, tcell_context
|
|
111
117
|
)
|
|
112
|
-
rescue StandardError =>
|
|
113
|
-
module_logger.error("Error reporting metric: (#{
|
|
114
|
-
module_logger.exception(
|
|
118
|
+
rescue StandardError => e
|
|
119
|
+
module_logger.error("Error reporting metric: (#{e.class}) #{e.message}")
|
|
120
|
+
module_logger.exception(e)
|
|
115
121
|
end
|
|
116
122
|
|
|
117
123
|
def start(server_name)
|
|
@@ -135,12 +141,11 @@ module TCellAgent
|
|
|
135
141
|
|
|
136
142
|
module_logger.info("Started thread agent: #{server_name}")
|
|
137
143
|
TCellAgent.report_settings
|
|
138
|
-
TCellAgent::Instrumentation::Rails.send_framework_info
|
|
139
144
|
TCellAgent::Instrumentation::Rails.send_settings
|
|
140
|
-
rescue StandardError =>
|
|
145
|
+
rescue StandardError => e
|
|
141
146
|
TCellAgent.configuration.enabled = false
|
|
142
|
-
module_logger.error("Error starting agent: (#{
|
|
143
|
-
module_logger.exception(
|
|
147
|
+
module_logger.error("Error starting agent: (#{e.class}) #{e.message}")
|
|
148
|
+
module_logger.exception(e)
|
|
144
149
|
end
|
|
145
150
|
end
|
|
146
151
|
end
|
|
@@ -9,7 +9,8 @@ module TCellAgent
|
|
|
9
9
|
:reverse_proxy_ip_address_header, :host_identifier,
|
|
10
10
|
:hmac_key, :password_hmac_key,
|
|
11
11
|
:js_agent_url, :js_agent_api_base_url,
|
|
12
|
-
:max_csp_header_bytes, :allow_payloads
|
|
12
|
+
:max_csp_header_bytes, :allow_payloads,
|
|
13
|
+
:proxy_url, :proxy_username, :proxy_password
|
|
13
14
|
|
|
14
15
|
attr_reader :logging_options
|
|
15
16
|
|
|
@@ -58,9 +59,5 @@ module TCellAgent
|
|
|
58
59
|
def enable_intercept_requests=(bool)
|
|
59
60
|
@disabled_instrumentation << 'intercept_requests' unless TCellAgent.configuration.to_bool(bool)
|
|
60
61
|
end
|
|
61
|
-
|
|
62
|
-
def get_config_file_dir
|
|
63
|
-
super
|
|
64
|
-
end
|
|
65
62
|
end
|
|
66
63
|
end
|
|
@@ -64,11 +64,11 @@ module TCellAgent
|
|
|
64
64
|
check_for_disabled_instrumentation(get_config_file_name)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
def
|
|
67
|
+
def get_config_file_path
|
|
68
68
|
return nil unless ENV['TCELL_AGENT_HOME']
|
|
69
69
|
return nil if ENV['TCELL_AGENT_CONFIG']
|
|
70
70
|
|
|
71
|
-
File.join(Dir.getwd, '/config')
|
|
71
|
+
File.join(Dir.getwd, '/config/tcell_agent.config')
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def get_config_file_name
|
|
@@ -85,7 +85,8 @@ module TCellAgent
|
|
|
85
85
|
app_data = config['applications'][0]
|
|
86
86
|
@disable_all = to_bool(app_data.fetch('disable_all', @disable_all))
|
|
87
87
|
end
|
|
88
|
-
rescue StandardError
|
|
88
|
+
rescue StandardError
|
|
89
|
+
# do nothing
|
|
89
90
|
end
|
|
90
91
|
end
|
|
91
92
|
|
|
@@ -108,9 +109,8 @@ module TCellAgent
|
|
|
108
109
|
@password_hmac_key = apps['password_hmac_key']
|
|
109
110
|
|
|
110
111
|
# proxy config
|
|
111
|
-
|
|
112
|
-
@
|
|
113
|
-
@reverse_proxy_ip_address_header = proxy_config['reverse_proxy_ip_address_header']
|
|
112
|
+
@reverse_proxy = apps['reverse_proxy']
|
|
113
|
+
@reverse_proxy_ip_address_header = apps['reverse_proxy_ip_address_header']
|
|
114
114
|
|
|
115
115
|
# endpoint config
|
|
116
116
|
endpoint = native_agent_config_response['endpoint_config'] || {}
|
|
@@ -3,7 +3,7 @@ require 'tcell_agent/agent'
|
|
|
3
3
|
module TCellAgent
|
|
4
4
|
module Hooks
|
|
5
5
|
module LoginFraud
|
|
6
|
-
#
|
|
6
|
+
# NOTE: mock out in tests
|
|
7
7
|
def self.get_logger
|
|
8
8
|
unless defined?(@login_fraud_logger)
|
|
9
9
|
@login_fraud_logger = TCellAgent::ModuleLogger.new(TCellAgent.logger, name)
|
|
@@ -56,5 +56,37 @@ module TCellAgent
|
|
|
56
56
|
|
|
57
57
|
cmd
|
|
58
58
|
end
|
|
59
|
+
|
|
60
|
+
def self.raise_if_block(cmd)
|
|
61
|
+
return unless TCellAgent::Cmdi.block_command?(cmd)
|
|
62
|
+
|
|
63
|
+
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.default_cmdi_handler(args)
|
|
67
|
+
cmd = TCellAgent::Cmdi.parse_command(*args)
|
|
68
|
+
|
|
69
|
+
raise_if_block(cmd)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.popen_cmdi_handler(args)
|
|
73
|
+
return if args.empty?
|
|
74
|
+
|
|
75
|
+
cmd = ''
|
|
76
|
+
|
|
77
|
+
TCellAgent::Instrumentation.safe_block('CMDI Parsing popen *args') do
|
|
78
|
+
args_copy = Array.new(args)
|
|
79
|
+
args_copy.shift if args_copy.first.is_a?(Hash)
|
|
80
|
+
args_copy.pop if args_copy.last.is_a?(Hash)
|
|
81
|
+
|
|
82
|
+
cmd = if args_copy.first.is_a?(String)
|
|
83
|
+
args_copy.shift
|
|
84
|
+
else
|
|
85
|
+
TCellAgent::Cmdi.parse_command(*args_copy.shift)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
raise_if_block(cmd)
|
|
90
|
+
end
|
|
59
91
|
end
|
|
60
92
|
end
|
|
@@ -5,6 +5,8 @@ require 'tcell_agent/configuration'
|
|
|
5
5
|
module TCellAgent
|
|
6
6
|
module Instrumentation
|
|
7
7
|
module Lfi
|
|
8
|
+
extend TCellAgent::ModuleLoggerAccess
|
|
9
|
+
|
|
8
10
|
def self.block_file_access?(path, mode)
|
|
9
11
|
TCellAgent::Instrumentation.safe_block('Checking Local Files Policy') do
|
|
10
12
|
if TCellAgent::Utils::Strings.present?(path)
|
|
@@ -54,17 +56,27 @@ module TCellAgent
|
|
|
54
56
|
mode = 'Read'
|
|
55
57
|
|
|
56
58
|
TCellAgent::Instrumentation.safe_block('LFI Parsing ARGF') do
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
path = argv_copy.shift
|
|
60
|
-
else
|
|
61
|
-
path = ARGF.filename
|
|
62
|
-
end
|
|
59
|
+
begin
|
|
60
|
+
return ['', ''] if ARGF.file == $stdin
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
if ARGF.eof? && !ARGV.empty?
|
|
63
|
+
argv_copy = Array.new(ARGV)
|
|
64
|
+
path = argv_copy.shift
|
|
65
|
+
else
|
|
66
|
+
path = ARGF.filename
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
if path && path.to_s[0] != '|'
|
|
70
|
+
[File.expand_path(path.to_s), mode]
|
|
71
|
+
else
|
|
72
|
+
['', '']
|
|
73
|
+
end
|
|
74
|
+
rescue Errno::ENOENT
|
|
75
|
+
module_logger.debug('LFI Parsing ARGF: attempted to read a non-existent file')
|
|
67
76
|
['', '']
|
|
77
|
+
rescue Errno::EISDIR
|
|
78
|
+
module_logger.debug('LFI Parsing ARGF: attempted to read a directory')
|
|
79
|
+
[ARGF.filename, mode]
|
|
68
80
|
end
|
|
69
81
|
end
|
|
70
82
|
end
|
|
@@ -79,6 +91,40 @@ module TCellAgent
|
|
|
79
91
|
end
|
|
80
92
|
'Read'
|
|
81
93
|
end
|
|
94
|
+
|
|
95
|
+
def self.raise_if_block(path, mode)
|
|
96
|
+
return unless block_file_access?(path, mode)
|
|
97
|
+
|
|
98
|
+
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def self.default_open_handler(args, override_mode = '')
|
|
102
|
+
path, mode = extract_path_mode(*args)
|
|
103
|
+
|
|
104
|
+
mode = override_mode unless override_mode.empty?
|
|
105
|
+
|
|
106
|
+
raise_if_block(path, mode)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def self.argf_open_handler
|
|
110
|
+
path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode_argf
|
|
111
|
+
|
|
112
|
+
raise_if_block(path, mode)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def self.cmdi_open_handler(args, override_mode = '')
|
|
116
|
+
path, mode = extract_path_mode(*args)
|
|
117
|
+
|
|
118
|
+
mode = override_mode unless override_mode.empty?
|
|
119
|
+
|
|
120
|
+
raise_if_block(path, mode)
|
|
121
|
+
|
|
122
|
+
return unless path.empty?
|
|
123
|
+
|
|
124
|
+
cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
|
|
125
|
+
|
|
126
|
+
TCellAgent::Cmdi.raise_if_block(cmd) if cmd
|
|
127
|
+
end
|
|
82
128
|
end
|
|
83
129
|
end
|
|
84
130
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class File
|
|
2
|
+
class << self
|
|
3
|
+
if TCellAgent.configuration.should_instrument?('File::new')
|
|
4
|
+
alias_method :tcell_original_new, :new
|
|
5
|
+
def new(*args, &block)
|
|
6
|
+
TCellAgent::Instrumentation::Lfi.default_open_handler(args)
|
|
7
|
+
|
|
8
|
+
tcell_original_new(*args, &block)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
if TCellAgent.configuration.should_instrument?('File::open')
|
|
13
|
+
alias_method :tcell_original_open, :open
|
|
14
|
+
def open(*args, &block)
|
|
15
|
+
TCellAgent::Instrumentation::Lfi.default_open_handler(args)
|
|
16
|
+
|
|
17
|
+
tcell_original_open(*args, &block)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
class IO
|
|
2
|
+
class << self
|
|
3
|
+
if TCellAgent.configuration.should_instrument?('IO::binread')
|
|
4
|
+
alias_method :tcell_original_binread, :binread
|
|
5
|
+
def binread(*args, &block)
|
|
6
|
+
TCellAgent::Instrumentation::Lfi.cmdi_open_handler(args)
|
|
7
|
+
|
|
8
|
+
tcell_original_binread(*args, &block)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
if TCellAgent.configuration.should_instrument?('IO::binwrite')
|
|
13
|
+
alias_method :tcell_original_binwrite, :binwrite
|
|
14
|
+
def binwrite(*args, &block)
|
|
15
|
+
TCellAgent::Instrumentation::Lfi.default_open_handler(args, 'Write')
|
|
16
|
+
|
|
17
|
+
tcell_original_binwrite(*args, &block)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
if TCellAgent.configuration.should_instrument?('IO::foreach')
|
|
22
|
+
alias_method :tcell_original_foreach, :foreach
|
|
23
|
+
def foreach(*args, &block)
|
|
24
|
+
TCellAgent::Instrumentation::Lfi.default_open_handler(args, 'Read')
|
|
25
|
+
|
|
26
|
+
tcell_original_foreach(*args, &block)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if TCellAgent.configuration.should_instrument?('IO::popen')
|
|
31
|
+
alias_method :tcell_original_popen, :popen
|
|
32
|
+
def popen(*args, &block)
|
|
33
|
+
TCellAgent::Cmdi.popen_cmdi_handler(args)
|
|
34
|
+
|
|
35
|
+
tcell_original_popen(*args, &block)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if TCellAgent.configuration.should_instrument?('IO::read')
|
|
40
|
+
alias_method :tcell_original_read, :read
|
|
41
|
+
def read(*args, &block)
|
|
42
|
+
TCellAgent::Instrumentation::Lfi.cmdi_open_handler(args, 'Read')
|
|
43
|
+
|
|
44
|
+
tcell_original_read(*args, &block)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
if TCellAgent.configuration.should_instrument?('IO::readlines')
|
|
49
|
+
alias_method :tcell_original_readlines, :readlines
|
|
50
|
+
def readlines(*args, &block)
|
|
51
|
+
TCellAgent::Instrumentation::Lfi.cmdi_open_handler(args, 'Read')
|
|
52
|
+
|
|
53
|
+
tcell_original_readlines(*args, &block)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
if TCellAgent.configuration.should_instrument?('IO::sysopen')
|
|
58
|
+
alias_method :tcell_original_sysopen, :sysopen
|
|
59
|
+
def sysopen(*args, &block)
|
|
60
|
+
TCellAgent::Instrumentation::Lfi.default_open_handler(args)
|
|
61
|
+
|
|
62
|
+
tcell_original_sysopen(*args, &block)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if TCellAgent.configuration.should_instrument?('IO::write')
|
|
67
|
+
alias_method :tcell_original_write, :write
|
|
68
|
+
def write(*args, &block)
|
|
69
|
+
TCellAgent::Instrumentation::Lfi.default_open_handler(args, 'Write')
|
|
70
|
+
|
|
71
|
+
tcell_original_write(*args, &block)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
private
|
|
3
|
+
|
|
4
|
+
if TCellAgent.configuration.should_instrument?('Kernel#`')
|
|
5
|
+
alias_method :tcell_original_backtick, :`
|
|
6
|
+
def `(cmd)
|
|
7
|
+
TCellAgent::Cmdi.raise_if_block(cmd)
|
|
8
|
+
|
|
9
|
+
tcell_original_backtick(cmd)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module_function :`
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if TCellAgent.configuration.should_instrument?('Kernel#exec')
|
|
16
|
+
alias_method :tcell_original_exec, :exec
|
|
17
|
+
def exec(*args)
|
|
18
|
+
TCellAgent::Cmdi.default_cmdi_handler(args)
|
|
19
|
+
|
|
20
|
+
tcell_original_exec(*args)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module_function :exec
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
if TCellAgent.configuration.should_instrument?('Kernel#gets')
|
|
27
|
+
alias_method :tcell_original_gets, :gets
|
|
28
|
+
def gets(*args, &block)
|
|
29
|
+
TCellAgent::Instrumentation::Lfi.argf_open_handler
|
|
30
|
+
|
|
31
|
+
tcell_original_gets(*args, &block)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module_function :gets
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if TCellAgent.configuration.should_instrument?('Kernel#open')
|
|
38
|
+
alias_method :tcell_original_open, :open
|
|
39
|
+
def open(*args, &block)
|
|
40
|
+
TCellAgent::Instrumentation::Lfi.cmdi_open_handler(args)
|
|
41
|
+
|
|
42
|
+
tcell_original_open(*args, &block)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
module_function :open
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
if TCellAgent.configuration.should_instrument?('Kernel#readline')
|
|
49
|
+
alias_method :tcell_original_readline, :readline
|
|
50
|
+
def readline(*args, &block)
|
|
51
|
+
TCellAgent::Instrumentation::Lfi.argf_open_handler
|
|
52
|
+
|
|
53
|
+
tcell_original_readline(*args, &block)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
module_function :readline
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
if TCellAgent.configuration.should_instrument?('Kernel#spawn')
|
|
60
|
+
alias_method :tcell_original_spawn, :spawn
|
|
61
|
+
def spawn(*args)
|
|
62
|
+
TCellAgent::Cmdi.default_cmdi_handler(args)
|
|
63
|
+
|
|
64
|
+
tcell_original_spawn(*args)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
module_function :spawn
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if TCellAgent.configuration.should_instrument?('Kernel#system')
|
|
71
|
+
alias_method :tcell_original_system, :system
|
|
72
|
+
def system(*args)
|
|
73
|
+
TCellAgent::Cmdi.default_cmdi_handler(args)
|
|
74
|
+
|
|
75
|
+
tcell_original_system(*args)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
module_function :system
|
|
79
|
+
end
|
|
80
|
+
end
|