Class: Arachni::Report::Base Abstract

Inherits:
Object
  • Object
show all
Includes:
Arachni, Module::Utilities, Arachni::Report, UI::Output
Defined in:
lib/arachni/report/base.rb

Overview

This class is abstract.

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

Author:

Defined Under Namespace

Modules: PluginFormatters

Constant Summary collapse

REPORT_FP =

where to report false positives info about this should be included in all templates

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

Constants included from Arachni

BANNER, Cookie, Form, Header, Link, Severity, VERSION, WEBSITE, WIKI

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Module::Utilities

#read_file

Methods included from Utilities

#cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #extract_domain, #form_decode, #form_encode, #form_parse_request_body, #forms_from_document, #forms_from_response, #get_path, #hash_keys_to_str, #html_decode, #html_encode, #include_path?, #links_from_document, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_query, #parse_set_cookie, #parse_url_vars, #path_in_domain?, #path_too_deep?, #remove_constants, #seed, #skip_path?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parser, #url_sanitize

Methods included from UI::Output

#debug?, #debug_off, #debug_on, #disable_only_positives, #flush_buffer, #mute, #muted?, old_reset_output_options, #only_positives, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_pp, #print_error, #print_error_backtrace, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?, reset_output_options, #set_buffer_cap, #uncap_buffer, #unmute, #verbose, #verbose?

Methods included from Arachni

URI

Constructor Details

#initialize(auditstore, options) ⇒ Base

Returns a new instance of Base.

Parameters:

  • auditstore (AuditStore)
  • options (Hash)

    options passed to the report



98
99
100
101
# File 'lib/arachni/report/base.rb', line 98

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

Instance Attribute Details

#auditstoreObject (readonly)

Returns the value of attribute auditstore.



92
93
94
# File 'lib/arachni/report/base.rb', line 92

def auditstore
  @auditstore
end

#optionsObject (readonly)

Returns the value of attribute options.



91
92
93
# File 'lib/arachni/report/base.rb', line 91

def options
  @options
end

Class Method Details

.has_outfile?Boolean

Returns:

  • (Boolean)


163
164
165
166
# File 'lib/arachni/report/base.rb', line 163

def self.has_outfile?
    (info[:options] || {}).each { |opt| return true if opt.name == Options.outfile.name }
    false
end

.infoObject

REQUIRED

Do not omit any of the info.



176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/arachni/report/base.rb', line 176

def self.info
    {
        name:        'Report abstract class.',
        options:     [
            #                    option name    required?       description                         default
            # Arachni::OptBool.new( 'html',    [ false, 'Include the HTML responses in the report?', true ] ),
            # Arachni::OptBool.new( 'headers', [ false, 'Include the headers in the report?', true ] ),
        ],
        description: %q{This class should be extended by all reports.},
        author:      'zapotek',
        version:     '0.1.1',
    }
end

Instance Method Details

#format_plugin_results(plugins = auditstore.plugins, &block) ⇒ Object

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

Parameters:

  • plugins (AuditStore#plugins) (defaults to: auditstore.plugins)

    plugin data/results



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/arachni/report/base.rb', line 115

def format_plugin_results( plugins = auditstore.plugins, &block )
    formatted = {}
    return formatted if !plugins

    # get the object that extends this class (i.e. the running report)
    ancestor = self.class.ancestors[0]

    # add the PluginFormatters module to the report
    eval "class #{ancestor}; module PluginFormatters end; end"

    # get the path to the report file
    # this is a very bad way to do it...
    report_path = ::Kernel.caller.first.split( ':' ).first

    # 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[ancestor] ||= FormatterManager.new( lib, ancestor.const_get( 'PluginFormatters' ) )

    # load all the formatters
    @@formatters[ancestor].load_all if @@formatters[ancestor].empty?

    # run the formatters and gather the formatted data they return
    @@formatters[ancestor].each do |name, formatter|
        plugin_results = plugins[name]
        next if !plugin_results || plugin_results[:results].empty?

        exception_jail( false ) {
            cr = plugin_results.clone
            block.call( cr ) if block_given?
            formatted[name] = formatter.new( cr ).run
        }
    end

    formatted
end

#has_outfile?Boolean

Returns:

  • (Boolean)


167
168
169
# File 'lib/arachni/report/base.rb', line 167

def has_outfile?
    self.class.has_outfile?
end

#outfileObject



155
156
157
# File 'lib/arachni/report/base.rb', line 155

def outfile
    options['outfile']
end

#runObject

REQUIRED



106
107
# File 'lib/arachni/report/base.rb', line 106

def run
end

#skip_responses?Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/arachni/report/base.rb', line 159

def skip_responses?
    !!options['skip_responses']
end