Class: Arachni::AuditStore
Overview
Arachni::AuditStore class
Represents a finished audit session.<br/> It holds information about the runtime environment, the results of the audit etc…
@author: Tasos “Zapotek” Laskos
<[email protected]>
<[email protected]>
@version: 0.1.2
Constant Summary collapse
- MODULE_NAMESPACE =
::Arachni::Modules
- ORDER =
[ ::Arachni::Issue::Severity::HIGH, ::Arachni::Issue::Severity::MEDIUM, ::Arachni::Issue::Severity::LOW, ::Arachni::Issue::Severity::INFORMATIONAL ]
Instance Attribute Summary collapse
-
#delta_time ⇒ String
readonly
How long the audit took.
-
#finish_datetime ⇒ String
readonly
The date and time when the audit finished.
-
#issues ⇒ Array<Issue>
readonly
The discovered issues.
-
#options ⇒ Hash
readonly
The runtime arguments/options of the environment.
-
#plugins ⇒ Hash
readonly
Plugin results.
-
#revision ⇒ String
readonly
The revision of the framework class.
-
#sitemap ⇒ Array
readonly
All the urls crawled.
-
#start_datetime ⇒ String
readonly
The date and time when the audit started.
-
#version ⇒ String
readonly
The version of the framework.
Class Method Summary collapse
-
.load(file) ⇒ AuditStore
Loads and returns an AuditStore object from file.
Instance Method Summary collapse
-
#initialize(audit = {}) ⇒ AuditStore
constructor
A new instance of AuditStore.
-
#save(file) ⇒ Object
Saves ‘self’ to file.
-
#to_h ⇒ Hash
Returns ‘self’ and all objects in its instance vars as hashes.
Constructor Details
#initialize(audit = {}) ⇒ AuditStore
Returns a new instance of AuditStore.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/arachni/audit_store.rb', line 84 def initialize( audit = {} ) @plugins = {} @sitemap = [] # set instance variables from audit opts audit.each { |k, v| self.instance_variable_set( '@' + k.to_s, v ) } @options = ( @options ) @issues = sort( prepare_variations( @issues ) ) if @options['start_datetime'] @start_datetime = @options['start_datetime'].asctime else @start_datetime = Time.now.asctime end if @options['finish_datetime'] @finish_datetime = @options['finish_datetime'].asctime else @finish_datetime = Time.now.asctime end @delta_time = secs_to_hms( @options['delta_time'] ) end |
Instance Attribute Details
#delta_time ⇒ String (readonly)
Returns how long the audit took.
73 74 75 |
# File 'lib/arachni/audit_store.rb', line 73 def delta_time @delta_time end |
#finish_datetime ⇒ String (readonly)
Returns the date and time when the audit finished.
68 69 70 |
# File 'lib/arachni/audit_store.rb', line 68 def finish_datetime @finish_datetime end |
#issues ⇒ Array<Issue> (readonly)
Returns the discovered issues.
53 54 55 |
# File 'lib/arachni/audit_store.rb', line 53 def issues @issues end |
#options ⇒ Hash (readonly)
Returns the runtime arguments/options of the environment.
43 44 45 |
# File 'lib/arachni/audit_store.rb', line 43 def @options end |
#plugins ⇒ Hash (readonly)
Returns plugin results.
58 59 60 |
# File 'lib/arachni/audit_store.rb', line 58 def plugins @plugins end |
#revision ⇒ String (readonly)
Returns the revision of the framework class.
38 39 40 |
# File 'lib/arachni/audit_store.rb', line 38 def revision @revision end |
#sitemap ⇒ Array (readonly)
Returns all the urls crawled.
48 49 50 |
# File 'lib/arachni/audit_store.rb', line 48 def sitemap @sitemap end |
#start_datetime ⇒ String (readonly)
Returns the date and time when the audit started.
63 64 65 |
# File 'lib/arachni/audit_store.rb', line 63 def start_datetime @start_datetime end |
#version ⇒ String (readonly)
Returns the version of the framework.
33 34 35 |
# File 'lib/arachni/audit_store.rb', line 33 def version @version end |
Class Method Details
.load(file) ⇒ AuditStore
Loads and returns an AuditStore object from file
118 119 120 121 122 123 124 125 126 |
# File 'lib/arachni/audit_store.rb', line 118 def AuditStore.load( file ) begin r = YAML.load( IO.read( file ) ) r.version r rescue Exception => e Marshal.load( File.binread( file ) ) end end |
Instance Method Details
#save(file) ⇒ Object
Saves ‘self’ to file
133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/arachni/audit_store.rb', line 133 def save( file ) begin File.open( file, 'w' ) { |f| f.write( YAML.dump( self ) ) } rescue File.open( file, 'wb' ) { |f| f.write( Marshal.dump( self ) ) } end end |
#to_h ⇒ Hash
Returns ‘self’ and all objects in its instance vars as hashes
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/arachni/audit_store.rb', line 152 def to_h hash = obj_to_hash( self ).dup hash['issues'] = hash['issues'].map { |issue| issue.variations = issue.variations.map { |var| obj_to_hash( var ) } obj_to_hash( issue ) } hash['plugins'].each { |plugin, results| next if !results[:options] hash['plugins'][plugin][:options] = hash['plugins'][plugin][:options].map { |opt| opt.to_h } } return hash end |