Sha256: 1181360db02dded7789c45c2de8242a67d5fa6e1aca16d27699880b5014ff6e7

Contents?: true

Size: 954 Bytes

Versions: 47

Compression:

Stored size: 954 Bytes

Contents

require 'brakeman/checks/base_check'

#This check looks for calls to +eval+, +instance_eval+, etc. which include
#user input.
class Brakeman::CheckEvaluation < Brakeman::BaseCheck
  Brakeman::Checks.add self

  @description = "Searches for evaluation of user input"

  #Process calls
  def run_check
    Brakeman.debug "Finding eval-like calls"
    calls = tracker.find_call :method => [:eval, :instance_eval, :class_eval, :module_eval]

    Brakeman.debug "Processing eval-like calls"
    calls.each do |call|
      process_result call
    end
  end

  #Warns if eval includes user input
  def process_result result
    if input = include_user_input?(result[:call].arglist)
      warn :result => result,
        :warning_type => "Dangerous Eval",
        :warning_code => :code_eval,
        :message => "User input in eval",
        :code => result[:call],
        :user_input => input.match,
        :confidence => CONFIDENCE[:high]
    end
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
brakeman-3.0.5 lib/brakeman/checks/check_evaluation.rb
brakeman-min-3.0.5 lib/brakeman/checks/check_evaluation.rb
brakeman-3.0.4 lib/brakeman/checks/check_evaluation.rb
brakeman-min-3.0.4 lib/brakeman/checks/check_evaluation.rb
brakeman-min-3.0.3 lib/brakeman/checks/check_evaluation.rb
brakeman-3.0.3 lib/brakeman/checks/check_evaluation.rb
brakeman-min-3.0.2 lib/brakeman/checks/check_evaluation.rb
brakeman-3.0.2 lib/brakeman/checks/check_evaluation.rb
brakeman-min-3.0.1 lib/brakeman/checks/check_evaluation.rb
brakeman-3.0.1 lib/brakeman/checks/check_evaluation.rb
brakeman-3.0.0 lib/brakeman/checks/check_evaluation.rb
brakeman-min-3.0.0 lib/brakeman/checks/check_evaluation.rb
brakeman-2.6.3 lib/brakeman/checks/check_evaluation.rb
brakeman-min-2.6.3 lib/brakeman/checks/check_evaluation.rb
brakeman-min-2.6.2 lib/brakeman/checks/check_evaluation.rb
brakeman-2.6.2 lib/brakeman/checks/check_evaluation.rb
brakeman-2.6.1 lib/brakeman/checks/check_evaluation.rb
brakeman-min-2.6.1 lib/brakeman/checks/check_evaluation.rb
brakeman-min-2.6.0 lib/brakeman/checks/check_evaluation.rb
brakeman-2.6.0 lib/brakeman/checks/check_evaluation.rb