tcell_agent 1.1.3 → 1.1.4

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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tcell_agent +10 -2
  3. data/lib/tcell_agent.rb +3 -3
  4. data/lib/tcell_agent/agent.rb +42 -52
  5. data/lib/tcell_agent/agent/event_processor.rb +129 -162
  6. data/lib/tcell_agent/agent/fork_pipe_manager.rb +57 -62
  7. data/lib/tcell_agent/agent/policy_manager.rb +83 -104
  8. data/lib/tcell_agent/agent/policy_types.rb +24 -29
  9. data/lib/tcell_agent/agent/route_manager.rb +36 -46
  10. data/lib/tcell_agent/agent/static_agent.rb +19 -21
  11. data/lib/tcell_agent/api.rb +23 -28
  12. data/lib/tcell_agent/appsensor/injections_reporter.rb +7 -11
  13. data/lib/tcell_agent/authlogic.rb +7 -7
  14. data/lib/tcell_agent/cmdi.rb +22 -23
  15. data/lib/tcell_agent/config/unknown_options.rb +71 -69
  16. data/lib/tcell_agent/configuration.rb +187 -191
  17. data/lib/tcell_agent/devise.rb +13 -15
  18. data/lib/tcell_agent/hooks/login_fraud.rb +1 -1
  19. data/lib/tcell_agent/instrumentation.rb +120 -124
  20. data/lib/tcell_agent/logger.rb +29 -45
  21. data/lib/tcell_agent/patches.rb +5 -5
  22. data/lib/tcell_agent/policies/dataloss_policy.rb +263 -288
  23. data/lib/tcell_agent/policies/http_redirect_policy.rb +25 -37
  24. data/lib/tcell_agent/policies/http_tx_policy.rb +48 -52
  25. data/lib/tcell_agent/policies/login_fraud_policy.rb +15 -20
  26. data/lib/tcell_agent/policies/policy.rb +0 -2
  27. data/lib/tcell_agent/policies/rust_policies.rb +24 -29
  28. data/lib/tcell_agent/rails.rb +2 -3
  29. data/lib/tcell_agent/rails/auth/authlogic.rb +2 -2
  30. data/lib/tcell_agent/rails/auth/devise.rb +2 -2
  31. data/lib/tcell_agent/rails/auth/doorkeeper.rb +2 -2
  32. data/lib/tcell_agent/rails/better_ip.rb +12 -16
  33. data/lib/tcell_agent/rails/csrf_exception.rb +4 -7
  34. data/lib/tcell_agent/rails/dlp.rb +208 -107
  35. data/lib/tcell_agent/rails/dlp/process_request.rb +37 -47
  36. data/lib/tcell_agent/rails/dlp_handler.rb +9 -11
  37. data/lib/tcell_agent/rails/js_agent_insert.rb +11 -14
  38. data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +8 -7
  39. data/lib/tcell_agent/rails/middleware/context_middleware.rb +4 -5
  40. data/lib/tcell_agent/rails/middleware/global_middleware.rb +5 -8
  41. data/lib/tcell_agent/rails/middleware/headers_middleware.rb +24 -27
  42. data/lib/tcell_agent/rails/on_start.rb +5 -5
  43. data/lib/tcell_agent/rails/responses.rb +7 -9
  44. data/lib/tcell_agent/rails/routes.rb +62 -81
  45. data/lib/tcell_agent/rails/routes/grape.rb +25 -30
  46. data/lib/tcell_agent/rails/routes/route_id.rb +9 -14
  47. data/lib/tcell_agent/rails/settings_reporter.rb +44 -33
  48. data/lib/tcell_agent/rails/tcell_body_proxy.rb +15 -18
  49. data/lib/tcell_agent/routes/table.rb +31 -33
  50. data/lib/tcell_agent/rust/{libtcellagent-1.3.0.dylib → libtcellagent-1.3.1.dylib} +0 -0
  51. data/lib/tcell_agent/rust/{libtcellagent-1.3.0.so → libtcellagent-1.3.1.so} +0 -0
  52. data/lib/tcell_agent/rust/{libtcellagent-alpine-1.3.0.so → libtcellagent-alpine-1.3.1.so} +0 -0
  53. data/lib/tcell_agent/rust/models.rb +32 -37
  54. data/lib/tcell_agent/rust/tcellagent-1.3.1.dll +0 -0
  55. data/lib/tcell_agent/rust/whisperer.rb +101 -104
  56. data/lib/tcell_agent/sensor_events/app_config.rb +7 -7
  57. data/lib/tcell_agent/sensor_events/appsensor_event.rb +26 -27
  58. data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +20 -88
  59. data/lib/tcell_agent/sensor_events/command_injection.rb +52 -80
  60. data/lib/tcell_agent/sensor_events/discovery.rb +27 -27
  61. data/lib/tcell_agent/sensor_events/dlp.rb +50 -56
  62. data/lib/tcell_agent/sensor_events/honeytokens.rb +9 -9
  63. data/lib/tcell_agent/sensor_events/metrics.rb +20 -21
  64. data/lib/tcell_agent/sensor_events/patches.rb +10 -12
  65. data/lib/tcell_agent/sensor_events/sensor.rb +32 -36
  66. data/lib/tcell_agent/sensor_events/server_agent.rb +130 -127
  67. data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +60 -80
  68. data/lib/tcell_agent/sensor_events/util/utils.rb +3 -5
  69. data/lib/tcell_agent/servers/passenger.rb +5 -9
  70. data/lib/tcell_agent/servers/puma.rb +18 -27
  71. data/lib/tcell_agent/servers/rails_server.rb +5 -9
  72. data/lib/tcell_agent/servers/thin.rb +2 -4
  73. data/lib/tcell_agent/servers/unicorn.rb +18 -27
  74. data/lib/tcell_agent/servers/webrick.rb +2 -4
  75. data/lib/tcell_agent/settings_reporter.rb +126 -0
  76. data/lib/tcell_agent/sinatra.rb +24 -26
  77. data/lib/tcell_agent/start_background_thread.rb +21 -142
  78. data/lib/tcell_agent/system_info.rb +4 -3
  79. data/lib/tcell_agent/tcell_context.rb +150 -0
  80. data/lib/tcell_agent/userinfo.rb +3 -3
  81. data/lib/tcell_agent/utils/io.rb +19 -24
  82. data/lib/tcell_agent/utils/params.rb +9 -15
  83. data/lib/tcell_agent/utils/queue_with_timeout.rb +26 -32
  84. data/lib/tcell_agent/utils/strings.rb +4 -6
  85. data/lib/tcell_agent/version.rb +1 -1
  86. data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +5 -5
  87. data/spec/lib/tcell_agent/agent/static_agent_spec.rb +7 -7
  88. data/spec/lib/tcell_agent/cmdi_spec.rb +21 -21
  89. data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +29 -24
  90. data/spec/lib/tcell_agent/instrumentation_spec.rb +4 -4
  91. data/spec/lib/tcell_agent/patches_spec.rb +8 -8
  92. data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +23 -23
  93. data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +2 -2
  94. data/spec/lib/tcell_agent/rails/csrf_exception_spec.rb +69 -0
  95. data/spec/lib/tcell_agent/rails/dlp_spec.rb +1039 -0
  96. data/spec/lib/tcell_agent/rails/js_agent_insert_spec.rb +271 -0
  97. data/spec/lib/tcell_agent/rails/logger_spec.rb +5 -5
  98. data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +3 -3
  99. data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +4 -4
  100. data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +5 -5
  101. data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +1 -1
  102. data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +11 -8
  103. data/spec/lib/tcell_agent/rails/responses_spec.rb +2 -2
  104. data/spec/lib/tcell_agent/rails/routes/grape_spec.rb +2 -2
  105. data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +1 -1
  106. data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +4 -4
  107. data/spec/lib/tcell_agent/rust/models_spec.rb +83 -75
  108. data/spec/lib/tcell_agent/rust/whisperer_spec.rb +14 -14
  109. data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +19 -70
  110. data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +1 -1
  111. data/spec/lib/tcell_agent/settings_reporter_spec.rb +162 -0
  112. data/spec/lib/tcell_agent/tcell_context_spec.rb +154 -0
  113. data/spec/spec_helper.rb +5 -0
  114. metadata +18 -10
  115. data/lib/tcell_agent/appsensor/meta_data.rb +0 -132
  116. data/lib/tcell_agent/patches/meta_data.rb +0 -59
  117. data/lib/tcell_agent/rust/tcellagent-1.3.0.dll +0 -0
  118. data/spec/lib/tcell_agent/appsensor/meta_data_spec.rb +0 -71
@@ -0,0 +1,162 @@
1
+ module TCellAgent
2
+ describe '.report_settings' do
3
+ require 'tcell_agent/settings_reporter'
4
+
5
+ context 'with send_startup_events=false' do
6
+ it 'should not report anything' do
7
+ expect(TCellAgent).to_not receive(:configuration)
8
+ expect(TCellAgent).to_not receive(:send_event)
9
+
10
+ TCellAgent.report_settings(false)
11
+ end
12
+ end
13
+
14
+ context 'with send_startup_events=true' do
15
+ context 'should_instrument?=false' do
16
+ it 'should not report anything' do
17
+ configuration = double('configuration',
18
+ :should_instrument? => false)
19
+
20
+ expect(TCellAgent).to receive(:configuration).and_return(
21
+ configuration
22
+ )
23
+ expect(TCellAgent).to_not receive(:send_event)
24
+
25
+ TCellAgent.report_settings(true)
26
+ end
27
+ end
28
+
29
+ context 'should_instrument?=true' do
30
+ it 'should not report all the settings' do
31
+ logger = double('logger')
32
+ configuration = double('configuration',
33
+ :enabled => true,
34
+ :should_instrument? => true,
35
+ :logger => logger,
36
+ :allow_payloads => true,
37
+ :reverse_proxy => true,
38
+ :reverse_proxy_ip_address_header => nil,
39
+ :log_filename => 'log-filename',
40
+ :config_filename => 'config-filename',
41
+ :agent_log_dir => 'agent-log-dir',
42
+ :agent_home_dir => 'agent-home-dir',
43
+ :agent_home_owner => nil,
44
+ :logging_options => {
45
+ },
46
+ :hmac_key => nil)
47
+
48
+ expect(TCellAgent).to receive(:configuration).and_return(
49
+ configuration
50
+ ).at_least(:once)
51
+ expect(TCellAgent).to receive(:logger).and_return(logger).at_least(:once)
52
+ expect(Thread).to receive(:new).and_yield
53
+ expect(logger).to receive(:debug).with('User unknown')
54
+ expect(logger).to receive(:debug).with('Group unknown')
55
+ expect(TCellAgent).to receive(:send_event).with(
56
+ {
57
+ 'event_type' => 'server_agent_details',
58
+ 'user' => 'unknown',
59
+ 'group' => 'unknown'
60
+ }
61
+ )
62
+ expect(logger).to receive(:debug).with(anything).at_least(:once)
63
+ expect(TCellAgent).to receive(:send_event).with(
64
+ hash_including('event_type' => 'server_agent_packages')
65
+ ) # packages event
66
+ expect(TCellAgent).to receive(:send_event).with(
67
+ {
68
+ 'event_type' => 'app_config_setting',
69
+ 'package' => 'tcell',
70
+ 'section' => 'config',
71
+ 'name' => 'native_lib_loaded',
72
+ 'value' => 'true'
73
+ }
74
+ )
75
+ expect(TCellAgent).to receive(:send_event).with(
76
+ {
77
+ 'event_type' => 'app_config_setting',
78
+ 'package' => 'tcell',
79
+ 'section' => 'config',
80
+ 'name' => 'allow_payloads',
81
+ 'value' => 'true'
82
+ }
83
+ )
84
+ expect(TCellAgent).to receive(:send_event).with(
85
+ {
86
+ 'event_type' => 'app_config_setting',
87
+ 'package' => 'tcell',
88
+ 'section' => 'config',
89
+ 'name' => 'reverse_proxy',
90
+ 'value' => 'true'
91
+ }
92
+ )
93
+ expect(TCellAgent).to receive(:send_event).with(
94
+ {
95
+ 'event_type' => 'app_config_setting',
96
+ 'package' => 'tcell',
97
+ 'section' => 'config',
98
+ 'name' => 'config_filename',
99
+ 'value' => 'config-filename'
100
+ }
101
+ )
102
+ expect(TCellAgent).to receive(:send_event).with(
103
+ {
104
+ 'event_type' => 'app_config_setting',
105
+ 'package' => 'tcell',
106
+ 'section' => 'config',
107
+ 'name' => 'logging_directory',
108
+ 'value' => 'agent-log-dir'
109
+ }
110
+ )
111
+ expect(TCellAgent).to receive(:send_event).with(
112
+ {
113
+ 'event_type' => 'app_config_setting',
114
+ 'package' => 'tcell',
115
+ 'section' => 'config',
116
+ 'name' => 'agent_home_directory',
117
+ 'value' => 'agent-home-dir'
118
+ }
119
+ )
120
+ expect(TCellAgent).to receive(:send_event).with(
121
+ {
122
+ 'event_type' => 'app_config_setting',
123
+ 'package' => 'tcell',
124
+ 'section' => 'config',
125
+ 'name' => 'agent_home_owner',
126
+ 'value' => ''
127
+ }
128
+ )
129
+ expect(TCellAgent).to receive(:send_event).with(
130
+ {
131
+ 'event_type' => 'app_config_setting',
132
+ 'package' => 'tcell',
133
+ 'section' => 'config',
134
+ 'name' => 'logging_enabled',
135
+ 'value' => 'true'
136
+ }
137
+ )
138
+ expect(TCellAgent).to receive(:send_event).with(
139
+ {
140
+ 'event_type' => 'app_config_setting',
141
+ 'package' => 'tcell',
142
+ 'section' => 'config',
143
+ 'name' => 'logging_level',
144
+ 'value' => 'INFO'
145
+ }
146
+ )
147
+ expect(TCellAgent).to receive(:send_event).with(
148
+ {
149
+ 'event_type' => 'app_config_setting',
150
+ 'package' => 'tcell',
151
+ 'section' => 'config',
152
+ 'name' => 'reverse_proxy_ip_address_header',
153
+ 'value' => ''
154
+ }
155
+ )
156
+
157
+ TCellAgent.report_settings(true)
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,154 @@
1
+ require 'spec_helper'
2
+
3
+ module TCellAgent
4
+ describe MetaData do
5
+ describe '#set_headers_dict' do
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
8
+
9
+ meta = MetaData.new(method, remote_address, route_id, session_id, user_id, transaction_id, location)
10
+ meta.headers_dict = {
11
+ 'rack.version' => [1, 2],
12
+ 'REQUEST_METHOD' => 'POST',
13
+ 'SERVER_NAME' => 'www.example.com',
14
+ 'HTTP_USER_AGENT' => 'Mozilla',
15
+ 'HTTP_MY_CUSTOM_HTTP_HEADER' => 'my value'
16
+ }
17
+
18
+ expect(meta.flattened_headers_dict).to eq(
19
+ {
20
+ ['user-agent'] => 'Mozilla',
21
+ ['my-custom-http-header'] => 'my value'
22
+ }
23
+ )
24
+ end
25
+
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
28
+
29
+ meta = MetaData.new(method, remote_address, route_id, session_id, user_id, transaction_id, location)
30
+ meta.headers_dict = {
31
+ 'REQUEST_METHOD' => 'POST',
32
+ 'HTTP_VERSION' => 'HTTP/1.1',
33
+ 'HTTP_CONNECTION' => 'keep-alive',
34
+ 'CONTENT_LENGTH' => '85',
35
+ 'HTTP_CACHE_CONTROL' => 'max-age=0',
36
+ 'HTTP_ORIGIN' => 'http://192.168.99.100:3000',
37
+ 'HTTP_UPGRADE_INSECURE_REQUESTS' => '1',
38
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5)',
39
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
40
+ 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
41
+ 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
42
+ 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
43
+ 'HTTP_MY_CUSTOM_HTTP_HEADER' => 'my value'
44
+ }
45
+
46
+ expect(meta.flattened_headers_dict).to eq(
47
+ {
48
+ ['version'] => 'HTTP/1.1',
49
+ ['connection'] => 'keep-alive',
50
+ ['content-length'] => '85',
51
+ ['cache-control'] => 'max-age=0',
52
+ ['origin'] => 'http://192.168.99.100:3000',
53
+ ['upgrade-insecure-requests'] => '1',
54
+ ['user-agent'] => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5)',
55
+ ['content-type'] => 'application/x-www-form-urlencoded',
56
+ ['accept'] => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
57
+ ['accept-encoding'] => 'gzip, deflate',
58
+ ['accept-language'] => 'en-US,en;q=0.8',
59
+ ['my-custom-http-header'] => 'my value'
60
+ }
61
+ )
62
+ end
63
+ end
64
+
65
+ describe '#body_params' do
66
+ before(:each) do
67
+ @meta_data = TCellAgent::MetaData.new(
68
+ 'get',
69
+ 'remote_address',
70
+ 'route_id',
71
+ 'session_id',
72
+ 'user_id',
73
+ 'transaction_id',
74
+ 'http://test.com'
75
+ )
76
+ end
77
+
78
+ context 'with text/html content type' do
79
+ it 'should set the body params to empty' do
80
+ @meta_data.set_body_dict(
81
+ 67,
82
+ 'text/html',
83
+ {
84
+ :username => 'tester',
85
+ :password => 'pass'
86
+ }.to_json
87
+ )
88
+
89
+ expect(@meta_data.flattened_body_dict).to eq({})
90
+ end
91
+ end
92
+
93
+ context 'with application/json content type' do
94
+ context 'with empty request body' do
95
+ it 'should set the body params to empty' do
96
+ @meta_data.set_body_dict(
97
+ 67,
98
+ 'application/json',
99
+ nil
100
+ )
101
+
102
+ expect(@meta_data.flattened_body_dict).to eq({})
103
+ end
104
+ end
105
+
106
+ context 'with bad json in the body' do
107
+ it 'should set the body params to empty' do
108
+ @meta_data.set_body_dict(
109
+ 67,
110
+ 'application/json',
111
+ '{"username":"tester""password":"pass"}'
112
+ )
113
+
114
+ expect(@meta_data.flattened_body_dict).to eq({})
115
+ end
116
+ end
117
+
118
+ context 'with valid json in the body' do
119
+ it 'should set the body params' do
120
+ @meta_data.set_body_dict(
121
+ 67,
122
+ 'application/json',
123
+ {
124
+ :username => 'tester',
125
+ :password => 'pass'
126
+ }.to_json
127
+ )
128
+
129
+ expect(@meta_data.flattened_body_dict).to eq(
130
+ {
131
+ ['username'] => 'tester',
132
+ ['password'] => 'pass'
133
+ }
134
+ )
135
+ end
136
+ end
137
+
138
+ context 'with a json body that is too big' do
139
+ it 'should set the body params to empty' do
140
+ @meta_data.set_body_dict(
141
+ 20_000_000,
142
+ 'application/json',
143
+ {
144
+ :username => 'tester',
145
+ :password => 'pass'
146
+ }.to_json
147
+ )
148
+ expect(@meta_data.flattened_body_dict).to eq({})
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
@@ -3,6 +3,11 @@ require 'rails'
3
3
  require 'webmock/rspec'
4
4
  require 'fork_break'
5
5
 
6
+ if ENV['COVERAGE']
7
+ require 'simplecov'
8
+ SimpleCov.start
9
+ end
10
+
6
11
  ENV['TCELL_AGENT_SERVER'] = 'mock'
7
12
  require File.join(File.dirname(__FILE__), '..', 'lib', 'tcell_agent')
8
13
  require File.join(File.dirname(__FILE__), '..', 'lib', 'tcell_agent', 'rails') if defined?(Rails)
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: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-05 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -118,7 +118,6 @@ files:
118
118
  - lib/tcell_agent/agent/static_agent.rb
119
119
  - lib/tcell_agent/api.rb
120
120
  - lib/tcell_agent/appsensor/injections_reporter.rb
121
- - lib/tcell_agent/appsensor/meta_data.rb
122
121
  - lib/tcell_agent/authlogic.rb
123
122
  - lib/tcell_agent/cmdi.rb
124
123
  - lib/tcell_agent/config/unknown_options.rb
@@ -128,7 +127,6 @@ files:
128
127
  - lib/tcell_agent/instrumentation.rb
129
128
  - lib/tcell_agent/logger.rb
130
129
  - lib/tcell_agent/patches.rb
131
- - lib/tcell_agent/patches/meta_data.rb
132
130
  - lib/tcell_agent/policies/dataloss_policy.rb
133
131
  - lib/tcell_agent/policies/http_redirect_policy.rb
134
132
  - lib/tcell_agent/policies/http_tx_policy.rb
@@ -157,11 +155,11 @@ files:
157
155
  - lib/tcell_agent/rails/settings_reporter.rb
158
156
  - lib/tcell_agent/rails/tcell_body_proxy.rb
159
157
  - lib/tcell_agent/routes/table.rb
160
- - lib/tcell_agent/rust/libtcellagent-1.3.0.dylib
161
- - lib/tcell_agent/rust/libtcellagent-1.3.0.so
162
- - lib/tcell_agent/rust/libtcellagent-alpine-1.3.0.so
158
+ - lib/tcell_agent/rust/libtcellagent-1.3.1.dylib
159
+ - lib/tcell_agent/rust/libtcellagent-1.3.1.so
160
+ - lib/tcell_agent/rust/libtcellagent-alpine-1.3.1.so
163
161
  - lib/tcell_agent/rust/models.rb
164
- - lib/tcell_agent/rust/tcellagent-1.3.0.dll
162
+ - lib/tcell_agent/rust/tcellagent-1.3.1.dll
165
163
  - lib/tcell_agent/rust/whisperer.rb
166
164
  - lib/tcell_agent/sensor_events/app_config.rb
167
165
  - lib/tcell_agent/sensor_events/appsensor_event.rb
@@ -183,9 +181,11 @@ files:
183
181
  - lib/tcell_agent/servers/thin.rb
184
182
  - lib/tcell_agent/servers/unicorn.rb
185
183
  - lib/tcell_agent/servers/webrick.rb
184
+ - lib/tcell_agent/settings_reporter.rb
186
185
  - lib/tcell_agent/sinatra.rb
187
186
  - lib/tcell_agent/start_background_thread.rb
188
187
  - lib/tcell_agent/system_info.rb
188
+ - lib/tcell_agent/tcell_context.rb
189
189
  - lib/tcell_agent/userinfo.rb
190
190
  - lib/tcell_agent/utils/io.rb
191
191
  - lib/tcell_agent/utils/params.rb
@@ -198,7 +198,6 @@ files:
198
198
  - spec/lib/tcell_agent/agent/static_agent_spec.rb
199
199
  - spec/lib/tcell_agent/api/api_spec.rb
200
200
  - spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb
201
- - spec/lib/tcell_agent/appsensor/meta_data_spec.rb
202
201
  - spec/lib/tcell_agent/cmdi_spec.rb
203
202
  - spec/lib/tcell_agent/config/unknown_options_spec.rb
204
203
  - spec/lib/tcell_agent/configuration_spec.rb
@@ -213,6 +212,9 @@ files:
213
212
  - spec/lib/tcell_agent/policies/login_policy_spec.rb
214
213
  - spec/lib/tcell_agent/policies/patches_policy_spec.rb
215
214
  - spec/lib/tcell_agent/rails/better_ip_spec.rb
215
+ - spec/lib/tcell_agent/rails/csrf_exception_spec.rb
216
+ - spec/lib/tcell_agent/rails/dlp_spec.rb
217
+ - spec/lib/tcell_agent/rails/js_agent_insert_spec.rb
216
218
  - spec/lib/tcell_agent/rails/logger_spec.rb
217
219
  - spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb
218
220
  - spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb
@@ -230,6 +232,8 @@ files:
230
232
  - spec/lib/tcell_agent/sensor_events/dlp_spec.rb
231
233
  - spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb
232
234
  - spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb
235
+ - spec/lib/tcell_agent/settings_reporter_spec.rb
236
+ - spec/lib/tcell_agent/tcell_context_spec.rb
233
237
  - spec/lib/tcell_agent/utils/bounded_queue_spec.rb
234
238
  - spec/lib/tcell_agent/utils/params_spec.rb
235
239
  - spec/lib/tcell_agent/utils/passwords_spec.rb
@@ -271,7 +275,6 @@ test_files:
271
275
  - spec/lib/tcell_agent/agent/static_agent_spec.rb
272
276
  - spec/lib/tcell_agent/api/api_spec.rb
273
277
  - spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb
274
- - spec/lib/tcell_agent/appsensor/meta_data_spec.rb
275
278
  - spec/lib/tcell_agent/cmdi_spec.rb
276
279
  - spec/lib/tcell_agent/config/unknown_options_spec.rb
277
280
  - spec/lib/tcell_agent/configuration_spec.rb
@@ -286,6 +289,9 @@ test_files:
286
289
  - spec/lib/tcell_agent/policies/login_policy_spec.rb
287
290
  - spec/lib/tcell_agent/policies/patches_policy_spec.rb
288
291
  - spec/lib/tcell_agent/rails/better_ip_spec.rb
292
+ - spec/lib/tcell_agent/rails/csrf_exception_spec.rb
293
+ - spec/lib/tcell_agent/rails/dlp_spec.rb
294
+ - spec/lib/tcell_agent/rails/js_agent_insert_spec.rb
289
295
  - spec/lib/tcell_agent/rails/logger_spec.rb
290
296
  - spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb
291
297
  - spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb
@@ -303,6 +309,8 @@ test_files:
303
309
  - spec/lib/tcell_agent/sensor_events/dlp_spec.rb
304
310
  - spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb
305
311
  - spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb
312
+ - spec/lib/tcell_agent/settings_reporter_spec.rb
313
+ - spec/lib/tcell_agent/tcell_context_spec.rb
306
314
  - spec/lib/tcell_agent/utils/bounded_queue_spec.rb
307
315
  - spec/lib/tcell_agent/utils/params_spec.rb
308
316
  - spec/lib/tcell_agent/utils/passwords_spec.rb
@@ -1,132 +0,0 @@
1
- require 'tcell_agent/logger'
2
- require 'tcell_agent/sensor_events/sensor'
3
- require 'tcell_agent/utils/params'
4
-
5
- module TCellAgent
6
- module AppSensor
7
-
8
- class MetaData < TCellAgent::SensorEvents::TCellSensorEvent
9
-
10
- attr_accessor :get_dict, :post_dict, :body_dict, :cookie_dict, :path_parameters,
11
- :remote_address, :method, :route_id, :session_id, :user_id, :transaction_id, :location
12
-
13
- attr_reader :headers_dict
14
-
15
- def initialize(method,
16
- remote_address,
17
- route_id,
18
- session_id,
19
- user_id,
20
- transaction_id,
21
- location)
22
- @send = false
23
-
24
- @method = method
25
- @remote_address = remote_address
26
- @route_id = route_id
27
- @session_id = session_id
28
- @user_id = user_id
29
- @transaction_id = transaction_id
30
- @location = location
31
-
32
- @body_dict = {}
33
- @get_dict = {}
34
- @post_dict = {}
35
- @cookie_dict = {}
36
- @path_parameters = {}
37
- @headers_dict = {}
38
- end
39
-
40
- def get_dict=(value)
41
- @flattened_get_dict = nil
42
- @get_dict = value
43
- end
44
-
45
- def body_dict=(value)
46
- @flattened_body_dict = nil
47
- @body_dict = value
48
- end
49
-
50
- def post_dict=(value)
51
- @flattened_post_dict = nil
52
- @post_dict = value
53
- end
54
-
55
- def cookie_dict=(value)
56
- @flattened_cookie_dict = nil
57
- @cookie_dict = value
58
- end
59
-
60
- def path_parameters=(value)
61
- @flattened_path_parameters = nil
62
- @path_parameters = value
63
- end
64
-
65
- def flattened_path_parameters
66
- @flattened_path_parameters ||= TCellAgent::Utils::Params.flatten(@path_parameters)
67
-
68
- @flattened_path_parameters
69
- end
70
-
71
- def flattened_get_dict
72
- @flattened_get_dict ||= TCellAgent::Utils::Params.flatten(@get_dict)
73
-
74
- @flattened_get_dict
75
- end
76
-
77
- def flattened_post_dict
78
- @flattened_post_dict ||= TCellAgent::Utils::Params.flatten(@post_dict)
79
-
80
- @flattened_post_dict
81
- end
82
-
83
- def flattened_body_dict
84
- @body_dict
85
- end
86
-
87
- def flattened_cookie_dict
88
- @flattened_cookie_dict ||= TCellAgent::Utils::Params.flatten(@cookie_dict)
89
-
90
- @flattened_cookie_dict
91
- end
92
-
93
- def flattened_headers_dict
94
- @flattened_headers_dict ||= TCellAgent::Utils::Params.flatten(@headers_dict)
95
-
96
- @flattened_headers_dict
97
- end
98
-
99
- def set_headers_dict(env)
100
- @flattened_headers_dict = nil
101
- @headers_dict = env.select { |k,v|
102
- header_downcased = k.downcase
103
- (header_downcased != "http_cookie" && header_downcased.start_with?('http_')) ||
104
- ["content_type", "content_length"].include?(header_downcased)
105
- }.inject({}) { |memo, (k,v)|
106
- memo[k.downcase.sub(/^http_/, '').tr('_', '-')] = v
107
- memo
108
- }
109
- end
110
-
111
- def set_body_dict(request_content_bytes_len, request_content_type, request_body)
112
- if request_content_bytes_len > 2000000
113
- @body_dict = {}
114
-
115
- else
116
- if request_content_type =~ %r{application/json}i && request_body
117
- begin
118
- # don't enqueue parameter values of unknown type to avoid any serialization issues
119
- @body_dict = TCellAgent::Utils::Params.flatten(JSON.parse(request_body))
120
- rescue JSON::ParserError
121
- TCellAgent.logger.debug("JSON body parameter parsing failed")
122
- @body_dict = {}
123
- end
124
- else
125
- @body_dict = {}
126
- end
127
- end
128
- end
129
- end
130
-
131
- end
132
- end