Sha256: 77949693c44de474412e656d7d86fbb2585b63e1df9ee75f5aee9d9e10231dbf

Contents?: true

Size: 1.3 KB

Versions: 13

Compression:

Stored size: 1.3 KB

Contents

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

require 'contrast/components/logger'

# This module is used to find funchook library and determine availability
module Funchook
  extend Contrast::Components::Logger::InstanceMethods

  attr_accessor :path

  # Possible platform library files
  ACCEPTABLE_FILES = %w[libfunchook.dylib libfunchook.so].cs__freeze

  # Top level agent directories that should have the funchook libraries
  SEARCH_DIRS = [File.join('ext'), File.join('shared_libraries'), File.join('funchook', 'src')].cs__freeze

  AGENT_ROOT = File.join(__dir__, '..', '..', '..')

  class << self
    def resolve_path!
      actual_path_segments = SEARCH_DIRS.product(ACCEPTABLE_FILES).find do |potential_funchook_path|
        load_path = absolute_path(potential_funchook_path)
        File.exist?(load_path)
      end

      if actual_path_segments.nil?
        logger.warn('Unable to find funchook')
      else
        @path = absolute_path(actual_path_segments)
      end
      @path
    end

    def absolute_path path_array
      File.absolute_path(File.join(AGENT_ROOT, *path_array))
    end

    def available?
      @_available = !!resolve_path! if @_available.nil?
      @_available
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/funchook/funchook.rb
contrast-agent-7.6.0 lib/contrast/funchook/funchook.rb
contrast-agent-7.5.0 lib/contrast/funchook/funchook.rb
contrast-agent-7.4.1 lib/contrast/funchook/funchook.rb
contrast-agent-7.4.0 lib/contrast/funchook/funchook.rb
contrast-agent-7.3.2 lib/contrast/funchook/funchook.rb
contrast-agent-7.3.1 lib/contrast/funchook/funchook.rb
contrast-agent-7.3.0 lib/contrast/funchook/funchook.rb
contrast-agent-7.2.0 lib/contrast/funchook/funchook.rb
contrast-agent-7.1.0 lib/contrast/funchook/funchook.rb
contrast-agent-7.0.0 lib/contrast/funchook/funchook.rb
contrast-agent-6.15.3 lib/contrast/funchook/funchook.rb
contrast-agent-6.15.2 lib/contrast/funchook/funchook.rb