contrast-agent 5.3.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/cs__assess_array/cs__assess_array.c +7 -0
- data/ext/cs__assess_basic_object/cs__assess_basic_object.c +19 -5
- data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +1 -1
- data/ext/cs__assess_hash/cs__assess_hash.c +3 -4
- data/ext/cs__assess_kernel/cs__assess_kernel.c +1 -2
- data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +26 -12
- data/ext/cs__assess_module/cs__assess_module.c +1 -1
- data/ext/cs__assess_string/cs__assess_string.c +13 -1
- data/ext/cs__common/cs__common.c +12 -11
- data/ext/cs__contrast_patch/cs__contrast_patch.c +54 -43
- data/ext/cs__os_information/cs__os_information.c +13 -10
- data/ext/cs__scope/cs__scope.c +146 -97
- data/lib/contrast/agent/assess/finalizers/hash.rb +2 -0
- data/lib/contrast/agent/assess/policy/policy_node.rb +50 -27
- data/lib/contrast/agent/assess/policy/policy_node_utils.rb +51 -0
- data/lib/contrast/agent/assess/policy/preshift.rb +8 -2
- data/lib/contrast/agent/assess/policy/propagation_method.rb +47 -13
- data/lib/contrast/agent/assess/policy/propagator/buffer.rb +118 -0
- data/lib/contrast/agent/assess/policy/propagator/keep.rb +19 -4
- data/lib/contrast/agent/assess/policy/propagator/remove.rb +18 -2
- data/lib/contrast/agent/assess/policy/propagator/splat.rb +17 -3
- data/lib/contrast/agent/assess/policy/propagator/substitution.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/substitution_utils.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/trim.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator.rb +1 -0
- data/lib/contrast/agent/assess/policy/source_method.rb +7 -7
- data/lib/contrast/agent/assess/policy/trigger_method.rb +3 -1
- data/lib/contrast/agent/assess/property/tagged.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/auto_complete_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/body_rule.rb +3 -3
- data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/parameters_pollution_rule.rb +1 -1
- data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +0 -7
- data/lib/contrast/agent/deadzone/policy/policy.rb +0 -6
- data/lib/contrast/agent/exclusion_matcher.rb +3 -3
- data/lib/contrast/agent/middleware.rb +3 -1
- data/lib/contrast/agent/patching/policy/patcher.rb +3 -3
- data/lib/contrast/agent/patching/policy/policy_node.rb +15 -2
- data/lib/contrast/agent/protect/exploitable_collection.rb +38 -0
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +61 -8
- data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +2 -1
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +2 -2
- data/lib/contrast/agent/protect/rule/base.rb +37 -5
- data/lib/contrast/agent/protect/rule/base_service.rb +3 -1
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +13 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +83 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +64 -0
- data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +96 -0
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +8 -0
- data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +231 -0
- data/lib/contrast/agent/protect/rule/no_sqli.rb +27 -0
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +18 -54
- data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +1 -4
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +82 -0
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +45 -0
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +42 -0
- data/lib/contrast/agent/reporting/attack_result/attack_result.rb +63 -0
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +52 -0
- data/lib/contrast/agent/reporting/attack_result/response_type.rb +29 -0
- data/lib/contrast/agent/reporting/attack_result/user_input.rb +87 -0
- data/lib/contrast/agent/reporting/masker/masker.rb +246 -0
- data/lib/contrast/agent/reporting/masker/masker_utils.rb +58 -0
- data/lib/contrast/agent/reporting/report.rb +2 -0
- data/lib/contrast/agent/reporting/reporter.rb +23 -11
- data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +30 -0
- data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +7 -3
- data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +40 -0
- data/lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb +27 -0
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +5 -5
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +9 -9
- data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +2 -1
- data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +2 -1
- data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +8 -6
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +16 -5
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +27 -26
- data/lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +97 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +68 -6
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb +63 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +122 -96
- data/lib/contrast/agent/reporting/settings/application_settings.rb +9 -0
- data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +5 -33
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sampling.rb +36 -0
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +110 -0
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb +58 -0
- data/lib/contrast/agent/request_context.rb +1 -1
- data/lib/contrast/agent/request_context_extend.rb +1 -1
- data/lib/contrast/agent/request_handler.rb +4 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_base.rb +51 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +36 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message.rb +97 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception.rb +65 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb +47 -0
- data/lib/contrast/agent/{metric_telemetry_event.rb → telemetry/events/metric_telemetry_event.rb} +1 -1
- data/lib/contrast/agent/{startup_metrics_telemetry_event.rb → telemetry/events/startup_metrics_telemetry_event.rb} +3 -3
- data/lib/contrast/agent/{telemetry_event.rb → telemetry/events/telemetry_event.rb} +1 -1
- data/lib/contrast/agent/{telemetry.rb → telemetry/telemetry.rb} +32 -19
- data/lib/contrast/agent/thread_watcher.rb +1 -1
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/agent.rb +3 -0
- data/lib/contrast/api/communication/speedracer.rb +1 -1
- data/lib/contrast/api/decorators/address.rb +1 -1
- data/lib/contrast/api/decorators/response_type.rb +30 -0
- data/lib/contrast/api/decorators.rb +1 -0
- data/lib/contrast/components/app_context.rb +0 -4
- data/lib/contrast/components/assess.rb +14 -0
- data/lib/contrast/components/protect.rb +2 -2
- data/lib/contrast/components/sampling.rb +7 -11
- data/lib/contrast/components/settings.rb +106 -8
- data/lib/contrast/config/agent_configuration.rb +13 -30
- data/lib/contrast/config/api_configuration.rb +4 -67
- data/lib/contrast/config/api_proxy_configuration.rb +2 -45
- data/lib/contrast/config/application_configuration.rb +9 -84
- data/lib/contrast/config/assess_configuration.rb +10 -69
- data/lib/contrast/config/assess_rules_configuration.rb +9 -38
- data/lib/contrast/config/base_configuration.rb +17 -50
- data/lib/contrast/config/certification_configuration.rb +6 -63
- data/lib/contrast/config/exception_configuration.rb +5 -52
- data/lib/contrast/config/heap_dump_configuration.rb +6 -64
- data/lib/contrast/config/inventory_configuration.rb +2 -49
- data/lib/contrast/config/logger_configuration.rb +0 -36
- data/lib/contrast/config/protect_configuration.rb +17 -7
- data/lib/contrast/config/protect_rule_configuration.rb +12 -30
- data/lib/contrast/config/protect_rules_configuration.rb +21 -26
- data/lib/contrast/config/request_audit_configuration.rb +6 -48
- data/lib/contrast/config/root_configuration.rb +52 -12
- data/lib/contrast/config/ruby_configuration.rb +0 -36
- data/lib/contrast/config/sampling_configuration.rb +1 -57
- data/lib/contrast/config/server_configuration.rb +0 -36
- data/lib/contrast/config/service_configuration.rb +5 -44
- data/lib/contrast/configuration.rb +2 -3
- data/lib/contrast/extension/assess/string.rb +20 -1
- data/lib/contrast/extension/module.rb +0 -1
- data/lib/contrast/framework/manager.rb +2 -2
- data/lib/contrast/logger/application.rb +1 -1
- data/lib/contrast/logger/cef_log.rb +1 -1
- data/lib/contrast/tasks/config.rb +90 -3
- data/lib/contrast/utils/assess/object_store.rb +36 -0
- data/lib/contrast/utils/assess/propagation_method_utils.rb +6 -0
- data/lib/contrast/utils/class_util.rb +3 -12
- data/lib/contrast/utils/input_classification.rb +73 -0
- data/lib/contrast/utils/log_utils.rb +1 -1
- data/lib/contrast/utils/middleware_utils.rb +9 -8
- data/lib/contrast/utils/net_http_base.rb +1 -1
- data/lib/contrast/utils/object_share.rb +2 -1
- data/lib/contrast/utils/os.rb +0 -5
- data/lib/contrast/utils/patching/policy/patch_utils.rb +4 -5
- data/lib/contrast/utils/response_utils.rb +18 -33
- data/lib/contrast/utils/telemetry.rb +1 -1
- data/lib/contrast/utils/telemetry_client.rb +1 -1
- data/lib/contrast/utils/telemetry_identifier.rb +1 -1
- data/resources/assess/policy.json +98 -0
- data/resources/deadzone/policy.json +0 -86
- data/ruby-agent.gemspec +9 -8
- data/service_executables/VERSION +1 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
- metadata +73 -28
@@ -50,8 +50,8 @@ module Contrast
|
|
50
50
|
# After implementing the LRU Cache, we firstly need to check if already had that object cached and if we have
|
51
51
|
# it - we can return it directly; otherwise we'll calculate and store the result before returning.
|
52
52
|
#
|
53
|
-
#
|
54
|
-
#
|
53
|
+
# Combining of the caches have close performance, but keeping the two with current implementation has
|
54
|
+
# a slight advantage in performance. For now we can keep the things the way they are.
|
55
55
|
#
|
56
56
|
# @param object [Object, nil] the entity to convert to a String
|
57
57
|
# @return [String, Object] the human readable form of the String, as defined by
|
@@ -98,16 +98,7 @@ module Contrast
|
|
98
98
|
def truly_defined? name
|
99
99
|
return false unless name
|
100
100
|
|
101
|
-
|
102
|
-
previous_module = Module
|
103
|
-
segments.each do |segment|
|
104
|
-
return false if previous_module.cs__autoload?(segment)
|
105
|
-
return false unless previous_module.cs__const_defined?(segment)
|
106
|
-
|
107
|
-
previous_module = previous_module.cs__const_get(segment)
|
108
|
-
end
|
109
|
-
|
110
|
-
true
|
101
|
+
Module.cs__const_defined?(name)
|
111
102
|
rescue NameError # account for nonsense / poorly formatted constants
|
112
103
|
false
|
113
104
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'contrast/utils/object_share'
|
5
|
+
require 'contrast/agent/reporting/input_analysis/input_type'
|
6
|
+
require 'contrast/agent/reporting/input_analysis/score_level'
|
7
|
+
require 'contrast/agent/protect/input_analyzer/input_analyzer'
|
8
|
+
|
9
|
+
module Contrast
|
10
|
+
module Agent
|
11
|
+
module Protect
|
12
|
+
module Rule
|
13
|
+
# This module will include all the similar information for all input classifications
|
14
|
+
# between different rules
|
15
|
+
module InputClassificationBase
|
16
|
+
include Contrast::Agent::Reporting::InputType
|
17
|
+
include Contrast::Agent::Reporting::ScoreLevel
|
18
|
+
|
19
|
+
# Input Classification stage is done to determine if an user input is
|
20
|
+
# WORTHWATCHING or to be ignored.
|
21
|
+
#
|
22
|
+
# @param input_type [Contrast::Agent::Reporting::InputType] The type of the user input.
|
23
|
+
# @param value [String, Array<String>] the value of the input.
|
24
|
+
# @param input_analysis [Contrast::Agent::Reporting::InputAnalysis] Holds all the results from the
|
25
|
+
# agent analysis from the current
|
26
|
+
# Request.
|
27
|
+
# @return ia [Contrast::Agent::Reporting::InputAnalysis] with updated results.
|
28
|
+
def classify input_type, value, input_analysis # rubocop:disable Lint/UnusedMethodArgument
|
29
|
+
return false unless input_analysis.request
|
30
|
+
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
# Creates new isntance of InputAnalysisResult with basic info.
|
35
|
+
#
|
36
|
+
# @param rule_id [String] The name of the Protect Rule.
|
37
|
+
# @param input_type [Contrast::Agent::Reporting::InputType] The type of the user input.
|
38
|
+
# @param value [String, Array<String>] the value of the input.
|
39
|
+
# @param path [String] the path of the current request context.
|
40
|
+
#
|
41
|
+
# @return res [Contrast::Agent::Reporting::InputAnalysisResult]
|
42
|
+
def new_ia_result rule_id, input_type, path, value = nil
|
43
|
+
res = Contrast::Agent::Reporting::InputAnalysisResult.new
|
44
|
+
res.rule_id = rule_id
|
45
|
+
res.input_type = input_type
|
46
|
+
res.path = path
|
47
|
+
res.value = value
|
48
|
+
res
|
49
|
+
end
|
50
|
+
|
51
|
+
# This methods checks if input is value that matches a key in the input.
|
52
|
+
#
|
53
|
+
# @param request [Contrast::Agent::Request] the current request context.
|
54
|
+
# @param result [Contrast::Agent::Reporting::InputAnalysisResult] result to be updated.
|
55
|
+
# @param input_type [Contrast::Agent::Reporting::InputType] The type of the user input.
|
56
|
+
# @param value [String, Array<String>] the value of the input.
|
57
|
+
#
|
58
|
+
# @return result [Contrast::Agent::Reporting::InputAnalysisResult] updated with key result.
|
59
|
+
def add_needed_key request, result, input_type, value
|
60
|
+
case input_type
|
61
|
+
when COOKIE_VALUE
|
62
|
+
result.key = request.cookies.key(value)
|
63
|
+
when PARAMETER_VALUE
|
64
|
+
result.key = request.parameters.key(value)
|
65
|
+
else
|
66
|
+
result.key
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -8,6 +8,13 @@ module Contrast
|
|
8
8
|
module MiddlewareUtils
|
9
9
|
private
|
10
10
|
|
11
|
+
# TODO: RUBY-1609 update this part of the method for Ruby Version and Year
|
12
|
+
LANGUAGE_DEPRECATION_VERSION = '2.7'
|
13
|
+
LANGUAGE_DEPRECATION_YEAR = '2023'
|
14
|
+
LANGUAGE_DEPRECATION_WARNING =
|
15
|
+
"[Contrast Security] [DEPRECATION] Support for Ruby #{ LANGUAGE_DEPRECATION_VERSION } will be removed in "\
|
16
|
+
"April #{ LANGUAGE_DEPRECATION_YEAR }. Please contact Customer Support prior if you require continued support."
|
17
|
+
|
11
18
|
def setup_agent
|
12
19
|
::Contrast::SETTINGS.reset_state
|
13
20
|
|
@@ -51,14 +58,8 @@ module Contrast
|
|
51
58
|
# deprecated and soon to be removed functionality. This method handles doing that by leveraging the standard
|
52
59
|
# Kernel#warn approach
|
53
60
|
def inform_deprecations
|
54
|
-
#
|
55
|
-
|
56
|
-
# TODO: RUBY-1188 remove this part of the method, leaving it empty if there are no other deprecations, when we
|
57
|
-
# drop 2.6 support.
|
58
|
-
return unless RUBY_VERSION < '2.7.0'
|
59
|
-
|
60
|
-
Kernel.warn('[Contrast Security] [DEPRECATION] Support for Ruby 2.6 will be removed in April 2022. '\
|
61
|
-
'Please contact Customer Support prior if you require continued support.')
|
61
|
+
# Warn customers that they're on a version that's losing support in the next year.
|
62
|
+
Kernel.warn(LANGUAGE_DEPRECATION_WARNING) if RUBY_VERSION.start_with?(LANGUAGE_DEPRECATION_VERSION)
|
62
63
|
end
|
63
64
|
|
64
65
|
# Displays Telemetry disclaimer if Telemetry is enabled.
|
@@ -22,7 +22,7 @@ module Contrast
|
|
22
22
|
# @param use_custom_cert [Boolean] flag used to indicate whether the client is to use
|
23
23
|
# self signed certificates provided by config [default = false]
|
24
24
|
# @return [Net::HTTP, nil] Return open connection or nil
|
25
|
-
def initialize_connection service_name, url, use_proxy
|
25
|
+
def initialize_connection service_name, url, use_proxy: false, use_custom_cert: false
|
26
26
|
return unless url
|
27
27
|
|
28
28
|
addr = URI(url)
|
@@ -10,6 +10,7 @@ module Contrast
|
|
10
10
|
module ObjectShare
|
11
11
|
# Strings
|
12
12
|
ASTERISK = '*'
|
13
|
+
AMPERSAND = '&'
|
13
14
|
BACK_SLASH = '\\'
|
14
15
|
EMPTY_STRING = ''
|
15
16
|
COLON = ':'
|
@@ -38,6 +39,7 @@ module Contrast
|
|
38
39
|
COLON_SLASH_SLASH = '://'
|
39
40
|
DOLLAR_SIGN = '$'
|
40
41
|
CARROT = '^'
|
42
|
+
BANG = '!'
|
41
43
|
|
42
44
|
WRITE_FLAG = 'w'
|
43
45
|
|
@@ -47,7 +49,6 @@ module Contrast
|
|
47
49
|
CACHE = 'cache'
|
48
50
|
|
49
51
|
CONTRAST_PATCHED_METHOD_START = 'cs__patched_'
|
50
|
-
DOUBLE_COLON = '::'
|
51
52
|
|
52
53
|
EMPTY_ARRAY = [].freeze
|
53
54
|
EMPTY_HASH = {}.freeze
|
data/lib/contrast/utils/os.rb
CHANGED
@@ -35,10 +35,9 @@ module Contrast
|
|
35
35
|
# Given a method, return a symbol in the format
|
36
36
|
# <method_start>_unbound_<method_name>
|
37
37
|
def build_unbound_method_name patcher_method
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
patcher_method.to_s).to_sym
|
38
|
+
"#{ Contrast::Utils::ObjectShare::CONTRAST_PATCHED_METHOD_START }unbound"\
|
39
|
+
"#{ Contrast::Utils::ObjectShare::UNDERSCORE }"\
|
40
|
+
"#{ patcher_method }".to_sym
|
42
41
|
end
|
43
42
|
|
44
43
|
# ===== PATCH APPLIERS =====
|
@@ -138,7 +137,7 @@ module Contrast
|
|
138
137
|
if method_policy.source_node
|
139
138
|
# If we were given a frozen return, and it was the target of a source, and we have frozen sources enabled,
|
140
139
|
# we'll need to replace the return. Note, this is not the default case.
|
141
|
-
source_ret = Contrast::Agent::Assess::Policy::SourceMethod.
|
140
|
+
source_ret = Contrast::Agent::Assess::Policy::SourceMethod.apply_source(method_policy, object, ret, args)
|
142
141
|
end
|
143
142
|
if method_policy.propagation_node
|
144
143
|
propagated_ret = Contrast::Agent::Assess::Policy::PropagationMethod.apply_propagation(
|
@@ -36,39 +36,24 @@ module Contrast
|
|
36
36
|
return unless body
|
37
37
|
return if defined?(Rack::File) && body.is_a?(Rack::File)
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# handle_rack_body_proxy(body)
|
58
|
-
# elsif (defined?(ActionDispatch::Response::RackBody) && body.is_a?(ActionDispatch::Response::RackBody)) ||
|
59
|
-
# body.is_a?(Rack::Response)
|
60
|
-
#
|
61
|
-
# extract_body(body.body)
|
62
|
-
# elsif Contrast::Utils::DuckUtils.quacks_to?(body, :each)
|
63
|
-
# acc = []
|
64
|
-
# body.each { |tmp| acc << read_or_string(tmp) }
|
65
|
-
# acc.compact.join(Contrast::Utils::ObjectShare::NEW_LINE)
|
66
|
-
# elsif ActionView::OutputBuffer
|
67
|
-
# # https://stackoverflow.com/questions/15654676/how-to-convert-activesupportsafebuffer-to-string
|
68
|
-
# body.to_str
|
69
|
-
# else
|
70
|
-
# read_or_string(body)
|
71
|
-
# end
|
39
|
+
return handle_rack_body_proxy(body) if body.is_a?(Rack::BodyProxy)
|
40
|
+
return extract_body(body.body) if sub_extractable?(body)
|
41
|
+
return enumerable_text_from(body) if Contrast::Utils::DuckUtils.quacks_to?(body, :each)
|
42
|
+
# https://stackoverflow.com/questions/15654676/how-to-convert-activesupportsafebuffer-to-string
|
43
|
+
return body.to_str if body.is_a?(ActionView::OutputBuffer)
|
44
|
+
|
45
|
+
read_or_string(body)
|
46
|
+
end
|
47
|
+
|
48
|
+
def sub_extractable? body
|
49
|
+
(defined?(ActionDispatch::Response::RackBody) && body.is_a?(ActionDispatch::Response::RackBody)) ||
|
50
|
+
body.is_a?(Rack::Response)
|
51
|
+
end
|
52
|
+
|
53
|
+
def enumerable_text_from body
|
54
|
+
entries = body.map { |entry| read_or_string(entry) }
|
55
|
+
entries.compact!
|
56
|
+
entries.join(Contrast::Utils::ObjectShare::NEW_LINE)
|
72
57
|
end
|
73
58
|
|
74
59
|
def handle_rack_body_proxy body
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require 'contrast/agent/telemetry'
|
4
|
+
require 'contrast/agent/telemetry/telemetry'
|
5
5
|
require 'contrast/utils/telemetry_identifier'
|
6
6
|
|
7
7
|
module Contrast
|
@@ -22,7 +22,7 @@ module Contrast
|
|
22
22
|
# @param url [String]
|
23
23
|
# @return [Net::HTTP, nil] Return open connection or nil
|
24
24
|
def initialize_connection url
|
25
|
-
super(SERVICE_NAME, url, false, false)
|
25
|
+
super(SERVICE_NAME, url, use_proxy: false, use_custom_cert: false)
|
26
26
|
end
|
27
27
|
|
28
28
|
# This method will be responsible for building the request. Because the telemetry collector expects to receive
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require 'contrast/agent/telemetry'
|
4
|
+
require 'contrast/agent/telemetry/telemetry'
|
5
5
|
require 'contrast/utils/os'
|
6
6
|
require 'socket'
|
7
7
|
|
@@ -790,6 +790,16 @@
|
|
790
790
|
"patch_method": "select_tagger",
|
791
791
|
"source": "O",
|
792
792
|
"target": "R"
|
793
|
+
},{
|
794
|
+
"class_name": "String",
|
795
|
+
"instance_method": true,
|
796
|
+
"method_visibility": "public",
|
797
|
+
"method_name": "slice",
|
798
|
+
"action": "CUSTOM",
|
799
|
+
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Select",
|
800
|
+
"patch_method": "select_tagger",
|
801
|
+
"source": "O",
|
802
|
+
"target": "R"
|
793
803
|
},{
|
794
804
|
"class_name":"CGI::Util",
|
795
805
|
"method_name":"unescape",
|
@@ -1112,6 +1122,67 @@
|
|
1112
1122
|
"target":"O",
|
1113
1123
|
"action":"SPLAT"
|
1114
1124
|
},
|
1125
|
+
{
|
1126
|
+
"class_name": "IO::Buffer",
|
1127
|
+
"instance_method": true,
|
1128
|
+
"method_visibility": "public",
|
1129
|
+
"method_name": "get_string",
|
1130
|
+
"source": "O",
|
1131
|
+
"target": "R",
|
1132
|
+
"action": "CUSTOM",
|
1133
|
+
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Buffer",
|
1134
|
+
"patch_method": "propagate_keep_select"
|
1135
|
+
},
|
1136
|
+
{
|
1137
|
+
"class_name": "IO::Buffer",
|
1138
|
+
"instance_method": true,
|
1139
|
+
"method_visibility": "public",
|
1140
|
+
"method_name": "slice",
|
1141
|
+
"source": "O",
|
1142
|
+
"target": "R",
|
1143
|
+
"action": "CUSTOM",
|
1144
|
+
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Buffer",
|
1145
|
+
"patch_method": "propagate_keep_select"
|
1146
|
+
},
|
1147
|
+
{
|
1148
|
+
"class_name": "IO::Buffer",
|
1149
|
+
"instance_method": true,
|
1150
|
+
"method_visibility": "public",
|
1151
|
+
"method_name": "set_string",
|
1152
|
+
"source":"P0,O",
|
1153
|
+
"target":"O",
|
1154
|
+
"action": "BUFFER",
|
1155
|
+
"patch_method": "propagate_insert"
|
1156
|
+
},
|
1157
|
+
{
|
1158
|
+
"class_name": "IO::Buffer",
|
1159
|
+
"instance_method": false,
|
1160
|
+
"method_visibility": "public",
|
1161
|
+
"method_name": "for",
|
1162
|
+
"source":"P0",
|
1163
|
+
"target":"R",
|
1164
|
+
"action": "KEEP"
|
1165
|
+
},
|
1166
|
+
{
|
1167
|
+
"class_name": "IO::Buffer",
|
1168
|
+
"instance_method": true,
|
1169
|
+
"method_visibility": "public",
|
1170
|
+
"method_name": "copy",
|
1171
|
+
"source":"P0,O",
|
1172
|
+
"target":"O",
|
1173
|
+
"action": "BUFFER",
|
1174
|
+
"patch_method": "buffer_keep_splat"
|
1175
|
+
},
|
1176
|
+
{
|
1177
|
+
"class_name": "IO::Buffer",
|
1178
|
+
"instance_method": true,
|
1179
|
+
"method_visibility": "public",
|
1180
|
+
"method_name": "pread",
|
1181
|
+
"source":"P0,O",
|
1182
|
+
"target":"O",
|
1183
|
+
"action": "BUFFER",
|
1184
|
+
"patch_method": "buffer_keep_splat"
|
1185
|
+
},
|
1115
1186
|
{
|
1116
1187
|
"class_name": "ERB",
|
1117
1188
|
"method_name": "result",
|
@@ -1177,6 +1248,33 @@
|
|
1177
1248
|
"action": "REMOVE",
|
1178
1249
|
"tags":["HTML_ENCODED"],
|
1179
1250
|
"untags":["HTML_DECODED"]
|
1251
|
+
},
|
1252
|
+
{
|
1253
|
+
"class_name": "IO::Buffer",
|
1254
|
+
"instance_method": false,
|
1255
|
+
"method_visibility": "public",
|
1256
|
+
"method_name": "map",
|
1257
|
+
"source": "P0,O",
|
1258
|
+
"target": "R",
|
1259
|
+
"action": "KEEP"
|
1260
|
+
},
|
1261
|
+
{
|
1262
|
+
"class_name": "IO::Buffer",
|
1263
|
+
"method_name": "pwrite",
|
1264
|
+
"instance_method": true,
|
1265
|
+
"method_visibility": "public",
|
1266
|
+
"source": "O",
|
1267
|
+
"target": "P0",
|
1268
|
+
"action": "KEEP"
|
1269
|
+
},
|
1270
|
+
{
|
1271
|
+
"class_name": "IO::Buffer",
|
1272
|
+
"method_name": "write",
|
1273
|
+
"instance_method": true,
|
1274
|
+
"method_visibility": "public",
|
1275
|
+
"source": "O",
|
1276
|
+
"target": "P0",
|
1277
|
+
"action": "KEEP"
|
1180
1278
|
}
|
1181
1279
|
],
|
1182
1280
|
"rules":[
|
@@ -200,92 +200,6 @@
|
|
200
200
|
"method_visibility": "public",
|
201
201
|
"method_name":"exists?",
|
202
202
|
"code": "https://github.com/rails/rails/blob/v6.0.3.4/actionpack/lib/action_dispatch/request/session.rb#L201"
|
203
|
-
},{
|
204
|
-
"class_name": "RSpec::Matchers::BuiltIn::BaseMatcher"
|
205
|
-
},{
|
206
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeAKindOf"
|
207
|
-
},{
|
208
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeAnInstanceOf"
|
209
|
-
},{
|
210
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeBetween"
|
211
|
-
},{
|
212
|
-
"class_name": "RSpec::Matchers::BuiltIn::Be"
|
213
|
-
},{
|
214
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeComparedTo"
|
215
|
-
},{
|
216
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeFalsey"
|
217
|
-
},{
|
218
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeHelpers"
|
219
|
-
},{
|
220
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeNil"
|
221
|
-
},{
|
222
|
-
"class_name": "RSpec::Matchers::BuiltIn::BePredicate"
|
223
|
-
},{
|
224
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeTruthy"
|
225
|
-
},{
|
226
|
-
"class_name": "RSpec::Matchers::BuiltIn::BeWithin"
|
227
|
-
},{
|
228
|
-
"class_name": "RSpec::Matchers::BuiltIn::Change"
|
229
|
-
},{
|
230
|
-
"class_name": "RSpec::Matchers::BuiltIn::ChangeRelatively"
|
231
|
-
},{
|
232
|
-
"class_name": "RSpec::Matchers::BuiltIn::SpecificValuesChange"
|
233
|
-
},{
|
234
|
-
"class_name": "RSpec::Matchers::BuiltIn::Compound"
|
235
|
-
},{
|
236
|
-
"class_name": "RSpec::Matchers::BuiltIn::Compound::And"
|
237
|
-
}, {
|
238
|
-
"class_name": "RSpec::Matchers::BuiltIn::Compound::Or"
|
239
|
-
},{
|
240
|
-
"class_name": "RSpec::Matchers::BuiltIn::ContainExactly"
|
241
|
-
},{
|
242
|
-
"class_name": "RSpec::Matchers::BuiltIn::Cover"
|
243
|
-
},{
|
244
|
-
"class_name": "RSpec::Matchers::BuiltIn::EndWith"
|
245
|
-
},{
|
246
|
-
"class_name": "RSpec::Matchers::BuiltIn::Eq"
|
247
|
-
},{
|
248
|
-
"class_name": "RSpec::Matchers::BuiltIn::Eql"
|
249
|
-
},{
|
250
|
-
"class_name": "RSpec::Matchers::BuiltIn::Equal"
|
251
|
-
},{
|
252
|
-
"class_name": "RSpec::Matchers::BuiltIn::Exist"
|
253
|
-
},{
|
254
|
-
"class_name": "RSpec::Matchers::BuiltIn::Has"
|
255
|
-
},{
|
256
|
-
"class_name": "RSpec::Matchers::BuiltIn::HaveAttributes"
|
257
|
-
},{
|
258
|
-
"class_name": "RSpec::Matchers::BuiltIn::All"
|
259
|
-
},{
|
260
|
-
"class_name": "RSpec::Matchers::BuiltIn::Match"
|
261
|
-
},{
|
262
|
-
"class_name": "RSpec::Matchers::BuiltIn::NegativeOperatorMatcher"
|
263
|
-
},{
|
264
|
-
"class_name": "RSpec::Matchers::BuiltIn::OperatorMatcher"
|
265
|
-
},{
|
266
|
-
"class_name": "RSpec::Matchers::BuiltIn::Output"
|
267
|
-
},{
|
268
|
-
"class_name": "RSpec::Matchers::BuiltIn::PositiveOperatorMatcher"
|
269
|
-
},{
|
270
|
-
"class_name": "RSpec::Matchers::BuiltIn::RaiseError"
|
271
|
-
},{
|
272
|
-
"class_name": "RSpec::Matchers::BuiltIn::RespondTo"
|
273
|
-
},{
|
274
|
-
"class_name": "RSpec::Matchers::BuiltIn::Satisfy"
|
275
|
-
},{
|
276
|
-
"class_name": "RSpec::Matchers::BuiltIn::StartWith"
|
277
|
-
},{
|
278
|
-
"class_name": "RSpec::Matchers::BuiltIn::ThrowSymbol"
|
279
|
-
},{
|
280
|
-
"class_name": "RSpec::Matchers::BuiltIn::YieldControl"
|
281
|
-
},{
|
282
|
-
"class_name": "RSpec::Matchers::BuiltIn::YieldSuccessiveArgs"
|
283
|
-
},{
|
284
|
-
"class_name": "RSpec::Matchers::BuiltIn::YieldWithArgs"
|
285
|
-
},{
|
286
|
-
"class_name": "RSpec::Matchers::BuiltIn::YieldWithNoArgs"
|
287
|
-
},{
|
288
|
-
"class_name": "SimpleCov"
|
289
203
|
}
|
290
204
|
]
|
291
205
|
}
|
data/ruby-agent.gemspec
CHANGED
@@ -50,7 +50,7 @@ end
|
|
50
50
|
def self.add_frameworks spec
|
51
51
|
spec.add_development_dependency 'grape', '~> 1.5', '>= 1.5.2'
|
52
52
|
spec.add_development_dependency 'rack-protection', '>= 2'
|
53
|
-
spec.add_development_dependency 'rails', '
|
53
|
+
spec.add_development_dependency 'rails', '~> 7'
|
54
54
|
spec.add_development_dependency 'sinatra', '>= 2'
|
55
55
|
end
|
56
56
|
|
@@ -70,6 +70,7 @@ def self.add_specs spec
|
|
70
70
|
add_tested_gems(spec)
|
71
71
|
|
72
72
|
spec.add_development_dependency 'benchmark-ips'
|
73
|
+
spec.add_development_dependency 'benchmark-memory', '~> 0.1'
|
73
74
|
spec.add_development_dependency 'climate_control' # mock ENV
|
74
75
|
spec.add_development_dependency 'factory_bot'
|
75
76
|
spec.add_development_dependency 'fake_ftp'
|
@@ -89,11 +90,11 @@ end
|
|
89
90
|
|
90
91
|
# Dependencies used to run all of our Rubocop during the linting phase.
|
91
92
|
def self.add_rubocop spec
|
92
|
-
spec.add_development_dependency 'rubocop', '1.
|
93
|
-
spec.add_development_dependency 'rubocop-performance', '1.
|
94
|
-
spec.add_development_dependency 'rubocop-rails', '2.
|
93
|
+
spec.add_development_dependency 'rubocop', '1.26.1'
|
94
|
+
spec.add_development_dependency 'rubocop-performance', '1.13.3'
|
95
|
+
spec.add_development_dependency 'rubocop-rails', '2.14.2'
|
95
96
|
spec.add_development_dependency 'rubocop-rake', '0.6.0'
|
96
|
-
spec.add_development_dependency 'rubocop-rspec', '2.
|
97
|
+
spec.add_development_dependency 'rubocop-rspec', '2.9.0'
|
97
98
|
end
|
98
99
|
|
99
100
|
# Dependencies not mocked out during RSpec that we test real code of, beyond just frameworks.
|
@@ -169,11 +170,11 @@ Gem::Specification.new do |spec|
|
|
169
170
|
|
170
171
|
spec.summary = 'Contrast Security\'s agent for rack-based applications.'
|
171
172
|
spec.description = 'This gem instantiates a Rack middleware for rack-based ' \
|
172
|
-
|
173
|
-
|
173
|
+
'web applications in order to provide Interactive Application Security ' \
|
174
|
+
'Testing and Protection.'
|
174
175
|
spec.homepage = 'https://www.contrastsecurity.com'
|
175
176
|
spec.license = 'CONTRAST SECURITY (see license file)'
|
176
|
-
spec.required_ruby_version = ['>= 2.
|
177
|
+
spec.required_ruby_version = ['>= 2.7.0', '< 3.2.0']
|
177
178
|
|
178
179
|
spec.bindir = 'exe'
|
179
180
|
spec.executables = ['contrast_service']
|
data/service_executables/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.28.
|
1
|
+
2.28.19
|
Binary file
|
Binary file
|