Class: Contrast::Extension::Assess::HashPropagator

Inherits:
Object
  • Object
show all
Includes:
Components::Logger::InstanceMethods
Defined in:
lib/contrast/extension/assess/hash.rb,
ext/cs__assess_hash/cs__assess_hash.c

Overview

This Class provides us with a way to invoke Hash propagation for those methods which are too complex to fit into one of the standard Contrast::Agent::Assess::Policy::Propagator molds.

Class Method Summary collapse

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Class Method Details

.cs__duplicate_and_freeze(object) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/contrast/extension/assess/hash.rb', line 16

def cs__duplicate_and_freeze object
  return object unless object.is_a?(String) && !object.cs__frozen?

  # Copy the object, then freeze it, so that it looks the same
  # externally, but will have our finalizer on it.
  copy = object.dup
  Contrast::Agent::Assess::Tracker.pre_freeze(copy)
  copy&.cs__freeze
rescue StandardError
  # we'll rescue this error, but we can't log it here as that will
  # result in a seg fault
  object
end