Sha256: a9abd49ed9162c1c48d30be44e604932562117f46fa75b4e4b9e7e15d03f0f51

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

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

# This module is used to track propagation through ERB template rendering
module ERBPropagator
  class << self
    def result_tagger patcher, preshift, ret, _block
      return unless preshift.args.length >= 1

      used_binding = preshift.args[0]
      binding_variable_set = used_binding.local_variables

      erb_pre_result = preshift.object.src
      binding_variable_set.each do |bound_var_symbol|
        bound_variable_value = used_binding.local_variable_get(bound_var_symbol)
        next unless bound_variable_value.cs__respond_to?(:cs__tracked?) && bound_variable_value.cs__tracked?
        next unless erb_pre_result.include?(bound_var_symbol.to_s)

        start_index = ret.index(bound_variable_value)
        next if start_index.nil?

        ret.cs__copy_from(bound_variable_value, start_index)
      end
      ret.cs__properties.build_event(
          patcher,
          ret,
          preshift.object,
          ret,
          preshift.args,
          1)
      ret
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
contrast-agent-3.14.0 lib/contrast/extension/assess/erb.rb
contrast-agent-3.13.2 lib/contrast/extension/assess/erb.rb
contrast-agent-3.13.1 lib/contrast/extension/assess/erb.rb
contrast-agent-3.13.0 lib/contrast/extension/assess/erb.rb
contrast-agent-3.12.2 lib/contrast/extension/assess/erb.rb
contrast-agent-3.12.1 lib/contrast/extension/assess/erb.rb
contrast-agent-3.12.0 lib/contrast/extension/assess/erb.rb
contrast-agent-3.11.0 lib/contrast/extensions/ruby_core/assess/erb.rb