Sha256: b19fb909de14b959220953c3e3847eb0cee9fa111b3471fee73cb41158d66b39

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

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

module Contrast
  module Agent
    module Patching
      module Policy
        # Used to handle tracking patches that need to apply special instrumentation when a module is loaded
        class AfterLoadPatch
          attr_reader :applied, :module_name, :instrumentation_file_path
          def initialize module_name, instrumentation_file_path
            @applied = false
            @module_name = module_name
            @instrumentation_file_path = instrumentation_file_path
          end

          def applied?
            @applied
          end

          def applies? loaded_module_name
            loaded_module_name == module_name
          end

          def target_defined?
            Module.cs__truly_defined?(module_name)
          end

          def instrument!
            cs__scoped_require instrumentation_file_path
            @applied = true
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-3.8.5 lib/contrast/agent/patching/policy/after_load_patch.rb
contrast-agent-3.8.4 lib/contrast/agent/patching/policy/after_load_patch.rb