tcell_agent 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tcell_agent +10 -2
- data/lib/tcell_agent.rb +3 -3
- data/lib/tcell_agent/agent.rb +42 -52
- data/lib/tcell_agent/agent/event_processor.rb +129 -162
- data/lib/tcell_agent/agent/fork_pipe_manager.rb +57 -62
- data/lib/tcell_agent/agent/policy_manager.rb +83 -104
- data/lib/tcell_agent/agent/policy_types.rb +24 -29
- data/lib/tcell_agent/agent/route_manager.rb +36 -46
- data/lib/tcell_agent/agent/static_agent.rb +19 -21
- data/lib/tcell_agent/api.rb +23 -28
- data/lib/tcell_agent/appsensor/injections_reporter.rb +7 -11
- data/lib/tcell_agent/authlogic.rb +7 -7
- data/lib/tcell_agent/cmdi.rb +22 -23
- data/lib/tcell_agent/config/unknown_options.rb +71 -69
- data/lib/tcell_agent/configuration.rb +187 -191
- data/lib/tcell_agent/devise.rb +13 -15
- data/lib/tcell_agent/hooks/login_fraud.rb +1 -1
- data/lib/tcell_agent/instrumentation.rb +120 -124
- data/lib/tcell_agent/logger.rb +29 -45
- data/lib/tcell_agent/patches.rb +5 -5
- data/lib/tcell_agent/policies/dataloss_policy.rb +263 -288
- data/lib/tcell_agent/policies/http_redirect_policy.rb +25 -37
- data/lib/tcell_agent/policies/http_tx_policy.rb +48 -52
- data/lib/tcell_agent/policies/login_fraud_policy.rb +15 -20
- data/lib/tcell_agent/policies/policy.rb +0 -2
- data/lib/tcell_agent/policies/rust_policies.rb +24 -29
- data/lib/tcell_agent/rails.rb +2 -3
- data/lib/tcell_agent/rails/auth/authlogic.rb +2 -2
- data/lib/tcell_agent/rails/auth/devise.rb +2 -2
- data/lib/tcell_agent/rails/auth/doorkeeper.rb +2 -2
- data/lib/tcell_agent/rails/better_ip.rb +12 -16
- data/lib/tcell_agent/rails/csrf_exception.rb +4 -7
- data/lib/tcell_agent/rails/dlp.rb +208 -107
- data/lib/tcell_agent/rails/dlp/process_request.rb +37 -47
- data/lib/tcell_agent/rails/dlp_handler.rb +9 -11
- data/lib/tcell_agent/rails/js_agent_insert.rb +11 -14
- data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +8 -7
- data/lib/tcell_agent/rails/middleware/context_middleware.rb +4 -5
- data/lib/tcell_agent/rails/middleware/global_middleware.rb +5 -8
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +24 -27
- data/lib/tcell_agent/rails/on_start.rb +5 -5
- data/lib/tcell_agent/rails/responses.rb +7 -9
- data/lib/tcell_agent/rails/routes.rb +62 -81
- data/lib/tcell_agent/rails/routes/grape.rb +25 -30
- data/lib/tcell_agent/rails/routes/route_id.rb +9 -14
- data/lib/tcell_agent/rails/settings_reporter.rb +44 -33
- data/lib/tcell_agent/rails/tcell_body_proxy.rb +15 -18
- data/lib/tcell_agent/routes/table.rb +31 -33
- data/lib/tcell_agent/rust/{libtcellagent-1.3.0.dylib → libtcellagent-1.3.1.dylib} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-1.3.0.so → libtcellagent-1.3.1.so} +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-alpine-1.3.0.so → libtcellagent-alpine-1.3.1.so} +0 -0
- data/lib/tcell_agent/rust/models.rb +32 -37
- data/lib/tcell_agent/rust/tcellagent-1.3.1.dll +0 -0
- data/lib/tcell_agent/rust/whisperer.rb +101 -104
- data/lib/tcell_agent/sensor_events/app_config.rb +7 -7
- data/lib/tcell_agent/sensor_events/appsensor_event.rb +26 -27
- data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +20 -88
- data/lib/tcell_agent/sensor_events/command_injection.rb +52 -80
- data/lib/tcell_agent/sensor_events/discovery.rb +27 -27
- data/lib/tcell_agent/sensor_events/dlp.rb +50 -56
- data/lib/tcell_agent/sensor_events/honeytokens.rb +9 -9
- data/lib/tcell_agent/sensor_events/metrics.rb +20 -21
- data/lib/tcell_agent/sensor_events/patches.rb +10 -12
- data/lib/tcell_agent/sensor_events/sensor.rb +32 -36
- data/lib/tcell_agent/sensor_events/server_agent.rb +130 -127
- data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +60 -80
- data/lib/tcell_agent/sensor_events/util/utils.rb +3 -5
- data/lib/tcell_agent/servers/passenger.rb +5 -9
- data/lib/tcell_agent/servers/puma.rb +18 -27
- data/lib/tcell_agent/servers/rails_server.rb +5 -9
- data/lib/tcell_agent/servers/thin.rb +2 -4
- data/lib/tcell_agent/servers/unicorn.rb +18 -27
- data/lib/tcell_agent/servers/webrick.rb +2 -4
- data/lib/tcell_agent/settings_reporter.rb +126 -0
- data/lib/tcell_agent/sinatra.rb +24 -26
- data/lib/tcell_agent/start_background_thread.rb +21 -142
- data/lib/tcell_agent/system_info.rb +4 -3
- data/lib/tcell_agent/tcell_context.rb +150 -0
- data/lib/tcell_agent/userinfo.rb +3 -3
- data/lib/tcell_agent/utils/io.rb +19 -24
- data/lib/tcell_agent/utils/params.rb +9 -15
- data/lib/tcell_agent/utils/queue_with_timeout.rb +26 -32
- data/lib/tcell_agent/utils/strings.rb +4 -6
- data/lib/tcell_agent/version.rb +1 -1
- data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +5 -5
- data/spec/lib/tcell_agent/agent/static_agent_spec.rb +7 -7
- data/spec/lib/tcell_agent/cmdi_spec.rb +21 -21
- data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +29 -24
- data/spec/lib/tcell_agent/instrumentation_spec.rb +4 -4
- data/spec/lib/tcell_agent/patches_spec.rb +8 -8
- data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +23 -23
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +2 -2
- data/spec/lib/tcell_agent/rails/csrf_exception_spec.rb +69 -0
- data/spec/lib/tcell_agent/rails/dlp_spec.rb +1039 -0
- data/spec/lib/tcell_agent/rails/js_agent_insert_spec.rb +271 -0
- data/spec/lib/tcell_agent/rails/logger_spec.rb +5 -5
- data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +3 -3
- data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +4 -4
- data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +5 -5
- data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +1 -1
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +11 -8
- data/spec/lib/tcell_agent/rails/responses_spec.rb +2 -2
- data/spec/lib/tcell_agent/rails/routes/grape_spec.rb +2 -2
- data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +1 -1
- data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +4 -4
- data/spec/lib/tcell_agent/rust/models_spec.rb +83 -75
- data/spec/lib/tcell_agent/rust/whisperer_spec.rb +14 -14
- data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +19 -70
- data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +1 -1
- data/spec/lib/tcell_agent/settings_reporter_spec.rb +162 -0
- data/spec/lib/tcell_agent/tcell_context_spec.rb +154 -0
- data/spec/spec_helper.rb +5 -0
- metadata +18 -10
- data/lib/tcell_agent/appsensor/meta_data.rb +0 -132
- data/lib/tcell_agent/patches/meta_data.rb +0 -59
- data/lib/tcell_agent/rust/tcellagent-1.3.0.dll +0 -0
- data/spec/lib/tcell_agent/appsensor/meta_data_spec.rb +0 -71
@@ -6,7 +6,6 @@ require 'tcell_agent/logger'
|
|
6
6
|
|
7
7
|
module TCellAgent
|
8
8
|
module Policies
|
9
|
-
|
10
9
|
class HttpRedirectPolicy < Policy
|
11
10
|
attr_accessor :policy_id, :enabled, :whitelist, :block, :data_scheme_allowed
|
12
11
|
|
@@ -19,7 +18,7 @@ module TCellAgent
|
|
19
18
|
end
|
20
19
|
|
21
20
|
def suspicious_redirect?(host, current_host)
|
22
|
-
if
|
21
|
+
if !host || host == '' || host == current_host
|
23
22
|
# local redirect
|
24
23
|
return false
|
25
24
|
end
|
@@ -33,22 +32,18 @@ module TCellAgent
|
|
33
32
|
true
|
34
33
|
end
|
35
34
|
|
36
|
-
def enforce(target_uri, request_uri, current_path, method, route_id, status_code, remote_addr, hmac_session_id=nil)
|
35
|
+
def enforce(target_uri, request_uri, current_path, method, route_id, status_code, remote_addr, hmac_session_id = nil)
|
37
36
|
return nil unless @enabled
|
38
37
|
|
39
38
|
current_host = URI.parse(request_uri).host
|
40
|
-
if target_uri.downcase.start_with?(
|
41
|
-
if @data_scheme_allowed
|
42
|
-
return nil
|
43
|
-
end
|
39
|
+
if target_uri.downcase.start_with?('data:')
|
40
|
+
return nil if @data_scheme_allowed
|
44
41
|
|
45
|
-
target_host = target_uri.split(
|
42
|
+
target_host = target_uri.split(',')[0]
|
46
43
|
|
47
44
|
else
|
48
45
|
target_host = URI.parse(target_uri).host
|
49
|
-
|
50
|
-
return nil
|
51
|
-
end
|
46
|
+
return nil unless suspicious_redirect?(target_host, current_host)
|
52
47
|
end
|
53
48
|
|
54
49
|
begin
|
@@ -61,48 +56,41 @@ module TCellAgent
|
|
61
56
|
status_code,
|
62
57
|
remote_addr,
|
63
58
|
hmac_session_id,
|
64
|
-
nil
|
59
|
+
nil
|
60
|
+
)
|
65
61
|
|
66
62
|
TCellAgent.send_event(event)
|
67
63
|
rescue StandardError => ie
|
68
64
|
TCellAgent.logger.error("uncaught exception while creating redirect event: #{ie.message}")
|
69
65
|
end
|
70
66
|
|
71
|
-
if @block
|
72
|
-
|
73
|
-
|
74
|
-
return nil
|
75
|
-
end
|
67
|
+
return '/' if @block
|
68
|
+
|
69
|
+
nil
|
76
70
|
end
|
77
71
|
|
78
72
|
def self.from_json(policy_json)
|
79
|
-
|
80
|
-
return nil
|
81
|
-
end
|
73
|
+
return nil unless policy_json
|
82
74
|
|
83
75
|
http_redirect_policy = HttpRedirectPolicy.new
|
84
|
-
|
85
|
-
|
86
|
-
else
|
87
|
-
raise "Policy ID missing"
|
88
|
-
end
|
76
|
+
http_redirect_policy.policy_id = policy_json['policy_id']
|
77
|
+
raise 'Policy ID missing' unless http_redirect_policy.policy_id
|
89
78
|
|
90
|
-
|
91
|
-
|
92
|
-
http_redirect_policy.enabled = policy_data_json.fetch("enabled", false)
|
93
|
-
http_redirect_policy.block = policy_data_json.fetch("block", false)
|
94
|
-
http_redirect_policy.data_scheme_allowed = policy_data_json.fetch("data_scheme_allowed", false)
|
79
|
+
policy_data_json = policy_json['data']
|
80
|
+
return http_redirect_policy unless policy_data_json
|
95
81
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
82
|
+
http_redirect_policy.enabled = policy_data_json.fetch('enabled', false)
|
83
|
+
http_redirect_policy.block = policy_data_json.fetch('block', false)
|
84
|
+
http_redirect_policy.data_scheme_allowed = policy_data_json.fetch('data_scheme_allowed', false)
|
85
|
+
|
86
|
+
http_redirect_policy.whitelist = []
|
87
|
+
policy_data_json.fetch('whitelist', []).each do |regex_pattern|
|
88
|
+
escaped = Regexp.escape(regex_pattern).gsub('\*', '.*?')
|
89
|
+
http_redirect_policy.whitelist.push(Regexp.new("^#{escaped}$", Regexp::IGNORECASE))
|
101
90
|
end
|
102
91
|
|
103
|
-
|
92
|
+
http_redirect_policy
|
104
93
|
end
|
105
94
|
end
|
106
|
-
|
107
95
|
end
|
108
96
|
end
|
@@ -1,64 +1,60 @@
|
|
1
|
-
#{}"http-tx": {
|
1
|
+
# {}"http-tx": {
|
2
2
|
# "policy_id":"afh023",
|
3
3
|
# "types": {
|
4
4
|
# "firehose": { enabled: true },
|
5
|
-
#{}"auth_framework_only": {enabled: true},
|
6
|
-
#{}"{}structure": {enabled: true },
|
7
|
-
#{}"fingerprint": {enabled: true }
|
8
|
-
#}
|
9
|
-
#},
|
5
|
+
# {}"auth_framework_only": {enabled: true},
|
6
|
+
# {}"{}structure": {enabled: true },
|
7
|
+
# {}"fingerprint": {enabled: true }
|
8
|
+
# }
|
9
|
+
# },
|
10
10
|
|
11
11
|
require 'tcell_agent/policies/policy'
|
12
12
|
|
13
|
-
|
14
13
|
module TCellAgent
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
module Policies
|
15
|
+
class HttpTxPolicy < Policy
|
16
|
+
attr_accessor :policy_id, :firehose, :auth_framework, :profile, :fingerprint
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@firehose = { 'enabled' => false, 'lite' => false }
|
20
|
+
@auth_framework = { 'enabled' => false, 'lite' => false }
|
21
|
+
@profile = { 'enabled' => false }
|
22
|
+
@fingerprint = { 'enabled' => false, 'hmacUserAgent' => false, 'hmacUserId' => false, 'sampling' => nil }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.from_json(policy_json)
|
26
|
+
return nil unless policy_json
|
27
|
+
http_tx_policy = HttpTxPolicy.new
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
http_tx_policy.policy_id = policy_json['policy_id']
|
30
|
+
raise 'Policy ID missing' unless http_tx_policy.policy_id
|
31
|
+
|
32
|
+
types = policy_json['types']
|
33
|
+
return http_tx_policy unless types
|
34
|
+
|
35
|
+
if types.key?('firehose')
|
36
|
+
http_tx_policy.firehose['enabled'] = types['firehose'].fetch('enabled', false)
|
37
|
+
http_tx_policy.firehose['lite'] = types['firehose'].fetch('lite', false)
|
38
|
+
end
|
29
39
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
http_tx_policy = HttpTxPolicy.new
|
35
|
-
if policy_json.has_key?("policy_id")
|
36
|
-
http_tx_policy.policy_id = policy_json["policy_id"]
|
37
|
-
else
|
38
|
-
raise "Policy ID missing"
|
39
|
-
end
|
40
|
-
if policy_json.has_key?("types")
|
41
|
-
types = policy_json["types"]
|
42
|
-
if types.has_key?("firehose")
|
43
|
-
http_tx_policy.firehose["enabled"] = types["firehose"].fetch("enabled", false)
|
44
|
-
http_tx_policy.firehose["lite"] = types["firehose"].fetch("lite", false)
|
45
|
-
end
|
46
|
-
if types.has_key?("auth_framework")
|
47
|
-
http_tx_policy.auth_framework["enabled"] = types["auth_framework"].fetch("enabled", false)
|
48
|
-
http_tx_policy.auth_framework["lite"] = types["auth_framework"].fetch("lite", false)
|
49
|
-
end
|
50
|
-
if types.has_key?("profile")
|
51
|
-
http_tx_policy.profile["enabled"] = types["profile"].fetch("enabled", false)
|
52
|
-
end
|
53
|
-
if types.has_key?("fingerprint")
|
54
|
-
http_tx_policy.fingerprint["enabled"] = types["fingerprint"].fetch("enabled", false)
|
55
|
-
http_tx_policy.fingerprint["hmacUserAgent"] = types["fingerprint"].fetch("hmacUserAgent", false)
|
56
|
-
http_tx_policy.fingerprint["hmacUserId"] = types["fingerprint"].fetch("hmacUserId", false)
|
57
|
-
http_tx_policy.fingerprint["sampling"] = types["fingerprint"].fetch("sampling", 0)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
return http_tx_policy
|
61
|
-
end
|
40
|
+
if types.key?('auth_framework')
|
41
|
+
http_tx_policy.auth_framework['enabled'] = types['auth_framework'].fetch('enabled', false)
|
42
|
+
http_tx_policy.auth_framework['lite'] = types['auth_framework'].fetch('lite', false)
|
62
43
|
end
|
44
|
+
|
45
|
+
if types.key?('profile')
|
46
|
+
http_tx_policy.profile['enabled'] = types['profile'].fetch('enabled', false)
|
47
|
+
end
|
48
|
+
|
49
|
+
if types.key?('fingerprint')
|
50
|
+
http_tx_policy.fingerprint['enabled'] = types['fingerprint'].fetch('enabled', false)
|
51
|
+
http_tx_policy.fingerprint['hmacUserAgent'] = types['fingerprint'].fetch('hmacUserAgent', false)
|
52
|
+
http_tx_policy.fingerprint['hmacUserId'] = types['fingerprint'].fetch('hmacUserId', false)
|
53
|
+
http_tx_policy.fingerprint['sampling'] = types['fingerprint'].fetch('sampling', 0)
|
54
|
+
end
|
55
|
+
|
56
|
+
http_tx_policy
|
57
|
+
end
|
63
58
|
end
|
59
|
+
end
|
64
60
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'tcell_agent/policies/policy'
|
2
2
|
|
3
|
-
|
4
3
|
module TCellAgent
|
5
4
|
module Policies
|
6
5
|
class LoginFraudPolicy < Policy
|
@@ -11,8 +10,9 @@ module TCellAgent
|
|
11
10
|
attr_accessor :session_hijacking_metrics
|
12
11
|
|
13
12
|
def initialize
|
14
|
-
|
13
|
+
init_options
|
15
14
|
end
|
15
|
+
|
16
16
|
def init_options
|
17
17
|
@policy_id = nil
|
18
18
|
@login_success_enabled = false
|
@@ -25,25 +25,20 @@ module TCellAgent
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.from_json(policy_json)
|
28
|
-
|
29
|
-
return nil
|
30
|
-
end
|
28
|
+
return nil unless policy_json
|
31
29
|
sensor_policy = LoginFraudPolicy.new
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
46
|
-
return sensor_policy
|
30
|
+
|
31
|
+
sensor_policy.policy_id = policy_json['policy_id']
|
32
|
+
raise 'Policy ID missing' unless sensor_policy.policy_id
|
33
|
+
|
34
|
+
options_json = (policy_json['data'] || {})['options']
|
35
|
+
return sensor_policy unless options_json
|
36
|
+
|
37
|
+
sensor_policy.login_failed_enabled = options_json.fetch('login_failed_enabled', false)
|
38
|
+
sensor_policy.login_success_enabled = options_json.fetch('login_success_enabled', false)
|
39
|
+
sensor_policy.session_hijacking_metrics = options_json.fetch('session_hijacking_enabled', false)
|
40
|
+
|
41
|
+
sensor_policy
|
47
42
|
end
|
48
43
|
end
|
49
44
|
end
|
@@ -6,15 +6,12 @@ require 'tcell_agent/rust/whisperer'
|
|
6
6
|
require 'tcell_agent/sensor_events/command_injection'
|
7
7
|
require 'tcell_agent/sensor_events/patches'
|
8
8
|
|
9
|
-
|
10
9
|
module TCellAgent
|
11
10
|
module Policies
|
12
|
-
|
13
11
|
class RustPolicies < Policy
|
14
|
-
|
15
12
|
attr_reader :appfirewall_enabled, :patches_enabled, :cmdi_enabled
|
16
13
|
|
17
|
-
def initialize
|
14
|
+
def initialize
|
18
15
|
@appfirewall_enabled = false
|
19
16
|
@patches_enabled = false
|
20
17
|
@cmdi_enabled = false
|
@@ -22,11 +19,11 @@ module TCellAgent
|
|
22
19
|
@jsagent_enabled = false
|
23
20
|
@agent_ptr = nil
|
24
21
|
|
25
|
-
whisper = TCellAgent::Rust::Whisperer.create_agent
|
26
|
-
if whisper[
|
27
|
-
TCellAgent.logger.error("Error initializing policies: #{whisper[
|
22
|
+
whisper = TCellAgent::Rust::Whisperer.create_agent
|
23
|
+
if whisper['error']
|
24
|
+
TCellAgent.logger.error("Error initializing policies: #{whisper['error']}")
|
28
25
|
else
|
29
|
-
@agent_ptr = whisper[
|
26
|
+
@agent_ptr = whisper['agent_ptr']
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
@@ -34,17 +31,17 @@ module TCellAgent
|
|
34
31
|
return if @agent_ptr.nil? || policies_json.nil? || policies_json.empty?
|
35
32
|
|
36
33
|
whisper = TCellAgent::Rust::Whisperer.update_policies(@agent_ptr, policies_json)
|
37
|
-
if whisper[
|
38
|
-
whisper[
|
34
|
+
if whisper['errors']
|
35
|
+
whisper['errors'].each do |error|
|
39
36
|
TCellAgent.logger.error("Error updating policies: #{error}")
|
40
37
|
end
|
41
38
|
else
|
42
|
-
enablements = whisper[
|
43
|
-
@appfirewall_enabled =
|
44
|
-
@patches_enabled =
|
45
|
-
@cmdi_enabled =
|
46
|
-
@headers_enabled =
|
47
|
-
@jsagent_enabled =
|
39
|
+
enablements = whisper['enablements']
|
40
|
+
@appfirewall_enabled = enablements['appfirewall']
|
41
|
+
@patches_enabled = enablements['patches']
|
42
|
+
@cmdi_enabled = enablements['cmdi']
|
43
|
+
@headers_enabled = enablements['headers']
|
44
|
+
@jsagent_enabled = enablements['jsagentinjection']
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
@@ -52,11 +49,11 @@ module TCellAgent
|
|
52
49
|
return false unless @agent_ptr && @patches_enabled
|
53
50
|
|
54
51
|
whisper = TCellAgent::Rust::Whisperer.apply_patches(@agent_ptr, appsensor_meta)
|
55
|
-
if whisper[
|
56
|
-
TCellAgent.logger.error("Error processing patches: #{whisper[
|
52
|
+
if whisper['error']
|
53
|
+
TCellAgent.logger.error("Error processing patches: #{whisper['error']}")
|
57
54
|
else
|
58
|
-
response = whisper[
|
59
|
-
if response && response[
|
55
|
+
response = whisper['apply_response']
|
56
|
+
if response && response['status'] == 'Blocked'
|
60
57
|
patches_event = TCellAgent::SensorEvents::PatchesEvent.new(response, appsensor_meta)
|
61
58
|
TCellAgent.send_event(patches_event)
|
62
59
|
return true
|
@@ -69,9 +66,9 @@ module TCellAgent
|
|
69
66
|
def check_appfirewall_injections(appsensor_meta)
|
70
67
|
return unless @agent_ptr && @appfirewall_enabled
|
71
68
|
|
72
|
-
TCellAgent::Instrumentation.safe_block(
|
69
|
+
TCellAgent::Instrumentation.safe_block('AppSensor inspection') do
|
73
70
|
whisper = TCellAgent::Rust::Whisperer.apply_appfirewall(@agent_ptr, appsensor_meta)
|
74
|
-
TCellAgent::AppSensor::InjectionsReporter.report_and_log(whisper[
|
71
|
+
TCellAgent::AppSensor::InjectionsReporter.report_and_log(whisper['apply_response'])
|
75
72
|
end
|
76
73
|
end
|
77
74
|
|
@@ -82,15 +79,13 @@ module TCellAgent
|
|
82
79
|
whisper = TCellAgent::Rust::Whisperer.apply_cmdi(
|
83
80
|
@agent_ptr, command, tcell_context
|
84
81
|
)
|
85
|
-
apply_response = whisper.fetch(
|
82
|
+
apply_response = whisper.fetch('apply_response', {})
|
86
83
|
cmdi_event =
|
87
84
|
TCellAgent::SensorEvents::CommandInjectionEvent.build_from_native_lib_response_and_tcell_context(apply_response,
|
88
85
|
tcell_context)
|
89
|
-
if cmdi_event
|
90
|
-
TCellAgent.send_event(cmdi_event)
|
91
|
-
end
|
86
|
+
TCellAgent.send_event(cmdi_event) if cmdi_event
|
92
87
|
|
93
|
-
apply_response.fetch(
|
88
|
+
apply_response.fetch('blocked', false)
|
94
89
|
end
|
95
90
|
|
96
91
|
def get_headers(tcell_context)
|
@@ -99,7 +94,7 @@ module TCellAgent
|
|
99
94
|
whisper = TCellAgent::Rust::Whisperer.get_headers(
|
100
95
|
@agent_ptr, tcell_context
|
101
96
|
)
|
102
|
-
|
97
|
+
whisper['headers'] || []
|
103
98
|
end
|
104
99
|
|
105
100
|
def get_js_agent_script_tag(tcell_context)
|
@@ -108,7 +103,7 @@ module TCellAgent
|
|
108
103
|
whisper = TCellAgent::Rust::Whisperer.get_js_agent_script_tag(
|
109
104
|
@agent_ptr, tcell_context
|
110
105
|
)
|
111
|
-
|
106
|
+
whisper['script_tag']
|
112
107
|
end
|
113
108
|
end
|
114
109
|
end
|
data/lib/tcell_agent/rails.rb
CHANGED
@@ -17,19 +17,18 @@ require 'tcell_agent/rails/settings_reporter'
|
|
17
17
|
require 'tcell_agent/rails/dlp'
|
18
18
|
require 'tcell_agent/rails/csrf_exception'
|
19
19
|
|
20
|
-
|
21
20
|
require 'tcell_agent/userinfo'
|
22
21
|
require 'cgi'
|
23
22
|
require 'thread'
|
24
23
|
|
25
24
|
module TCellAgent
|
26
25
|
class Railtie < Rails::Railtie
|
27
|
-
initializer
|
26
|
+
initializer 'tcell_agent.insert_middleware' do |app|
|
28
27
|
app.config.to_prepare do
|
29
28
|
require 'tcell_agent/devise' if defined?(Devise)
|
30
29
|
require 'tcell_agent/rails/auth/devise' if defined?(Devise)
|
31
30
|
require 'tcell_agent/authlogic' if defined?(Authlogic)
|
32
|
-
require 'tcell_agent/rails/auth/authlogic'
|
31
|
+
require 'tcell_agent/rails/auth/authlogic' if defined?(Authlogic)
|
33
32
|
require 'tcell_agent/rails/auth/doorkeeper'
|
34
33
|
end
|
35
34
|
app.config.middleware.insert_before(0, TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware)
|
@@ -23,11 +23,11 @@ if TCellAgent.configuration.should_instrument_authlogic?
|
|
23
23
|
user_logged_in_after = !user.nil?
|
24
24
|
|
25
25
|
TCellAgent::Instrumentation.safe_block('Authlogic login info') do
|
26
|
-
login_fraud_policy = TCellAgent.policy(TCellAgent::PolicyTypes::
|
26
|
+
login_fraud_policy = TCellAgent.policy(TCellAgent::PolicyTypes::LOGINFRAUD)
|
27
27
|
if login_fraud_policy && login_fraud_policy.enabled
|
28
28
|
user_id = nil
|
29
29
|
TCellAgent::Instrumentation.safe_block('getting userid for login form') do
|
30
|
-
user_id =
|
30
|
+
user_id = send(self.class.login_field.to_sym)
|
31
31
|
end
|
32
32
|
|
33
33
|
password = nil
|
@@ -22,7 +22,7 @@ if TCellAgent.configuration.should_instrument_devise? && defined?(Devise)
|
|
22
22
|
password = tcell_data.password
|
23
23
|
password ||= _get_tcell_password
|
24
24
|
|
25
|
-
login_fraud_policy = TCellAgent.policy(TCellAgent::PolicyTypes::
|
25
|
+
login_fraud_policy = TCellAgent.policy(TCellAgent::PolicyTypes::LOGINFRAUD)
|
26
26
|
if login_fraud_policy && login_fraud_policy.login_failed_enabled
|
27
27
|
TCellAgent.send_event(
|
28
28
|
TCellAgent::SensorEvents::LoginFailure.new(
|
@@ -105,7 +105,7 @@ if TCellAgent.configuration.should_instrument_devise? && defined?(Devise)
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
login_fraud_policy = TCellAgent.policy(TCellAgent::PolicyTypes::
|
108
|
+
login_fraud_policy = TCellAgent.policy(TCellAgent::PolicyTypes::LOGINFRAUD)
|
109
109
|
if login_fraud_policy && login_fraud_policy.login_success_enabled
|
110
110
|
tcell_data = request.env[TCellAgent::Instrumentation::TCELL_ID]
|
111
111
|
if tcell_data
|