contrast-agent 4.7.0 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -1
  3. data/.rspec +0 -1
  4. data/.rspec_parallel +6 -0
  5. data/.simplecov +1 -0
  6. data/ext/cs__contrast_patch/cs__contrast_patch.c +0 -1
  7. data/ext/cs__contrast_patch/cs__contrast_patch.h +0 -2
  8. data/lib/contrast/agent/assess/contrast_event.rb +1 -5
  9. data/lib/contrast/agent/assess/finalizers/hash.rb +2 -5
  10. data/lib/contrast/agent/assess/policy/patcher.rb +5 -4
  11. data/lib/contrast/agent/assess/policy/policy.rb +1 -1
  12. data/lib/contrast/agent/assess/policy/policy_scanner.rb +2 -6
  13. data/lib/contrast/agent/assess/policy/preshift.rb +11 -8
  14. data/lib/contrast/agent/assess/policy/propagation_method.rb +102 -59
  15. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +2 -7
  16. data/lib/contrast/agent/assess/policy/propagator/match_data.rb +31 -11
  17. data/lib/contrast/agent/assess/policy/propagator/rack_protection.rb +73 -0
  18. data/lib/contrast/agent/assess/policy/propagator/split.rb +10 -6
  19. data/lib/contrast/agent/assess/policy/propagator/substitution.rb +3 -3
  20. data/lib/contrast/agent/assess/policy/propagator.rb +1 -0
  21. data/lib/contrast/agent/assess/policy/rewriter_patch.rb +6 -7
  22. data/lib/contrast/agent/assess/policy/source_method.rb +18 -22
  23. data/lib/contrast/agent/assess/policy/trigger/xpath.rb +0 -4
  24. data/lib/contrast/agent/assess/policy/trigger_method.rb +61 -86
  25. data/lib/contrast/agent/assess/policy/trigger_node.rb +1 -1
  26. data/lib/contrast/agent/assess/property/evented.rb +2 -1
  27. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +3 -4
  28. data/lib/contrast/agent/at_exit_hook.rb +3 -3
  29. data/lib/contrast/agent/class_reopener.rb +6 -5
  30. data/lib/contrast/agent/disable_reaction.rb +4 -5
  31. data/lib/contrast/agent/exclusion_matcher.rb +2 -7
  32. data/lib/contrast/agent/inventory/database_config.rb +117 -0
  33. data/lib/contrast/agent/inventory/dependency_analysis.rb +2 -6
  34. data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +8 -9
  35. data/lib/contrast/agent/inventory/policy/datastores.rb +5 -6
  36. data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
  37. data/lib/contrast/agent/middleware.rb +15 -13
  38. data/lib/contrast/agent/patching/policy/after_load_patch.rb +6 -3
  39. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +21 -16
  40. data/lib/contrast/agent/patching/policy/module_policy.rb +2 -4
  41. data/lib/contrast/agent/patching/policy/patch.rb +13 -8
  42. data/lib/contrast/agent/patching/policy/patch_status.rb +3 -7
  43. data/lib/contrast/agent/patching/policy/patcher.rb +14 -14
  44. data/lib/contrast/agent/patching/policy/policy.rb +2 -4
  45. data/lib/contrast/agent/patching/policy/policy_node.rb +2 -3
  46. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +1 -1
  47. data/lib/contrast/agent/protect/policy/policy.rb +1 -1
  48. data/lib/contrast/agent/protect/policy/rule_applicator.rb +3 -5
  49. data/lib/contrast/agent/protect/rule/base.rb +10 -10
  50. data/lib/contrast/agent/protect/rule/cmd_injection.rb +4 -5
  51. data/lib/contrast/agent/protect/rule/no_sqli.rb +7 -53
  52. data/lib/contrast/agent/protect/rule/path_traversal.rb +1 -5
  53. data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +137 -0
  54. data/lib/contrast/agent/protect/rule/sqli.rb +7 -70
  55. data/lib/contrast/agent/reaction_processor.rb +3 -4
  56. data/lib/contrast/agent/request.rb +9 -5
  57. data/lib/contrast/agent/request_context.rb +28 -31
  58. data/lib/contrast/agent/request_handler.rb +5 -3
  59. data/lib/contrast/agent/response.rb +2 -3
  60. data/lib/contrast/agent/rewriter.rb +4 -3
  61. data/lib/contrast/agent/rule_set.rb +5 -4
  62. data/lib/contrast/agent/service_heartbeat.rb +2 -3
  63. data/lib/contrast/agent/static_analysis.rb +7 -6
  64. data/lib/contrast/agent/thread.rb +2 -4
  65. data/lib/contrast/agent/thread_watcher.rb +3 -4
  66. data/lib/contrast/agent/tracepoint_hook.rb +10 -5
  67. data/lib/contrast/agent/version.rb +1 -1
  68. data/lib/contrast/api/communication/messaging_queue.rb +16 -11
  69. data/lib/contrast/api/communication/response_processor.rb +11 -11
  70. data/lib/contrast/api/communication/service_lifecycle.rb +9 -5
  71. data/lib/contrast/api/communication/socket_client.rb +18 -14
  72. data/lib/contrast/api/communication/speedracer.rb +5 -6
  73. data/lib/contrast/api/decorators/address.rb +2 -3
  74. data/lib/contrast/api/decorators/agent_startup.rb +7 -9
  75. data/lib/contrast/api/decorators/application_startup.rb +9 -10
  76. data/lib/contrast/api/decorators/application_update.rb +0 -4
  77. data/lib/contrast/api/decorators/http_request.rb +3 -7
  78. data/lib/contrast/api/decorators/instrumentation_mode.rb +3 -5
  79. data/lib/contrast/api/decorators/message.rb +7 -7
  80. data/lib/contrast/api/decorators/route_coverage.rb +24 -1
  81. data/lib/contrast/api/decorators/trace_event_object.rb +2 -3
  82. data/lib/contrast/components/agent.rb +13 -15
  83. data/lib/contrast/components/app_context.rb +7 -11
  84. data/lib/contrast/components/assess.rb +19 -16
  85. data/lib/contrast/components/base.rb +40 -0
  86. data/lib/contrast/components/config.rb +1 -2
  87. data/lib/contrast/components/contrast_service.rb +8 -11
  88. data/lib/contrast/components/heap_dump.rb +5 -4
  89. data/lib/contrast/components/inventory.rb +2 -7
  90. data/lib/contrast/components/logger.rb +14 -10
  91. data/lib/contrast/components/protect.rb +10 -13
  92. data/lib/contrast/components/sampling.rb +5 -5
  93. data/lib/contrast/components/scope.rb +9 -32
  94. data/lib/contrast/components/settings.rb +1 -5
  95. data/lib/contrast/config/base_configuration.rb +14 -6
  96. data/lib/contrast/configuration.rb +22 -19
  97. data/lib/contrast/extension/assess/array.rb +3 -15
  98. data/lib/contrast/extension/assess/eval_trigger.rb +2 -23
  99. data/lib/contrast/extension/assess/fiber.rb +6 -16
  100. data/lib/contrast/extension/assess/hash.rb +3 -13
  101. data/lib/contrast/extension/assess/kernel.rb +3 -14
  102. data/lib/contrast/extension/assess/marshal.rb +6 -14
  103. data/lib/contrast/extension/assess/regexp.rb +5 -15
  104. data/lib/contrast/extension/assess/string.rb +6 -31
  105. data/lib/contrast/extension/extension.rb +61 -0
  106. data/lib/contrast/extension/kernel.rb +2 -4
  107. data/lib/contrast/extension/protect/kernel.rb +0 -15
  108. data/lib/contrast/framework/grape/support.rb +174 -0
  109. data/lib/contrast/framework/manager.rb +44 -9
  110. data/lib/contrast/framework/rack/patch/session_cookie.rb +6 -6
  111. data/lib/contrast/framework/rack/support.rb +1 -1
  112. data/lib/contrast/framework/rails/patch/assess_configuration.rb +5 -8
  113. data/lib/contrast/framework/rails/patch/support.rb +44 -37
  114. data/lib/contrast/framework/rails/railtie.rb +34 -0
  115. data/lib/contrast/framework/rails/rewrite/active_record_named.rb +4 -4
  116. data/lib/contrast/framework/rails/support.rb +60 -13
  117. data/lib/contrast/framework/sinatra/support.rb +1 -1
  118. data/lib/contrast/funchook/funchook.rb +4 -3
  119. data/lib/contrast/logger/application.rb +1 -6
  120. data/lib/contrast/logger/log.rb +103 -13
  121. data/lib/contrast/logger/request.rb +0 -4
  122. data/lib/contrast/tasks/config.rb +0 -1
  123. data/lib/contrast/tasks/service.rb +1 -6
  124. data/lib/contrast/utils/assess/sampling_util.rb +2 -3
  125. data/lib/contrast/utils/assess/tracking_util.rb +2 -4
  126. data/lib/contrast/utils/heap_dump_util.rb +5 -3
  127. data/lib/contrast/utils/invalid_configuration_util.rb +4 -3
  128. data/lib/contrast/utils/io_util.rb +3 -5
  129. data/lib/contrast/utils/job_servers_running.rb +4 -3
  130. data/lib/contrast/utils/os.rb +2 -3
  131. data/lib/contrast/utils/ruby_ast_rewriter.rb +16 -13
  132. data/lib/contrast/utils/string_utils.rb +2 -3
  133. data/lib/contrast/utils/tag_util.rb +26 -19
  134. data/lib/contrast.rb +24 -14
  135. data/resources/assess/policy.json +252 -2
  136. data/resources/deadzone/policy.json +10 -0
  137. data/ruby-agent.gemspec +14 -3
  138. data/service_executables/VERSION +1 -1
  139. data/service_executables/linux/contrast-service +0 -0
  140. data/service_executables/mac/contrast-service +0 -0
  141. metadata +104 -24
  142. data/lib/contrast/agent/railtie.rb +0 -31
  143. data/lib/contrast/components/interface.rb +0 -196
  144. data/lib/contrast/delegators/input_analysis.rb +0 -12
  145. data/lib/contrast/utils/inventory_util.rb +0 -114
@@ -22,9 +22,7 @@ module Contrast
22
22
 
23
23
  # This is a class.
24
24
  class Interface
25
- include Contrast::Components::ComponentBase
26
- include Contrast::Components::Interface
27
- access_component :config
25
+ extend Contrast::Components::Config
28
26
 
29
27
  # tainted_columns are database columns that receive unsanitized input.
30
28
  attr_reader :tainted_columns # This can probably go into assess_state?
@@ -76,8 +74,6 @@ module Contrast
76
74
  Contrast::Agent::Protect::Rule::Xxe.new
77
75
  end
78
76
  end
79
-
80
- COMPONENT_INTERFACE = Interface.new
81
77
  end
82
78
  end
83
79
  end
@@ -12,7 +12,7 @@ module Contrast
12
12
  class BaseConfiguration
13
13
  extend Forwardable
14
14
 
15
- BOOLEANS = [true, false].cs__freeze
15
+ STRING_BOOLEANS = %w[false true].cs__freeze
16
16
 
17
17
  attr_reader :map
18
18
 
@@ -73,8 +73,18 @@ module Contrast
73
73
  spec_value.new(user_provided_value)
74
74
  elsif spec_value.is_a?(Contrast::Config::DefaultValue) && user_provided_value == EMPTY_VALUE
75
75
  spec_value.value
76
- elsif BOOLEANS.include?(user_provided_value)
77
- user_provided_value.to_s
76
+ elsif user_provided_value.cs__is_a?(String)
77
+ value = user_provided_value.downcase
78
+ # converts string values to 'true' => true or 'false' => false
79
+ case value
80
+ when STRING_BOOLEANS[1]
81
+ true
82
+ when STRING_BOOLEANS[0]
83
+ false
84
+ else
85
+ # returns non boolean string values
86
+ user_provided_value
87
+ end
78
88
  else
79
89
  user_provided_value
80
90
  end
@@ -95,9 +105,7 @@ module Contrast
95
105
 
96
106
  def define_setter str_key
97
107
  define_singleton_method "#{ str_key }=".to_sym do |new_value|
98
- boolean_value = new_value == true
99
- boolean_value ||= new_value == false
100
- @map[str_key] = boolean_value ? new_value.to_s : new_value
108
+ @map[str_key] = new_value
101
109
  end
102
110
  end
103
111
  end
@@ -6,7 +6,7 @@ require 'fileutils'
6
6
 
7
7
  require 'contrast/config'
8
8
  require 'contrast/utils/object_share'
9
- require 'contrast/components/interface'
9
+ require 'contrast/components/scope'
10
10
 
11
11
  module Contrast
12
12
  # This is how we read in the local settings for the Agent, both ENV/ CMD line
@@ -15,9 +15,8 @@ module Contrast
15
15
  class Configuration
16
16
  extend Forwardable
17
17
 
18
- include Contrast::Components::Interface
19
-
20
- access_component :scope
18
+ include Contrast::Components::Scope::InstanceMethods
19
+ extend Contrast::Components::Scope::InstanceMethods
21
20
 
22
21
  def_delegator :root, :assign_value_to_path_array
23
22
 
@@ -49,9 +48,7 @@ module Contrast
49
48
  # in an infinite loop on the to_sym method used later.
50
49
  def method_missing symbol, *args
51
50
  with_contrast_scope do
52
- root.public_send(symbol, *args)
53
- rescue NoMethodError => _e
54
- super
51
+ root.public_send(symbol, *args) if root.cs__respond_to?(symbol)
55
52
  end
56
53
  end
57
54
 
@@ -102,8 +99,7 @@ module Contrast
102
99
  {}
103
100
  end
104
101
 
105
- # We're updating properties loaded from the configuration
106
- # files to match the new agreed upon standard configuration
102
+ # We're updating properties loaded from the configuration files to match the new agreed upon standard configuration
107
103
  # names, so that one file works for all agents
108
104
  def update_prop_keys config
109
105
  CONVERSION.each_pair do |old_method, new_method|
@@ -121,16 +117,7 @@ module Contrast
121
117
  # We changed the seconds values into ms values. Multiply them accordingly
122
118
  old_value = old_value.to_i * 1000 if new_method.end_with?(MILLISECOND_MARKER)
123
119
  new_value = config
124
- end_idx = new_keys.length - 1
125
- new_keys.each_with_index do |new_key, index|
126
- if index == end_idx
127
- new_value[new_key] = old_value if new_value[new_key].nil?
128
- else
129
- new_value = {} if new_value.nil?
130
- new_value[new_key] = {} if new_value[new_key].nil?
131
- new_value = new_value[new_key]
132
- end
133
- end
120
+ replace_props(new_keys, new_value, old_value)
134
121
  end
135
122
 
136
123
  config
@@ -238,5 +225,21 @@ module Contrast
238
225
  convert
239
226
  end
240
227
  end
228
+
229
+ def replace_props new_keys, new_value, old_value
230
+ idx = 0
231
+ end_idx = new_keys.length - 1
232
+ while idx < new_keys.length
233
+ new_key = new_keys[idx]
234
+ if idx == end_idx
235
+ new_value[new_key] = old_value if new_value[new_key].nil?
236
+ else
237
+ new_value = {} if new_value.nil?
238
+ new_value[new_key] = {} if new_value[new_key].nil?
239
+ new_value = new_value[new_key]
240
+ end
241
+ idx += 1
242
+ end
243
+ end
241
244
  end
242
245
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'contrast/agent/patching/policy/patch'
5
5
  require 'contrast/agent/patching/policy/patcher'
6
- require 'contrast/components/interface'
6
+ require 'contrast/components/scope'
7
7
 
8
8
  module Contrast
9
9
  module Extension
@@ -11,10 +11,8 @@ module Contrast
11
11
  # This is our patch of the Array class required to handle propagation
12
12
  # Disclaimer: there may be a better way, but we're in a 'get it work' state.
13
13
  # Hopefully, we'll be in a 'get it right' state soon.
14
- class ArrayPropagator
15
- include Contrast::Components::Interface
16
-
17
- access_component :scope
14
+ class ArrayPropagator # rubocop:disable Style/StaticClass
15
+ extend Contrast::Components::Scope::InstanceMethods
18
16
 
19
17
  ARRAY_JOIN_HASH = {
20
18
  'class_name' => 'Array',
@@ -61,16 +59,6 @@ module Contrast
61
59
  ret
62
60
  end
63
61
  end
64
-
65
- def instrument_array_track
66
- @_instrument_array_track ||= begin
67
- require 'cs__assess_array/cs__assess_array'
68
- true
69
- end
70
- rescue StandardError, LoadError => e
71
- logger.error('Error loading assess track patch', e)
72
- false
73
- end
74
62
  end
75
63
  end
76
64
  end
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2021 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/components/interface'
4
+ require 'contrast/components/logger'
5
5
 
6
6
  module Contrast
7
7
  module Extension
@@ -11,8 +11,7 @@ module Contrast
11
11
  # apply the trigger in a custom patch over one of the generic triggers in
12
12
  # TriggerMethod.
13
13
  class EvalTrigger
14
- include Contrast::Components::Interface
15
- access_component :logging
14
+ include Contrast::Components::Logger::InstanceMethods
16
15
 
17
16
  class << self
18
17
  def instance_eval_trigger_check obj, source, ret
@@ -35,26 +34,6 @@ module Contrast
35
34
  ret, source)
36
35
  end
37
36
 
38
- def instrument_basic_object_track
39
- @_instrument_basic_object_track ||= begin
40
- require 'cs__assess_basic_object/cs__assess_basic_object'
41
- true
42
- end
43
- rescue StandardError, LoadError => e
44
- logger.error('Error loading basic object track patch', e)
45
- false
46
- end
47
-
48
- def instrument_module_track
49
- @_instrument_module_track ||= begin
50
- require 'cs__assess_module/cs__assess_module'
51
- true
52
- end
53
- rescue StandardError, LoadError => e
54
- logger.error('Error loading module track patch', e)
55
- false
56
- end
57
-
58
37
  private
59
38
 
60
39
  def trigger_node clazz, method
@@ -2,7 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/assess/policy/propagation_node'
5
- require 'contrast/components/interface'
5
+ require 'contrast/components/logger'
6
+ require 'contrast/components/scope'
6
7
 
7
8
  # In order to instrument some difficult methods like String#gsub, as it
8
9
  # returns an enumerator, we need to instrument methods on Fiber.
@@ -16,9 +17,8 @@ module Contrast
16
17
  # Contrast::Agent::Assess::Policy::Propagator molds without cluttering up the
17
18
  # Fiber Class or exposing our methods there.
18
19
  class FiberPropagator
19
- include Contrast::Components::Interface
20
-
21
- access_component :analysis, :logging, :scope
20
+ extend Contrast::Components::Logger::InstanceMethods
21
+ extend Contrast::Components::Scope::InstanceMethods
22
22
 
23
23
  # we use funchook to patch rb_fiber_new the initialize method is not exposed by Ruby core
24
24
  FIBER_NEW_NODE_HASH = {
@@ -53,7 +53,7 @@ module Contrast
53
53
 
54
54
  class << self
55
55
  def track_rb_fiber_yield fiber, _method, results
56
- return unless ASSESS.enabled?
56
+ return unless ::Contrast::ASSESS.enabled?
57
57
 
58
58
  # results will be nil if StopIteration was raised,
59
59
  # otherwise an Array of the yielded arguments
@@ -72,7 +72,7 @@ module Contrast
72
72
  end
73
73
 
74
74
  def track_rb_fiber_new fiber, _enum, _enum_method, underlying, _underlying_method
75
- return unless ASSESS.enabled?
75
+ return unless ::Contrast::ASSESS.enabled?
76
76
  return unless underlying.is_a?(String) && !underlying.empty?
77
77
 
78
78
  with_contrast_scope do
@@ -85,16 +85,6 @@ module Contrast
85
85
  rescue Exception => e # rubocop:disable Lint/RescueException
86
86
  logger.error('Unable to propagate during Fiber.new', e)
87
87
  end
88
-
89
- def instrument_fiber_track
90
- @_instrument_fiber_variables ||= begin
91
- require 'cs__assess_fiber_track/cs__assess_fiber_track' if Funchook.available?
92
- true
93
- end
94
- rescue StandardError, LoadError => e
95
- logger.error('Error loading fiber track patch', e)
96
- false
97
- end
98
88
  end
99
89
  end
100
90
  end
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2021 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/components/interface'
4
+ require 'contrast/components/logger'
5
5
 
6
6
  module Contrast
7
7
  module Extension
@@ -10,8 +10,8 @@ module Contrast
10
10
  # methods which are too complex to fit into one of the standard
11
11
  # Contrast::Agent::Assess::Policy::Propagator molds.
12
12
  class HashPropagator
13
- include Contrast::Components::Interface
14
- access_component :logging
13
+ include Contrast::Components::Logger::InstanceMethods
14
+
15
15
  class << self
16
16
  def cs__duplicate_and_freeze object
17
17
  return object unless object.is_a?(String) && !object.cs__frozen?
@@ -25,16 +25,6 @@ module Contrast
25
25
  # result in a seg fault
26
26
  object
27
27
  end
28
-
29
- def instrument_hash_track
30
- @_instrument_hash_track ||= begin
31
- require 'cs__assess_hash/cs__assess_hash'
32
- true
33
- end
34
- rescue StandardError, LoadError => e
35
- logger.error('Error loading hash track patch', e)
36
- false
37
- end
38
28
  end
39
29
  end
40
30
  end
@@ -1,8 +1,8 @@
1
1
  # Copyright (c) 2021 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/components/interface'
5
4
  require 'contrast/extension/assess/exec_trigger'
5
+ require 'contrast/components/logger'
6
6
 
7
7
  module Contrast
8
8
  module Extension
@@ -13,11 +13,10 @@ module Contrast
13
13
  # Kernel Module or exposing our methods there.
14
14
  module KernelPropagator
15
15
  class << self
16
- include Contrast::Components::Interface
16
+ extend Contrast::Components::Logger::InstanceMethods
17
+ include Contrast::Components::Logger::InstanceMethods
17
18
  include Contrast::Extension::Assess::ExecTrigger
18
19
 
19
- access_component :logging
20
-
21
20
  # We're 'tracking' sprintf now, meaning if anything is tracked on the way
22
21
  # in, the entire result will be tracked out. We're going to take this
23
22
  # approach for now b/c it's fast and easy. I don't super love it, and by
@@ -67,16 +66,6 @@ module Contrast
67
66
  logger.error('Unable to track dataflow through sprintf', e)
68
67
  end
69
68
 
70
- def instrument_kernel_track
71
- @_instrument_fiber_variables ||= begin
72
- require 'cs__assess_kernel/cs__assess_kernel'
73
- true
74
- end
75
- rescue StandardError, LoadError => e
76
- logger.error('Error loading kernel track patch', e)
77
- false
78
- end
79
-
80
69
  private
81
70
 
82
71
  def handle_sprintf_value value, result, parent_events
@@ -1,7 +1,8 @@
1
1
  # Copyright (c) 2021 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/components/interface'
4
+ require 'contrast/components/logger'
5
+ require 'contrast/components/scope'
5
6
 
6
7
  module Contrast
7
8
  module Extension
@@ -11,11 +12,12 @@ module Contrast
11
12
  # Hopefully, we'll be in a 'get it right' state soon.
12
13
  # This module is used for our Marshal.load patches
13
14
  class MarshalPropagator
14
- include Contrast::Components::Interface
15
-
16
- access_component :logging, :scope
15
+ extend Contrast::Components::Scope::InstanceMethods
17
16
 
18
17
  class << self
18
+ extend Contrast::Components::Logger::InstanceMethods
19
+ include Contrast::Components::Logger::InstanceMethods
20
+
19
21
  def cs__load_protect arg
20
22
  return if in_contrast_scope?
21
23
 
@@ -44,16 +46,6 @@ module Contrast
44
46
  end
45
47
  end
46
48
 
47
- def instrument_marshal_load
48
- @_instrument_marshal_load ||= begin
49
- require 'cs__assess_marshal_module/cs__assess_marshal_module'
50
- true
51
- end
52
- rescue StandardError, LoadError => e
53
- logger.error('Error loading marshal load patch', e)
54
- false
55
- end
56
-
57
49
  def trigger_node clazz, method
58
50
  triggers = Contrast::Agent::Assess::Policy::Policy.instance.triggers
59
51
  return unless triggers
@@ -2,7 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'contrast/agent/assess/policy/propagation_node'
5
- require 'contrast/components/interface'
5
+ require 'contrast/components/logger'
6
+ require 'contrast/components/scope'
6
7
 
7
8
  module Contrast
8
9
  module Extension
@@ -12,9 +13,8 @@ module Contrast
12
13
  # Contrast::Agent::Assess::Policy::Propagator molds without cluttering up the
13
14
  # Regexp Class or exposing our methods there.
14
15
  class RegexpPropagator
15
- include Contrast::Components::Interface
16
-
17
- access_component :analysis, :logging, :scope
16
+ extend Contrast::Components::Logger::InstanceMethods
17
+ extend Contrast::Components::Scope::InstanceMethods
18
18
 
19
19
  REGEXP_EQUAL_SQUIGGLE_HASH = {
20
20
  'id' => 'regexp_100',
@@ -34,7 +34,7 @@ module Contrast
34
34
 
35
35
  class << self
36
36
  def track_equal_squiggle info_hash
37
- return unless ASSESS.enabled?
37
+ return unless ::Contrast::ASSESS.enabled?
38
38
 
39
39
  # Because we have a special case for this propagation,
40
40
  # it falls out of regular scoping. As such, any patch to the `=~` method
@@ -58,16 +58,6 @@ module Contrast
58
58
  rescue Exception => e # rubocop:disable Lint/RescueException
59
59
  logger.error('Unable to propagate during Regexp#=~', e)
60
60
  end
61
-
62
- def instrument_regexp_track
63
- @_instrument_regexp_track ||= begin
64
- require 'cs__assess_regexp/cs__assess_regexp'
65
- true
66
- end
67
- rescue StandardError, LoadError => e
68
- logger.error('Error loading regexp track patch', e)
69
- false
70
- end
71
61
  end
72
62
  end
73
63
  end