Class: Arachni::Check::Manager

Inherits:
Arachni::Component::Manager show all
Defined in:
lib/arachni/check/manager.rb

Overview

Manages and runs Arachni::Checks against Pages.

Direct Known Subclasses

RPC::Server::Check::Manager

Defined Under Namespace

Classes: Error

Constant Summary collapse

NAMESPACE =

Namespace under which all checks reside.

::Arachni::Checks

Constants inherited from Arachni::Component::Manager

Arachni::Component::Manager::EXCLUDE, Arachni::Component::Manager::WILDCARD

Instance Attribute Summary

Attributes inherited from Arachni::Component::Manager

#lib, #namespace

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Arachni::Component::Manager

#available, #clear, #delete, #include?, #load, #load_all, #load_by_tags, #loaded, #matches_glob?, #matches_globs?, #name_to_path, #parse, #path_to_name, #paths, #prepare_options

Methods included from Utilities

#available_port, available_port_mutex, #bytes_to_kilobytes, #bytes_to_megabytes, #caller_name, #caller_path, #cookie_decode, #cookie_encode, #cookies_from_file, #cookies_from_parser, #cookies_from_response, #exception_jail, #exclude_path?, #follow_protocol?, #form_decode, #form_encode, #forms_from_parser, #forms_from_response, #full_and_absolute_url?, #generate_token, #get_path, #hms_to_seconds, #html_decode, #html_encode, #include_path?, #links_from_parser, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_set_cookie, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #random_seed, #redundant_path?, #regexp_array_match, #remove_constants, #request_parse_body, #seconds_to_hms, #skip_page?, #skip_path?, #skip_resource?, #skip_response?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parse_query, #uri_parser, #uri_rewrite

Methods included from UI::Output

#debug?, #debug_level_1?, #debug_level_2?, #debug_level_3?, #debug_level_4?, #debug_off, #debug_on, #disable_only_positives, #included, #mute, #muted?, #only_positives, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_level_1, #print_debug_level_2, #print_debug_level_3, #print_debug_level_4, #print_error, #print_error_backtrace, #print_exception, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?, reset_output_options, #unmute, #verbose?, #verbose_on

Methods inherited from Hash

#apply_recursively, #downcase, #find_symbol_keys_recursively, #my_stringify, #my_stringify_keys, #my_symbolize_keys, #recode, #recode!, #stringify_recursively_and_freeze

Constructor Details

#initialize(framework) ⇒ Manager



39
40
41
42
43
44
# File 'lib/arachni/check/manager.rb', line 39

def initialize( framework )
    self.class.reset

    @framework = framework
    super( @framework.options.paths.checks, NAMESPACE )
end

Class Method Details

.resetObject



134
135
136
# File 'lib/arachni/check/manager.rb', line 134

def self.reset
    remove_constants( NAMESPACE )
end

Instance Method Details

#[](name) ⇒ Check::Base

Raises:



59
60
61
62
63
64
65
66
67
68
69
# 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

#resetObject



137
138
139
# File 'lib/arachni/check/manager.rb', line 137

def reset
    self.class.reset
end

#run(page) ⇒ Object



48
49
50
# 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) ⇒ Bool

Runs a single ‘check` against `page`.



123
124
125
126
127
128
129
130
131
132
# 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

#scheduleArray



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# 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_platformsHash



103
104
105
# File 'lib/arachni/check/manager.rb', line 103

def with_platforms
    select { |k, v| v.has_platforms? }
end

#without_platformsHash



109
110
111
# File 'lib/arachni/check/manager.rb', line 109

def without_platforms
    select { |k, v| !v.has_platforms? }
end