Sha256: a5aa95fd572007834233afb818218f107d888f0d6df362f4450ce44052f40033
Contents?: true
Size: 1.67 KB
Versions: 18
Compression:
Stored size: 1.67 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/propagator/substitution_utils' module Contrast module Agent module Assess module Policy module Propagator # This class is specifically for String#(g)sub propagation # # Disclaimer: there may be a better way, but we're # in a 'get it work' state. hopefully, we'll be in # a 'get it right' state soon. class Substitution include Contrast::Components::Logger::InstanceMethods extend Contrast::Components::Logger::InstanceMethods extend Contrast::Agent::Assess::Policy::Propagator::SubstitutionUtils class << self # gsub is hard. there are four versions of this method # 1) pattern, replacement (my fav) # 2) pattern, hash (not bad) # 3) pattern, block (are you kidding me?) # 4) pattern (plz no) # # In addition, it requires things from $~ & $1-9, which # are method scoped. Rather than fight that, we'll # call gsub from C land using a CUSTOM patch. def gsub_tagger patcher, preshift, ret, block substitution_tagger(patcher, preshift, ret, !block.nil?) end def sub_tagger patcher, preshift, ret, block substitution_tagger(patcher, preshift, ret, !block.nil?, global: false) end end end end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems