contrast-agent 3.13.2 → 3.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/contrast_service +1 -7
- data/ext/cs__assess_active_record_named/cs__active_record_named.c +8 -7
- data/ext/cs__assess_array/cs__assess_array.c +6 -5
- data/ext/cs__assess_basic_object/cs__assess_basic_object.c +5 -5
- data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +2 -1
- data/ext/cs__assess_hash/cs__assess_hash.c +18 -17
- data/ext/cs__assess_hash/cs__assess_hash.h +2 -1
- data/ext/cs__assess_kernel/cs__assess_kernel.c +7 -8
- data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +4 -5
- data/ext/cs__assess_module/cs__assess_module.c +6 -6
- data/ext/cs__assess_regexp/cs__assess_regexp.c +4 -4
- data/ext/cs__assess_string/cs__assess_string.c +20 -4
- data/ext/cs__assess_string/cs__assess_string.h +4 -1
- data/ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c +4 -2
- data/ext/cs__assess_yield_track/cs__assess_yield_track.c +2 -2
- data/ext/cs__common/cs__common.c +44 -37
- data/ext/cs__common/cs__common.h +15 -20
- data/ext/cs__contrast_patch/cs__contrast_patch.c +27 -25
- data/ext/cs__contrast_patch/cs__contrast_patch.h +5 -7
- data/ext/cs__protect_kernel/cs__protect_kernel.c +11 -12
- data/ext/cs__protect_kernel/cs__protect_kernel.h +2 -2
- data/lib/contrast-agent.rb +1 -1
- data/lib/contrast.rb +13 -23
- data/lib/contrast/agent.rb +39 -39
- data/lib/contrast/agent/assess.rb +11 -12
- data/lib/contrast/agent/assess/contrast_event.rb +11 -9
- data/lib/contrast/agent/assess/events/event_factory.rb +2 -2
- data/lib/contrast/agent/assess/events/source_event.rb +2 -2
- data/lib/contrast/agent/assess/finalizers/finalize.rb +21 -0
- data/lib/contrast/agent/assess/finalizers/freeze.rb +13 -0
- data/lib/contrast/agent/assess/finalizers/hash.rb +53 -0
- data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +1 -1
- data/lib/contrast/agent/assess/policy/patcher.rb +5 -5
- data/lib/contrast/agent/assess/policy/policy.rb +9 -9
- data/lib/contrast/agent/assess/policy/policy_node.rb +2 -2
- data/lib/contrast/agent/assess/policy/policy_scanner.rb +3 -3
- data/lib/contrast/agent/assess/policy/preshift.rb +15 -5
- data/lib/contrast/agent/assess/policy/propagation_method.rb +25 -22
- data/lib/contrast/agent/assess/policy/propagation_node.rb +2 -2
- data/lib/contrast/agent/assess/policy/propagator.rb +18 -18
- data/lib/contrast/agent/assess/policy/propagator/custom.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/database_write.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/match_data.rb +3 -2
- data/lib/contrast/agent/assess/policy/propagator/prepend.rb +5 -0
- data/lib/contrast/agent/assess/policy/propagator/split.rb +4 -4
- data/lib/contrast/agent/assess/policy/propagator/substitution.rb +5 -4
- data/lib/contrast/agent/assess/policy/rewriter_patch.rb +5 -5
- data/lib/contrast/agent/assess/policy/source_method.rb +5 -14
- data/lib/contrast/agent/assess/policy/source_validation/cross_site_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/source_validation/source_validation.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger/xpath.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +5 -5
- data/lib/contrast/agent/assess/policy/trigger_node.rb +3 -3
- data/lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb +2 -2
- data/lib/contrast/agent/assess/properties.rb +13 -5
- data/lib/contrast/agent/assess/property/evented.rb +2 -2
- data/lib/contrast/agent/assess/property/tagged.rb +4 -4
- data/lib/contrast/agent/assess/rule.rb +2 -2
- data/lib/contrast/agent/assess/rule/base.rb +3 -4
- data/lib/contrast/agent/assess/rule/provider.rb +3 -3
- data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +2 -2
- data/lib/contrast/agent/at_exit_hook.rb +1 -1
- data/lib/contrast/agent/class_reopener.rb +7 -6
- data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +1 -1
- data/lib/contrast/agent/deadzone/policy/policy.rb +2 -2
- data/lib/contrast/agent/disable_reaction.rb +1 -1
- data/lib/contrast/agent/exclusion_matcher.rb +1 -1
- data/lib/contrast/agent/inventory/policy/datastores.rb +2 -2
- data/lib/contrast/agent/inventory/policy/policy.rb +3 -3
- data/lib/contrast/agent/inventory/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/middleware.rb +33 -32
- data/lib/contrast/agent/patching/policy/after_load_patch.rb +4 -4
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +6 -5
- data/lib/contrast/agent/patching/policy/module_policy.rb +1 -1
- data/lib/contrast/agent/patching/policy/patch.rb +15 -15
- data/lib/contrast/agent/patching/policy/patcher.rb +30 -22
- data/lib/contrast/agent/patching/policy/policy.rb +6 -6
- data/lib/contrast/agent/patching/policy/policy_node.rb +1 -1
- data/lib/contrast/agent/patching/policy/trigger_node.rb +2 -2
- data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +3 -3
- data/lib/contrast/agent/protect/policy/applies_deserialization_rule.rb +2 -2
- data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +2 -2
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +3 -3
- data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +2 -2
- data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +3 -3
- data/lib/contrast/agent/protect/policy/policy.rb +8 -8
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
- data/lib/contrast/agent/protect/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/protect/rule.rb +18 -18
- data/lib/contrast/agent/protect/rule/base.rb +4 -3
- data/lib/contrast/agent/protect/rule/base_service.rb +1 -1
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +5 -5
- data/lib/contrast/agent/protect/rule/deserialization.rb +1 -1
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +1 -1
- data/lib/contrast/agent/protect/rule/no_sqli.rb +1 -1
- data/lib/contrast/agent/protect/rule/path_traversal.rb +4 -5
- data/lib/contrast/agent/protect/rule/sqli.rb +2 -2
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +1 -1
- data/lib/contrast/agent/protect/rule/xss.rb +1 -1
- data/lib/contrast/agent/protect/rule/xxe.rb +3 -5
- data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +2 -2
- data/lib/contrast/agent/railtie.rb +1 -1
- data/lib/contrast/agent/reaction_processor.rb +2 -2
- data/lib/contrast/agent/request.rb +11 -9
- data/lib/contrast/agent/request_context.rb +10 -6
- data/lib/contrast/agent/response.rb +6 -6
- data/lib/contrast/agent/rewriter.rb +5 -6
- data/lib/contrast/agent/service_heartbeat.rb +2 -2
- data/lib/contrast/agent/static_analysis.rb +3 -3
- data/lib/contrast/agent/thread.rb +1 -1
- data/lib/contrast/agent/thread_watcher.rb +2 -2
- data/lib/contrast/agent/tracepoint_hook.rb +1 -1
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/api.rb +4 -4
- data/lib/contrast/api/communication.rb +9 -9
- data/lib/contrast/api/communication/messaging_queue.rb +2 -2
- data/lib/contrast/api/communication/response_processor.rb +1 -1
- data/lib/contrast/api/communication/socket_client.rb +5 -5
- data/lib/contrast/api/communication/speedracer.rb +1 -1
- data/lib/contrast/api/communication/tcp_socket.rb +1 -1
- data/lib/contrast/api/communication/unix_socket.rb +1 -1
- data/lib/contrast/api/decorators.rb +14 -14
- data/lib/contrast/api/decorators/address.rb +7 -6
- data/lib/contrast/api/decorators/application_settings.rb +3 -2
- data/lib/contrast/api/decorators/application_update.rb +5 -4
- data/lib/contrast/api/decorators/http_request.rb +13 -12
- data/lib/contrast/api/decorators/input_analysis.rb +3 -2
- data/lib/contrast/api/decorators/message.rb +3 -2
- data/lib/contrast/api/decorators/rasp_rule_sample.rb +2 -1
- data/lib/contrast/api/decorators/route_coverage.rb +3 -2
- data/lib/contrast/api/decorators/server_features.rb +3 -2
- data/lib/contrast/api/decorators/trace_event.rb +3 -2
- data/lib/contrast/api/decorators/trace_event_object.rb +6 -5
- data/lib/contrast/api/decorators/trace_event_signature.rb +5 -4
- data/lib/contrast/api/decorators/trace_taint_range.rb +4 -3
- data/lib/contrast/api/decorators/user_input.rb +4 -4
- data/lib/contrast/common_agent_configuration.rb +2 -2
- data/lib/contrast/components/agent.rb +2 -2
- data/lib/contrast/components/app_context.rb +1 -1
- data/lib/contrast/components/config.rb +4 -4
- data/lib/contrast/components/contrast_service.rb +1 -1
- data/lib/contrast/components/interface.rb +15 -15
- data/lib/contrast/components/logger.rb +1 -1
- data/lib/contrast/components/scope.rb +3 -3
- data/lib/contrast/config.rb +18 -18
- data/lib/contrast/config/base_configuration.rb +2 -2
- data/lib/contrast/config/protect_rule_configuration.rb +1 -1
- data/lib/contrast/configuration.rb +5 -5
- data/lib/contrast/extension/assess.rb +22 -21
- data/lib/contrast/extension/assess/array.rb +4 -4
- data/lib/contrast/extension/assess/assess_extension.rb +27 -29
- data/lib/contrast/extension/assess/eval_trigger.rb +3 -3
- data/lib/contrast/extension/assess/exec_trigger.rb +1 -1
- data/lib/contrast/extension/assess/fiber.rb +3 -3
- data/lib/contrast/extension/assess/hash.rb +5 -3
- data/lib/contrast/extension/assess/kernel.rb +7 -6
- data/lib/contrast/extension/assess/marshal.rb +62 -0
- data/lib/contrast/extension/assess/regexp.rb +3 -3
- data/lib/contrast/extension/assess/string.rb +5 -5
- data/lib/contrast/extension/inventory.rb +4 -4
- data/lib/contrast/extension/kernel.rb +1 -1
- data/lib/contrast/extension/module.rb +1 -1
- data/lib/contrast/extension/protect.rb +3 -3
- data/lib/contrast/extension/protect/kernel.rb +2 -2
- data/lib/contrast/extension/protect/psych.rb +2 -2
- data/lib/contrast/framework/manager.rb +7 -8
- data/lib/contrast/framework/rack/patch/session_cookie.rb +1 -1
- data/lib/contrast/framework/rack/patch/support.rb +1 -1
- data/lib/contrast/framework/rack/support.rb +2 -2
- data/lib/contrast/framework/rails/patch/assess_configuration.rb +2 -2
- data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +1 -1
- data/lib/contrast/framework/rails/patch/support.rb +3 -3
- data/lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb +2 -2
- data/lib/contrast/framework/rails/rewrite/active_record_named.rb +2 -2
- data/lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb +2 -2
- data/lib/contrast/framework/rails/support.rb +62 -14
- data/lib/contrast/framework/sinatra/patch/base.rb +1 -1
- data/lib/contrast/framework/sinatra/patch/support.rb +1 -1
- data/lib/contrast/framework/sinatra/support.rb +2 -2
- data/lib/contrast/funchook/funchook.rb +1 -1
- data/lib/contrast/logger/application.rb +2 -2
- data/lib/contrast/logger/format.rb +22 -9
- data/lib/contrast/logger/log.rb +10 -8
- data/lib/contrast/logger/request.rb +30 -0
- data/lib/contrast/tasks/config.rb +1 -1
- data/lib/contrast/tasks/service.rb +2 -2
- data/lib/contrast/utils/assess/sampling_util.rb +2 -2
- data/lib/contrast/utils/assess/tracking_util.rb +1 -1
- data/lib/contrast/utils/boolean_util.rb +1 -1
- data/lib/contrast/utils/class_util.rb +2 -2
- data/lib/contrast/utils/freeze_util.rb +1 -1
- data/lib/contrast/utils/gemfile_reader.rb +5 -5
- data/lib/contrast/utils/hash_digest.rb +2 -1
- data/lib/contrast/utils/heap_dump_util.rb +2 -2
- data/lib/contrast/utils/invalid_configuration_util.rb +1 -1
- data/lib/contrast/utils/inventory_util.rb +4 -4
- data/lib/contrast/utils/io_util.rb +1 -1
- data/lib/contrast/utils/os.rb +1 -1
- data/lib/contrast/utils/ruby_ast_rewriter.rb +1 -1
- data/lib/contrast/utils/sha256_builder.rb +2 -2
- data/lib/contrast/utils/stack_trace_utils.rb +2 -2
- data/lib/contrast/utils/string_utils.rb +1 -1
- data/ruby-agent.gemspec +5 -5
- data/service_executables/VERSION +1 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
- metadata +22 -19
- data/lib/contrast/agent/assess/insulator.rb +0 -49
- data/lib/contrast/agent/require_state.rb +0 -61
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
require 'contrast/logger/log'
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Components
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
require 'fiber'
|
5
|
+
require 'monitor'
|
6
|
+
require 'contrast/agent/scope'
|
7
7
|
|
8
8
|
# This is the Scope component.
|
9
9
|
#
|
data/lib/contrast/config.rb
CHANGED
@@ -10,24 +10,24 @@ module Contrast
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
require 'contrast/config/base_configuration'
|
14
|
+
require 'contrast/config/default_value'
|
15
15
|
|
16
|
-
|
16
|
+
require 'contrast/config/logger_configuration'
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
require 'contrast/config/heap_dump_configuration'
|
19
|
+
require 'contrast/config/service_configuration'
|
20
|
+
require 'contrast/config/exception_configuration'
|
21
|
+
require 'contrast/config/assess_rules_configuration'
|
22
|
+
require 'contrast/config/protect_rule_configuration'
|
23
|
+
require 'contrast/config/protect_rules_configuration'
|
24
|
+
require 'contrast/config/sampling_configuration'
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
require 'contrast/config/ruby_configuration'
|
27
|
+
require 'contrast/config/agent_configuration'
|
28
|
+
require 'contrast/config/application_configuration'
|
29
|
+
require 'contrast/config/server_configuration'
|
30
|
+
require 'contrast/config/assess_configuration'
|
31
|
+
require 'contrast/config/inventory_configuration'
|
32
|
+
require 'contrast/config/protect_configuration'
|
33
|
+
require 'contrast/config/root_configuration'
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
require 'forwardable'
|
5
|
+
require 'contrast/utils/object_share'
|
6
6
|
|
7
7
|
module Contrast
|
8
8
|
module Config
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
require 'yaml'
|
5
|
+
require 'fileutils'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
require 'contrast/config'
|
8
|
+
require 'contrast/utils/object_share'
|
9
|
+
require 'contrast/components/interface'
|
10
10
|
|
11
11
|
module Contrast
|
12
12
|
# This is how we read in the local settings for the Agent, both ENV/ CMD line
|
@@ -12,37 +12,38 @@ module Contrast
|
|
12
12
|
# therein.
|
13
13
|
# Removing it requires a C refactor to handle the namespace.
|
14
14
|
module Assess
|
15
|
-
|
15
|
+
require 'contrast/agent/patching/policy/patcher'
|
16
16
|
|
17
|
-
|
17
|
+
require 'contrast/utils/tag_util'
|
18
18
|
|
19
19
|
# provider rules - have to come before policy
|
20
|
-
|
20
|
+
require 'contrast/agent/assess/rule/provider'
|
21
21
|
|
22
22
|
# tagging / dataflow
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
require 'contrast/agent/assess/policy/policy_node'
|
24
|
+
require 'contrast/agent/assess/policy/source_node'
|
25
|
+
require 'contrast/agent/assess/policy/source_method'
|
26
|
+
require 'contrast/agent/assess/policy/propagation_node'
|
27
|
+
require 'contrast/agent/assess/policy/propagation_method'
|
28
|
+
require 'contrast/agent/assess/policy/trigger_node'
|
29
|
+
require 'contrast/agent/assess/policy/trigger_method'
|
30
|
+
require 'contrast/agent/assess/policy/policy'
|
31
|
+
require 'contrast/agent/assess/policy/patcher'
|
32
32
|
|
33
33
|
# classes that don't play nice w/ our standard propagation
|
34
|
-
|
34
|
+
require 'contrast/extension/assess/assess_extension'
|
35
35
|
# this needs to come first b/c array and others work on strings and
|
36
36
|
# expect them to be trackable
|
37
|
-
|
37
|
+
require 'contrast/extension/assess/string'
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
require 'contrast/extension/assess/array'
|
40
|
+
require 'contrast/extension/assess/erb'
|
41
|
+
require 'contrast/extension/assess/eval_trigger'
|
42
|
+
require 'contrast/extension/assess/fiber'
|
43
|
+
require 'contrast/extension/assess/hash'
|
44
|
+
require 'contrast/extension/assess/kernel'
|
45
|
+
require 'contrast/extension/assess/regexp'
|
46
|
+
require 'contrast/extension/assess/marshal'
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
require 'contrast/agent/patching/policy/patch'
|
5
|
+
require 'contrast/agent/patching/policy/patcher'
|
6
|
+
require 'contrast/components/interface'
|
7
7
|
|
8
8
|
module Contrast
|
9
9
|
module Extension
|
@@ -63,7 +63,7 @@ module Contrast
|
|
63
63
|
|
64
64
|
def instrument_array_track
|
65
65
|
@_instrument_array_track ||= begin
|
66
|
-
|
66
|
+
require 'cs__assess_array/cs__assess_array'
|
67
67
|
true
|
68
68
|
end
|
69
69
|
rescue StandardError, LoadError => e
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
require 'contrast/agent/assess/properties'
|
5
|
+
require 'contrast/agent/assess/finalizers/finalize'
|
6
6
|
|
7
7
|
module Contrast
|
8
8
|
module Extension
|
@@ -13,28 +13,17 @@ module Contrast
|
|
13
13
|
# dataflow features should be sent
|
14
14
|
# 'include Contrast::Extension::Assess::AssessExtension'
|
15
15
|
module AssessExtension
|
16
|
+
def cs__transfer_properties dup
|
17
|
+
Contrast::Agent::Assess::Finalizers::Finalize::PROPERTIES_HASH[dup] ||= Contrast::Agent::Assess::Finalizers::Finalize::PROPERTIES_HASH[self].dup
|
18
|
+
end
|
19
|
+
|
16
20
|
# Lazily build properties object. Only objects that have been tracked
|
17
21
|
# will have the @_cs__properties, but all will respond to the
|
18
22
|
# cs__properties method call. You should only call this method if you
|
19
23
|
# either intend to start tracking an object or you have already checked
|
20
24
|
# cs__tracked? and it is true.
|
21
25
|
def cs__properties
|
22
|
-
|
23
|
-
# mutable properties we need inside of the insulator @_cs__properties
|
24
|
-
if cs__frozen?
|
25
|
-
if instance_variable_defined?(:@_cs__properties)
|
26
|
-
@_cs__properties.properties
|
27
|
-
else
|
28
|
-
Contrast::Agent::Assess::Insulator.generate_frozen.properties
|
29
|
-
end
|
30
|
-
else
|
31
|
-
@_cs__properties ||= Contrast::Agent::Assess::Insulator.generate
|
32
|
-
@_cs__properties.properties
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def cs__properties?
|
37
|
-
instance_variable_defined?(:@_cs__properties)
|
26
|
+
Contrast::Agent::Assess::Finalizers::Finalize::PROPERTIES_HASH[self] ||= Contrast::Agent::Assess::Properties.new
|
38
27
|
end
|
39
28
|
|
40
29
|
# This is a way to check if we are already tracking an object without
|
@@ -43,13 +32,11 @@ module Contrast
|
|
43
32
|
# already been tracked we will return false without starting to track
|
44
33
|
# it
|
45
34
|
def cs__tracked?
|
46
|
-
|
35
|
+
!!Contrast::Agent::Assess::Finalizers::Finalize::PROPERTIES_HASH[self]&.tracked?
|
47
36
|
end
|
48
37
|
|
49
38
|
def cs__reset_properties
|
50
|
-
|
51
|
-
|
52
|
-
@_cs__properties = nil
|
39
|
+
Contrast::Agent::Assess::Finalizers::Finalize::PROPERTIES_HASH[self] = nil
|
53
40
|
end
|
54
41
|
|
55
42
|
# copy tags and info from object to self if object support methods
|
@@ -61,14 +48,9 @@ module Contrast
|
|
61
48
|
return unless Contrast::Utils::DuckUtils.quacks_to?(obj,
|
62
49
|
:cs__tracked?)
|
63
50
|
return unless obj.cs__tracked?
|
64
|
-
return
|
51
|
+
return unless cs__properties
|
65
52
|
|
66
|
-
|
67
|
-
# the clone and dup methods don't apply to instance variables in the
|
68
|
-
# cloned/ duped thing, so the arrays in the properties were the same.
|
69
|
-
# The most infinite of infinite loops ensued.
|
70
|
-
# DO NOT TAKE THIS OUT!
|
71
|
-
cs__reset_properties if obj.cs__properties == cs__properties
|
53
|
+
cs__adjust_duplicate(obj)
|
72
54
|
|
73
55
|
obj.cs__properties.events.each do |event|
|
74
56
|
cs__properties.events << event
|
@@ -141,6 +123,22 @@ module Contrast
|
|
141
123
|
end
|
142
124
|
end
|
143
125
|
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
# Because of how our tracking works now, sometimes the Source and
|
130
|
+
# Target are the same, but their IDs in our map will be different due
|
131
|
+
# to PreShift duplication. To account for this, we have to ensure that
|
132
|
+
# the Object we're copying from does not have the same Properties
|
133
|
+
# that the Object we're copying to does. If they are the same, wipe the
|
134
|
+
# Target so that the copy method can update events and ranges as
|
135
|
+
# necessary.
|
136
|
+
# DO NOT TAKE THIS OUT!
|
137
|
+
def cs__adjust_duplicate obj
|
138
|
+
cs__reset_properties if obj.cs__properties == cs__properties
|
139
|
+
cs__reset_properties if obj.cs__properties.__id__ == cs__properties.dupped_from
|
140
|
+
cs__reset_properties if obj.cs__properties.dupped_from == cs__properties.__id__
|
141
|
+
end
|
144
142
|
end
|
145
143
|
end
|
146
144
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
require 'contrast/components/interface'
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Extension
|
@@ -45,7 +45,7 @@ module Contrast
|
|
45
45
|
|
46
46
|
def instrument_basic_object_track
|
47
47
|
@_instrument_basic_object_track ||= begin
|
48
|
-
|
48
|
+
require 'cs__assess_basic_object/cs__assess_basic_object'
|
49
49
|
true
|
50
50
|
end
|
51
51
|
rescue StandardError, LoadError => e
|
@@ -55,7 +55,7 @@ module Contrast
|
|
55
55
|
|
56
56
|
def instrument_module_track
|
57
57
|
@_instrument_module_track ||= begin
|
58
|
-
|
58
|
+
require 'cs__assess_module/cs__assess_module'
|
59
59
|
true
|
60
60
|
end
|
61
61
|
rescue StandardError, LoadError => e
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
require 'contrast/agent/at_exit_hook'
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Extension
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
require 'contrast/agent/assess/policy/propagation_node'
|
5
|
+
require 'contrast/components/interface'
|
6
6
|
|
7
7
|
# In order to instrument some difficult methods like String#gsub, as it
|
8
8
|
# returns an enumerator, we need to instrument methods on Fiber.
|
@@ -99,7 +99,7 @@ module Contrast
|
|
99
99
|
|
100
100
|
def instrument_fiber_track
|
101
101
|
@_instrument_fiber_variables ||= begin
|
102
|
-
|
102
|
+
require 'cs__assess_fiber_track/cs__assess_fiber_track' if Funchook.available?
|
103
103
|
true
|
104
104
|
end
|
105
105
|
rescue StandardError, LoadError => e
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
require 'contrast/components/interface'
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Extension
|
@@ -17,7 +17,9 @@ module Contrast
|
|
17
17
|
return object unless object.is_a?(String) && !object.cs__frozen?
|
18
18
|
return object unless object.cs__tracked?
|
19
19
|
|
20
|
-
object.dup
|
20
|
+
ret = object.dup
|
21
|
+
object.cs__transfer_properties(ret)
|
22
|
+
ret.cs__freeze
|
21
23
|
rescue StandardError
|
22
24
|
# we'll rescue this error, but we can't log it here as that will
|
23
25
|
# result in a seg fault
|
@@ -25,7 +27,7 @@ module Contrast
|
|
25
27
|
|
26
28
|
def instrument_hash_track
|
27
29
|
@_instrument_hash_track ||= begin
|
28
|
-
|
30
|
+
require 'cs__assess_hash/cs__assess_hash'
|
29
31
|
true
|
30
32
|
end
|
31
33
|
rescue StandardError, LoadError => e
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
require 'contrast/components/interface'
|
5
|
+
require 'contrast/extension/assess/exec_trigger'
|
6
6
|
|
7
7
|
module Contrast
|
8
8
|
module Extension
|
@@ -56,11 +56,12 @@ module Contrast
|
|
56
56
|
|
57
57
|
def track_sprintf result, format_string, args
|
58
58
|
handle_sprintf_value(format_string, result)
|
59
|
-
|
59
|
+
case args
|
60
|
+
when String
|
60
61
|
handle_sprintf_value(args, result)
|
61
|
-
|
62
|
+
when Hash
|
62
63
|
handle_sprintf_hash(args, result)
|
63
|
-
|
64
|
+
when Array
|
64
65
|
handle_sprintf_array args, result
|
65
66
|
end
|
66
67
|
|
@@ -73,7 +74,7 @@ module Contrast
|
|
73
74
|
|
74
75
|
def instrument_kernel_track
|
75
76
|
@_instrument_fiber_variables ||= begin
|
76
|
-
|
77
|
+
require 'cs__assess_kernel/cs__assess_kernel'
|
77
78
|
true
|
78
79
|
end
|
79
80
|
rescue StandardError, LoadError => e
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'contrast/components/interface'
|
5
|
+
|
6
|
+
module Contrast
|
7
|
+
module Extension
|
8
|
+
module Assess
|
9
|
+
# This is our patch of the Array class required to handle propagation
|
10
|
+
# Disclaimer: there may be a better way, but we're in a 'get it work' state.
|
11
|
+
# Hopefully, we'll be in a 'get it right' state soon.
|
12
|
+
# This module is used for our Marshal#load patches
|
13
|
+
class MarshalPropagator
|
14
|
+
include Contrast::Components::Interface
|
15
|
+
|
16
|
+
access_component :logging
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def cs__load_trigger_check source, ret
|
20
|
+
current_context = Contrast::Agent::REQUEST_TRACKER.current
|
21
|
+
return unless current_context
|
22
|
+
|
23
|
+
# Since we know this is the source of the trigger, we can do some
|
24
|
+
# optimization here and return when it is not tracked
|
25
|
+
return unless Contrast::Utils::Assess::TrackingUtil.tracked?(source)
|
26
|
+
|
27
|
+
# source might not be all the args passed in, but it is the one we care
|
28
|
+
# about. we could pass in all the args in the last param here if it
|
29
|
+
# becomes an issue in rendering on TS
|
30
|
+
Contrast::Agent::Assess::Policy::TriggerMethod.build_finding(
|
31
|
+
current_context,
|
32
|
+
trigger_node('Marshal', :load),
|
33
|
+
source,
|
34
|
+
self,
|
35
|
+
ret,
|
36
|
+
source)
|
37
|
+
ret.cs__copy_from(source) if ret.cs__respond_to?(:cs__copy_from)
|
38
|
+
rescue StandardError => e
|
39
|
+
logger.error('Unable to determine if a trigger occurred in Marshal.load', e)
|
40
|
+
end
|
41
|
+
|
42
|
+
def instrument_marshal_load
|
43
|
+
@_instrument_marshal_load ||= begin
|
44
|
+
require 'cs__assess_marshal_module/cs__assess_marshal_module'
|
45
|
+
true
|
46
|
+
end
|
47
|
+
rescue StandardError, LoadError => e
|
48
|
+
logger.error('Error loading marshal load patch', e)
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
def trigger_node clazz, method
|
53
|
+
triggers = Contrast::Agent::Assess::Policy::Policy.instance.triggers
|
54
|
+
return unless triggers
|
55
|
+
|
56
|
+
triggers.find { |node| node.class_name == clazz && node.method_name == method }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|