contrast-agent 4.4.0 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (313) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +1 -1
  3. data/.simplecov +1 -1
  4. data/Gemfile +1 -1
  5. data/LICENSE.txt +1 -1
  6. data/Rakefile +2 -3
  7. data/exe/contrast_service +1 -1
  8. data/ext/build_funchook.rb +4 -4
  9. data/ext/cs__assess_active_record_named/cs__active_record_named.c +1 -1
  10. data/ext/cs__assess_active_record_named/extconf.rb +1 -1
  11. data/ext/cs__assess_array/cs__assess_array.c +1 -1
  12. data/ext/cs__assess_array/extconf.rb +1 -1
  13. data/ext/cs__assess_basic_object/cs__assess_basic_object.c +1 -1
  14. data/ext/cs__assess_basic_object/extconf.rb +1 -1
  15. data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +1 -1
  16. data/ext/cs__assess_fiber_track/extconf.rb +1 -1
  17. data/ext/cs__assess_hash/cs__assess_hash.c +4 -2
  18. data/ext/cs__assess_hash/extconf.rb +1 -1
  19. data/ext/cs__assess_kernel/cs__assess_kernel.c +1 -1
  20. data/ext/cs__assess_kernel/extconf.rb +1 -1
  21. data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +1 -1
  22. data/ext/cs__assess_marshal_module/extconf.rb +1 -1
  23. data/ext/cs__assess_module/cs__assess_module.c +1 -1
  24. data/ext/cs__assess_module/extconf.rb +1 -1
  25. data/ext/cs__assess_regexp/cs__assess_regexp.c +1 -1
  26. data/ext/cs__assess_regexp/extconf.rb +1 -1
  27. data/ext/cs__assess_string/cs__assess_string.c +1 -1
  28. data/ext/cs__assess_string/extconf.rb +1 -1
  29. data/ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c +1 -1
  30. data/ext/cs__assess_string_interpolation26/extconf.rb +1 -1
  31. data/ext/cs__assess_yield_track/cs__assess_yield_track.c +1 -1
  32. data/ext/cs__assess_yield_track/extconf.rb +1 -1
  33. data/ext/cs__common/cs__common.c +5 -5
  34. data/ext/cs__common/cs__common.h +4 -4
  35. data/ext/cs__common/extconf.rb +1 -1
  36. data/ext/cs__contrast_patch/cs__contrast_patch.c +22 -25
  37. data/ext/cs__contrast_patch/extconf.rb +1 -1
  38. data/ext/cs__protect_kernel/cs__protect_kernel.c +1 -1
  39. data/ext/cs__protect_kernel/extconf.rb +1 -1
  40. data/ext/extconf_common.rb +2 -6
  41. data/lib/contrast-agent.rb +1 -1
  42. data/lib/contrast.rb +20 -1
  43. data/lib/contrast/agent.rb +1 -3
  44. data/lib/contrast/agent/assess.rb +2 -2
  45. data/lib/contrast/agent/assess/contrast_event.rb +54 -69
  46. data/lib/contrast/agent/assess/contrast_object.rb +3 -3
  47. data/lib/contrast/agent/assess/events/event_factory.rb +3 -2
  48. data/lib/contrast/agent/assess/events/source_event.rb +7 -2
  49. data/lib/contrast/agent/assess/finalizers/freeze.rb +1 -1
  50. data/lib/contrast/agent/assess/finalizers/hash.rb +26 -34
  51. data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +24 -20
  52. data/lib/contrast/agent/assess/policy/patcher.rb +11 -18
  53. data/lib/contrast/agent/assess/policy/policy.rb +1 -1
  54. data/lib/contrast/agent/assess/policy/policy_node.rb +26 -34
  55. data/lib/contrast/agent/assess/policy/policy_scanner.rb +1 -1
  56. data/lib/contrast/agent/assess/policy/preshift.rb +4 -2
  57. data/lib/contrast/agent/assess/policy/propagation_method.rb +8 -21
  58. data/lib/contrast/agent/assess/policy/propagation_node.rb +20 -9
  59. data/lib/contrast/agent/assess/policy/propagator.rb +2 -1
  60. data/lib/contrast/agent/assess/policy/propagator/append.rb +1 -1
  61. data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
  62. data/lib/contrast/agent/assess/policy/propagator/center.rb +3 -2
  63. data/lib/contrast/agent/assess/policy/propagator/custom.rb +1 -1
  64. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +1 -1
  65. data/lib/contrast/agent/assess/policy/propagator/insert.rb +4 -2
  66. data/lib/contrast/agent/assess/policy/propagator/keep.rb +1 -1
  67. data/lib/contrast/agent/assess/policy/propagator/match_data.rb +3 -2
  68. data/lib/contrast/agent/assess/policy/propagator/next.rb +1 -1
  69. data/lib/contrast/agent/assess/policy/propagator/prepend.rb +1 -1
  70. data/lib/contrast/agent/assess/policy/propagator/rack_protection.rb +73 -0
  71. data/lib/contrast/agent/assess/policy/propagator/remove.rb +23 -19
  72. data/lib/contrast/agent/assess/policy/propagator/replace.rb +1 -1
  73. data/lib/contrast/agent/assess/policy/propagator/reverse.rb +1 -1
  74. data/lib/contrast/agent/assess/policy/propagator/select.rb +3 -13
  75. data/lib/contrast/agent/assess/policy/propagator/splat.rb +1 -1
  76. data/lib/contrast/agent/assess/policy/propagator/split.rb +4 -8
  77. data/lib/contrast/agent/assess/policy/propagator/substitution.rb +2 -8
  78. data/lib/contrast/agent/assess/policy/propagator/trim.rb +64 -45
  79. data/lib/contrast/agent/assess/policy/rewriter_patch.rb +7 -4
  80. data/lib/contrast/agent/assess/policy/source_method.rb +92 -81
  81. data/lib/contrast/agent/assess/policy/source_node.rb +1 -1
  82. data/lib/contrast/agent/assess/policy/source_validation/cross_site_validator.rb +8 -6
  83. data/lib/contrast/agent/assess/policy/source_validation/source_validation.rb +2 -4
  84. data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +7 -3
  85. data/lib/contrast/agent/assess/policy/trigger/xpath.rb +7 -8
  86. data/lib/contrast/agent/assess/policy/trigger_method.rb +102 -74
  87. data/lib/contrast/agent/assess/policy/trigger_node.rb +5 -4
  88. data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +5 -4
  89. data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +2 -3
  90. data/lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb +1 -1
  91. data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +2 -9
  92. data/lib/contrast/agent/assess/properties.rb +1 -1
  93. data/lib/contrast/agent/assess/property/evented.rb +9 -6
  94. data/lib/contrast/agent/assess/property/tagged.rb +1 -1
  95. data/lib/contrast/agent/assess/property/updated.rb +1 -1
  96. data/lib/contrast/agent/assess/rule/provider.rb +1 -1
  97. data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +12 -6
  98. data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +5 -2
  99. data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +4 -6
  100. data/lib/contrast/agent/assess/tag.rb +1 -1
  101. data/lib/contrast/agent/assess/tracker.rb +1 -1
  102. data/lib/contrast/agent/at_exit_hook.rb +1 -1
  103. data/lib/contrast/agent/class_reopener.rb +4 -2
  104. data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +1 -1
  105. data/lib/contrast/agent/deadzone/policy/policy.rb +7 -3
  106. data/lib/contrast/agent/disable_reaction.rb +2 -4
  107. data/lib/contrast/agent/exclusion_matcher.rb +6 -12
  108. data/lib/contrast/agent/inventory.rb +1 -2
  109. data/lib/contrast/agent/inventory/dependencies.rb +3 -1
  110. data/lib/contrast/agent/inventory/dependency_analysis.rb +1 -1
  111. data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +35 -23
  112. data/lib/contrast/agent/inventory/policy/datastores.rb +1 -1
  113. data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
  114. data/lib/contrast/agent/inventory/policy/trigger_node.rb +1 -1
  115. data/lib/contrast/agent/middleware.rb +38 -67
  116. data/lib/contrast/agent/module_data.rb +4 -4
  117. data/lib/contrast/agent/patching/policy/after_load_patch.rb +1 -1
  118. data/lib/contrast/agent/patching/policy/after_load_patcher.rb +9 -4
  119. data/lib/contrast/agent/patching/policy/method_policy.rb +7 -3
  120. data/lib/contrast/agent/patching/policy/module_policy.rb +15 -8
  121. data/lib/contrast/agent/patching/policy/patch.rb +23 -29
  122. data/lib/contrast/agent/patching/policy/patch_status.rb +7 -8
  123. data/lib/contrast/agent/patching/policy/patcher.rb +23 -22
  124. data/lib/contrast/agent/patching/policy/policy.rb +14 -21
  125. data/lib/contrast/agent/patching/policy/policy_node.rb +15 -5
  126. data/lib/contrast/agent/patching/policy/trigger_node.rb +22 -9
  127. data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +2 -2
  128. data/lib/contrast/agent/protect/policy/applies_deserialization_rule.rb +2 -2
  129. data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +2 -2
  130. data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +3 -4
  131. data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +2 -2
  132. data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +6 -10
  133. data/lib/contrast/agent/protect/policy/policy.rb +1 -1
  134. data/lib/contrast/agent/protect/policy/rule_applicator.rb +6 -6
  135. data/lib/contrast/agent/protect/policy/trigger_node.rb +1 -1
  136. data/lib/contrast/agent/protect/rule.rb +1 -1
  137. data/lib/contrast/agent/protect/rule/base.rb +19 -33
  138. data/lib/contrast/agent/protect/rule/base_service.rb +10 -6
  139. data/lib/contrast/agent/protect/rule/cmd_injection.rb +15 -19
  140. data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
  141. data/lib/contrast/agent/protect/rule/deserialization.rb +7 -14
  142. data/lib/contrast/agent/protect/rule/http_method_tampering.rb +4 -15
  143. data/lib/contrast/agent/protect/rule/no_sqli.rb +7 -3
  144. data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +2 -4
  145. data/lib/contrast/agent/protect/rule/path_traversal.rb +6 -6
  146. data/lib/contrast/agent/protect/rule/sqli.rb +3 -3
  147. data/lib/contrast/agent/protect/rule/sqli/default_sql_scanner.rb +1 -1
  148. data/lib/contrast/agent/protect/rule/sqli/mysql_sql_scanner.rb +1 -1
  149. data/lib/contrast/agent/protect/rule/sqli/postgres_sql_scanner.rb +2 -2
  150. data/lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb +1 -1
  151. data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +2 -2
  152. data/lib/contrast/agent/protect/rule/xss.rb +2 -2
  153. data/lib/contrast/agent/protect/rule/xxe.rb +6 -13
  154. data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +2 -3
  155. data/lib/contrast/agent/reaction_processor.rb +12 -11
  156. data/lib/contrast/agent/request.rb +25 -24
  157. data/lib/contrast/agent/request_context.rb +13 -23
  158. data/lib/contrast/agent/request_handler.rb +1 -1
  159. data/lib/contrast/agent/response.rb +1 -1
  160. data/lib/contrast/agent/rewriter.rb +6 -4
  161. data/lib/contrast/agent/rule_set.rb +3 -3
  162. data/lib/contrast/agent/scope.rb +1 -1
  163. data/lib/contrast/agent/service_heartbeat.rb +3 -4
  164. data/lib/contrast/agent/static_analysis.rb +1 -1
  165. data/lib/contrast/agent/thread.rb +1 -1
  166. data/lib/contrast/agent/thread_watcher.rb +1 -1
  167. data/lib/contrast/agent/tracepoint_hook.rb +2 -2
  168. data/lib/contrast/agent/version.rb +2 -2
  169. data/lib/contrast/agent/worker_thread.rb +1 -1
  170. data/lib/contrast/api.rb +1 -1
  171. data/lib/contrast/api/communication.rb +1 -1
  172. data/lib/contrast/api/communication/connection_status.rb +1 -1
  173. data/lib/contrast/api/communication/messaging_queue.rb +1 -1
  174. data/lib/contrast/api/communication/response_processor.rb +5 -7
  175. data/lib/contrast/api/communication/service_lifecycle.rb +5 -3
  176. data/lib/contrast/api/communication/socket.rb +1 -1
  177. data/lib/contrast/api/communication/socket_client.rb +9 -22
  178. data/lib/contrast/api/communication/speedracer.rb +6 -10
  179. data/lib/contrast/api/communication/tcp_socket.rb +1 -1
  180. data/lib/contrast/api/communication/unix_socket.rb +1 -1
  181. data/lib/contrast/api/decorators.rb +1 -1
  182. data/lib/contrast/api/decorators/address.rb +1 -1
  183. data/lib/contrast/api/decorators/agent_startup.rb +1 -1
  184. data/lib/contrast/api/decorators/application_settings.rb +1 -1
  185. data/lib/contrast/api/decorators/application_startup.rb +10 -4
  186. data/lib/contrast/api/decorators/application_update.rb +1 -1
  187. data/lib/contrast/api/decorators/http_request.rb +1 -1
  188. data/lib/contrast/api/decorators/input_analysis.rb +1 -1
  189. data/lib/contrast/api/decorators/instrumentation_mode.rb +37 -0
  190. data/lib/contrast/api/decorators/library.rb +9 -7
  191. data/lib/contrast/api/decorators/library_usage_update.rb +1 -1
  192. data/lib/contrast/api/decorators/message.rb +4 -4
  193. data/lib/contrast/api/decorators/rasp_rule_sample.rb +1 -1
  194. data/lib/contrast/api/decorators/route_coverage.rb +1 -1
  195. data/lib/contrast/api/decorators/server_features.rb +1 -1
  196. data/lib/contrast/api/decorators/trace_event.rb +4 -2
  197. data/lib/contrast/api/decorators/trace_event_object.rb +2 -4
  198. data/lib/contrast/api/decorators/trace_event_signature.rb +1 -1
  199. data/lib/contrast/api/decorators/trace_taint_range.rb +1 -1
  200. data/lib/contrast/api/decorators/trace_taint_range_tags.rb +2 -7
  201. data/lib/contrast/api/decorators/user_input.rb +1 -1
  202. data/lib/contrast/components/agent.rb +14 -15
  203. data/lib/contrast/components/app_context.rb +7 -7
  204. data/lib/contrast/components/assess.rb +6 -11
  205. data/lib/contrast/components/config.rb +3 -2
  206. data/lib/contrast/components/contrast_service.rb +8 -9
  207. data/lib/contrast/components/heap_dump.rb +1 -1
  208. data/lib/contrast/components/interface.rb +4 -3
  209. data/lib/contrast/components/inventory.rb +1 -1
  210. data/lib/contrast/components/logger.rb +1 -1
  211. data/lib/contrast/components/protect.rb +11 -14
  212. data/lib/contrast/components/sampling.rb +9 -3
  213. data/lib/contrast/components/scope.rb +2 -1
  214. data/lib/contrast/components/settings.rb +27 -98
  215. data/lib/contrast/config.rb +1 -1
  216. data/lib/contrast/config/agent_configuration.rb +1 -1
  217. data/lib/contrast/config/application_configuration.rb +1 -1
  218. data/lib/contrast/config/assess_configuration.rb +1 -1
  219. data/lib/contrast/config/assess_rules_configuration.rb +2 -4
  220. data/lib/contrast/config/base_configuration.rb +5 -6
  221. data/lib/contrast/config/default_value.rb +1 -1
  222. data/lib/contrast/config/exception_configuration.rb +2 -6
  223. data/lib/contrast/config/heap_dump_configuration.rb +13 -7
  224. data/lib/contrast/config/inventory_configuration.rb +1 -1
  225. data/lib/contrast/config/logger_configuration.rb +2 -6
  226. data/lib/contrast/config/protect_configuration.rb +1 -1
  227. data/lib/contrast/config/protect_rule_configuration.rb +23 -1
  228. data/lib/contrast/config/protect_rules_configuration.rb +1 -1
  229. data/lib/contrast/config/root_configuration.rb +1 -1
  230. data/lib/contrast/config/ruby_configuration.rb +1 -1
  231. data/lib/contrast/config/sampling_configuration.rb +1 -1
  232. data/lib/contrast/config/server_configuration.rb +1 -1
  233. data/lib/contrast/config/service_configuration.rb +1 -1
  234. data/lib/contrast/configuration.rb +4 -15
  235. data/lib/contrast/delegators/input_analysis.rb +12 -0
  236. data/lib/contrast/extension/assess.rb +1 -1
  237. data/lib/contrast/extension/assess/array.rb +2 -7
  238. data/lib/contrast/extension/assess/erb.rb +2 -8
  239. data/lib/contrast/extension/assess/eval_trigger.rb +3 -11
  240. data/lib/contrast/extension/assess/exec_trigger.rb +4 -14
  241. data/lib/contrast/extension/assess/fiber.rb +3 -13
  242. data/lib/contrast/extension/assess/hash.rb +1 -1
  243. data/lib/contrast/extension/assess/kernel.rb +3 -10
  244. data/lib/contrast/extension/assess/marshal.rb +3 -11
  245. data/lib/contrast/extension/assess/regexp.rb +2 -7
  246. data/lib/contrast/extension/assess/string.rb +4 -2
  247. data/lib/contrast/extension/delegator.rb +1 -1
  248. data/lib/contrast/extension/inventory.rb +1 -1
  249. data/lib/contrast/extension/kernel.rb +5 -3
  250. data/lib/contrast/extension/module.rb +1 -1
  251. data/lib/contrast/extension/protect.rb +1 -1
  252. data/lib/contrast/extension/protect/kernel.rb +1 -1
  253. data/lib/contrast/extension/protect/psych.rb +1 -1
  254. data/lib/contrast/extension/thread.rb +1 -1
  255. data/lib/contrast/framework/base_support.rb +1 -1
  256. data/lib/contrast/framework/manager.rb +5 -9
  257. data/lib/contrast/framework/platform_version.rb +1 -1
  258. data/lib/contrast/framework/rack/patch/session_cookie.rb +6 -19
  259. data/lib/contrast/framework/rack/patch/support.rb +7 -5
  260. data/lib/contrast/framework/rack/support.rb +1 -1
  261. data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +1 -1
  262. data/lib/contrast/framework/rails/patch/assess_configuration.rb +8 -3
  263. data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +4 -4
  264. data/lib/contrast/framework/rails/patch/support.rb +6 -4
  265. data/lib/contrast/framework/rails/railtie.rb +32 -0
  266. data/lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb +5 -2
  267. data/lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb +3 -1
  268. data/lib/contrast/framework/rails/rewrite/active_record_named.rb +3 -1
  269. data/lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb +3 -1
  270. data/lib/contrast/framework/rails/support.rb +3 -3
  271. data/lib/contrast/framework/sinatra/support.rb +4 -2
  272. data/lib/contrast/funchook/funchook.rb +2 -6
  273. data/lib/contrast/logger/application.rb +13 -10
  274. data/lib/contrast/logger/format.rb +3 -6
  275. data/lib/contrast/logger/log.rb +5 -4
  276. data/lib/contrast/logger/request.rb +2 -3
  277. data/lib/contrast/logger/time.rb +1 -1
  278. data/lib/contrast/security_exception.rb +2 -2
  279. data/lib/contrast/tasks/config.rb +1 -1
  280. data/lib/contrast/tasks/service.rb +6 -2
  281. data/lib/contrast/utils/assess/sampling_util.rb +1 -1
  282. data/lib/contrast/utils/assess/tracking_util.rb +2 -3
  283. data/lib/contrast/utils/class_util.rb +15 -11
  284. data/lib/contrast/utils/duck_utils.rb +1 -1
  285. data/lib/contrast/utils/env_configuration_item.rb +1 -1
  286. data/lib/contrast/utils/hash_digest.rb +16 -24
  287. data/lib/contrast/utils/heap_dump_util.rb +1 -1
  288. data/lib/contrast/utils/invalid_configuration_util.rb +1 -1
  289. data/lib/contrast/utils/inventory_util.rb +1 -1
  290. data/lib/contrast/utils/io_util.rb +2 -2
  291. data/lib/contrast/utils/job_servers_running.rb +10 -5
  292. data/lib/contrast/utils/object_share.rb +1 -1
  293. data/lib/contrast/utils/os.rb +3 -2
  294. data/lib/contrast/utils/preflight_util.rb +1 -1
  295. data/lib/contrast/utils/resource_loader.rb +1 -1
  296. data/lib/contrast/utils/ruby_ast_rewriter.rb +3 -2
  297. data/lib/contrast/utils/sha256_builder.rb +1 -1
  298. data/lib/contrast/utils/stack_trace_utils.rb +1 -1
  299. data/lib/contrast/utils/string_utils.rb +1 -1
  300. data/lib/contrast/utils/tag_util.rb +1 -1
  301. data/lib/contrast/utils/thread_tracker.rb +1 -1
  302. data/lib/contrast/utils/timer.rb +1 -1
  303. data/resources/assess/policy.json +60 -2
  304. data/resources/deadzone/policy.json +7 -23
  305. data/ruby-agent.gemspec +22 -20
  306. data/service_executables/VERSION +1 -1
  307. data/service_executables/linux/contrast-service +0 -0
  308. data/service_executables/mac/contrast-service +0 -0
  309. data/sonar-project.properties +9 -0
  310. metadata +94 -50
  311. data/lib/contrast/agent/inventory/gemfile_digest_cache.rb +0 -38
  312. data/lib/contrast/agent/railtie.rb +0 -31
  313. data/lib/contrast/common_agent_configuration.rb +0 -87
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  $TO_MAKE = File.basename(__dir__)
@@ -1,4 +1,4 @@
1
- /* Copyright (c) 2020 Contrast Security, Inc. See
1
+ /* Copyright (c) 2021 Contrast Security, Inc. See
2
2
  * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */
3
3
 
4
4
  #include "cs__protect_kernel.h"
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  $TO_MAKE = File.basename(__dir__)
@@ -1,15 +1,11 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  require 'mkmf'
5
5
  require_relative '../lib/contrast/agent/version'
6
6
 
7
- def name
8
- $TO_MAKE
9
- end
10
-
11
7
  def make!
12
- create_makefile "#{ name }/#{ name }"
8
+ create_makefile "#{ $TO_MAKE }/#{ $TO_MAKE }"
13
9
  end
14
10
 
15
11
  def ext_path
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  # We need this to make bundler happy since it's the name of the gem, unless we
data/lib/contrast.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  # Used to prevent deprecation warnings from flooding stdout
@@ -25,6 +25,19 @@ class Object
25
25
  alias_method :cs__singleton_class, :singleton_class
26
26
  end
27
27
 
28
+ if RUBY_VERSION >= '3.0.0'
29
+ # This fixes Ruby 3.0 issues with Module#(some instance method) patching by preventing the prepending of
30
+ # a JSON helper on protobuf load. String.instance_method(:+) is one of the most noticable.
31
+ # TODO: RUBY-1132 Remove this once Ruby 3 is fixed.
32
+ # See bug here: https://bugs.ruby-lang.org/issues/17725
33
+ class Class
34
+ alias_method(:cs__orig_prepend, :prepend)
35
+ def prepend other
36
+ include(other)
37
+ end
38
+ end
39
+ end
40
+
28
41
  # component interface for class creation
29
42
  # config gets built as a consequence of this require
30
43
  require 'contrast/components/interface'
@@ -47,3 +60,9 @@ require 'contrast/utils/preflight_util'
47
60
 
48
61
  require 'contrast/utils/assess/sampling_util'
49
62
  require 'contrast/agent'
63
+
64
+ if RUBY_VERSION >= '3.0.0'
65
+ # Put prepend back as it was.
66
+ Class.alias_method(:prepend, :cs__orig_prepend)
67
+ Class.remove_method(:cs__orig_prepend)
68
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  require 'English'
@@ -27,8 +27,6 @@ require 'contrast/utils/string_utils'
27
27
  require 'contrast/utils/io_util'
28
28
  require 'contrast/utils/os'
29
29
 
30
- require 'contrast/common_agent_configuration'
31
-
32
30
  require 'contrast/utils/hash_digest'
33
31
  require 'contrast/utils/invalid_configuration_util'
34
32
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  module Contrast
@@ -10,7 +10,7 @@ module Contrast
10
10
  module Assess
11
11
  require 'contrast/agent/assess/tracker'
12
12
  require 'contrast/agent/module_data'
13
- require 'contrast/agent/rewriter'
13
+ require 'contrast/agent/rewriter' if RUBY_VERSION < '2.6.0' # TODO: RUBY-714 remove guard w/ EOL of 2.5
14
14
  require 'contrast/agent/assess/policy/preshift'
15
15
 
16
16
  # Dynamic Sources
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  require 'contrast/utils/assess/tracking_util'
@@ -14,37 +14,27 @@ require 'contrast/agent/assess/contrast_object'
14
14
  module Contrast
15
15
  module Agent
16
16
  module Assess
17
- # This class holds the data about an event in the application
18
- # We'll use it to build an event that TeamServer can consume if
19
- # the object to which this event belongs ends in a trigger.
17
+ # This class holds the data about an event in the application We'll use it to build an event that TeamServer can
18
+ # consume if the object to which this event belongs ends in a trigger.
20
19
  #
21
20
  # @attr_reader event_id [Integer] the atomic id of this event
22
- # @attr_reader policy_node [Contrast::Agent::Assess::Policy::PolicyNode]
23
- # the node that governs this event.
24
- # @attr_reader stack_trace [Array<String>] the execution stack at the
25
- # time the method for this event was invoked
26
- # @attr_reader time [Integer] the time, in epoch ms, when this event was
27
- # created
28
- # @attr_reader thread [Integer] the object id of the thread on which this
29
- # event was generated
30
- # @attr_reader object [Contrast::Agent::Assess::ContrastObject] the safe
31
- # representation of the Object on which the method was invoked
32
- # @attr_reader ret [Contrast::Agent::Assess::ContrastObject] the safe
33
- # representation of the Return of the invoked method
34
- # @attr_reader args [Array<Contrast::Agent::Assess::ContrastObject>] the
35
- # safe representation of the Arguments with which the method was invoked
21
+ # @attr_reader policy_node [Contrast::Agent::Assess::Policy::PolicyNode] the node that governs this event.
22
+ # @attr_reader stack_trace [Array<String>] the execution stack at the time the method for this event was invoked
23
+ # @attr_reader time [Integer] the time, in epoch ms, when this event was created
24
+ # @attr_reader thread [Integer] the object id of the thread on which this event was generated
25
+ # @attr_reader object [Contrast::Agent::Assess::ContrastObject] the safe representation of the Object on which
26
+ # the method was invoked
27
+ # @attr_reader ret [Contrast::Agent::Assess::ContrastObject] the safe representation of the Return of the invoked
28
+ # method
29
+ # @attr_reader args [Array<Contrast::Agent::Assess::ContrastObject>] the safe representation of the Arguments
30
+ # with which the method was invoked
36
31
  class ContrastEvent
37
32
  include Contrast::Components::Interface
38
33
  access_component :analysis
39
34
 
40
- attr_reader :event_id, :policy_node, :stack_trace, :time, :thread,
41
- :object,
42
- :ret,
43
- :args,
44
- :tags
35
+ attr_reader :event_id, :policy_node, :stack_trace, :time, :thread, :object, :ret, :args, :tags
45
36
 
46
- # We need this to track the parent id's of events to build up a flow
47
- # chart of the finding
37
+ # We need this to track the parent id's of events to build up a flow chart of the finding
48
38
  @atomic_id = 0
49
39
  @atomic_mutex = Mutex.new
50
40
  def self.next_atomic_id
@@ -56,26 +46,13 @@ module Contrast
56
46
  end
57
47
  end
58
48
 
59
- # @param policy_node [Contrast::Agent::Assess::Policy::PolicyNode]
60
- # the node that governs this event.
49
+ # @param policy_node [Contrast::Agent::Assess::Policy::PolicyNode] the node that governs this event.
61
50
  # @param tagged [Object] the Target to which this event pertains.
62
51
  # @param object [Object] the Object on which the method was invoked
63
52
  # @param ret [Object] the Return of the invoked method
64
- # @param args [Array<Object>] the Arguments with which the method
65
- # was invoked
53
+ # @param args [Array<Object>] the Arguments with which the method was invoked
66
54
  def initialize policy_node, tagged, object, ret, args
67
55
  @policy_node = policy_node
68
-
69
- # Capture stacktraces only as configured.
70
- #
71
- # So long as this event is built in a factory, we know Contrast Code
72
- # will be the first three events
73
- @stack_trace = if ASSESS.capture_stacktrace?(policy_node)
74
- caller(3, 20)
75
- else
76
- Contrast::Utils::ObjectShare::EMPTY_ARRAY
77
- end
78
-
79
56
  @time = Contrast::Utils::Timer.now_ms
80
57
  @thread = Thread.current.object_id
81
58
 
@@ -84,17 +61,17 @@ module Contrast
84
61
  @tags = Contrast::Agent::Assess::Tracker.properties(tagged)&.tags
85
62
  find_parent_events!(policy_node, object, ret, args)
86
63
  snapshot!(object, ret, args)
64
+ capture_stacktrace!
87
65
  end
88
66
 
89
67
  def parent_events
90
68
  @_parent_events ||= []
91
69
  end
92
70
 
93
- # We have to do a little work to figure out what our TS appropriate
94
- # target is. To break this down, the logic is as follows:
95
- # 1) If my policy_node has a target, work on targets. Else, work on sources.
96
- # Per TS law, each policy_node must have at least a source or a target.
97
- # The only type of policy_node w/o targets is a Trigger, but that may
71
+ # We have to do a little work to figure out what our TS appropriate target is. To break this down, the logic is
72
+ # as follows:
73
+ # 1) If my policy_node has a target, work on targets. Else, work on sources. Per TS law, each policy_node must
74
+ # have at least a source or a target. The only type of policy_node w/o targets is a Trigger, but that may
98
75
  # change.
99
76
  # 2) I'll set the event's source and target to TS values.
100
77
  # 3) Return the first source/target as the taint target.
@@ -117,21 +94,17 @@ module Contrast
117
94
 
118
95
  private
119
96
 
120
- # Parent events are the events of all the sources of this event which
121
- # were tracked prior to this event occurring. Depending on which, if
122
- # any of the sources were tracked, there may be more than one parent.
97
+ # Parent events are the events of all the sources of this event which were tracked prior to this event
98
+ # occurring. Depending on which, if any of the sources were tracked, there may be more than one parent.
123
99
  #
124
- # All events except for [Contrast::Agent::Assess::Events::SourceEvent]
125
- # will have at least one parent.
100
+ # All events except for [Contrast::Agent::Assess::Events::SourceEvent] will have at least one parent.
126
101
  #
127
102
  # We set those events to this event's instance variables.
128
103
  #
129
- # @param policy_node [Contrast::Agent::Assess::Policy::PolicyNode]
130
- # the node that governs this event.
104
+ # @param policy_node [Contrast::Agent::Assess::Policy::PolicyNode] the node that governs this event.
131
105
  # @param object [Object] the Object on which the method was invoked
132
106
  # @param ret [Object] the Return of the invoked method
133
- # @param args [Array<Object>] the Arguments with which the method
134
- # was invoked
107
+ # @param args [Array<Object>] the Arguments with which the method was invoked
135
108
  def find_parent_events! policy_node, object, ret, args
136
109
  policy_node.sources.each do |source_marker|
137
110
  source = value_of_source(source_marker, object, ret, args)
@@ -145,10 +118,8 @@ module Contrast
145
118
  # @param source [String] the marker for the source type
146
119
  # @param object [Object] the Object on which the method was invoked
147
120
  # @param ret [Object] the Return of the invoked method
148
- # @param args [Array<Object>] the Arguments with which the method
149
- # was invoked
150
- # @return [Object,nil] the literal value of the source indicated by the
151
- # given marker
121
+ # @param args [Array<Object>] the Arguments with which the method was invoked
122
+ # @return [Object,nil] the literal value of the source indicated by the given marker
152
123
  def value_of_source source, object, ret, args
153
124
  case source
154
125
  when Contrast::Utils::ObjectShare::OBJECT_KEY
@@ -160,16 +131,13 @@ module Contrast
160
131
  end
161
132
  end
162
133
 
163
- # Everything* is mutable in Ruby. As such, to ensure we can accurately
164
- # report the application state at the time of this method's invocation,
165
- # we have to snapshot the given values, making safe representations of
166
- # them for our later use. We set those safe values to this event's
167
- # instance variables.
134
+ # Everything* is mutable in Ruby. As such, to ensure we can accurately report the application state at the time
135
+ # of this method's invocation, we have to snapshot the given values, making safe representations of them for
136
+ # our later use. We set those safe values to this event's instance variables.
168
137
  #
169
138
  # @param object [Object] the Object on which the method was invoked
170
139
  # @param ret [Object] the Return of the invoked method
171
- # @param args [Array<Object>] the Arguments with which the method
172
- # was invoked
140
+ # @param args [Array<Object>] the Arguments with which the method was invoked
173
141
  def snapshot! object, ret, args
174
142
  @object = Contrast::Agent::Assess::ContrastObject.new(object) if object
175
143
  @ret = Contrast::Agent::Assess::ContrastObject.new(ret) if ret
@@ -177,18 +145,35 @@ module Contrast
177
145
  self
178
146
  end
179
147
 
180
- # Given an array of arguments, copy them into a safe, meaning String,
181
- # format that we can use to send to SR and TS for rendering.
148
+ # Given an array of arguments, copy them into a safe, meaning String, format that we can use to send to SR and
149
+ # TS for rendering.
182
150
  #
183
151
  # @param args [Array<Object>] the arguments to translate
184
- # @return [Array<Contrast::Agent::Assess::ContrastObject>] the String forms of those Objects, as
185
- # determined by Contrast::Utils::ClassUtil.to_contrast_string
152
+ # @return [Array<Contrast::Agent::Assess::ContrastObject>] the String forms of those Objects, as determined by
153
+ # Contrast::Utils::ClassUtil.to_contrast_string
186
154
  def safe_args_representation args
187
155
  return unless args
188
156
  return Contrast::Utils::ObjectShare::EMPTY_ARRAY if args.empty?
189
157
 
190
158
  args.map { |arg| arg ? Contrast::Agent::Assess::ContrastObject.new(arg) : nil }
191
159
  end
160
+
161
+ # Capture stack traces only as configured. We'll use this to grab the start of the call stack as if the
162
+ # instrumented method were the caller. This means we'll start at the entry just after the first block of
163
+ # Contrast code.
164
+ def capture_stacktrace!
165
+ # If we're configured to not capture the stacktrace, usually for performance reasons, then don't and return an
166
+ # empty array instead
167
+ unless ASSESS.capture_stacktrace?(policy_node)
168
+ @stack_trace = Contrast::Utils::ObjectShare::EMPTY_ARRAY
169
+ return
170
+ end
171
+
172
+ # Otherwise, find where in the stack the application / Ruby code starts
173
+ start = caller(0, 20)&.find_index { |stack| !stack.include?('/lib/contrast') }
174
+ # And then use that to build out the reported stacktrace, or a fallback if we couldn't find it.
175
+ @stack_trace = start ? caller(start + 1, 20) : caller(20, 20)
176
+ end
192
177
  end
193
178
  end
194
179
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  require 'contrast/utils/class_util'
@@ -34,14 +34,14 @@ module Contrast
34
34
  def initialize object
35
35
  if object
36
36
  @object = Contrast::Utils::ClassUtil.to_contrast_string(object)
37
- @object_type = object.cs__class.name
37
+ @object_type = object.cs__class.cs__name
38
38
  # TODO: RUBY-1084 determine if we need to copy these tags to
39
39
  # restore immutability. For instance, if these tags were on a
40
40
  # String that was then #reverse!'d, would our tags be wrong?
41
41
  @tags = Contrast::Agent::Assess::Tracker.properties(object)&.tags
42
42
  else
43
43
  @object = Contrast::Utils::ObjectShare::NIL_STRING
44
- @object_type = nil.cs__class.name
44
+ @object_type = nil.cs__class.cs__name
45
45
  end
46
46
  end
47
47
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  require 'contrast/agent/assess/contrast_event'
@@ -13,7 +13,8 @@ module Contrast
13
13
  def self.build policy_node, tagged, object, ret, args, source_type = nil, source_name = nil
14
14
  case policy_node
15
15
  when Contrast::Agent::Assess::Policy::SourceNode
16
- Contrast::Agent::Assess::Events::SourceEvent.new(policy_node, tagged, object, ret, args, source_type, source_name)
16
+ Contrast::Agent::Assess::Events::SourceEvent.new(policy_node, tagged, object, ret, args, source_type,
17
+ source_name)
17
18
  when Contrast::Agent::Assess::Policy::PolicyNode
18
19
  Contrast::Agent::Assess::ContrastEvent.new(policy_node, tagged, object, ret, args)
19
20
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  require 'contrast/agent/assess/contrast_event'
@@ -11,8 +11,13 @@ module Contrast
11
11
  # This class holds the data about an event in the application
12
12
  # We'll use it to build an event that TeamServer can consume if
13
13
  # the object to which this event belongs ends in a trigger.
14
+ #
15
+ # @attr_reader request [Contrast::Agent::Request] our wrapper around the Rack::Request at the time this source
16
+ # was created
17
+ # @attr_reader source_name [String] the name of the source if it comes from a map-like entity
18
+ # @attr_reader source_type [String] the TeamServer understood type of source; i.e. parameter
14
19
  class SourceEvent < Contrast::Agent::Assess::ContrastEvent
15
- attr_reader :source_name, :source_type, :request
20
+ attr_reader :request, :source_name, :source_type
16
21
 
17
22
  def initialize policy_node, tagged, object, ret, args, source_type = nil, source_name = nil
18
23
  super(policy_node, tagged, object, ret, args)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  require 'contrast/agent/assess/tracker'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
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
4
  require 'contrast/utils/duck_utils'
@@ -7,10 +7,8 @@ module Contrast
7
7
  module Agent
8
8
  module Assess
9
9
  module Finalizers
10
- # An extension of Hash that doesn't impact GC of the object being
11
- # stored by storing its ID as a Key to lookup and registering a
12
- # finalizer on the object to remove its entry from the Hash immediately
13
- # after it's GC'd.
10
+ # An extension of Hash that doesn't impact GC of the object being stored by storing its ID as a Key to lookup
11
+ # and registering a finalizer on the object to remove its entry from the Hash immediately after it's GC'd.
14
12
  class Hash < Hash
15
13
  include Contrast::Components::Interface
16
14
  access_component :agent, :analysis
@@ -20,12 +18,11 @@ module Contrast
20
18
  def []= key, obj
21
19
  return unless AGENT.enabled? && ASSESS.enabled?
22
20
 
23
- # We can't finalize frozen things, so only act on those that went
24
- # through .pre_freeze
21
+ # We can't finalize frozen things, so only act on those that went through .pre_freeze
25
22
  if key.cs__frozen?
26
23
  return unless FROZEN_FINALIZED_IDS.include?(key.__id__)
27
24
  else
28
- ObjectSpace.define_finalizer(key, finalize(key.__id__))
25
+ ObjectSpace.define_finalizer(key, finalizing_proc)
29
26
  end
30
27
  super key.__id__, obj
31
28
  end
@@ -34,8 +31,8 @@ module Contrast
34
31
  super key.__id__
35
32
  end
36
33
 
37
- # Something is trackable if it is not a collection and either not
38
- # frozen or it was frozen after we put a finalizer on it.
34
+ # Something is trackable if it is not a collection and either not frozen or it was frozen after we put a
35
+ # finalizer on it.
39
36
  #
40
37
  # @param key [Object] the thing to determine if trackable
41
38
  # @return [Boolean]
@@ -47,51 +44,46 @@ module Contrast
47
44
  # If it's not frozen, we can finalize/ track it.
48
45
  return true unless key.cs__frozen?
49
46
 
50
- # Otherwise, we can only track it if we've finalized it in our
51
- # freeze patch.
47
+ # Otherwise, we can only track it if we've finalized it in our freeze patch.
52
48
  FROZEN_FINALIZED_IDS.include?(key.__id__)
53
49
  end
54
50
 
55
- # Determine if the given Object is tracked, meaning it has a known
56
- # set of properties and those properties are tracked.
51
+ # Determine if the given Object is tracked, meaning it has a known set of properties and those properties are
52
+ # tracked.
57
53
  #
58
- # @param key [Object] the Object whose properties, by id, we want to
59
- # check for tracked status
54
+ # @param key [Object] the Object whose properties, by id, we want to check for tracked status
60
55
  # @return [Boolean]
61
56
  def tracked? key
62
57
  key?(key.__id__) && fetch(key.__id__, nil)&.tracked?
63
58
  end
64
59
 
65
- # Remove the given key from our frozen and properties tracking during
66
- # finalization of the Object to which the given key_id pertains.
67
- # NOTE: by necessity, this is the only method which takes the __id__,
68
- # not the Object itself. You CANNOT pass the Object to this as a
69
- # finalizer cannot hold reference to the Object being finalized; that
70
- # prevents GC, which introduces a memory leak and defeats the entire
71
- # purpose of this.
60
+ # Create a Proc to remove the given key from our frozen and properties tracking during finalization of the
61
+ # Object to which the given key_id pertains. The ObjectSpace's finalizer mechanism will handle passing this
62
+ # ID in, so we only need to define the Proc once.
72
63
  #
73
- # @param key_id [Integer] the Object Identifier to clean up during
74
- # finalization.
75
- def finalize key_id
76
- proc do
64
+ # NOTE: by necessity, this is the only method which takes the __id__, not the Object itself. You CANNOT pass
65
+ # the Object to this as a finalizer cannot hold reference to the Object being finalized; that prevents GC,
66
+ # which introduces a memory leak and defeats the entire purpose of this.
67
+ #
68
+ # @return [Proc] the Proc to remove references to the ID of the GC'd object from our Hash
69
+ def finalizing_proc
70
+ @_finalizing_proc ||= proc do |key_id|
77
71
  FROZEN_FINALIZED_IDS.delete(key_id)
78
72
  delete(key_id)
79
73
  end
80
74
  end
81
75
 
82
- # Frozen things cannot be finalized. To avoid any issue here, we
83
- # intercept the #freeze call and set finalizers on the Object. To
84
- # ensure later we know it's been pre-finalized, we add it's __id__ to
85
- # our tracking.
76
+ # Frozen things cannot be finalized. To avoid any issue here, we intercept the #freeze call and set
77
+ # finalizers on the Object. To ensure later we know it's been pre-finalized, we add it's __id__ to our
78
+ # tracking.
86
79
  #
87
- # @param key [Object] the Object on which we need to pre-define
88
- # finalizers
80
+ # @param key [Object] the Object on which we need to pre-define finalizers
89
81
  def pre_freeze key
90
82
  return unless AGENT.enabled? && ASSESS.enabled?
91
83
  return if key.cs__frozen?
92
84
  return if FROZEN_FINALIZED_IDS.include?(key.__id__)
93
85
 
94
- ObjectSpace.define_finalizer(key, finalize(key.__id__))
86
+ ObjectSpace.define_finalizer(key, finalizing_proc)
95
87
 
96
88
  FROZEN_FINALIZED_IDS << key.__id__
97
89
  rescue StandardError => _e