tcell_agent 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tcell_agent/instrumentation/cmdi.rb +1 -1
- data/lib/tcell_agent/instrumentation/lfi.rb +8 -8
- data/lib/tcell_agent/instrumentation/monkey_patches/io.rb +20 -12
- data/lib/tcell_agent/instrumentation/monkey_patches/kernel.rb +12 -8
- data/lib/tcell_agent/policies/command_injection_policy.rb +1 -1
- data/lib/tcell_agent/rails/dlp.rb +10 -4
- data/lib/tcell_agent/rails/routes.rb +3 -3
- data/lib/tcell_agent/rust/{libtcellagent-4.14.0.dylib → libtcellagent-4.17.1.dylib} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-4.14.0.so → libtcellagent-4.17.1.so} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-alpine-4.14.0.so → libtcellagent-alpine-4.17.1.so} +0 -0
- data/lib/tcell_agent/rust/native_library.rb +1 -1
- data/lib/tcell_agent/rust/{tcellagent-4.14.0.dll → tcellagent-4.17.1.dll} +0 -0
- data/lib/tcell_agent/version.rb +1 -1
- data/spec/lib/tcell_agent/{cmdi_spec.rb → instrumentation/cmdi_spec.rb} +8 -0
- data/spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb +6 -0
- data/spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb +19 -4
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d37df3ff2819b9794d9bde01418437c3efed75358fa58f4f65d80ea4f63e7b8
|
4
|
+
data.tar.gz: 97efa888f4adf090f13fa5bc0597a91ea981ad299062d3dbd267ed4216b18ba8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f77740a99dd8678ca62a5ccf7e0e69304e680a8fa65258105c101ec360413920afcfea4d6e03237e1c6893198fa6232133ab05111bb2b0341586635db43a9bd
|
7
|
+
data.tar.gz: c980a3e122b6453e3660358a2ba6a2bbe86179a9f54ca09e34135c8e9f86eb6498ebd8346dbf28b117f2f0b160bc23338b80502dc6c07c28d0b3b03472756a39
|
@@ -32,12 +32,12 @@ module TCellAgent
|
|
32
32
|
args_copy = Array.new(args)
|
33
33
|
path = args_copy.shift
|
34
34
|
mode = args_copy.shift || 'r'
|
35
|
-
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
if path && path.to_s[0] != '|'
|
37
|
+
[File.expand_path(path).to_s, convert_mode(mode)]
|
38
|
+
else
|
39
|
+
['', '']
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -52,10 +52,10 @@ module TCellAgent
|
|
52
52
|
else
|
53
53
|
path = ARGF.filename
|
54
54
|
end
|
55
|
-
end
|
56
55
|
|
57
|
-
|
58
|
-
|
56
|
+
path = File.expand_path(path) unless path.nil?
|
57
|
+
[path.to_s, mode]
|
58
|
+
end
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.convert_mode(mode)
|
@@ -4,12 +4,15 @@ class IO
|
|
4
4
|
def binread(*args, &block)
|
5
5
|
path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
6
6
|
|
7
|
-
if path && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
7
|
+
if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
8
8
|
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
9
9
|
end
|
10
|
-
|
11
|
-
if
|
12
|
-
|
10
|
+
|
11
|
+
if path.empty?
|
12
|
+
cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
|
13
|
+
if cmd && TCellAgent::Cmdi.block_command?(cmd)
|
14
|
+
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
tcell_original_binread(*args, &block)
|
@@ -69,14 +72,17 @@ class IO
|
|
69
72
|
path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
70
73
|
mode = 'Read'
|
71
74
|
|
72
|
-
if path && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
75
|
+
if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
73
76
|
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
74
77
|
end
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
if path.empty?
|
80
|
+
cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
|
81
|
+
if cmd && TCellAgent::Cmdi.block_command?(cmd)
|
82
|
+
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
83
|
+
end
|
79
84
|
end
|
85
|
+
|
80
86
|
tcell_original_read(*args, &block)
|
81
87
|
end
|
82
88
|
|
@@ -85,13 +91,15 @@ class IO
|
|
85
91
|
path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
86
92
|
mode = 'Read'
|
87
93
|
|
88
|
-
if path && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
94
|
+
if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
89
95
|
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
90
96
|
end
|
91
97
|
|
92
|
-
|
93
|
-
|
94
|
-
|
98
|
+
if path.empty?
|
99
|
+
cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
|
100
|
+
if cmd && TCellAgent::Cmdi.block_command?(cmd)
|
101
|
+
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
102
|
+
end
|
95
103
|
end
|
96
104
|
|
97
105
|
tcell_original_readlines(*args, &block)
|
@@ -4,13 +4,15 @@ module Kernel
|
|
4
4
|
def open(*args, &block)
|
5
5
|
path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
6
6
|
|
7
|
-
if path && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
7
|
+
if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
8
8
|
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
if path.empty?
|
12
|
+
cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
|
13
|
+
if cmd && TCellAgent::Cmdi.block_command?(cmd)
|
14
|
+
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
tcell_original_1_open(*args, &block)
|
@@ -72,13 +74,15 @@ module Kernel
|
|
72
74
|
def open(*args, &block)
|
73
75
|
path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
74
76
|
|
75
|
-
if path && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
77
|
+
if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
76
78
|
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
77
79
|
end
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
81
|
+
if path.empty?
|
82
|
+
cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
|
83
|
+
if cmd && TCellAgent::Cmdi.block_command?(cmd)
|
84
|
+
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
85
|
+
end
|
82
86
|
end
|
83
87
|
|
84
88
|
tcell_original_2_open(*args, &block)
|
@@ -228,9 +228,15 @@ module TCellAgent
|
|
228
228
|
)
|
229
229
|
tcell_data = request_env[TCellAgent::Instrumentation::TCELL_ID]
|
230
230
|
if tcell_data && result.is_a?(ActiveRecord::StatementInvalid)
|
231
|
-
|
232
|
-
|
233
|
-
|
231
|
+
if message.is_a? Hash
|
232
|
+
tcell_data.sql_exceptions.push(
|
233
|
+
{ 'exception_name' => result.class.name, 'exception_payload' => message[:message] }
|
234
|
+
)
|
235
|
+
else
|
236
|
+
tcell_data.sql_exceptions.push(
|
237
|
+
{ 'exception_name' => result.class.name, 'exception_payload' => message }
|
238
|
+
)
|
239
|
+
end
|
234
240
|
end
|
235
241
|
end
|
236
242
|
end
|
@@ -253,7 +259,7 @@ module TCellAgent
|
|
253
259
|
end
|
254
260
|
|
255
261
|
ActiveRecord::Querying.module_eval do
|
256
|
-
if ::Rails::VERSION::MAJOR
|
262
|
+
if ::Rails::VERSION::MAJOR >= 5
|
257
263
|
alias_method :tcell_find_by_sql, :find_by_sql
|
258
264
|
def find_by_sql(*args)
|
259
265
|
results = tcell_find_by_sql(*args)
|
@@ -77,7 +77,7 @@ module TCellAgent
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def self.create_tcell_route(route)
|
80
|
-
return TCellRoute5.new(route) if route && ::Rails::VERSION::MAJOR
|
80
|
+
return TCellRoute5.new(route) if route && ::Rails::VERSION::MAJOR >= 5
|
81
81
|
return TCellRoute4.new(route) if route && ::Rails::VERSION::MAJOR < 5
|
82
82
|
|
83
83
|
TCellRoute.new
|
@@ -173,7 +173,7 @@ module TCellAgent
|
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
-
if ::Rails::VERSION::MAJOR
|
176
|
+
if ::Rails::VERSION::MAJOR >= 5
|
177
177
|
ActionDispatch::Journey::Routes.class_eval do
|
178
178
|
alias_method :tcell_add_route, :add_route
|
179
179
|
def add_route(name, mapping)
|
@@ -188,7 +188,7 @@ module TCellAgent
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
if ::Rails::VERSION::MAJOR
|
191
|
+
if ::Rails::VERSION::MAJOR >= 5 || (::Rails::VERSION::MAJOR == 4 && ::Rails::VERSION::MINOR >= 2)
|
192
192
|
ActionDispatch::Journey::Router.class_eval do
|
193
193
|
alias_method :tcell_serve, :serve
|
194
194
|
def serve(req)
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/tcell_agent/version.rb
CHANGED
@@ -147,5 +147,13 @@ module TCellAgent
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
150
|
+
describe '.parse_command_from_open' do
|
151
|
+
context 'with string command' do
|
152
|
+
it 'should parse the command properly' do
|
153
|
+
cmd = TCellAgent::Cmdi.parse_command_from_open('|echo')
|
154
|
+
expect(cmd).to eq('echo')
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
150
158
|
end
|
151
159
|
end
|
@@ -42,6 +42,7 @@ describe 'IO' do
|
|
42
42
|
TCellAgent::PolicyTypes::LFI
|
43
43
|
).and_return(@local_files_policy)
|
44
44
|
expect(@local_files_policy).to receive(:block_file_access?).and_return(false)
|
45
|
+
expect(TCellAgent::Cmdi).not_to receive(:parse_command_from_open)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
@@ -75,6 +76,7 @@ describe 'IO' do
|
|
75
76
|
TCellAgent::PolicyTypes::LFI
|
76
77
|
).and_return(@local_files_policy)
|
77
78
|
expect(@local_files_policy).to receive(:block_file_access?).and_return(true)
|
79
|
+
expect(TCellAgent::Cmdi).not_to receive(:parse_command_from_open)
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
@@ -254,6 +256,7 @@ describe 'IO' do
|
|
254
256
|
).and_return(@local_files_policy)
|
255
257
|
|
256
258
|
expect(@local_files_policy).to receive(:block_file_access?).and_return(false)
|
259
|
+
expect(TCellAgent::Cmdi).not_to receive(:parse_command_from_open)
|
257
260
|
end
|
258
261
|
end
|
259
262
|
|
@@ -288,6 +291,7 @@ describe 'IO' do
|
|
288
291
|
).and_return(@local_files_policy)
|
289
292
|
|
290
293
|
expect(@local_files_policy).to receive(:block_file_access?).and_return(true)
|
294
|
+
expect(TCellAgent::Cmdi).not_to receive(:parse_command_from_open)
|
291
295
|
end
|
292
296
|
end
|
293
297
|
|
@@ -338,6 +342,7 @@ describe 'IO' do
|
|
338
342
|
).and_return(@local_files_policy)
|
339
343
|
|
340
344
|
expect(@local_files_policy).to receive(:block_file_access?).and_return(false)
|
345
|
+
expect(TCellAgent::Cmdi).not_to receive(:parse_command_from_open)
|
341
346
|
end
|
342
347
|
end
|
343
348
|
|
@@ -366,6 +371,7 @@ describe 'IO' do
|
|
366
371
|
).and_return(@local_files_policy)
|
367
372
|
|
368
373
|
expect(@local_files_policy).to receive(:block_file_access?).and_return(true)
|
374
|
+
expect(TCellAgent::Cmdi).not_to receive(:parse_command_from_open)
|
369
375
|
end
|
370
376
|
end
|
371
377
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# rubocop:disable Lint/UselessAssignment
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'securerandom'
|
5
|
+
require 'pathname'
|
5
6
|
|
6
7
|
describe 'Kernel' do
|
7
8
|
before do
|
@@ -15,6 +16,7 @@ describe 'Kernel' do
|
|
15
16
|
|
16
17
|
before(:all) do
|
17
18
|
@new_file_name = '/tmp/' + SecureRandom.uuid
|
19
|
+
@new_pathname = Pathname.new(@new_file_name)
|
18
20
|
end
|
19
21
|
describe '#open and ::open' do
|
20
22
|
context 'empty path' do
|
@@ -39,13 +41,14 @@ describe 'Kernel' do
|
|
39
41
|
end.to raise_error(Errno::ENOENT)
|
40
42
|
end
|
41
43
|
end
|
42
|
-
context 'with a filename not blocked for read/write' do
|
44
|
+
context 'with a non-existent file, with filename not blocked for read/write' do
|
43
45
|
before do |test|
|
44
46
|
unless test.metadata[:skip_before]
|
45
47
|
expect(TCellAgent).to receive(:policy).with(
|
46
48
|
TCellAgent::PolicyTypes::LFI
|
47
49
|
).and_return(@local_files_policy, @local_files_policy)
|
48
50
|
expect(@local_files_policy).to receive(:block_file_access?).and_return(false, false)
|
51
|
+
expect(TCellAgent::Cmdi).not_to receive(:parse_command_from_open)
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
@@ -56,7 +59,18 @@ describe 'Kernel' do
|
|
56
59
|
result = open('|echo test').read
|
57
60
|
expect(result).to eq "test\n"
|
58
61
|
end
|
59
|
-
context 'with a
|
62
|
+
context 'with a pathname filename with mode w' do
|
63
|
+
it 'should create the file' do
|
64
|
+
Kernel.open(@new_pathname, 'w')
|
65
|
+
expect(File.exist?(@new_pathname)).to be_truthy
|
66
|
+
File.delete(@new_pathname)
|
67
|
+
|
68
|
+
open(@new_pathname, 'w')
|
69
|
+
expect(File.exist?(@new_pathname)).to be_truthy
|
70
|
+
File.delete(@new_pathname)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
context 'with a filename with mode w' do
|
60
74
|
it 'should create the file' do
|
61
75
|
Kernel.open(@new_file_name, 'w')
|
62
76
|
expect(File.exist?(@new_file_name)).to be_truthy
|
@@ -90,13 +104,14 @@ describe 'Kernel' do
|
|
90
104
|
end
|
91
105
|
end
|
92
106
|
end
|
93
|
-
context 'with a filename blocked for read/write' do
|
107
|
+
context 'with a non-existent file, with filename blocked for read/write' do
|
94
108
|
before do |test|
|
95
109
|
unless test.metadata[:skip_before]
|
96
110
|
expect(TCellAgent).to receive(:policy).with(
|
97
111
|
TCellAgent::PolicyTypes::LFI
|
98
112
|
).and_return(@local_files_policy, @local_files_policy)
|
99
113
|
expect(@local_files_policy).to receive(:block_file_access?).and_return(true, true)
|
114
|
+
expect(TCellAgent::Cmdi).not_to receive(:parse_command_from_open)
|
100
115
|
end
|
101
116
|
end
|
102
117
|
|
@@ -107,7 +122,7 @@ describe 'Kernel' do
|
|
107
122
|
result = open('|echo test').read
|
108
123
|
expect(result).to eq "test\n"
|
109
124
|
end
|
110
|
-
context 'with a
|
125
|
+
context 'with a filename with mode w' do
|
111
126
|
it 'should raise an error' do
|
112
127
|
expect do
|
113
128
|
Kernel.open(@new_file_name, 'w')
|
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.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -162,14 +162,14 @@ files:
|
|
162
162
|
- lib/tcell_agent/rails/tcell_body_proxy.rb
|
163
163
|
- lib/tcell_agent/routes/table.rb
|
164
164
|
- lib/tcell_agent/rust/agent_config.rb
|
165
|
-
- lib/tcell_agent/rust/libtcellagent-4.
|
166
|
-
- lib/tcell_agent/rust/libtcellagent-4.
|
167
|
-
- lib/tcell_agent/rust/libtcellagent-alpine-4.
|
165
|
+
- lib/tcell_agent/rust/libtcellagent-4.17.1.dylib
|
166
|
+
- lib/tcell_agent/rust/libtcellagent-4.17.1.so
|
167
|
+
- lib/tcell_agent/rust/libtcellagent-alpine-4.17.1.so
|
168
168
|
- lib/tcell_agent/rust/models.rb
|
169
169
|
- lib/tcell_agent/rust/native_agent.rb
|
170
170
|
- lib/tcell_agent/rust/native_agent_response.rb
|
171
171
|
- lib/tcell_agent/rust/native_library.rb
|
172
|
-
- lib/tcell_agent/rust/tcellagent-4.
|
172
|
+
- lib/tcell_agent/rust/tcellagent-4.17.1.dll
|
173
173
|
- lib/tcell_agent/sensor_events/agent_setting_event.rb
|
174
174
|
- lib/tcell_agent/sensor_events/app_config_setting_event.rb
|
175
175
|
- lib/tcell_agent/sensor_events/discovery.rb
|
@@ -192,12 +192,12 @@ files:
|
|
192
192
|
- lib/tcell_agent/utils/params.rb
|
193
193
|
- lib/tcell_agent/utils/strings.rb
|
194
194
|
- lib/tcell_agent/version.rb
|
195
|
-
- spec/lib/tcell_agent/cmdi_spec.rb
|
196
195
|
- spec/lib/tcell_agent/config/unknown_options_spec.rb
|
197
196
|
- spec/lib/tcell_agent/configuration_spec.rb
|
198
197
|
- spec/lib/tcell_agent/hooks/login_fraud_spec.rb
|
199
198
|
- spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb
|
200
199
|
- spec/lib/tcell_agent/instrumentation/cmdi/kernel_cmdi_spec.rb
|
200
|
+
- spec/lib/tcell_agent/instrumentation/cmdi_spec.rb
|
201
201
|
- spec/lib/tcell_agent/instrumentation/lfi/file_lfi_spec.rb
|
202
202
|
- spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb
|
203
203
|
- spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb
|
@@ -266,12 +266,12 @@ signing_key:
|
|
266
266
|
specification_version: 4
|
267
267
|
summary: tCell.io Agent for Rails
|
268
268
|
test_files:
|
269
|
-
- spec/lib/tcell_agent/cmdi_spec.rb
|
270
269
|
- spec/lib/tcell_agent/config/unknown_options_spec.rb
|
271
270
|
- spec/lib/tcell_agent/configuration_spec.rb
|
272
271
|
- spec/lib/tcell_agent/hooks/login_fraud_spec.rb
|
273
272
|
- spec/lib/tcell_agent/instrumentation/cmdi/io_cmdi_spec.rb
|
274
273
|
- spec/lib/tcell_agent/instrumentation/cmdi/kernel_cmdi_spec.rb
|
274
|
+
- spec/lib/tcell_agent/instrumentation/cmdi_spec.rb
|
275
275
|
- spec/lib/tcell_agent/instrumentation/lfi/file_lfi_spec.rb
|
276
276
|
- spec/lib/tcell_agent/instrumentation/lfi/io_lfi_spec.rb
|
277
277
|
- spec/lib/tcell_agent/instrumentation/lfi/kernel_lfi_spec.rb
|