class Arachni::Check::Manager
Manages and runs {Checks} against {Page}s.
@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com>
Constants
- NAMESPACE
The namespace under which all checks exist.
Public Class Methods
new( framework )
click to toggle source
@param [Arachni::Framework] framework
Calls superclass method
Arachni::Component::Manager::new
# File lib/arachni/check/manager.rb, line 39 def initialize( framework ) self.class.reset @framework = framework super( @framework.options.paths.checks, NAMESPACE ) end
reset()
click to toggle source
# File lib/arachni/check/manager.rb, line 134 def self.reset remove_constants( NAMESPACE ) end
Public Instance Methods
[]( name )
click to toggle source
@param [Symbol, String] name
Name of the check to retrieve.
@return [Check::Base]
@raise [Error::InvalidPlatforms]
On invalid check platforms.
Calls superclass method
Arachni::Component::Manager#[]
# File lib/arachni/check/manager.rb, line 59 def []( name ) check = super( name ) if !Platform::Manager.valid?( check.platforms ) unload name fail Error::InvalidPlatforms, "Check #{name} contains invalid platforms: #{check.platforms.join(', ')}" end check end
reset()
click to toggle source
# File lib/arachni/check/manager.rb, line 137 def reset self.class.reset end
run( page )
click to toggle source
@param [Arachni::Page] page
Page to audit.
# File lib/arachni/check/manager.rb, line 48 def run( page ) schedule.each { |mod| exception_jail( false ){ run_one( mod, page ) } } end
run_one( check, page )
click to toggle source
Runs a single ‘check` against `page`.
@param [Check::Base] check
Check to run as a class.
@param [Page] page
Page to audit.
@return [Bool]
`true` if the check was ran (based on {Check::Auditor.check?}), `false` otherwise.
# File lib/arachni/check/manager.rb, line 123 def run_one( check, page ) return false if !check.check?( page ) check_new = check.new( page, @framework ) check_new.prepare check_new.run check_new.clean_up true end
schedule()
click to toggle source
@return [Array]
Checks in proper running order, taking account their declared {Check::Base.prefer preferences}.
# File lib/arachni/check/manager.rb, line 74 def schedule schedule = Set.new preferred_over = Hash.new([]) preferred = self.reject do |name, klass| preferred_over[name] = klass.preferred if klass.preferred.any? end return self.values if preferred_over.empty? || preferred.empty? preferred_over.size.times do update = {} preferred.each do |name, klass| schedule << klass preferred_over.select { |_, v| v.include?( name.to_sym ) }.each do |k, v| schedule << (update[k] = self[k]) end end preferred.merge!( update ) end schedule |= preferred_over.keys.map { |n| self[n] } schedule.to_a end
with_platforms()
click to toggle source
@return [Hash]
Checks targeting specific platforms.
# File lib/arachni/check/manager.rb, line 103 def with_platforms select { |k, v| v.has_platforms? } end
without_platforms()
click to toggle source
@return [Hash]
Platform-agnostic checks.
# File lib/arachni/check/manager.rb, line 109 def without_platforms select { |k, v| !v.has_platforms? } end