tcell_agent 2.3.0 → 2.5.1
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 +4 -4
- 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 +18 -0
- data/lib/tcell_agent/rust/{libtcellagent-alpine-6.2.1.so → libtcellagent-alpine.so} +0 -0
- data/lib/tcell_agent/rust/{tcellagent-6.2.1.dll → libtcellagent-x64.dll} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-6.2.1.dylib → libtcellagent.dylib} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-6.2.1.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 +14 -4
- 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 +42 -7
- 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 → puma_mock_1.rb} +5 -1
- data/spec/support/server_mocks/puma_mock_2.rb +26 -0
- data/spec/support/server_mocks/puma_mock_3.rb +22 -0
- data/spec/support/shared_spec.rb +29 -0
- data/tcell_agent.gemspec +14 -14
- metadata +29 -21
- 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
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
|
3
3
|
module TCellAgent
|
|
4
4
|
module Instrumentation
|
|
5
5
|
describe RouteId do
|
|
6
|
-
|
|
6
|
+
tcell_context_key = TCellAgent::Instrumentation::TCELL_ID
|
|
7
7
|
|
|
8
8
|
describe '.update_context' do
|
|
9
9
|
context 'with nil route' do
|
|
@@ -11,7 +11,7 @@ module TCellAgent
|
|
|
11
11
|
tcell_context = TCellData.new
|
|
12
12
|
tcell_context.route_id = nil
|
|
13
13
|
|
|
14
|
-
RouteId.update_context({
|
|
14
|
+
RouteId.update_context({ tcell_context_key => tcell_context }, {}, nil)
|
|
15
15
|
|
|
16
16
|
expect(tcell_context.route_id).to eq(nil)
|
|
17
17
|
expect(tcell_context.grape_mount_endpoint).to eq(nil)
|
|
@@ -41,7 +41,7 @@ module TCellAgent
|
|
|
41
41
|
|
|
42
42
|
expect(TCellAgent::Instrumentation).to receive(:grape_route?).with(route).and_return(false)
|
|
43
43
|
|
|
44
|
-
RouteId.update_context({
|
|
44
|
+
RouteId.update_context({ tcell_context_key => tcell_context }, { :id => 1 }, route)
|
|
45
45
|
|
|
46
46
|
expect(tcell_context.route_id).to eq(
|
|
47
47
|
TCellAgent::SensorEvents::Util.calculate_route_id('GET', '/some/regular/path')
|
|
@@ -64,7 +64,7 @@ module TCellAgent
|
|
|
64
64
|
|
|
65
65
|
expect(TCellAgent::Instrumentation).to receive(:grape_route?).with(route).and_return(true)
|
|
66
66
|
|
|
67
|
-
RouteId.update_context({
|
|
67
|
+
RouteId.update_context({ tcell_context_key => tcell_context }, { :id => 1 }, route)
|
|
68
68
|
|
|
69
69
|
expect(tcell_context.route_id).to eq(nil)
|
|
70
70
|
expect(tcell_context.grape_mount_endpoint).to eq('/grape_api')
|
|
@@ -27,26 +27,12 @@ module TCellAgent
|
|
|
27
27
|
).at_least(:once)
|
|
28
28
|
expect(TCellAgent).to receive(:logger).and_return(logger).at_least(:once)
|
|
29
29
|
expect(Thread).to receive(:new).and_yield
|
|
30
|
-
|
|
31
|
-
expect(logger).to receive(:debug).with('TCellAgent::SensorEvents::ServerAgentDetailsSensorEvent', 'Group unknown')
|
|
32
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
33
|
-
{
|
|
34
|
-
'event_type' => 'server_agent_details',
|
|
35
|
-
'user' => 'unknown',
|
|
36
|
-
'group' => 'unknown'
|
|
37
|
-
}
|
|
38
|
-
)
|
|
30
|
+
|
|
39
31
|
expect(logger).to receive(:debug).with(anything, anything).at_least(:once)
|
|
40
32
|
expect(TCellAgent).to receive(:send_event).with(
|
|
41
33
|
hash_including('event_type' => 'server_agent_packages')
|
|
42
|
-
) # packages event
|
|
43
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
44
|
-
{
|
|
45
|
-
'event_type' => 'server_agent_details',
|
|
46
|
-
'language' => 'Ruby',
|
|
47
|
-
'language_version' => RUBY_VERSION
|
|
48
|
-
}
|
|
49
34
|
)
|
|
35
|
+
|
|
50
36
|
expect(TCellAgent).to receive(:send_event).with(
|
|
51
37
|
{
|
|
52
38
|
'event_type' => 'app_config_setting',
|
|
@@ -4,9 +4,9 @@ module TCellAgent
|
|
|
4
4
|
describe MetaData do
|
|
5
5
|
describe '#set_headers_dict' do
|
|
6
6
|
it 'should set all headers that start with http and skip cookies' do
|
|
7
|
-
method = remote_address = route_id = session_id = user_id = transaction_id = location = nil
|
|
7
|
+
method = remote_address = route_id = session_id = user_id = transaction_id = location = reverse_proxy_header_value = nil
|
|
8
8
|
|
|
9
|
-
meta = MetaData.new(method, remote_address, route_id, session_id, user_id, transaction_id, location)
|
|
9
|
+
meta = MetaData.new(method, remote_address, route_id, session_id, user_id, transaction_id, location, reverse_proxy_header_value)
|
|
10
10
|
meta.headers_dict = {
|
|
11
11
|
'rack.version' => [1, 2],
|
|
12
12
|
'REQUEST_METHOD' => 'POST',
|
|
@@ -24,9 +24,9 @@ module TCellAgent
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it 'should set all headers that start with http and include content_length and content_type' do
|
|
27
|
-
method = remote_address = route_id = session_id = user_id = transaction_id = location = nil
|
|
27
|
+
method = remote_address = route_id = session_id = user_id = transaction_id = location = reverse_proxy_header_value = nil
|
|
28
28
|
|
|
29
|
-
meta = MetaData.new(method, remote_address, route_id, session_id, user_id, transaction_id, location)
|
|
29
|
+
meta = MetaData.new(method, remote_address, route_id, session_id, user_id, transaction_id, location, reverse_proxy_header_value)
|
|
30
30
|
meta.headers_dict = {
|
|
31
31
|
'REQUEST_METHOD' => 'POST',
|
|
32
32
|
'HTTP_VERSION' => 'HTTP/1.1',
|
|
@@ -71,7 +71,8 @@ module TCellAgent
|
|
|
71
71
|
'session_id',
|
|
72
72
|
'user_id',
|
|
73
73
|
'transaction_id',
|
|
74
|
-
'http://test.com'
|
|
74
|
+
'http://test.com',
|
|
75
|
+
'0.0.0.0'
|
|
75
76
|
)
|
|
76
77
|
end
|
|
77
78
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -12,12 +12,14 @@ end
|
|
|
12
12
|
ENV['TCELL_AGENT_SERVER'] = 'mock'
|
|
13
13
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'tcell_agent')
|
|
14
14
|
|
|
15
|
-
Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each { |f| require f }
|
|
15
|
+
Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].sort.each { |f| require f }
|
|
16
16
|
|
|
17
17
|
def get_test_resource_path(name)
|
|
18
18
|
File.join(File.dirname(__FILE__), 'support', 'resources', name)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
NEW_FILE_NAME ||= "/tmp/#{SecureRandom.uuid}".freeze
|
|
22
|
+
|
|
21
23
|
require 'tcell_agent/agent'
|
|
22
24
|
require 'tcell_agent/rails/routes'
|
|
23
25
|
|
data/spec/support/builders.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Puma
|
|
4
4
|
class Server
|
|
5
|
-
def run; end
|
|
5
|
+
def run(background = true, thread_name: 'server'); end
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
class Config
|
|
@@ -14,4 +14,8 @@ module Puma
|
|
|
14
14
|
def self.cli_config
|
|
15
15
|
Config
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
module Const
|
|
19
|
+
PUMA_VERSION = '5.1.0'
|
|
20
|
+
end
|
|
17
21
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Puma
|
|
4
|
+
class Server
|
|
5
|
+
def run(background = true, thread_name: 'server'); end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class Runner
|
|
9
|
+
def start_server; end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Config
|
|
13
|
+
def self.options
|
|
14
|
+
{ :preload_app => true,
|
|
15
|
+
:workers => 0 }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.cli_config
|
|
20
|
+
Config
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module Const
|
|
24
|
+
PUMA_VERSION = '5.1.0'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Puma
|
|
4
|
+
class Server
|
|
5
|
+
def run(background = true, thread_name: 'server'); end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class Config
|
|
9
|
+
def self.options
|
|
10
|
+
{ :preload_app => true,
|
|
11
|
+
:workers => 1 }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.cli_config
|
|
16
|
+
Config
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module Const
|
|
20
|
+
PUMA_VERSION = '5.1.0'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
def test_ruby2_ruby3_keywords(cls, func, args, options, res, min_ruby = '2.0.0')
|
|
2
|
+
ruby_version = Gem::Version.new(RUBY_VERSION)
|
|
3
|
+
|
|
4
|
+
context 'using ruby2_3 helper function' do
|
|
5
|
+
after(:each) do
|
|
6
|
+
expect(@result).to eq res unless res.nil?
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
if ruby_version >= Gem::Version.new(min_ruby) && \
|
|
10
|
+
ruby_version < Gem::Version.new('3.0.0')
|
|
11
|
+
# This spec tests the following format:
|
|
12
|
+
# File.new('/dev/null', 'w', 0o644, { :binmode => true })
|
|
13
|
+
it 'behaves correctly in ruby < 2.7' do
|
|
14
|
+
args_cp = Array.new(args)
|
|
15
|
+
args_cp << options
|
|
16
|
+
|
|
17
|
+
@result = cls.send(func, *args_cp)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
if ruby_version >= Gem::Version.new(min_ruby)
|
|
22
|
+
# This spec tests the following format:
|
|
23
|
+
# File.new('/dev/null', 'w', 0o644, :binmode => true )
|
|
24
|
+
it 'behaves correctly in ruby >= 3.0' do
|
|
25
|
+
@result = cls.send(func, *args, **options)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/tcell_agent.gemspec
CHANGED
|
@@ -6,23 +6,23 @@ require 'tcell_agent/version'
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'tcell_agent'
|
|
8
8
|
spec.version = TCellAgent::VERSION
|
|
9
|
-
spec.authors =
|
|
10
|
-
spec.
|
|
11
|
-
spec.
|
|
12
|
-
spec.
|
|
13
|
-
spec.
|
|
14
|
-
spec.license = 'Copyright (c) 2017 tCell.io (see LICENSE file)'
|
|
9
|
+
spec.authors = 'Rapid7, Inc.'
|
|
10
|
+
spec.summary = 'tCell Agent for Rails'
|
|
11
|
+
spec.description = 'This agent allows users to use the tCell service with their Rails app.'
|
|
12
|
+
spec.homepage = 'https://www.rapid7.com/tcell'
|
|
13
|
+
spec.license = 'Copyright (c) 2020 Rapid7, Inc. (see LICENSE file)'
|
|
15
14
|
|
|
16
15
|
spec.files = Dir[
|
|
17
|
-
'
|
|
16
|
+
'README.md',
|
|
17
|
+
'LICENSE',
|
|
18
|
+
'tcell_agent.gemspec',
|
|
19
|
+
'spec/**/*',
|
|
18
20
|
'lib/tcell_agent.rb',
|
|
19
|
-
'
|
|
20
|
-
'lib/tcell_agent/rust/libtcellagent
|
|
21
|
-
'lib/tcell_agent/rust/libtcellagent
|
|
22
|
-
'lib/tcell_agent/rust/
|
|
23
|
-
'
|
|
24
|
-
'LICENSE*',
|
|
25
|
-
'tcell_agent.gemspec'
|
|
21
|
+
'lib/tcell_agent/**/*rb',
|
|
22
|
+
'lib/tcell_agent/rust/libtcellagent.dylib',
|
|
23
|
+
'lib/tcell_agent/rust/libtcellagent.so',
|
|
24
|
+
'lib/tcell_agent/rust/libtcellagent-alpine.so',
|
|
25
|
+
'lib/tcell_agent/rust/libtcellagent-x64.dll',
|
|
26
26
|
]
|
|
27
27
|
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
28
28
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
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.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- Rapid7, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-11-17 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
|
|
98
|
-
|
|
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,7 +103,6 @@ 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
|
|
@@ -118,9 +115,12 @@ files:
|
|
|
118
115
|
- lib/tcell_agent/instrumentation.rb
|
|
119
116
|
- lib/tcell_agent/instrumentation/cmdi.rb
|
|
120
117
|
- lib/tcell_agent/instrumentation/lfi.rb
|
|
121
|
-
- lib/tcell_agent/instrumentation/monkey_patches/file.rb
|
|
122
|
-
- lib/tcell_agent/instrumentation/monkey_patches/io.rb
|
|
123
|
-
- 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
|
|
124
124
|
- lib/tcell_agent/logger.rb
|
|
125
125
|
- lib/tcell_agent/patches.rb
|
|
126
126
|
- lib/tcell_agent/policies/appfirewall_policy.rb
|
|
@@ -163,14 +163,14 @@ files:
|
|
|
163
163
|
- lib/tcell_agent/rails/tcell_body_proxy.rb
|
|
164
164
|
- lib/tcell_agent/routes/table.rb
|
|
165
165
|
- lib/tcell_agent/rust/agent_config.rb
|
|
166
|
-
- lib/tcell_agent/rust/libtcellagent-
|
|
167
|
-
- lib/tcell_agent/rust/libtcellagent-
|
|
168
|
-
- lib/tcell_agent/rust/libtcellagent
|
|
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
|
|
169
170
|
- lib/tcell_agent/rust/models.rb
|
|
170
171
|
- lib/tcell_agent/rust/native_agent.rb
|
|
171
172
|
- lib/tcell_agent/rust/native_agent_response.rb
|
|
172
173
|
- lib/tcell_agent/rust/native_library.rb
|
|
173
|
-
- lib/tcell_agent/rust/tcellagent-6.2.1.dll
|
|
174
174
|
- lib/tcell_agent/sensor_events/agent_setting_event.rb
|
|
175
175
|
- lib/tcell_agent/sensor_events/app_config_setting_event.rb
|
|
176
176
|
- lib/tcell_agent/sensor_events/discovery.rb
|
|
@@ -193,6 +193,7 @@ files:
|
|
|
193
193
|
- lib/tcell_agent/utils/params.rb
|
|
194
194
|
- lib/tcell_agent/utils/strings.rb
|
|
195
195
|
- lib/tcell_agent/version.rb
|
|
196
|
+
- spec/cruby_spec_helper.rb
|
|
196
197
|
- spec/lib/tcell_agent/configuration_spec.rb
|
|
197
198
|
- spec/lib/tcell_agent/hooks/login_fraud_spec.rb
|
|
198
199
|
- spec/lib/tcell_agent/instrument_servers_spec.rb
|
|
@@ -241,15 +242,18 @@ files:
|
|
|
241
242
|
- spec/support/resources/lfi_sample_file.txt
|
|
242
243
|
- spec/support/resources/normal_config.json
|
|
243
244
|
- spec/support/server_mocks/passenger_mock.rb
|
|
244
|
-
- spec/support/server_mocks/
|
|
245
|
+
- spec/support/server_mocks/puma_mock_1.rb
|
|
246
|
+
- spec/support/server_mocks/puma_mock_2.rb
|
|
247
|
+
- spec/support/server_mocks/puma_mock_3.rb
|
|
245
248
|
- spec/support/server_mocks/rails_mock.rb
|
|
246
249
|
- spec/support/server_mocks/thin_mock.rb
|
|
247
250
|
- spec/support/server_mocks/unicorn_mock.rb
|
|
251
|
+
- spec/support/shared_spec.rb
|
|
248
252
|
- spec/support/static_agent_overrides.rb
|
|
249
253
|
- tcell_agent.gemspec
|
|
250
|
-
homepage: https://www.tcell
|
|
254
|
+
homepage: https://www.rapid7.com/tcell
|
|
251
255
|
licenses:
|
|
252
|
-
- Copyright (c)
|
|
256
|
+
- Copyright (c) 2020 Rapid7, Inc. (see LICENSE file)
|
|
253
257
|
metadata: {}
|
|
254
258
|
post_install_message:
|
|
255
259
|
rdoc_options: []
|
|
@@ -268,11 +272,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
268
272
|
- !ruby/object:Gem::Version
|
|
269
273
|
version: '0'
|
|
270
274
|
requirements: []
|
|
271
|
-
rubygems_version: 3.
|
|
275
|
+
rubygems_version: 3.2.22
|
|
272
276
|
signing_key:
|
|
273
277
|
specification_version: 4
|
|
274
|
-
summary: tCell
|
|
278
|
+
summary: tCell Agent for Rails
|
|
275
279
|
test_files:
|
|
280
|
+
- spec/cruby_spec_helper.rb
|
|
276
281
|
- spec/lib/tcell_agent/configuration_spec.rb
|
|
277
282
|
- spec/lib/tcell_agent/hooks/login_fraud_spec.rb
|
|
278
283
|
- spec/lib/tcell_agent/instrument_servers_spec.rb
|
|
@@ -321,8 +326,11 @@ test_files:
|
|
|
321
326
|
- spec/support/resources/lfi_sample_file.txt
|
|
322
327
|
- spec/support/resources/normal_config.json
|
|
323
328
|
- spec/support/server_mocks/passenger_mock.rb
|
|
324
|
-
- spec/support/server_mocks/
|
|
329
|
+
- spec/support/server_mocks/puma_mock_1.rb
|
|
330
|
+
- spec/support/server_mocks/puma_mock_2.rb
|
|
331
|
+
- spec/support/server_mocks/puma_mock_3.rb
|
|
325
332
|
- spec/support/server_mocks/rails_mock.rb
|
|
326
333
|
- spec/support/server_mocks/thin_mock.rb
|
|
327
334
|
- spec/support/server_mocks/unicorn_mock.rb
|
|
335
|
+
- spec/support/shared_spec.rb
|
|
328
336
|
- 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,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,131 +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.strip.empty? && 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
|
-
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
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
tcell_original_binread(*args, &block)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
alias_method :tcell_original_binwrite, :binwrite
|
|
22
|
-
def binwrite(*args, &block)
|
|
23
|
-
path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
|
24
|
-
mode = 'Write'
|
|
25
|
-
|
|
26
|
-
if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
27
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
tcell_original_binwrite(*args, &block)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
alias_method :tcell_original_foreach, :foreach
|
|
34
|
-
def foreach(*args, &block)
|
|
35
|
-
path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
|
36
|
-
mode = 'Read'
|
|
37
|
-
|
|
38
|
-
if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
39
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
tcell_original_foreach(*args, &block)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
alias_method :tcell_original_popen, :popen
|
|
46
|
-
def popen(*args, &block)
|
|
47
|
-
unless args.empty?
|
|
48
|
-
cmd = ''
|
|
49
|
-
|
|
50
|
-
TCellAgent::Instrumentation.safe_block('CMDI Parsing popen *args') do
|
|
51
|
-
args_copy = Array.new(args)
|
|
52
|
-
args_copy.shift if args_copy.first.is_a?(Hash)
|
|
53
|
-
args_copy.pop if args_copy.last.is_a?(Hash)
|
|
54
|
-
|
|
55
|
-
cmd = if args_copy.first.is_a?(String)
|
|
56
|
-
args_copy.shift
|
|
57
|
-
else
|
|
58
|
-
TCellAgent::Cmdi.parse_command(*args_copy.shift)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
if TCellAgent::Cmdi.block_command?(cmd)
|
|
63
|
-
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
tcell_original_popen(*args, &block)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
alias_method :tcell_original_read, :read
|
|
71
|
-
def read(*args, &block)
|
|
72
|
-
path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
|
73
|
-
mode = 'Read'
|
|
74
|
-
|
|
75
|
-
if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
76
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
77
|
-
end
|
|
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
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
tcell_original_read(*args, &block)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
alias_method :tcell_original_readlines, :readlines
|
|
90
|
-
def readlines(*args, &block)
|
|
91
|
-
path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
|
92
|
-
mode = 'Read'
|
|
93
|
-
|
|
94
|
-
if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
95
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
96
|
-
end
|
|
97
|
-
|
|
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
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
tcell_original_readlines(*args, &block)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
alias_method :tcell_original_sysopen, :sysopen
|
|
109
|
-
def sysopen(*args, &block)
|
|
110
|
-
path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
|
111
|
-
|
|
112
|
-
if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
113
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
tcell_original_sysopen(*args, &block)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
alias_method :tcell_original_write, :write
|
|
120
|
-
def write(*args, &block)
|
|
121
|
-
path, _mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
|
122
|
-
mode = 'Write'
|
|
123
|
-
|
|
124
|
-
if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
125
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
tcell_original_write(*args, &block)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
module Kernel
|
|
2
|
-
private
|
|
3
|
-
|
|
4
|
-
alias_method :tcell_original_backtick, :`
|
|
5
|
-
alias_method :tcell_original_exec, :exec
|
|
6
|
-
alias_method :tcell_original_open, :open
|
|
7
|
-
alias_method :tcell_original_gets, :gets
|
|
8
|
-
alias_method :tcell_original_readline, :readline
|
|
9
|
-
alias_method :tcell_original_spawn, :spawn
|
|
10
|
-
alias_method :tcell_original_system, :system
|
|
11
|
-
|
|
12
|
-
class << self
|
|
13
|
-
alias_method :tcell_original_exec, :exec
|
|
14
|
-
alias_method :tcell_original_open, :open
|
|
15
|
-
alias_method :tcell_original_gets, :gets
|
|
16
|
-
alias_method :tcell_original_readline, :readline
|
|
17
|
-
alias_method :tcell_original_spawn, :spawn
|
|
18
|
-
alias_method :tcell_original_system, :system
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def `(cmd)
|
|
22
|
-
if TCellAgent::Cmdi.block_command?(cmd)
|
|
23
|
-
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
tcell_original_backtick(cmd)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
if TCellAgent.configuration.should_instrument?('kernel_exec')
|
|
30
|
-
def exec(*args)
|
|
31
|
-
cmd = TCellAgent::Cmdi.parse_command(*args)
|
|
32
|
-
if TCellAgent::Cmdi.block_command?(cmd)
|
|
33
|
-
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
tcell_original_exec(*args)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def gets(*args, &block)
|
|
41
|
-
path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode_argf
|
|
42
|
-
|
|
43
|
-
if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
44
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
tcell_original_gets(*args, &block)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def open(*args, &block)
|
|
51
|
-
path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)
|
|
52
|
-
|
|
53
|
-
if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
54
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
if path.empty?
|
|
58
|
-
cmd = TCellAgent::Cmdi.parse_command_from_open(*args)
|
|
59
|
-
if cmd && TCellAgent::Cmdi.block_command?(cmd)
|
|
60
|
-
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
tcell_original_open(*args, &block)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def readline(*args, &block)
|
|
68
|
-
path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode_argf
|
|
69
|
-
|
|
70
|
-
if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode)
|
|
71
|
-
raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied"
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
tcell_original_readline(*args, &block)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def spawn(*args)
|
|
78
|
-
cmd = TCellAgent::Cmdi.parse_command(*args)
|
|
79
|
-
if TCellAgent::Cmdi.block_command?(cmd)
|
|
80
|
-
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
tcell_original_spawn(*args)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def system(*args)
|
|
87
|
-
cmd = TCellAgent::Cmdi.parse_command(*args)
|
|
88
|
-
if TCellAgent::Cmdi.block_command?(cmd)
|
|
89
|
-
raise "tCell.io Agent: Command not allowed by policy: #{cmd}"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
tcell_original_system(*args)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
module_function :`
|
|
96
|
-
module_function :exec
|
|
97
|
-
module_function :gets
|
|
98
|
-
module_function :open
|
|
99
|
-
module_function :readline
|
|
100
|
-
module_function :spawn
|
|
101
|
-
module_function :system
|
|
102
|
-
end
|