Class: Arachni::Report::Registry
- Inherits:
-
Object
- Object
- Arachni::Report::Registry
- Defined in:
- lib/report/registry.rb
Overview
Arachni::Report::Registry class
Holds and manages the registry of the reports.
@author: Anastasios “Zapotek” Laskos
<tasos.laskos@gmail.com> <zapotek@segfault.gr> <br/>
@version: 0.1-pre
Class Attribute Summary (collapse)
-
+ (Object) registry
readonly
Returns the value of attribute registry.
Class Method Summary (collapse)
-
+ (Array<Arachni::Reports>) clean
Class method.
-
+ (Array<Arachni::Reports>) clean_up
Class method.
-
+ (Array<Arachni::Reports>) get_registry
Class method.
-
+ (Object) register(report)
Registers a report with the framework.
Instance Method Summary (collapse)
-
- (Arachni::Reports) get_by_name(name)
Gets a report by its filename, without the extension.
-
- (String) get_path_from_name(name)
Gets the path of the specified report.
-
- (Hash) info(reg_id)
Grabs the information of a report based on its ID in the @@registry.
-
- (Registry) initialize(lib)
constructor
A new instance of Registry.
-
- (Hash<Hash<String, String>>) ls_available
Lists all available reports and puts them in a Hash.
-
- (Array<Arachni::Reports>) ls_loaded
Lists the loaded modules.
-
- (Arachni::Reports) rep_load(name)
Loads and registers a report by it’s filename, without the extension.
Constructor Details
- (Registry) initialize(lib)
A new instance of Registry
32 33 34 35 36 |
# File 'lib/report/registry.rb', line 32 def initialize( lib ) @lib = lib @@registry = [] @available = Hash.new end |
Class Attribute Details
+ (Object) registry (readonly)
Returns the value of attribute registry
29 30 31 |
# File 'lib/report/registry.rb', line 29 def registry @registry end |
Class Method Details
+ (Array<Arachni::Reports>) clean
Class method
Empties the report registry
127 128 129 |
# File 'lib/report/registry.rb', line 127 def Registry.clean( ) @@registry = [] end |
+ (Array<Arachni::Reports>) clean_up
Class method
Cleans the registry from boolean values passed with the Arachni::Reports objects and updates it
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/report/registry.rb', line 167 def Registry.clean_up( ) clean_reg = [] @@registry.each { |report| begin if report < Arachni::Report::Base clean_reg << report end rescue Exception => e end } @@registry = clean_reg.uniq.flatten end |
+ (Array<Arachni::Reports>) get_registry
Class method
Lists the loaded reports
116 117 118 |
# File 'lib/report/registry.rb', line 116 def Registry.get_registry( ) @@registry.uniq end |
+ (Object) register(report)
Registers a report with the framework
Used by the Registrar only
153 154 155 156 |
# File 'lib/report/registry.rb', line 153 def Registry.register( report ) @@registry << report Registry.clean_up( ) end |
Instance Method Details
- (Arachni::Reports) get_by_name(name)
Gets a report by its filename, without the extension
65 66 67 68 69 70 71 |
# File 'lib/report/registry.rb', line 65 def get_by_name( name ) begin load( get_path_from_name( name ) ) rescue Exception => e raise e end end |
- (String) get_path_from_name(name)
Gets the path of the specified report
80 81 82 83 84 85 86 87 |
# File 'lib/report/registry.rb', line 80 def get_path_from_name( name ) begin return ls_available( )[name]['path'].to_s rescue Exception => e raise( Arachni::Exceptions::ReportNotFound, 'Uknown report \'' + name + '\'.' ) end end |
- (Hash) info(reg_id)
Grabs the information of a report based on its ID in the @@registry
139 140 141 142 143 144 145 146 |
# File 'lib/report/registry.rb', line 139 def info( reg_id ) @@registry.each_with_index { |mod, i| if i == reg_id return mod.info end } end |
- (Hash<Hash<String, String>>) ls_available
Lists all available reports and puts them in a Hash
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/report/registry.rb', line 95 def ls_available( ) Dir.glob( @lib + '*.rb' ).each { |class_path| filename = class_path.gsub( Regexp.escape( @lib ) , '' ) filename.gsub!( Regexp.new( '.rb' ) , '' ) @available[filename] = Hash.new @available[filename]['path'] = class_path } @available end |
- (Array<Arachni::Reports>) ls_loaded
Lists the loaded modules
54 55 56 |
# File 'lib/report/registry.rb', line 54 def ls_loaded( ) Registry.get_registry( ) end |
- (Arachni::Reports) rep_load(name)
Loads and registers a report by it’s filename, without the extension
45 46 47 |
# File 'lib/report/registry.rb', line 45 def rep_load( name ) Registry.register( get_by_name( name ) ) end |