tcell_agent 2.1.1 → 2.4.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 +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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
require 'spec_helper'
|
|
3
2
|
|
|
4
3
|
module TCellAgent
|
|
@@ -23,7 +22,7 @@ module TCellAgent
|
|
|
23
22
|
expect(native_agent).to_not receive(:get_headers)
|
|
24
23
|
|
|
25
24
|
tcell_context = double('tcell_context')
|
|
26
|
-
policy.get_headers(tcell_context)
|
|
25
|
+
policy.get_headers('text/html', tcell_context)
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
|
|
@@ -65,7 +64,7 @@ module TCellAgent
|
|
|
65
64
|
expect(@policy.enabled).to eq(true)
|
|
66
65
|
|
|
67
66
|
expect(
|
|
68
|
-
@policy.get_headers(@tcell_context)
|
|
67
|
+
@policy.get_headers('text/html', @tcell_context)
|
|
69
68
|
).to eq(
|
|
70
69
|
[{ 'name' => 'Content-Security-Policy', 'value' => 'test321' }]
|
|
71
70
|
)
|
|
@@ -92,7 +91,7 @@ module TCellAgent
|
|
|
92
91
|
expect(@policy.enabled).to eq(true)
|
|
93
92
|
|
|
94
93
|
expect(
|
|
95
|
-
@policy.get_headers(@tcell_context)
|
|
94
|
+
@policy.get_headers('text/html', @tcell_context)
|
|
96
95
|
).to eq(
|
|
97
96
|
[{ 'name' => 'Content-Security-Policy',
|
|
98
97
|
'value' => 'normalvalue; report-uri https://www.example.com/xys?sid=ab7074d0bf86c2884766d88b6ad9de4a&rid=route-id' }]
|
|
@@ -121,7 +120,7 @@ module TCellAgent
|
|
|
121
120
|
expect(@policy.enabled).to eq(true)
|
|
122
121
|
|
|
123
122
|
expect(
|
|
124
|
-
@policy.get_headers(@tcell_context)
|
|
123
|
+
@policy.get_headers('text/html', @tcell_context)
|
|
125
124
|
).to eq(
|
|
126
125
|
[{ 'name' => 'Content-Security-Policy',
|
|
127
126
|
'value' => 'normalvalue; report-uri https://www.example.com/1234567?sid=ab7074d0bf86c2884766d88b6ad9de4a&rid=route-id' }]
|
|
@@ -150,7 +149,7 @@ module TCellAgent
|
|
|
150
149
|
expect(@policy.enabled).to eq(true)
|
|
151
150
|
|
|
152
151
|
expect(
|
|
153
|
-
@policy.get_headers(@tcell_context)
|
|
152
|
+
@policy.get_headers('text/html', @tcell_context)
|
|
154
153
|
).to eq([])
|
|
155
154
|
end
|
|
156
155
|
end
|
|
@@ -78,6 +78,8 @@ module TCellAgent
|
|
|
78
78
|
meta_data = TCellAgent::Tests::MetaDataBuilder.new.update_attribute(
|
|
79
79
|
'remote_address', nil
|
|
80
80
|
).build
|
|
81
|
+
expect(@native_agent).to receive(:apply_suspicious_quick_check).with(any_args)
|
|
82
|
+
expect(@native_agent).not_to receive(:apply_patches).with(any_args)
|
|
81
83
|
resp = @policy.block_request?(meta_data)
|
|
82
84
|
expect(resp).to eq(false)
|
|
83
85
|
end
|
|
@@ -88,6 +90,8 @@ module TCellAgent
|
|
|
88
90
|
meta_data = TCellAgent::Tests::MetaDataBuilder.new.update_attribute(
|
|
89
91
|
'remote_address', ''
|
|
90
92
|
).build
|
|
93
|
+
expect(@native_agent).to receive(:apply_suspicious_quick_check).with(any_args)
|
|
94
|
+
expect(@native_agent).not_to receive(:apply_patches).with(any_args)
|
|
91
95
|
resp = @policy.block_request?(meta_data)
|
|
92
96
|
expect(resp).to eq(false)
|
|
93
97
|
end
|
|
@@ -98,20 +102,35 @@ module TCellAgent
|
|
|
98
102
|
meta_data = TCellAgent::Tests::MetaDataBuilder.new.update_attribute(
|
|
99
103
|
'remote_address', '2.2.2.2'
|
|
100
104
|
).build
|
|
105
|
+
expect(@native_agent).to receive(:apply_suspicious_quick_check).with(any_args)
|
|
106
|
+
expect(@native_agent).not_to receive(:apply_patches).with(any_args)
|
|
101
107
|
resp = @policy.block_request?(meta_data)
|
|
102
108
|
expect(resp).to eq(false)
|
|
103
109
|
end
|
|
104
110
|
end
|
|
105
111
|
|
|
106
|
-
context 'request comes from
|
|
107
|
-
it 'should
|
|
112
|
+
context 'request comes from blocked ip' do
|
|
113
|
+
it 'should block request' do
|
|
108
114
|
meta_data = TCellAgent::Tests::MetaDataBuilder.new.update_attribute(
|
|
109
115
|
'remote_address', '1.1.1.1'
|
|
110
116
|
).build
|
|
117
|
+
expect(@native_agent).to receive(:apply_suspicious_quick_check).with(any_args).and_return(2)
|
|
118
|
+
expect(@native_agent).not_to receive(:apply_patches).with(any_args)
|
|
111
119
|
resp = @policy.block_request?(meta_data)
|
|
112
120
|
expect(resp).to eq(true)
|
|
113
121
|
end
|
|
114
122
|
end
|
|
123
|
+
|
|
124
|
+
context 'request comes from suspcious ip' do
|
|
125
|
+
it 'should call apply_patches' do
|
|
126
|
+
meta_data = TCellAgent::Tests::MetaDataBuilder.new.update_attribute(
|
|
127
|
+
'remote_address', '1.1.1.1'
|
|
128
|
+
).build
|
|
129
|
+
expect(@native_agent).to receive(:apply_suspicious_quick_check).with(any_args).and_return(1)
|
|
130
|
+
expect(@native_agent).to receive(:apply_patches).with(any_args).and_return('Blocked Response')
|
|
131
|
+
@policy.block_request?(meta_data)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
115
134
|
end
|
|
116
135
|
end
|
|
117
136
|
end
|
|
@@ -6,7 +6,7 @@ module TCellAgent
|
|
|
6
6
|
assert_policy_state = proc do |policies, state|
|
|
7
7
|
expect(policies.keys.size).to eq(10)
|
|
8
8
|
|
|
9
|
-
policies.
|
|
9
|
+
policies.each_value do |policy|
|
|
10
10
|
next if policy.instance_of?(TCellAgent::Policies::LoginPolicy)
|
|
11
11
|
next if policy.instance_of?(TCellAgent::Policies::SystemEnablements)
|
|
12
12
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
require 'spec_helper'
|
|
3
2
|
|
|
4
3
|
module TCellAgent
|
|
@@ -16,13 +15,7 @@ module TCellAgent
|
|
|
16
15
|
).update_attribute(
|
|
17
16
|
'route_id', 'route-id'
|
|
18
17
|
).build
|
|
19
|
-
end
|
|
20
18
|
|
|
21
|
-
after(:each) do
|
|
22
|
-
TCellAgent::Rust::NativeAgent.free_agent(@native_agent.agent_ptr)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'should return csp header' do
|
|
26
19
|
enablements = @native_agent.update_policies(
|
|
27
20
|
{
|
|
28
21
|
'secure-headers' => {
|
|
@@ -41,14 +34,27 @@ module TCellAgent
|
|
|
41
34
|
|
|
42
35
|
@policy = HeadersPolicy.new(@native_agent, enablements)
|
|
43
36
|
expect(@policy.enabled).to eq(true)
|
|
37
|
+
end
|
|
44
38
|
|
|
39
|
+
after(:each) do
|
|
40
|
+
TCellAgent::Rust::NativeAgent.free_agent(@native_agent.agent_ptr)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should return csp header' do
|
|
45
44
|
expect(
|
|
46
|
-
@policy.get_headers(@tcell_context)
|
|
45
|
+
@policy.get_headers('text/html', @tcell_context)
|
|
47
46
|
).to eq(
|
|
48
47
|
[{ 'name' => 'X-Content-Type-Options',
|
|
49
48
|
'value' => 'nosniff' }]
|
|
50
49
|
)
|
|
51
50
|
end
|
|
51
|
+
|
|
52
|
+
it 'should not return csp header on json' do
|
|
53
|
+
expect(
|
|
54
|
+
@policy.get_headers('application/json', @tcell_context)
|
|
55
|
+
).to eq( [] )
|
|
56
|
+
|
|
57
|
+
end
|
|
52
58
|
end
|
|
53
59
|
end
|
|
54
60
|
end
|
|
@@ -4,37 +4,34 @@ module TCellAgent
|
|
|
4
4
|
module Utils
|
|
5
5
|
describe '.better_ip' do
|
|
6
6
|
context 'with reverse_proxy off' do
|
|
7
|
-
it '
|
|
7
|
+
it 'returns null' do
|
|
8
8
|
configuration = double('configuration')
|
|
9
9
|
request = double('request', :ip => '127.0.0.0')
|
|
10
10
|
|
|
11
11
|
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
|
12
12
|
expect(configuration).to receive(:reverse_proxy).and_return(false)
|
|
13
|
-
expect(Rails.
|
|
13
|
+
expect(Rails.reverse_proxy_header(request)).to eq(nil)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
context 'with reverse_proxy on' do
|
|
18
18
|
context 'with empty reverse_proxy_ip_address_header' do
|
|
19
|
-
it '
|
|
19
|
+
it 'returns null' do
|
|
20
20
|
configuration = double('configuration')
|
|
21
21
|
request = double('request', :ip => '127.0.0.0')
|
|
22
|
-
env = double('env')
|
|
23
22
|
|
|
24
23
|
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
|
25
24
|
expect(configuration).to receive(:reverse_proxy).and_return(true)
|
|
26
25
|
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
|
27
26
|
expect(configuration).to receive(:reverse_proxy_ip_address_header).and_return('')
|
|
28
|
-
expect(request).to
|
|
29
|
-
expect(env).to receive(:[]).with('HTTP_X_FORWARDED_FOR').and_return('')
|
|
30
|
-
expect(Rails.better_ip(request)).to eq('127.0.0.0')
|
|
27
|
+
expect(Rails.reverse_proxy_header(request)).to eq(nil)
|
|
31
28
|
end
|
|
32
29
|
end
|
|
33
30
|
|
|
34
31
|
context "with reverse_proxy_ip_address_header that doesn't exist" do
|
|
35
|
-
it '
|
|
32
|
+
it 'returns null' do
|
|
36
33
|
configuration = double('configuration')
|
|
37
|
-
request = double('request', :ip => '127.0.0.0')
|
|
34
|
+
request = double('request', :ip => '127.0.0.0', :env => {})
|
|
38
35
|
env = double('env')
|
|
39
36
|
|
|
40
37
|
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
|
@@ -45,7 +42,7 @@ module TCellAgent
|
|
|
45
42
|
)
|
|
46
43
|
expect(request).to receive(:env).and_return(env)
|
|
47
44
|
expect(env).to receive(:[]).with('HTTP_WEIRD_HTTP_PROXY_HEADER').and_return(nil)
|
|
48
|
-
expect(Rails.
|
|
45
|
+
expect(Rails.reverse_proxy_header(request)).to eq(nil)
|
|
49
46
|
end
|
|
50
47
|
end
|
|
51
48
|
|
|
@@ -57,13 +54,14 @@ module TCellAgent
|
|
|
57
54
|
|
|
58
55
|
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
|
59
56
|
expect(configuration).to receive(:reverse_proxy).and_return(true)
|
|
57
|
+
|
|
60
58
|
expect(TCellAgent).to receive(:configuration).and_return(configuration)
|
|
61
59
|
expect(configuration).to receive(:reverse_proxy_ip_address_header).and_return(
|
|
62
60
|
'X-Real-IP'
|
|
63
61
|
)
|
|
64
62
|
expect(request).to receive(:env).and_return(env)
|
|
65
63
|
expect(env).to receive(:[]).with('HTTP_X_REAL_IP').and_return('192.168.99.100')
|
|
66
|
-
expect(Rails.
|
|
64
|
+
expect(Rails.reverse_proxy_header(request)).to eq('192.168.99.100')
|
|
67
65
|
end
|
|
68
66
|
end
|
|
69
67
|
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class WrapperClass
|
|
6
|
-
include TCellAgent::CsrfExceptionReporter
|
|
3
|
+
class WrapperClass
|
|
4
|
+
include TCellAgent::CsrfExceptionReporter
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
def request; end
|
|
7
|
+
end
|
|
10
8
|
|
|
9
|
+
module TCellAgent
|
|
10
|
+
describe 'CsrfExceptionReporter' do
|
|
11
11
|
before(:all) do
|
|
12
12
|
@csrf_class = WrapperClass.new
|
|
13
13
|
end
|
|
@@ -127,10 +127,10 @@ module TCellAgent
|
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
context 'with a <HEAD> tag' do
|
|
130
|
-
it 'should
|
|
130
|
+
it 'should append script after <HEAD> tag' do
|
|
131
131
|
response = JSAgent.handle_js_agent_insert('SCRIPT', 'i am the <HEAD> response')
|
|
132
132
|
|
|
133
|
-
expect(response).to eq('i am the <HEAD> response')
|
|
133
|
+
expect(response).to eq('i am the <HEAD>SCRIPT response')
|
|
134
134
|
end
|
|
135
135
|
end
|
|
136
136
|
|
|
@@ -142,6 +142,14 @@ module TCellAgent
|
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
+
context 'with a <HEAD\n> tag' do
|
|
146
|
+
it 'should append script after <HEAD\n> tag' do
|
|
147
|
+
response = JSAgent.handle_js_agent_insert('SCRIPT', "i am the <HEAD\n> response")
|
|
148
|
+
|
|
149
|
+
expect(response).to eq("i am the <HEAD\n>SCRIPT response")
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
145
153
|
context 'with invalid parameters' do
|
|
146
154
|
context 'with nil response' do
|
|
147
155
|
it 'should return the unmodified response' do
|
|
@@ -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')
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module TCellAgent
|
|
4
|
+
module Rust
|
|
5
|
+
describe AgentConfig do
|
|
6
|
+
context 'with initializers set' do
|
|
7
|
+
before do
|
|
8
|
+
TCellAgent.configure do |config|
|
|
9
|
+
config.app_id = 'initializer_app_id_set'
|
|
10
|
+
config.api_key = 'initializer_api_key_set'
|
|
11
|
+
config.enabled_instrumentations = { 'authlogic' => false, :devise => false, 'doorkeeper' => false }
|
|
12
|
+
config.hmac_key = config.app_id
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
it 'should return the correct values' do
|
|
16
|
+
config = AgentConfig.new(TCellAgent.initializer_configuration)
|
|
17
|
+
|
|
18
|
+
expect(config['agent_type']).to eq 'Ruby'
|
|
19
|
+
expect(config['overrides']['disabled_instrumentation']).to contain_exactly('authlogic', 'devise', 'doorkeeper')
|
|
20
|
+
expect(config['overrides']['applications'][0][:api_key]).to eq 'initializer_api_key_set'
|
|
21
|
+
expect(config['overrides']['applications'][0][:app_id]).to eq 'initializer_app_id_set'
|
|
22
|
+
expect(config['overrides']['applications'][0][:api_key]).to eq 'initializer_api_key_set'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -14,7 +14,6 @@ module TCellAgent
|
|
|
14
14
|
:reverse_proxy => true,
|
|
15
15
|
:reverse_proxy_ip_address_header => nil,
|
|
16
16
|
:log_filename => 'log-filename',
|
|
17
|
-
:config_filename => 'config-filename',
|
|
18
17
|
:agent_log_dir => 'agent-log-dir',
|
|
19
18
|
:agent_home_dir => 'agent-home-dir',
|
|
20
19
|
:agent_home_owner => nil,
|
|
@@ -28,26 +27,12 @@ module TCellAgent
|
|
|
28
27
|
).at_least(:once)
|
|
29
28
|
expect(TCellAgent).to receive(:logger).and_return(logger).at_least(:once)
|
|
30
29
|
expect(Thread).to receive(:new).and_yield
|
|
31
|
-
|
|
32
|
-
expect(logger).to receive(:debug).with('TCellAgent::SensorEvents::ServerAgentDetailsSensorEvent', 'Group unknown')
|
|
33
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
34
|
-
{
|
|
35
|
-
'event_type' => 'server_agent_details',
|
|
36
|
-
'user' => 'unknown',
|
|
37
|
-
'group' => 'unknown'
|
|
38
|
-
}
|
|
39
|
-
)
|
|
30
|
+
|
|
40
31
|
expect(logger).to receive(:debug).with(anything, anything).at_least(:once)
|
|
41
32
|
expect(TCellAgent).to receive(:send_event).with(
|
|
42
33
|
hash_including('event_type' => 'server_agent_packages')
|
|
43
|
-
) # packages event
|
|
44
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
45
|
-
{
|
|
46
|
-
'event_type' => 'server_agent_details',
|
|
47
|
-
'language' => 'Ruby',
|
|
48
|
-
'language_version' => RUBY_VERSION
|
|
49
|
-
}
|
|
50
34
|
)
|
|
35
|
+
|
|
51
36
|
expect(TCellAgent).to receive(:send_event).with(
|
|
52
37
|
{
|
|
53
38
|
'event_type' => 'app_config_setting',
|
|
@@ -57,78 +42,6 @@ module TCellAgent
|
|
|
57
42
|
'value' => 'true'
|
|
58
43
|
}
|
|
59
44
|
)
|
|
60
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
61
|
-
{
|
|
62
|
-
'event_type' => 'app_config_setting',
|
|
63
|
-
'package' => 'tcell',
|
|
64
|
-
'section' => 'config',
|
|
65
|
-
'name' => 'allow_payloads',
|
|
66
|
-
'value' => 'true'
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
70
|
-
{
|
|
71
|
-
'event_type' => 'app_config_setting',
|
|
72
|
-
'package' => 'tcell',
|
|
73
|
-
'section' => 'config',
|
|
74
|
-
'name' => 'reverse_proxy',
|
|
75
|
-
'value' => 'true'
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
79
|
-
{
|
|
80
|
-
'event_type' => 'app_config_setting',
|
|
81
|
-
'package' => 'tcell',
|
|
82
|
-
'section' => 'config',
|
|
83
|
-
'name' => 'config_filename',
|
|
84
|
-
'value' => 'config-filename'
|
|
85
|
-
}
|
|
86
|
-
)
|
|
87
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
88
|
-
{
|
|
89
|
-
'event_type' => 'app_config_setting',
|
|
90
|
-
'package' => 'tcell',
|
|
91
|
-
'section' => 'config',
|
|
92
|
-
'name' => 'logging_directory',
|
|
93
|
-
'value' => 'agent-log-dir'
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
97
|
-
{
|
|
98
|
-
'event_type' => 'app_config_setting',
|
|
99
|
-
'package' => 'tcell',
|
|
100
|
-
'section' => 'config',
|
|
101
|
-
'name' => 'agent_home_directory',
|
|
102
|
-
'value' => 'agent-home-dir'
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
106
|
-
{
|
|
107
|
-
'event_type' => 'app_config_setting',
|
|
108
|
-
'package' => 'tcell',
|
|
109
|
-
'section' => 'config',
|
|
110
|
-
'name' => 'logging_enabled',
|
|
111
|
-
'value' => 'true'
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
115
|
-
{
|
|
116
|
-
'event_type' => 'app_config_setting',
|
|
117
|
-
'package' => 'tcell',
|
|
118
|
-
'section' => 'config',
|
|
119
|
-
'name' => 'logging_level',
|
|
120
|
-
'value' => 'INFO'
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
124
|
-
{
|
|
125
|
-
'event_type' => 'app_config_setting',
|
|
126
|
-
'package' => 'tcell',
|
|
127
|
-
'section' => 'config',
|
|
128
|
-
'name' => 'reverse_proxy_ip_address_header',
|
|
129
|
-
'value' => ''
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
45
|
|
|
133
46
|
TCellAgent.report_settings
|
|
134
47
|
end
|