reports/plugin_formatters/stdout/metamodules.rb in arachni-0.3 vs reports/plugin_formatters/stdout/metamodules.rb in arachni-0.4

- old
+ new

@@ -1,8 +1,8 @@ =begin Arachni - Copyright (c) 2010-2011 Tasos "Zapotek" Laskos <tasos.laskos@gmail.com> + Copyright (c) 2010-2012 Tasos "Zapotek" Laskos <tasos.laskos@gmail.com> This is free software; you can copy and distribute and modify this program under the term of the GPL v2.0 License (See LICENSE file for details) @@ -10,80 +10,73 @@ module Arachni module Reports class Stdout - module PluginFormatters +module PluginFormatters - # - # Stdout formatter for the results of the MetaModules plugin - # - # @author: Tasos "Zapotek" Laskos - # <tasos.laskos@gmail.com> - # <zapotek@segfault.gr> - # @version: 0.1 - # - class MetaModules + # + # Stdout formatter for the results of the MetaModules plugin + # + # @author: Tasos "Zapotek" Laskos + # <tasos.laskos@gmail.com> + # <zapotek@segfault.gr> + # @version: 0.1 + # + class MetaModules < Arachni::Plugin::Formatter - include Arachni::UI::Output + def run + print_status( 'Meta-Modules' ) + print_info( '~~~~~~~~~~~~~~' ) - def initialize( plugin_data ) - @results = plugin_data[:results] - @description = plugin_data[:description] - end + print_info( 'Description: ' + @description ) + print_line - def run - print_status( 'Meta-Modules' ) - print_info( '~~~~~~~~~~~~~~' ) + format_meta_results( @results ) - print_info( 'Description: ' + @description ) - print_line + print_line + end - format_meta_results( @results ) + # + # Runs plugin formatters for the running report and returns a hash + # with the prepared/formatted results. + # + # @param [AuditStore#plugins] plugins plugin data/results + # + def format_meta_results( plugins ) - print_line - end + ancestor = self.class.ancestors[0] - # - # Runs plugin formatters for the running report and returns a hash - # with the prepared/formatted results. - # - # @param [AuditStore#plugins] plugins plugin data/results - # - def format_meta_results( plugins ) + # add the PluginFormatters module to the report + eval( "module MetaFormatters end" ) - ancestor = self.class.ancestors[0] + # prepare the directory of the formatters for the running report + lib = File.dirname( __FILE__ ) + '/metaformatters/' - # add the PluginFormatters module to the report - eval( "module MetaFormatters end" ) + @@formatters ||= {} + # initialize a new component manager to handle the plugin formatters + @@formatters[ancestor] ||= ::Arachni::Report::FormatterManager.new( lib, ancestor.const_get( 'MetaFormatters' ) ) - # prepare the directory of the formatters for the running report - lib = File.dirname( __FILE__ ) + '/metaformatters/' + # load all the formatters + @@formatters[ancestor].load( ['*'] ) if @@formatters[ancestor].empty? - @@formatters ||= {} - # initialize a new component manager to handle the plugin formatters - @@formatters[ancestor] ||= ::Arachni::Report::FormatterManager.new( lib, ancestor.const_get( 'MetaFormatters' ) ) + # run the formatters and gather the formatted data they return + formatted = {} + @@formatters[ancestor].each_pair { + |name, formatter| + plugin_results = plugins[name] + next if !plugin_results || plugin_results[:results].empty? - # load all the formatters - @@formatters[ancestor].load( ['*'] ) if @@formatters[ancestor].empty? + formatted[name] = formatter.new( plugin_results.deep_clone ).run + } - # run the formatters and gather the formatted data they return - formatted = {} - @@formatters[ancestor].each_pair { - |name, formatter| - plugin_results = plugins[name] - next if !plugin_results || plugin_results[:results].empty? - - formatted[name] = formatter.new( plugin_results.deep_clone ).run - } - - return formatted - end - - + return formatted end + end + +end end end end