Class: TaintedLove::Replacer::ReplaceObject

Inherits:
Base
  • Object
show all
Defined in:
lib/tainted_love/replacer/replace_object.rb

Constant Summary collapse

TAGS =
{}

Instance Method Summary collapse

Methods inherited from Base

replacers, #should_replace?

Instance Method Details

#replace!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tainted_love/replacer/replace_object.rb', line 8

def replace!
  mod = Module.new do
    def send(*args, &block)
      if args[0].tainted? && args[1].tainted?
        TaintedLove.report(
          :ReplaceObject,
          args.first,
          [:rce],
          'User input in the first 2 arguments of Object#send'
        )
      end

      super(*args, &block)
    end

    def tainted_love_tags
      TAGS[object_id] ||= []
    end

    def tainted_love_tags=(tags)
      TAGS[object_id] = tags
    end
  end

  Object.prepend(mod)
end