tcell_agent 2.7.0 → 2.7.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/lib/tcell_agent/agent.rb +1 -2
- data/lib/tcell_agent/instrumentation.rb +0 -192
- data/lib/tcell_agent/policies/policies_manager.rb +1 -17
- data/lib/tcell_agent/policies/policy_polling.rb +1 -2
- data/lib/tcell_agent/policies/policy_types.rb +0 -1
- data/lib/tcell_agent/rails/database.rb +49 -0
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +1 -1
- data/lib/tcell_agent/rails/railties/tcell_agent_database_railties.rb +81 -0
- data/lib/tcell_agent/rails/railties/tcell_agent_railties.rb +0 -1
- data/lib/tcell_agent/rails/routes.rb +0 -8
- data/lib/tcell_agent/rust/libtcellagent-alpine.so +0 -0
- data/lib/tcell_agent/rust/libtcellagent-x64.dll +0 -0
- data/lib/tcell_agent/rust/libtcellagent.dylib +0 -0
- data/lib/tcell_agent/rust/libtcellagent.so +0 -0
- data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +0 -17
- data/lib/tcell_agent/version.rb +1 -1
- data/lib/tcell_agent.rb +5 -3
- data/spec/lib/tcell_agent/policies/policies_manager_spec.rb +5 -16
- data/spec/lib/tcell_agent/rails/database.rb +60 -0
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +2 -2
- data/spec/support/force_logger_mocking.rb +0 -8
- metadata +6 -16
- data/lib/tcell_agent/policies/dataloss_policy.rb +0 -304
- data/lib/tcell_agent/rails/dlp/process_request.rb +0 -83
- data/lib/tcell_agent/rails/dlp.rb +0 -410
- data/lib/tcell_agent/rails/dlp_handler.rb +0 -63
- data/lib/tcell_agent/sensor_events/dlp.rb +0 -53
- data/lib/tcell_agent/sinatra.rb +0 -38
- data/spec/lib/tcell_agent/policies/dataloss_policy_spec.rb +0 -222
- data/spec/lib/tcell_agent/rails/dlp_spec.rb +0 -1040
- data/spec/lib/tcell_agent/rails/logger_spec.rb +0 -169
- data/spec/lib/tcell_agent/sensor_events/dlp_spec.rb +0 -14
@@ -1,169 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Logger do
|
4
|
-
describe '#add' do
|
5
|
-
context 'with a warn logger' do
|
6
|
-
before(:each) do
|
7
|
-
req_env = double('request_env')
|
8
|
-
lfi_policy = double('lfi_policy')
|
9
|
-
native_agent = double('native_agent')
|
10
|
-
@local_files_policy = TCellAgent::Policies::LocalFileInclusion.new(
|
11
|
-
native_agent, {}
|
12
|
-
)
|
13
|
-
allow(req_env).to receive(:[])
|
14
|
-
allow(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::LFI).and_return(
|
15
|
-
lfi_policy
|
16
|
-
)
|
17
|
-
allow(TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware::THREADS).to receive(
|
18
|
-
:fetch
|
19
|
-
).with(anything, {}).and_return(req_env)
|
20
|
-
allow(lfi_policy).to receive(:block_file_access?).and_return(false)
|
21
|
-
end
|
22
|
-
context 'writing a debug message' do
|
23
|
-
it 'should skip the tcell logic' do
|
24
|
-
expect(TCellAgent::Instrumentation).to_not receive(:safe_block_no_log)
|
25
|
-
|
26
|
-
logger = Logger.new('/dev/null')
|
27
|
-
|
28
|
-
logger.level = Logger::WARN
|
29
|
-
logger.add(Logger::DEBUG, 'This will not be logged')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'writing a warn message' do
|
34
|
-
it 'should run the tcell logic' do
|
35
|
-
expect(TCellAgent::Instrumentation).to receive(:safe_block_no_log).with(
|
36
|
-
'Handling DLP log message filtering'
|
37
|
-
)
|
38
|
-
|
39
|
-
logger = Logger.new('/dev/null')
|
40
|
-
|
41
|
-
logger.level = Logger::WARN
|
42
|
-
logger.add(Logger::WARN, 'This will be logged')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'writing an error message' do
|
47
|
-
it 'should run the tcell logic' do
|
48
|
-
expect(TCellAgent::Instrumentation).to receive(:safe_block_no_log).with(
|
49
|
-
'Handling DLP log message filtering'
|
50
|
-
)
|
51
|
-
|
52
|
-
logger = Logger.new('/dev/null')
|
53
|
-
|
54
|
-
logger.level = Logger::WARN
|
55
|
-
logger.add(Logger::ERROR, 'This will be logged')
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with an empty message' do
|
59
|
-
it 'should not run the context filter' do
|
60
|
-
dlp_policy = double('dlp_policy', :enabled => true)
|
61
|
-
expect(TCellAgent::Instrumentation).to receive(:safe_block_no_log).with(
|
62
|
-
'Handling DLP log message filtering'
|
63
|
-
).and_call_original
|
64
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::DATALOSS).and_return(
|
65
|
-
dlp_policy
|
66
|
-
)
|
67
|
-
expect(TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware::THREADS).to receive(
|
68
|
-
:fetch
|
69
|
-
).with(anything, nil).and_return(double('request_env'))
|
70
|
-
|
71
|
-
logger = Logger.new('/dev/null')
|
72
|
-
|
73
|
-
logger.level = Logger::WARN
|
74
|
-
logger.add(Logger::ERROR, nil)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'with no dlp policy' do
|
79
|
-
it 'should not run the context filter' do
|
80
|
-
expect(TCellAgent::Instrumentation).to receive(:safe_block_no_log).with(
|
81
|
-
'Handling DLP log message filtering'
|
82
|
-
).and_call_original
|
83
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::DATALOSS).and_return(
|
84
|
-
nil
|
85
|
-
)
|
86
|
-
expect(TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware::THREADS).to_not receive(
|
87
|
-
:fetch
|
88
|
-
).with(anything, nil)
|
89
|
-
|
90
|
-
logger = Logger.new('/dev/null')
|
91
|
-
|
92
|
-
logger.level = Logger::WARN
|
93
|
-
logger.add(Logger::ERROR, 'My DLP Policy :(')
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'with no request env' do
|
98
|
-
it 'should not run the context filter' do
|
99
|
-
dlp_policy = double('dlp_policy', :enabled => true)
|
100
|
-
expect(TCellAgent::Instrumentation).to receive(:safe_block_no_log).with(
|
101
|
-
'Handling DLP log message filtering'
|
102
|
-
).and_call_original
|
103
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::DATALOSS).and_return(
|
104
|
-
dlp_policy
|
105
|
-
)
|
106
|
-
expect(TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware::THREADS).to receive(
|
107
|
-
:fetch
|
108
|
-
).with(anything, nil).and_return(nil)
|
109
|
-
|
110
|
-
logger = Logger.new('/dev/null')
|
111
|
-
|
112
|
-
logger.level = Logger::WARN
|
113
|
-
logger.add(Logger::ERROR, 'My DLP Policy :(')
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'with a dlp policy, a message, and request env' do
|
118
|
-
context 'with no tcell_context' do
|
119
|
-
it 'should not run the context filter' do
|
120
|
-
request_env = double('request_env')
|
121
|
-
dlp_policy = double('dlp_policy', :enabled => true)
|
122
|
-
|
123
|
-
expect(TCellAgent::Instrumentation).to receive(:safe_block_no_log).with(
|
124
|
-
'Handling DLP log message filtering'
|
125
|
-
).and_call_original
|
126
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::DATALOSS).and_return(
|
127
|
-
dlp_policy
|
128
|
-
)
|
129
|
-
expect(TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware::THREADS).to receive(
|
130
|
-
:fetch
|
131
|
-
).with(anything, nil).and_return(request_env)
|
132
|
-
expect(request_env).to receive(:[]).and_return(nil)
|
133
|
-
|
134
|
-
logger = Logger.new('/dev/null')
|
135
|
-
|
136
|
-
logger.level = Logger::WARN
|
137
|
-
logger.add(Logger::ERROR, 'My DLP Policy :(')
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'with tcell_context' do
|
142
|
-
it 'should run the context filter' do
|
143
|
-
request_env = double('request_env')
|
144
|
-
tcell_context = double('tcell_context')
|
145
|
-
dlp_policy = double('dlp_policy', :enabled => true)
|
146
|
-
|
147
|
-
expect(TCellAgent::Instrumentation).to receive(:safe_block_no_log).with(
|
148
|
-
'Handling DLP log message filtering'
|
149
|
-
).and_call_original
|
150
|
-
expect(TCellAgent).to receive(:policy).with(TCellAgent::PolicyTypes::DATALOSS).and_return(
|
151
|
-
dlp_policy
|
152
|
-
)
|
153
|
-
expect(TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware::THREADS).to receive(
|
154
|
-
:fetch
|
155
|
-
).with(anything, nil).and_return(request_env)
|
156
|
-
expect(request_env).to receive(:[]).and_return(tcell_context)
|
157
|
-
expect(tcell_context).to receive(:filter_log).with('My DLP Policy :(')
|
158
|
-
|
159
|
-
logger = Logger.new('/dev/null')
|
160
|
-
|
161
|
-
logger.level = Logger::WARN
|
162
|
-
logger.add(Logger::ERROR, 'My DLP Policy :(')
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TCellAgent
|
4
|
-
module SensorEvents
|
5
|
-
describe DlpEvent do
|
6
|
-
context 'Domain from Url' do
|
7
|
-
it 'Test Simple Domain' do
|
8
|
-
dlp_event = DlpEvent.new('a', 'b', 'c').for_request('x', 'y')
|
9
|
-
expect(dlp_event['context']).to eq('x')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|