Sha256: b59ffed5b8a257187bd8ca77b2728e3238475999b5983ab14e3f894dc1916cae

Contents?: true

Size: 866 Bytes

Versions: 5

Compression:

Stored size: 866 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 result includes user input
  def process_result result
    if include_user_input? result[:call]
      warn :result => result,
        :warning_type => "Dangerous Eval",
        :message => "User input in eval",
        :code => result[:call],
        :confidence => CONFIDENCE[:high]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
brakeman-1.5.2 lib/brakeman/checks/check_evaluation.rb
brakeman-1.5.1 lib/brakeman/checks/check_evaluation.rb
brakeman-1.5.0 lib/brakeman/checks/check_evaluation.rb
brakeman-1.4.0 lib/brakeman/checks/check_evaluation.rb
brakeman-1.3.0 lib/brakeman/checks/check_evaluation.rb