Sha256: 4b49f2232e41ff05a5c140feb062c34a6acbaedf9841c8f7653eb85bc0ac862d
Contents?: true
Size: 1.87 KB
Versions: 16
Compression:
Stored size: 1.87 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/agent/assess/policy/policy' require 'contrast/agent/patching/policy/patcher' require 'contrast/agent/patching/policy/method_policy' require 'contrast/agent/patching/policy/module_policy' require 'contrast/components/logger' require 'contrast/components/scope' module Contrast module Agent module Assess module Policy # This is how we patch into our customer's code. It provides a way to # track which classes we need to patch into and, once we've woven, # provides a map for which methods our renamed functions need to call # and how. module Patcher extend Contrast::Components::Logger::InstanceMethods extend Contrast::Components::Scope::InstanceMethods class << self def policy Contrast::Agent::Assess::Policy::Policy.instance end def patcher Contrast::Agent::Patching::Policy::Patcher end # Some of the methods we care about, especially those used as dynamic # sources, are truly dynamic, in that they do not exist on class # load. These methods only exist once a module or class eval has been # called. This hook is provided so that patches to those methods can # pass us execution flow once a new method has been made available. def patch_assess_on_eval mod return unless ::Contrast::ASSESS.enabled? return if in_contrast_scope? patcher.patch_specific_module(mod) rescue StandardError => e logger.warn('Unable to patch assess during eval', e, module: mod.cs__name) end end end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems