Sha256: f45f99ae2a9199ad079f3ee0b7f04994fff606957d1acb8a0980ea0f5a647a1a

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

cs__scoped_require 'contrast/components/interface'

module Contrast
  module CoreExtensions
    module Assess
      # 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 HashPropagator
        include Contrast::Components::Interface
        access_component :logging
        class << self
          def cs__duplicate_and_freeze object
            return object unless object.is_a?(String) && !object.cs__frozen?
            return object unless object.cs__tracked?

            object.dup.cs__freeze
          rescue StandardError
            # we'll rescue this error, but we can't log it here as that will
            # result in a seg fault
          end

          def instrument_hash_track
            @_instrument_hash_track ||= begin
                                            cs__scoped_require 'cs__assess_hash/cs__assess_hash'
                                            true
                                          end
          rescue StandardError => e
            logger.error('Error loading hash track patch', e)
            false
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contrast-agent-3.11.0 lib/contrast/extensions/ruby_core/assess/hash.rb