Sha256: 8eb3e9d9b97ee754d982b227289ab8eb7a7b576be59ae345498a248374b640c4

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

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

module Contrast
  module Extension
    module Protect
      # This Module functions as our patch into the Kernel class for Protect,
      # allowing us to track activity as it crosses spawned processes.
      module Kernel
        class << self
          def build_wrapper
            lambda {
              proc_start
              yield
              # AtExitHook handles sending any messages generated in the new forked process
            }
          end

          def proc_start
            context = Contrast::Agent::REQUEST_TRACKER.current
            return unless context

            context.reset_activity
          end

          def instrument
            @_instrument ||= begin
              require 'cs__protect_kernel/cs__protect_kernel'
              true
            end
          rescue StandardError, LoadError => e
            logger.error('Error loading kernel protect patch', e)
            false
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-4.9.1 lib/contrast/extension/protect/kernel.rb
contrast-agent-4.9.0 lib/contrast/extension/protect/kernel.rb