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

#available_port, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #extract_domain, #follow_protocol?, #form_decode, #form_encode, #form_parse_request_body, #forms_from_document, #forms_from_response, #generate_token, #get_path, #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?, #port_available?, #rand_port, #redundant_path?, #remove_constants, #seed, #skip_page?, #skip_path?, #skip_resource?, #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, #error_logfile, #flush_buffer, #log_error, #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, #set_error_logfile, #uncap_buffer, #unmute, #verbose, #verbose?

Methods included from Arachni

URI, profile?

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)


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

def self.has_outfile?
    !!outfile_option
end

.infoObject

REQUIRED

Do not omit any of the info.



180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/arachni/report/base.rb', line 180

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

.outfile_optionObject



194
195
196
197
# File 'lib/arachni/report/base.rb', line 194

def self.outfile_option
    (info[:options] || {}).
        select { |opt| opt.name == Options.outfile.name }.first
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)


171
172
173
# File 'lib/arachni/report/base.rb', line 171

def has_outfile?
    self.class.has_outfile?
end

#outfileObject



155
156
157
158
159
160
161
162
# File 'lib/arachni/report/base.rb', line 155

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

    options['outfile']
end

#runObject

REQUIRED



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

def run
end

#skip_responses?Boolean

Returns:

  • (Boolean)


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

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