Class: Spektr::Checks::Evaluation

Inherits:
Base
  • Object
show all
Defined in:
lib/spektr/checks/evaluation.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#app_version_between?, #dupe?, #full_receiver, #model_attribute?, #receivers_for, #should_run?, #target_affected?, #user_input?, #version_affected, #version_between?, #warn!

Constructor Details

#initialize(app, target) ⇒ Evaluation

Returns a new instance of Evaluation.



4
5
6
7
8
9
# File 'lib/spektr/checks/evaluation.rb', line 4

def initialize(app, target)
  super
  @name = "Arbitrary code execution"
  @type = "Remote Code Execution"
  @targets = ["Spektr::Targets::Base", "Spektr::Targets::Model", "Spektr::Targets::Controller", "Spektr::Targets::Routes", "Spektr::Targets::View"]
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/spektr/checks/evaluation.rb', line 11

def run
  return unless super
  [:eval, :instance_eval, :class_eval, :module_eval].each do |name|
    @target.find_calls(name).each do |call|
      call.arguments.arguments.each do |argument|
        if user_input?(argument)
          warn! @target, self, call.location, "User input in eval"
        end
      end
    end
  end
end