Class: Arachni::UI::Web::ReportManager
- Defined in:
- lib/ui/web/report_manager.rb
Overview
Provides nice little wrapper for the Arachni::Report::Manager while also handling<br/> conversions, storing etc.
@author: Tasos “Zapotek” Laskos
<tasos.laskos@gmail.com>
<zapotek@segfault.gr>
@version: 0.1
Constant Summary collapse
- FOLDERNAME =
"reports"- EXTENSION =
'.afr'
Instance Method Summary collapse
-
#all ⇒ Array
Returns the paths of all saved report files as an array.
-
#available ⇒ Array
Returns all available report types.
-
#classes ⇒ Array
Returns all available report classes.
- #delete(report) ⇒ Object
- #delete_all ⇒ Object
-
#get(type, report_file) ⇒ String
Returns a stored report as a <type> file.
-
#get_filename(report) ⇒ String
Generates a filename based on the contents of the report in the form of host:audit_date.
-
#initialize(opts, settings) ⇒ ReportManager
constructor
A new instance of ReportManager.
-
#report_to_path(report) ⇒ String
Gets the path to a given report based on the contents of the report.
-
#save(report) ⇒ String
Saves the report to a file.
-
#savedir ⇒ String
Save directory.
-
#tmpdir ⇒ String
Tmp directory for storage while converting.
-
#valid_class?(type) ⇒ Bool
Checks whether the provided type is a usable report.
Constructor Details
#initialize(opts, settings) ⇒ ReportManager
Returns a new instance of ReportManager.
30 31 32 33 34 |
# File 'lib/ui/web/report_manager.rb', line 30 def initialize( opts, settings ) @opts = opts @settings = settings populate_available end |
Instance Method Details
#all ⇒ Array
Returns the paths of all saved report files as an array
90 91 92 |
# File 'lib/ui/web/report_manager.rb', line 90 def all Dir.glob( savedir + "*#{EXTENSION}" ) end |
#available ⇒ Array
Returns all available report types
139 140 141 |
# File 'lib/ui/web/report_manager.rb', line 139 def available return @@available end |
#classes ⇒ Array
Returns all available report classes
148 149 150 |
# File 'lib/ui/web/report_manager.rb', line 148 def classes @@available_rep_classes end |
#delete(report) ⇒ Object
101 102 103 |
# File 'lib/ui/web/report_manager.rb', line 101 def delete( report ) FileUtils.rm( savedir + File.basename( report, '.afr' ) + '.afr' ) end |
#delete_all ⇒ Object
94 95 96 97 98 99 |
# File 'lib/ui/web/report_manager.rb', line 94 def delete_all all.each { |report| delete( report ) } end |
#get(type, report_file) ⇒ String
Returns a stored report as a <type> file. Basically a convertion/export method.
127 128 129 130 131 132 |
# File 'lib/ui/web/report_manager.rb', line 127 def get( type, report_file ) return if !valid_class?( type ) location = savedir + report_file + EXTENSION convert( type, File.read( location ) ) end |
#get_filename(report) ⇒ String
Generates a filename based on the contents of the report in the form of host:audit_date
114 115 116 117 |
# File 'lib/ui/web/report_manager.rb', line 114 def get_filename( report ) rep = YAML::load( report ) filename = "#{URI(rep.options['url']).host}:#{rep.start_datetime}" end |
#report_to_path(report) ⇒ String
Gets the path to a given report based on the contents of the report
70 71 72 |
# File 'lib/ui/web/report_manager.rb', line 70 def report_to_path( report ) savedir + File.basename( get_filename( report ) + EXTENSION ) end |
#save(report) ⇒ String
Saves the report to a file
58 59 60 61 |
# File 'lib/ui/web/report_manager.rb', line 58 def save( report ) @settings.log.report_saved( {}, get_filename( report ) ) return save_to_file( report, report_to_path( report ) ) end |
#savedir ⇒ String
Returns save directory.
39 40 41 |
# File 'lib/ui/web/report_manager.rb', line 39 def savedir @settings.public + "/#{FOLDERNAME}/" end |
#tmpdir ⇒ String
Returns tmp directory for storage while converting.
46 47 48 |
# File 'lib/ui/web/report_manager.rb', line 46 def tmpdir @settings.tmp + '/' end |
#valid_class?(type) ⇒ Bool
Checks whether the provided type is a usable report
81 82 83 |
# File 'lib/ui/web/report_manager.rb', line 81 def valid_class?( type ) classes[type] || false end |