module Pentest
Constants
- VERSION
Public Class Methods
add_before_attack(*args, &block)
click to toggle source
# File lib/pentest.rb, line 77 def add_before_attack(*args, &block) @@hooks[:before_attacks] << block end
add_setup(*args, &block)
click to toggle source
# File lib/pentest.rb, line 73 def add_setup(*args, &block) @@hooks[:setups] << block end
get_project_name()
click to toggle source
# File lib/pentest.rb, line 67 def get_project_name if defined?(::Rails) ::Rails.application.class.parent_name end end
is_project_loaded?()
click to toggle source
# File lib/pentest.rb, line 63 def is_project_loaded? defined?(::Rails) end
run(options)
click to toggle source
# File lib/pentest.rb, line 22 def run options Logger.debug "launched" ENV['RAILS_ENV'] ||= 'test' Logger.debug "Loading Rails project..." @app_path = File.expand_path(options[:app_path]) unless File.directory?(@app_path) Logger.error "#{options[:app_path]} is not valid directory." return :error end environment_path = File.expand_path('config/environment.rb', @app_path) unless File.file?(environment_path) Logger.error "Your project does not contain config/environment.rb file, which must be exist on every valid Rails project. Check your configuration." return :error end require environment_path unless is_project_loaded? Logger.error "Rails project not loaded. Check if your config/environment.rb file is valid." return :error end Logger.debug "Loaded Rails project #{get_project_name.inspect} (Rails #{Rails::VERSION::STRING})" # TODO: Check if Pentestfile exists pentestfile_path = options[:pentestfile] || 'Pentestfile' Logger.debug "Loading #{pentestfile_path}..." load_pentestfile(pentestfile_path) Logger.debug "Initializing scanner..." runner = Runner.new(@app_path, @@hooks) runner.run end
Private Class Methods
load_pentestfile(pentestfile_path)
click to toggle source
# File lib/pentest.rb, line 83 def load_pentestfile(pentestfile_path) load(File.expand_path(pentestfile_path, @app_path)) end