Class: Arachni::Reporter::Base Abstract

Inherits:
Component::Base show all
Includes:
Arachni::Reporter
Defined in:
lib/arachni/reporter/base.rb

Overview

This class is abstract.

An abstract class for the reporters, all reporters must extend this.

Defined Under Namespace

Modules: PluginFormatters

Constant Summary collapse

REPORT_FP =

Where to report false positives.

'http://github.com/Arachni/arachni/issues'

Constants included from Arachni

BANNER, Cookie, Form, Header, JSON, Link, LinkTemplate, Severity, VERSION, WEBSITE, WIKI, XML

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Component::Base

author, description, fullname, #shortname, shortname, shortname=, version

Methods included from Component::Utilities

#read_file

Methods included from Utilities

#available_port, #bytes_to_kilobytes, #bytes_to_megabytes, #caller_name, #caller_path, #cookie_decode, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #follow_protocol?, #form_decode, #form_encode, #forms_from_document, #forms_from_response, #full_and_absolute_url?, #generate_token, #get_path, #hms_to_seconds, #html_decode, #html_encode, #include_path?, #links_from_document, #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 Component::Output

#depersonalize_output, #depersonalize_output?, #intercept_print_message

Methods included from UI::Output

#debug?, #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_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 included from Arachni

URI, jruby?, null_device, profile?, windows?

Constructor Details

#initialize(report, options) ⇒ Base

Returns a new instance of Base.

Parameters:

  • report (Report)
  • options (Hash)

    Options to pass to the report.



35
36
37
38
# File 'lib/arachni/reporter/base.rb', line 35

def initialize( report, options )
    @report  = report
    @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



29
30
31
# File 'lib/arachni/reporter/base.rb', line 29

def options
  @options
end

#reportObject (readonly)

Returns the value of attribute report.



30
31
32
# File 'lib/arachni/reporter/base.rb', line 30

def report
  @report
end

Class Method Details

.has_outfile?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/arachni/reporter/base.rb', line 100

def self.has_outfile?
    !!outfile_option
end

.infoObject

Note:

REQUIRED

Do not omit any of the info.



110
111
112
113
114
115
116
117
118
# File 'lib/arachni/reporter/base.rb', line 110

def self.info
    {
        name:        'Reporter abstract class.',
        options:     [],
        description: %q{This class should be extended by all reports.},
        author:      'zapotek',
        version:     '0.1.1',
    }
end

.outfile_optionObject



120
121
122
# File 'lib/arachni/reporter/base.rb', line 120

def self.outfile_option
    (info[:options] || {}).find { |opt| opt.name == Options.outfile.name }
end

Instance Method Details

#format_plugin_results(run = true, &block) ⇒ Object

Runs plugin formatters for the running report and returns a hash with the prepared/formatted results.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/arachni/reporter/base.rb', line 48

def format_plugin_results( run = true, &block )
    # Add the PluginFormatters module to the report.
    eval "class #{self.class}; module PluginFormatters end; end"

    # Get the path to the report file, we're assuming it's the one who
    # called us.
    report_path = caller_path(1)

    # Prepare the directory of the formatters for the running report.
    lib = File.dirname( report_path ) + '/plugin_formatters/' +
        File.basename( report_path, '.rb' ) +  '/'

    @@formatters ||= {}

    # Initialize a new component manager to handle the plugin formatters.
    @@formatters[shortname] ||= FormatterManager.new(
        lib, self.class.const_get( :PluginFormatters )
    )

    @@formatters[shortname].load_all if @@formatters[shortname].empty?

    formatted = {}
    @@formatters[shortname].each do |name, formatter_klass|
        name    = name.to_sym
        results = report.plugins[name]

        next if !results || results[:results].empty?

        formatter = formatter_klass.new( self, report, results )

        block.call( name, formatter ) if block_given?

        next if !run
        formatted[name] = formatter.run
    end

    formatted
end

#has_outfile?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/arachni/reporter/base.rb', line 103

def has_outfile?
    self.class.has_outfile?
end

#outfileObject



87
88
89
90
91
92
93
94
# File 'lib/arachni/reporter/base.rb', line 87

def outfile
    if File.directory?( options[:outfile] )
        return File.expand_path "#{options[:outfile]}/" +
                "#{self.class.outfile_option.default}"
    end

    options[:outfile]
end

#runObject

This method is abstract.
Note:

REQUIRED



43
44
# File 'lib/arachni/reporter/base.rb', line 43

def run
end

#skip_responses?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/arachni/reporter/base.rb', line 96

def skip_responses?
    !!options[:skip_responses]
end