tcell_agent 2.1.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +2 -2
- data/bin/tcell_agent +41 -150
- data/lib/tcell_agent.rb +8 -16
- data/lib/tcell_agent/agent.rb +87 -52
- data/lib/tcell_agent/config_initializer.rb +62 -0
- data/lib/tcell_agent/configuration.rb +72 -267
- data/lib/tcell_agent/hooks/login_fraud.rb +1 -1
- data/lib/tcell_agent/instrument_servers.rb +14 -18
- data/lib/tcell_agent/instrumentation.rb +14 -6
- data/lib/tcell_agent/instrumentation/cmdi.rb +47 -15
- data/lib/tcell_agent/instrumentation/lfi.rb +68 -11
- 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/logger.rb +3 -4
- 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/authlogic.rb +49 -44
- data/lib/tcell_agent/rails/auth/authlogic_helper.rb +20 -0
- data/lib/tcell_agent/rails/auth/devise.rb +103 -102
- data/lib/tcell_agent/rails/auth/devise_helper.rb +29 -0
- data/lib/tcell_agent/rails/auth/doorkeeper.rb +54 -57
- data/lib/tcell_agent/{userinfo.rb → rails/auth/userinfo.rb} +0 -0
- data/lib/tcell_agent/rails/better_ip.rb +7 -19
- data/lib/tcell_agent/rails/csrf_exception.rb +0 -8
- data/lib/tcell_agent/rails/dlp.rb +48 -52
- data/lib/tcell_agent/rails/dlp/process_request.rb +5 -0
- 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 +3 -4
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +1 -0
- data/lib/tcell_agent/rails/{on_start.rb → railties/tcell_agent_railties.rb} +9 -16
- data/lib/tcell_agent/rails/railties/tcell_agent_unicorn_railties.rb +8 -0
- data/lib/tcell_agent/rails/routes.rb +3 -6
- data/lib/tcell_agent/rails/routes/grape.rb +5 -12
- data/lib/tcell_agent/rails/settings_reporter.rb +0 -8
- data/lib/tcell_agent/rails/tcell_body_proxy.rb +4 -7
- data/lib/tcell_agent/routes/table.rb +3 -0
- data/lib/tcell_agent/rust/agent_config.rb +52 -32
- data/lib/tcell_agent/rust/{libtcellagent-4.18.0.so → libtcellagent-alpine.so} +0 -0
- data/lib/tcell_agent/rust/libtcellagent-x64.dll +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-4.18.0.dylib → libtcellagent.dylib} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-alpine-4.18.0.so → libtcellagent.so} +0 -0
- data/lib/tcell_agent/rust/models.rb +9 -0
- data/lib/tcell_agent/rust/native_agent.rb +58 -50
- data/lib/tcell_agent/rust/native_library.rb +8 -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 +30 -13
- data/lib/tcell_agent/servers/rack_puma_handler.rb +33 -0
- data/lib/tcell_agent/servers/rails_server.rb +4 -4
- data/lib/tcell_agent/servers/unicorn.rb +1 -1
- data/lib/tcell_agent/servers/webrick.rb +12 -3
- data/lib/tcell_agent/settings_reporter.rb +0 -93
- data/lib/tcell_agent/sinatra.rb +1 -0
- data/lib/tcell_agent/tcell_context.rb +16 -7
- 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/configuration_spec.rb +62 -212
- data/spec/lib/tcell_agent/instrument_servers_spec.rb +95 -0
- data/spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb +2 -2
- data/spec/lib/tcell_agent/instrumentation/cmdi_spec.rb +46 -4
- 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 +120 -2
- 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 +14 -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/rust/agent_config_spec.rb +27 -0
- data/spec/lib/tcell_agent/settings_reporter_spec.rb +2 -89
- data/spec/lib/tcell_agent/tcell_context_spec.rb +6 -5
- data/spec/spec_helper.rb +9 -1
- data/spec/support/builders.rb +8 -7
- data/spec/support/server_mocks/passenger_mock.rb +7 -0
- data/spec/support/server_mocks/puma_mock.rb +21 -0
- data/spec/support/server_mocks/rails_mock.rb +7 -0
- data/spec/support/server_mocks/thin_mock.rb +7 -0
- data/spec/support/server_mocks/unicorn_mock.rb +11 -0
- data/spec/support/shared_spec.rb +29 -0
- data/tcell_agent.gemspec +14 -14
- metadata +44 -27
- data/Rakefile +0 -18
- data/lib/tcell_agent/authlogic.rb +0 -23
- data/lib/tcell_agent/config/unknown_options.rb +0 -119
- data/lib/tcell_agent/devise.rb +0 -33
- 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 -163
- data/lib/tcell_agent/rails/start_agent_after_initializers.rb +0 -12
- data/lib/tcell_agent/rust/tcellagent-4.18.0.dll +0 -0
- data/spec/lib/tcell_agent/config/unknown_options_spec.rb +0 -195
@@ -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)
|
@@ -1,25 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
tcell_server = ENV['TCELL_AGENT_SERVER']
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
if (tcell_server && tcell_server == 'webrick') || defined?(Rails::Server)
|
6
|
-
require('tcell_agent/servers/rails_server')
|
5
|
+
TCellAgent.thread_agent.instrument_built_ins if tcell_server &&
|
6
|
+
tcell_server == 'mock'
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
require('tcell_agent/servers/rails_server') if (tcell_server && tcell_server == 'webrick') ||
|
9
|
+
defined?(Rails::Server)
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
require('tcell_agent/servers/thin') if (tcell_server && tcell_server == 'thin') ||
|
12
|
+
defined?(Thin)
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
require('tcell_agent/servers/puma') if (tcell_server && tcell_server == 'puma') ||
|
15
|
+
defined?(Puma)
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
17
|
+
require('tcell_agent/servers/unicorn') if (tcell_server && tcell_server == 'unicorn') ||
|
18
|
+
defined?(Unicorn)
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
require('tcell_agent/servers/unicorn')
|
25
|
-
end
|
20
|
+
require('tcell_agent/servers/passenger') if (tcell_server && tcell_server == 'passenger') ||
|
21
|
+
defined?(PhusionPassenger)
|
@@ -65,7 +65,8 @@ module TCellAgent
|
|
65
65
|
:password, :route_id, :path, :uri, :fullpath, :context_filters_by_term,
|
66
66
|
:database_filters, :remote_address, :user_agent, :request_method,
|
67
67
|
:path_parameters, :patches_blocking_triggered, :grape_mount_endpoint,
|
68
|
-
:referrer, :csrf_exception_name, :sql_exceptions, :database_result_sizes
|
68
|
+
:referrer, :csrf_exception_name, :sql_exceptions, :database_result_sizes,
|
69
|
+
:reverse_proxy_header_value
|
69
70
|
|
70
71
|
def self.filterx(sanitize_string, event_flag, replace_flag, term)
|
71
72
|
send_event = false
|
@@ -91,26 +92,31 @@ module TCellAgent
|
|
91
92
|
|
92
93
|
def valid_term?(term)
|
93
94
|
return true if !term.nil? && term != '' && term.to_s.length >= 5
|
95
|
+
|
94
96
|
false
|
95
97
|
end
|
96
98
|
|
97
99
|
def add_response_db_filter(term, action_obj, database, schema, table, field)
|
98
100
|
return unless valid_term?(term)
|
101
|
+
|
99
102
|
context_filters_by_term[term.to_s].add(ContextFilter.new.for_database(database, schema, table, field, action_obj))
|
100
103
|
end
|
101
104
|
|
102
105
|
def add_filter_for_request_parameter(term, rule, parameter_name)
|
103
106
|
return unless valid_term?(term)
|
107
|
+
|
104
108
|
context_filters_by_term[term.to_s].add(ContextFilter.new.for_request('form', parameter_name, rule))
|
105
109
|
end
|
106
110
|
|
107
111
|
def add_filter_for_header_value(term, rule, header_name)
|
108
112
|
return unless valid_term?(term)
|
113
|
+
|
109
114
|
context_filters_by_term[term.to_s].add(ContextFilter.new.for_request('header', header_name, rule))
|
110
115
|
end
|
111
116
|
|
112
117
|
def add_filter_for_cookie_value(term, rule, cookie_name)
|
113
118
|
return unless valid_term?(term)
|
119
|
+
|
114
120
|
context_filters_by_term[term.to_s].add(ContextFilter.new.for_request('cookie', cookie_name, rule))
|
115
121
|
end
|
116
122
|
|
@@ -139,6 +145,7 @@ module TCellAgent
|
|
139
145
|
send_flag = TCellData.filterx(body, !event_filters.empty?, !replace_filters.empty?, term)
|
140
146
|
send_flag ||= TCellData.filterx(body, !event_filters.empty?, !replace_filters.empty?, CGI.escapeHTML(term))
|
141
147
|
next unless send_flag
|
148
|
+
|
142
149
|
(replace_filters + event_filters).each do |filter|
|
143
150
|
base_event = TCellAgent::SensorEvents::DlpEvent.new(
|
144
151
|
route_id,
|
@@ -183,6 +190,7 @@ module TCellAgent
|
|
183
190
|
event_filters = (context_filters.select { |context_filter| (context_filter.rule.log_redact != true && context_filter.rule.log_event == true) })
|
184
191
|
send_flag = TCellData.filterx(log_msg, !event_filters.empty?, !replace_filters.empty?, term)
|
185
192
|
next unless send_flag
|
193
|
+
|
186
194
|
(replace_filters + event_filters).each do |filter|
|
187
195
|
base_event = TCellAgent::SensorEvents::DlpEvent.new(
|
188
196
|
route_id,
|
@@ -213,7 +221,7 @@ module TCellAgent
|
|
213
221
|
end
|
214
222
|
end
|
215
223
|
|
216
|
-
#
|
224
|
+
# NOTE: mock for tests
|
217
225
|
def self.get_safe_block_logger
|
218
226
|
unless defined?(@safe_block_logger)
|
219
227
|
@safe_block_logger = TCellAgent::ModuleLogger.new(TCellAgent.logger, name)
|
@@ -224,15 +232,15 @@ module TCellAgent
|
|
224
232
|
|
225
233
|
def self.safe_block(message, &block)
|
226
234
|
block.call
|
227
|
-
rescue StandardError =>
|
235
|
+
rescue StandardError => e
|
228
236
|
logger = get_safe_block_logger
|
229
|
-
logger.error("Error #{message} (#{
|
230
|
-
logger.exception(
|
237
|
+
logger.error("Error #{message} (#{e.class}): #{e.message}")
|
238
|
+
logger.exception(e)
|
231
239
|
end
|
232
240
|
|
233
241
|
def self.safe_block_no_log(_message, &block)
|
234
242
|
block.call
|
235
|
-
rescue StandardError
|
243
|
+
rescue StandardError
|
236
244
|
# do nothing
|
237
245
|
end
|
238
246
|
end
|
@@ -25,18 +25,18 @@ module TCellAgent
|
|
25
25
|
cmd = ''
|
26
26
|
|
27
27
|
TCellAgent::Instrumentation.safe_block('CMDI Parsing *args') do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
if args_copy.first.is_a?(Array)
|
34
|
-
cmd_n_argv0 = args_copy.shift
|
35
|
-
args_copy.unshift(cmd_n_argv0.first)
|
36
|
-
end
|
28
|
+
return cmd if args.nil? || args.empty?
|
29
|
+
|
30
|
+
args_copy = Array.new(args)
|
31
|
+
args_copy.shift if args_copy.first.is_a?(Hash)
|
32
|
+
args_copy.pop if args_copy.last.is_a?(Hash)
|
37
33
|
|
38
|
-
|
34
|
+
if args_copy.first.is_a?(Array)
|
35
|
+
cmd_n_argv0 = args_copy.shift
|
36
|
+
args_copy.unshift(cmd_n_argv0.first)
|
39
37
|
end
|
38
|
+
|
39
|
+
cmd = args_copy.join(' ')
|
40
40
|
end
|
41
41
|
|
42
42
|
cmd
|
@@ -46,15 +46,47 @@ module TCellAgent
|
|
46
46
|
cmd = ''
|
47
47
|
|
48
48
|
TCellAgent::Instrumentation.safe_block('CMDI Parsing *args') do
|
49
|
-
|
50
|
-
args_copy = Array.new(args)
|
51
|
-
first_arg = args_copy.shift
|
49
|
+
return cmd if args.nil? || args.empty?
|
52
50
|
|
53
|
-
|
54
|
-
|
51
|
+
args_copy = Array.new(args)
|
52
|
+
first_arg = args_copy.shift
|
53
|
+
|
54
|
+
cmd = first_arg[1..-1] if first_arg && (first_arg.is_a? String) && first_arg[0] == '|'
|
55
55
|
end
|
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)
|
@@ -26,15 +28,23 @@ module TCellAgent
|
|
26
28
|
path = ''
|
27
29
|
mode = ''
|
28
30
|
|
29
|
-
return ['', ''] if args.empty?
|
30
|
-
|
31
31
|
TCellAgent::Instrumentation.safe_block('LFI Parsing *args') do
|
32
|
+
return ['', ''] if args.nil? || args.empty?
|
33
|
+
|
32
34
|
args_copy = Array.new(args)
|
33
35
|
path = args_copy.shift
|
34
36
|
mode = args_copy.shift || 'r'
|
35
37
|
|
36
38
|
if path && path.to_s[0] != '|'
|
37
|
-
|
39
|
+
path = File.expand_path(path.to_s)
|
40
|
+
|
41
|
+
mode = if mode && mode.is_a?(Hash)
|
42
|
+
convert_mode(mode[:mode])
|
43
|
+
else
|
44
|
+
convert_mode(mode)
|
45
|
+
end
|
46
|
+
|
47
|
+
[path, mode]
|
38
48
|
else
|
39
49
|
['', '']
|
40
50
|
end
|
@@ -46,15 +56,28 @@ module TCellAgent
|
|
46
56
|
mode = 'Read'
|
47
57
|
|
48
58
|
TCellAgent::Instrumentation.safe_block('LFI Parsing ARGF') do
|
49
|
-
|
50
|
-
|
51
|
-
path = argv_copy.shift
|
52
|
-
else
|
53
|
-
path = ARGF.filename
|
54
|
-
end
|
59
|
+
begin
|
60
|
+
return ['', ''] if ARGF.file == $stdin
|
55
61
|
|
56
|
-
|
57
|
-
|
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')
|
76
|
+
['', '']
|
77
|
+
rescue Errno::EISDIR
|
78
|
+
module_logger.debug('LFI Parsing ARGF: attempted to read a directory')
|
79
|
+
[ARGF.filename, mode]
|
80
|
+
end
|
58
81
|
end
|
59
82
|
end
|
60
83
|
|
@@ -68,6 +91,40 @@ module TCellAgent
|
|
68
91
|
end
|
69
92
|
'Read'
|
70
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
|
71
128
|
end
|
72
129
|
end
|
73
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
|