contrast-agent 3.14.0 → 4.2.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_marshal_module/cs__assess_marshal_module.c +18 -15
- data/ext/cs__assess_marshal_module/cs__assess_marshal_module.h +1 -0
- data/ext/cs__assess_string/cs__assess_string.c +24 -25
- data/ext/cs__assess_string/cs__assess_string.h +3 -1
- data/ext/cs__common/cs__common.c +4 -2
- data/ext/cs__common/cs__common.h +1 -1
- data/lib/contrast.rb +1 -1
- data/lib/contrast/agent.rb +4 -12
- data/lib/contrast/agent/assess.rb +1 -0
- data/lib/contrast/agent/assess/contrast_event.rb +143 -79
- data/lib/contrast/agent/assess/events/source_event.rb +1 -1
- data/lib/contrast/agent/assess/finalizers/freeze.rb +3 -1
- data/lib/contrast/agent/assess/finalizers/hash.rb +45 -1
- data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +10 -3
- data/lib/contrast/agent/assess/policy/patcher.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy.rb +0 -2
- data/lib/contrast/agent/assess/policy/policy_node.rb +15 -10
- data/lib/contrast/agent/assess/policy/policy_scanner.rb +19 -3
- data/lib/contrast/agent/assess/policy/preshift.rb +7 -11
- data/lib/contrast/agent/assess/policy/propagation_method.rb +50 -33
- data/lib/contrast/agent/assess/policy/propagator/append.rb +8 -5
- data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/center.rb +9 -5
- data/lib/contrast/agent/assess/policy/propagator/database_write.rb +5 -3
- data/lib/contrast/agent/assess/policy/propagator/insert.rb +7 -4
- data/lib/contrast/agent/assess/policy/propagator/keep.rb +4 -1
- data/lib/contrast/agent/assess/policy/propagator/match_data.rb +4 -7
- data/lib/contrast/agent/assess/policy/propagator/next.rb +7 -5
- data/lib/contrast/agent/assess/policy/propagator/prepend.rb +8 -5
- data/lib/contrast/agent/assess/policy/propagator/remove.rb +8 -4
- data/lib/contrast/agent/assess/policy/propagator/replace.rb +5 -2
- data/lib/contrast/agent/assess/policy/propagator/reverse.rb +7 -5
- data/lib/contrast/agent/assess/policy/propagator/select.rb +13 -7
- data/lib/contrast/agent/assess/policy/propagator/splat.rb +10 -9
- data/lib/contrast/agent/assess/policy/propagator/split.rb +24 -19
- data/lib/contrast/agent/assess/policy/propagator/substitution.rb +47 -31
- data/lib/contrast/agent/assess/policy/propagator/trim.rb +11 -5
- data/lib/contrast/agent/assess/policy/source_method.rb +85 -58
- data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +16 -12
- data/lib/contrast/agent/assess/policy/trigger/xpath.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +76 -28
- data/lib/contrast/agent/assess/policy/trigger_node.rb +38 -43
- data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +2 -1
- data/lib/contrast/agent/assess/properties.rb +2 -0
- data/lib/contrast/agent/assess/property/evented.rb +5 -18
- data/lib/contrast/agent/assess/property/tagged.rb +9 -3
- data/lib/contrast/agent/assess/property/updated.rb +131 -0
- data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +58 -5
- data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +23 -8
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +83 -14
- data/lib/contrast/agent/assess/tag.rb +1 -1
- data/lib/contrast/agent/assess/tracker.rb +66 -0
- data/lib/contrast/agent/at_exit_hook.rb +5 -5
- data/lib/contrast/agent/class_reopener.rb +7 -5
- data/lib/contrast/agent/inventory.rb +15 -0
- data/lib/contrast/agent/inventory/dependencies.rb +50 -0
- data/lib/contrast/agent/inventory/dependency_analysis.rb +37 -0
- data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +104 -0
- data/lib/contrast/agent/inventory/gemfile_digest_cache.rb +38 -0
- data/lib/contrast/agent/middleware.rb +1 -3
- data/lib/contrast/agent/patching/policy/after_load_patch.rb +5 -5
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +20 -20
- data/lib/contrast/agent/patching/policy/module_policy.rb +10 -10
- data/lib/contrast/agent/patching/policy/patch.rb +6 -0
- data/lib/contrast/agent/patching/policy/patcher.rb +13 -22
- data/lib/contrast/agent/patching/policy/policy.rb +17 -6
- data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +3 -5
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +4 -3
- data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +1 -1
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +9 -25
- data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +1 -0
- data/lib/contrast/agent/request.rb +34 -34
- data/lib/contrast/agent/request_handler.rb +1 -1
- data/lib/contrast/agent/response.rb +17 -6
- data/lib/contrast/agent/rewriter.rb +1 -3
- data/lib/contrast/agent/scope.rb +59 -53
- data/lib/contrast/agent/static_analysis.rb +7 -7
- data/lib/contrast/agent/tracepoint_hook.rb +1 -1
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/api/communication/messaging_queue.rb +1 -4
- data/lib/contrast/api/communication/socket_client.rb +36 -1
- data/lib/contrast/api/decorators.rb +3 -0
- data/lib/contrast/api/decorators/address.rb +13 -14
- data/lib/contrast/api/decorators/application_update.rb +2 -4
- data/lib/contrast/api/decorators/library.rb +53 -0
- data/lib/contrast/api/decorators/library_usage_update.rb +30 -0
- data/lib/contrast/api/decorators/message.rb +1 -0
- data/lib/contrast/api/decorators/trace_event.rb +25 -23
- data/lib/contrast/common_agent_configuration.rb +2 -1
- data/lib/contrast/components/agent.rb +6 -5
- data/lib/contrast/components/app_context.rb +49 -38
- data/lib/contrast/components/config.rb +30 -48
- data/lib/contrast/components/contrast_service.rb +9 -9
- data/lib/contrast/components/interface.rb +25 -3
- data/lib/contrast/components/inventory.rb +6 -1
- data/lib/contrast/components/scope.rb +49 -6
- data/lib/contrast/components/settings.rb +23 -23
- data/lib/contrast/config/application_configuration.rb +5 -2
- data/lib/contrast/config/inventory_configuration.rb +2 -2
- data/lib/contrast/config/service_configuration.rb +8 -0
- data/lib/contrast/configuration.rb +88 -47
- data/lib/contrast/extension/assess.rb +0 -2
- data/lib/contrast/extension/assess/array.rb +15 -8
- data/lib/contrast/extension/assess/erb.rb +11 -3
- data/lib/contrast/extension/assess/eval_trigger.rb +6 -6
- data/lib/contrast/extension/assess/exec_trigger.rb +1 -4
- data/lib/contrast/extension/assess/fiber.rb +12 -12
- data/lib/contrast/extension/assess/hash.rb +5 -6
- data/lib/contrast/extension/assess/kernel.rb +28 -23
- data/lib/contrast/extension/assess/marshal.rb +11 -6
- data/lib/contrast/extension/assess/regexp.rb +8 -7
- data/lib/contrast/extension/assess/string.rb +21 -21
- data/lib/contrast/extension/protect/kernel.rb +3 -3
- data/lib/contrast/framework/base_support.rb +1 -1
- data/lib/contrast/framework/manager.rb +3 -3
- data/lib/contrast/framework/rack/patch/session_cookie.rb +22 -28
- data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +13 -13
- data/lib/contrast/framework/rails/patch/assess_configuration.rb +5 -11
- data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +10 -10
- data/lib/contrast/framework/rails/patch/support.rb +1 -1
- data/lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb +11 -11
- data/lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb +12 -12
- data/lib/contrast/framework/rails/rewrite/active_record_named.rb +3 -3
- data/lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb +12 -12
- data/lib/contrast/framework/rails/support.rb +5 -0
- data/lib/contrast/framework/sinatra/patch/base.rb +11 -11
- data/lib/contrast/framework/sinatra/support.rb +4 -4
- data/lib/contrast/logger/application.rb +11 -3
- data/lib/contrast/logger/log.rb +7 -2
- data/lib/contrast/utils/assess/tracking_util.rb +48 -3
- data/lib/contrast/utils/duck_utils.rb +0 -10
- data/lib/contrast/utils/env_configuration_item.rb +2 -1
- data/lib/contrast/utils/invalid_configuration_util.rb +20 -21
- data/lib/contrast/utils/inventory_util.rb +0 -7
- data/lib/contrast/utils/sha256_builder.rb +0 -12
- data/lib/contrast/utils/string_utils.rb +10 -5
- data/resources/assess/policy.json +31 -22
- data/ruby-agent.gemspec +21 -18
- data/service_executables/VERSION +1 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
- metadata +71 -30
- data/lib/contrast/agent/assess/finalizers/finalize.rb +0 -21
- data/lib/contrast/extension/assess/assess_extension.rb +0 -145
- data/lib/contrast/utils/boolean_util.rb +0 -30
- data/lib/contrast/utils/freeze_util.rb +0 -32
- data/lib/contrast/utils/gemfile_reader.rb +0 -193
@@ -1,7 +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
|
+
require 'contrast/agent/assess/tracker'
|
4
5
|
require 'contrast/components/interface'
|
6
|
+
require 'contrast/utils/duck_utils'
|
5
7
|
|
6
8
|
module Contrast
|
7
9
|
module Utils
|
@@ -23,6 +25,16 @@ module Contrast
|
|
23
25
|
_tracked?(obj, 0)
|
24
26
|
end
|
25
27
|
|
28
|
+
# Public interface to our tracking check, isolating the internals
|
29
|
+
# required for recursion.
|
30
|
+
#
|
31
|
+
# @param obj [Object] the thing to check if tracked
|
32
|
+
# @return [Boolean] if the obj, or something in it if a collection, is
|
33
|
+
# tracked.
|
34
|
+
def trackable? obj
|
35
|
+
_trackable?(obj, 0)
|
36
|
+
end
|
37
|
+
|
26
38
|
private
|
27
39
|
|
28
40
|
# Sometimes things are nested inside of each other, such as an Array
|
@@ -49,10 +61,8 @@ module Contrast
|
|
49
61
|
obj.any? do |ele|
|
50
62
|
_tracked?(ele, idx) unless obj == ele
|
51
63
|
end
|
52
|
-
elsif Contrast::Utils::DuckUtils.quacks_to?(obj, :cs__tracked?)
|
53
|
-
obj.cs__tracked?
|
54
64
|
else
|
55
|
-
|
65
|
+
Contrast::Agent::Assess::Tracker.tracked?(obj)
|
56
66
|
end
|
57
67
|
rescue StandardError => e
|
58
68
|
# This is used to ask if a ton of objects are tracked. They may not
|
@@ -61,6 +71,41 @@ module Contrast
|
|
61
71
|
logger.warn('Failed to determine tracking', e, module: obj.cs__class)
|
62
72
|
false
|
63
73
|
end
|
74
|
+
|
75
|
+
# Sometimes things are nested inside of each other, such as an Array
|
76
|
+
# holding a Hash, holding that Array. In those cases, rather than
|
77
|
+
# entering an infinite loop, we'll break out.
|
78
|
+
# Right now, that level of nesting has been arbitrarily set to 10.
|
79
|
+
#
|
80
|
+
# @param obj [Object] the thing to check if trackable
|
81
|
+
# @param idx [Integer] the number of levels nested we've gone
|
82
|
+
# @return [Boolean] if the obj, or something in it if a collection, is
|
83
|
+
# trackable.
|
84
|
+
def _trackable? obj, idx
|
85
|
+
return false if obj.nil?
|
86
|
+
return false if idx > 10
|
87
|
+
|
88
|
+
idx += 1
|
89
|
+
if Contrast::Utils::DuckUtils.iterable_hash?(obj)
|
90
|
+
obj.each_pair do |k, v|
|
91
|
+
return true if _trackable?(k, idx)
|
92
|
+
return true if _trackable?(v, idx)
|
93
|
+
end
|
94
|
+
false
|
95
|
+
elsif Contrast::Utils::DuckUtils.iterable_enumerable?(obj)
|
96
|
+
obj.any? do |ele|
|
97
|
+
_trackable?(ele, idx) unless obj == ele
|
98
|
+
end
|
99
|
+
else
|
100
|
+
Contrast::Agent::Assess::Tracker.trackable?(obj)
|
101
|
+
end
|
102
|
+
rescue StandardError => e
|
103
|
+
# This is used to ask if a ton of objects are tracked. They may not
|
104
|
+
# all be iterable. Bad things could happen in some cases, like when
|
105
|
+
# checking a closed statement for SQL injection trigger events
|
106
|
+
logger.warn('Failed to determine trackable', e, module: obj.cs__class)
|
107
|
+
false
|
108
|
+
end
|
64
109
|
end
|
65
110
|
end
|
66
111
|
end
|
@@ -62,16 +62,6 @@ module Contrast
|
|
62
62
|
# otherwise, don't risk it
|
63
63
|
false
|
64
64
|
end
|
65
|
-
|
66
|
-
# This method will return true if the object being checked has been patched
|
67
|
-
# to have the cs__properties field. We check the cs__tracked? method since it
|
68
|
-
# is side effect free (ie doesn't cause the properties object to be created).
|
69
|
-
def trackable? object
|
70
|
-
return true if object.cs__respond_to?(:cs__tracked?)
|
71
|
-
return false unless object.is_a?(Delegator)
|
72
|
-
|
73
|
-
object.cs__delegator_respond_to?(:cs__tracked?)
|
74
|
-
end
|
75
65
|
end
|
76
66
|
end
|
77
67
|
end
|
@@ -10,10 +10,11 @@ module Contrast
|
|
10
10
|
END_UNDERSCORE = /(_+)$/.cs__freeze
|
11
11
|
REPEATING_UNDERSCORE = /_{3,}/.cs__freeze
|
12
12
|
|
13
|
-
attr_reader :value, :dot_path_array
|
13
|
+
attr_reader :value, :dot_path_array, :key
|
14
14
|
|
15
15
|
def initialize key, value
|
16
16
|
key = EnvConfigurationItem.resolve_corrected_path(key)
|
17
|
+
@key = key
|
17
18
|
@dot_path_array = key.downcase.split(Contrast::Utils::ObjectShare::DOUBLE_UNDERSCORE)
|
18
19
|
@value = value
|
19
20
|
|
@@ -1,6 +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
|
+
require 'contrast/agent/assess/policy/trigger_method'
|
4
5
|
require 'contrast/components/interface'
|
5
6
|
|
6
7
|
module Contrast
|
@@ -9,7 +10,7 @@ module Contrast
|
|
9
10
|
# customer applications, as determined by Configuration Rules at runtime.
|
10
11
|
module InvalidConfigurationUtil
|
11
12
|
include Contrast::Components::Interface
|
12
|
-
access_component :analysis, :app_context, :logging
|
13
|
+
access_component :analysis, :app_context, :logging, :scope
|
13
14
|
|
14
15
|
CS__PATH = 'path'
|
15
16
|
CS__SESSION_ID = 'sessionId'
|
@@ -23,28 +24,26 @@ module Contrast
|
|
23
24
|
# @param call_location [Thread::Backtrace::Location] the location where
|
24
25
|
# the bad configuration was set
|
25
26
|
def cs__report_finding rule_id, user_provided_options, call_location
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
with_contrast_scope do
|
28
|
+
finding = Contrast::Api::Dtm::Finding.new
|
29
|
+
finding.rule_id = rule_id
|
30
|
+
path = call_location.path
|
31
|
+
# just get the file name, not the full path
|
32
|
+
path = path.split(Contrast::Utils::ObjectShare::SLASH).last
|
33
|
+
session_id = user_provided_options[:key].to_s if user_provided_options
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
finding.version = Contrast::Agent::Assess::Policy::TriggerMethod::CURRENT_FINDING_VERSION
|
36
|
+
finding.properties[CS__SESSION_ID] = Contrast::Utils::StringUtils.force_utf8(session_id)
|
37
|
+
finding.properties[CS__PATH] = Contrast::Utils::StringUtils.force_utf8(path)
|
38
|
+
file_path = call_location.absolute_path
|
39
|
+
snippet = file_snippet(file_path, call_location)
|
40
|
+
finding.properties[CS__SNIPPET] = Contrast::Utils::StringUtils.force_utf8(snippet)
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
activity.findings << finding
|
46
|
-
|
47
|
-
Contrast::Agent.messaging_queue.send_event_eventually(activity)
|
42
|
+
hash = Contrast::Utils::HashDigest.generate_config_hash(finding)
|
43
|
+
finding.hash_code = Contrast::Utils::StringUtils.force_utf8(hash)
|
44
|
+
finding.preflight = Contrast::Utils::PreflightUtil.create_preflight(finding)
|
45
|
+
Contrast::Agent::Assess::Policy::TriggerMethod.report_finding(finding)
|
46
|
+
end
|
48
47
|
rescue StandardError => e
|
49
48
|
logger.error('Unable to build a finding', e, rule: rule_id)
|
50
49
|
end
|
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
require 'contrast/utils/timer'
|
5
5
|
require 'contrast/utils/object_share'
|
6
|
-
require 'contrast/utils/gemfile_reader'
|
7
6
|
require 'contrast/components/interface'
|
8
7
|
|
9
8
|
module Contrast
|
@@ -25,12 +24,6 @@ module Contrast
|
|
25
24
|
DEFAULT = 'default'
|
26
25
|
LOCALHOST = 'localhost'
|
27
26
|
|
28
|
-
def self.inventory_class class_path
|
29
|
-
Contrast::Utils::GemfileReader.instance.map_class(class_path)
|
30
|
-
rescue StandardError => e
|
31
|
-
logger.error('Unable to inventory module', e, path: class_path)
|
32
|
-
end
|
33
|
-
|
34
27
|
def self.active_record_config
|
35
28
|
return @_active_record_config if instance_variable_defined?(:@_active_record_config)
|
36
29
|
|
@@ -52,18 +52,6 @@ module Contrast
|
|
52
52
|
parent_dir = File.dirname(gems_dir)
|
53
53
|
File.join(parent_dir, Contrast::Utils::ObjectShare::CACHE)
|
54
54
|
end
|
55
|
-
|
56
|
-
def self.files path
|
57
|
-
instance.files(path)
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.sha256 path
|
61
|
-
instance.sha256(path)
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.build_from_spec spec
|
65
|
-
instance.build_from_spec(spec)
|
66
|
-
end
|
67
55
|
end
|
68
56
|
end
|
69
57
|
end
|
@@ -11,7 +11,7 @@ module Contrast
|
|
11
11
|
access_component :logging
|
12
12
|
|
13
13
|
UTF8 = 'utf-8'
|
14
|
-
HTTP_PREFIX = '
|
14
|
+
HTTP_PREFIX = 'HTTP_'
|
15
15
|
|
16
16
|
# Convenience method. We assume that we're working on Strings or tags
|
17
17
|
# String representations of things. To that end, we'll to_s anything
|
@@ -69,6 +69,10 @@ module Contrast
|
|
69
69
|
# Given a string return a normalized version of that string.
|
70
70
|
# Keys are memoized so that the normalization process doesn't need
|
71
71
|
# to happen every time.
|
72
|
+
#
|
73
|
+
# @param str [String] the String to normalize
|
74
|
+
# @return [String] a copy of the given String, upper cased, trimmed,
|
75
|
+
# dashes replaced with underscore, and HTTP trimmed
|
72
76
|
def self.normalized_key str
|
73
77
|
return nil unless str
|
74
78
|
|
@@ -77,10 +81,11 @@ module Contrast
|
|
77
81
|
if @_normalized_keys.key?(str)
|
78
82
|
@_normalized_keys[str]
|
79
83
|
else
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
upped = str.upcase
|
85
|
+
stripped = upped.strip! || upped
|
86
|
+
trimmed = stripped.tr!('-', '_') || stripped
|
87
|
+
cut = trimmed.start_with?(HTTP_PREFIX) ? trimmed[5..-1] : trimmed
|
88
|
+
@_normalized_keys[str] = cut
|
84
89
|
end
|
85
90
|
end
|
86
91
|
end
|
@@ -1,14 +1,4 @@
|
|
1
1
|
{
|
2
|
-
"tracked_classes": [
|
3
|
-
"ActionDispatch::Http::UploadedFile",
|
4
|
-
"Fiber",
|
5
|
-
"Symbol",
|
6
|
-
"Pathname",
|
7
|
-
"File",
|
8
|
-
"MatchData",
|
9
|
-
"URI::Generic",
|
10
|
-
"Rack::File::Iterator"
|
11
|
-
],
|
12
2
|
"sources":[
|
13
3
|
{
|
14
4
|
"class_name":"Rack::Request",
|
@@ -285,7 +275,7 @@
|
|
285
275
|
"instance_method": true,
|
286
276
|
"method_visibility": "public",
|
287
277
|
"method_name":"insert",
|
288
|
-
"source":"P1",
|
278
|
+
"source":"O,P1",
|
289
279
|
"target":"O",
|
290
280
|
"action":"INSERT"
|
291
281
|
}, {
|
@@ -624,7 +614,6 @@
|
|
624
614
|
"action":"CUSTOM",
|
625
615
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::MatchData",
|
626
616
|
"patch_method": "captures_tagger"
|
627
|
-
|
628
617
|
}, {
|
629
618
|
"class_name":"MatchData",
|
630
619
|
"instance_method": true,
|
@@ -650,7 +639,9 @@
|
|
650
639
|
"method_name": "gsub",
|
651
640
|
"action": "CUSTOM",
|
652
641
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Substitution",
|
653
|
-
"patch_method": "gsub_tagger"
|
642
|
+
"patch_method": "gsub_tagger",
|
643
|
+
"source": "O,P",
|
644
|
+
"target": "R"
|
654
645
|
}, {
|
655
646
|
"class_name": "String",
|
656
647
|
"instance_method": true,
|
@@ -658,7 +649,9 @@
|
|
658
649
|
"method_name": "gsub!",
|
659
650
|
"action": "CUSTOM",
|
660
651
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Substitution",
|
661
|
-
"patch_method": "gsub_tagger"
|
652
|
+
"patch_method": "gsub_tagger",
|
653
|
+
"source": "O,P",
|
654
|
+
"target": "O"
|
662
655
|
}, {
|
663
656
|
"class_name": "String",
|
664
657
|
"instance_method": true,
|
@@ -666,7 +659,9 @@
|
|
666
659
|
"method_name": "sub",
|
667
660
|
"action": "CUSTOM",
|
668
661
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Substitution",
|
669
|
-
"patch_method": "sub_tagger"
|
662
|
+
"patch_method": "sub_tagger",
|
663
|
+
"source": "O,P",
|
664
|
+
"target": "R"
|
670
665
|
}, {
|
671
666
|
"class_name": "String",
|
672
667
|
"instance_method": true,
|
@@ -674,7 +669,9 @@
|
|
674
669
|
"method_name": "sub!",
|
675
670
|
"action": "CUSTOM",
|
676
671
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Substitution",
|
677
|
-
"patch_method": "sub_tagger"
|
672
|
+
"patch_method": "sub_tagger",
|
673
|
+
"source": "O,P",
|
674
|
+
"target": "O"
|
678
675
|
}, {
|
679
676
|
"class_name": "String",
|
680
677
|
"instance_method": true,
|
@@ -682,7 +679,9 @@
|
|
682
679
|
"method_name": "tr",
|
683
680
|
"action": "CUSTOM",
|
684
681
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Trim",
|
685
|
-
"patch_method": "tr_tagger"
|
682
|
+
"patch_method": "tr_tagger",
|
683
|
+
"source": "O,P",
|
684
|
+
"target": "R"
|
686
685
|
}, {
|
687
686
|
"class_name": "String",
|
688
687
|
"instance_method": true,
|
@@ -690,7 +689,9 @@
|
|
690
689
|
"method_name": "tr!",
|
691
690
|
"action": "CUSTOM",
|
692
691
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Trim",
|
693
|
-
"patch_method": "tr_tagger"
|
692
|
+
"patch_method": "tr_tagger",
|
693
|
+
"source": "O,P",
|
694
|
+
"target": "O"
|
694
695
|
}, {
|
695
696
|
"class_name": "String",
|
696
697
|
"instance_method": true,
|
@@ -698,7 +699,9 @@
|
|
698
699
|
"method_name": "tr_s",
|
699
700
|
"action": "CUSTOM",
|
700
701
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Trim",
|
701
|
-
"patch_method": "tr_s_tagger"
|
702
|
+
"patch_method": "tr_s_tagger",
|
703
|
+
"source": "O,P",
|
704
|
+
"target": "R"
|
702
705
|
}, {
|
703
706
|
"class_name": "String",
|
704
707
|
"instance_method": true,
|
@@ -706,7 +709,9 @@
|
|
706
709
|
"method_name": "tr_s!",
|
707
710
|
"action": "CUSTOM",
|
708
711
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Trim",
|
709
|
-
"patch_method": "tr_s_tagger"
|
712
|
+
"patch_method": "tr_s_tagger",
|
713
|
+
"source": "O,P",
|
714
|
+
"target": "O"
|
710
715
|
}, {
|
711
716
|
"class_name": "String",
|
712
717
|
"instance_method": true,
|
@@ -714,7 +719,9 @@
|
|
714
719
|
"method_name": "[]",
|
715
720
|
"action": "CUSTOM",
|
716
721
|
"patch_class": "Contrast::Agent::Assess::Policy::Propagator::Select",
|
717
|
-
"patch_method": "select_tagger"
|
722
|
+
"patch_method": "select_tagger",
|
723
|
+
"source": "O",
|
724
|
+
"target": "R"
|
718
725
|
}, {
|
719
726
|
"class_name":"CGI::Util",
|
720
727
|
"method_name":"escapeHTML",
|
@@ -976,7 +983,9 @@
|
|
976
983
|
"method_name": "sprintf",
|
977
984
|
"action": "CUSTOM",
|
978
985
|
"patch_class": "Contrast::Extension::Assess::KernelPropagator",
|
979
|
-
"patch_method": "sprintf_tagger"
|
986
|
+
"patch_method": "sprintf_tagger",
|
987
|
+
"source": "O,P",
|
988
|
+
"target": "R"
|
980
989
|
}, {
|
981
990
|
"class_name":"ActiveRecord::ConnectionAdapters::Quoting",
|
982
991
|
"instance_method": true,
|
data/ruby-agent.gemspec
CHANGED
@@ -2,20 +2,6 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require_relative './lib/contrast/agent/version'
|
5
|
-
require 'bundler'
|
6
|
-
# https://github.com/grpc/grpc/issues/21514#issuecomment-581417788
|
7
|
-
module BundlerHack
|
8
|
-
def __materialize__
|
9
|
-
if name == 'google-protobuf'
|
10
|
-
Bundler.settings.temporary(force_ruby_platform: true) do
|
11
|
-
super
|
12
|
-
end
|
13
|
-
else
|
14
|
-
super
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
Bundler::LazySpecification.prepend(BundlerHack)
|
19
5
|
|
20
6
|
lib = File.expand_path('lib', __dir__)
|
21
7
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -28,6 +14,7 @@ def self.add_authors spec
|
|
28
14
|
donald.propst@contrastsecurity.com
|
29
15
|
alex.macdonald@contrastsecurity.com
|
30
16
|
mark.petersen@contrastsecurity.com
|
17
|
+
joshua.reed@contrastsecurity.com
|
31
18
|
]
|
32
19
|
end
|
33
20
|
|
@@ -36,11 +23,13 @@ def self.add_dev_dependencies spec
|
|
36
23
|
spec.add_development_dependency 'amazing_print'
|
37
24
|
spec.add_development_dependency 'bundler'
|
38
25
|
spec.add_development_dependency 'climate_control' # mock ENV
|
26
|
+
spec.add_development_dependency 'debase'
|
39
27
|
spec.add_development_dependency 'debride'
|
40
28
|
spec.add_development_dependency 'execjs'
|
41
29
|
spec.add_development_dependency 'factory_bot'
|
42
30
|
spec.add_development_dependency 'fake_ftp'
|
43
31
|
spec.add_development_dependency 'fasterer'
|
32
|
+
spec.add_development_dependency 'flay'
|
44
33
|
spec.add_development_dependency 'openssl'
|
45
34
|
spec.add_development_dependency 'parser', '~> 2.6'
|
46
35
|
spec.add_development_dependency 'pry'
|
@@ -50,9 +39,10 @@ def self.add_dev_dependencies spec
|
|
50
39
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
51
40
|
spec.add_development_dependency 'rspec-benchmark'
|
52
41
|
spec.add_development_dependency 'rspec_junit_formatter', '0.3.0'
|
53
|
-
spec.add_development_dependency 'rubocop', '0.
|
54
|
-
spec.add_development_dependency 'rubocop-performance', '1.
|
55
|
-
spec.add_development_dependency 'rubocop-rspec', '1.
|
42
|
+
spec.add_development_dependency 'rubocop', '0.93.1'
|
43
|
+
spec.add_development_dependency 'rubocop-performance', '1.8.1'
|
44
|
+
spec.add_development_dependency 'rubocop-rspec', '1.43.2'
|
45
|
+
spec.add_development_dependency 'ruby-debug-ide'
|
56
46
|
spec.add_development_dependency 'simplecov', '~> 0.18'
|
57
47
|
spec.add_development_dependency 'sinatra', '>= 2'
|
58
48
|
spec.add_development_dependency 'sqlite3', '1.3.9'
|
@@ -71,7 +61,7 @@ def self.add_dependencies spec
|
|
71
61
|
spec.add_dependency 'ougai', '~> 1.8'
|
72
62
|
spec.add_dependency 'parser', '~> 2.6'
|
73
63
|
spec.add_dependency 'protobuf', '~> 3.10'
|
74
|
-
spec.add_dependency 'rack', '
|
64
|
+
spec.add_dependency 'rack', '~> 2.0'
|
75
65
|
end
|
76
66
|
|
77
67
|
# Enumerate the files required to build the Agent.
|
@@ -95,6 +85,19 @@ def self.add_files spec
|
|
95
85
|
spec.files += Dir['service_executables/**/*']
|
96
86
|
spec.files += Dir['funchook/**/*']
|
97
87
|
spec.files += Dir['shared_libraries/**/*']
|
88
|
+
|
89
|
+
# Clean up compiled funchook files that may have been generated during
|
90
|
+
# testing. Only a concern locally, but better than leaving it to chance.
|
91
|
+
spec.files.delete_if do |file|
|
92
|
+
file.end_with?('ext/libfunchook.dylib',
|
93
|
+
'ext/libfunchook.so',
|
94
|
+
'ext/funchook.h',
|
95
|
+
'shared_libraries/libfunchook.dylib',
|
96
|
+
'shared_libraries/libfunchook.so',
|
97
|
+
'shared_libraries/funchook.h',
|
98
|
+
'funchook/src/libfunchook.dylib',
|
99
|
+
'funchook/src/libfunchook.so')
|
100
|
+
end
|
98
101
|
end
|
99
102
|
|
100
103
|
def self.add_metadata spec
|