Class: Arachni::AuditStore
Overview
Represents a finished audit session.
It holds information about the runtime environment, the results of the audit etc…
Constant Summary collapse
- MODULE_NAMESPACE =
::Arachni::Modules
- ORDER =
[ Severity::HIGH, Severity::MEDIUM, Severity::LOW, 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.
- .sort(issues) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(opts = {}) ⇒ AuditStore
constructor
A new instance of AuditStore.
-
#save(file) ⇒ Object
Saves ‘self’ to file.
-
#to_hash ⇒ Hash
(also: #to_h)
Returns ‘self’ and all objects in its instance vars as hashes.
Constructor Details
#initialize(opts = {}) ⇒ AuditStore
Returns a new instance of AuditStore.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/arachni/audit_store.rb', line 86 def initialize( opts = {} ) @plugins = {} @sitemap = [] @issues ||= [] @options ||= Options # set instance variables from audit opts opts.each { |k, v| self.instance_variable_set( '@' + k.to_s, v ) } @options = ( @options ) @issues = self.class.sort( prepare_variations( @issues.deep_clone ) ) @start_datetime = if @options['start_datetime'] @options['start_datetime'].asctime else Time.now.asctime end @finish_datetime = if @options['finish_datetime'] @options['finish_datetime'].asctime else 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.
75 76 77 |
# File 'lib/arachni/audit_store.rb', line 75 def delta_time @delta_time end |
#finish_datetime ⇒ String (readonly)
Returns the date and time when the audit finished.
70 71 72 |
# File 'lib/arachni/audit_store.rb', line 70 def finish_datetime @finish_datetime end |
#issues ⇒ Array<Issue> (readonly)
Returns the discovered issues.
55 56 57 |
# File 'lib/arachni/audit_store.rb', line 55 def issues @issues end |
#options ⇒ Hash (readonly)
Returns the runtime arguments/options of the environment.
45 46 47 |
# File 'lib/arachni/audit_store.rb', line 45 def @options end |
#plugins ⇒ Hash (readonly)
Returns plugin results.
60 61 62 |
# File 'lib/arachni/audit_store.rb', line 60 def plugins @plugins end |
#revision ⇒ String (readonly)
Returns the revision of the framework class.
40 41 42 |
# File 'lib/arachni/audit_store.rb', line 40 def revision @revision end |
#sitemap ⇒ Array (readonly)
Returns all the urls crawled.
50 51 52 |
# File 'lib/arachni/audit_store.rb', line 50 def sitemap @sitemap end |
#start_datetime ⇒ String (readonly)
Returns the date and time when the audit started.
65 66 67 |
# File 'lib/arachni/audit_store.rb', line 65 def start_datetime @start_datetime end |
#version ⇒ String (readonly)
Returns the version of the framework.
35 36 37 |
# File 'lib/arachni/audit_store.rb', line 35 def version @version end |
Class Method Details
.load(file) ⇒ AuditStore
Loads and returns an AuditStore object from file
121 122 123 124 125 126 127 128 129 |
# File 'lib/arachni/audit_store.rb', line 121 def self.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
#==(other) ⇒ Object
168 169 170 |
# File 'lib/arachni/audit_store.rb', line 168 def ==( other ) to_hash == other.to_hash end |
#hash ⇒ Object
172 173 174 |
# File 'lib/arachni/audit_store.rb', line 172 def hash to_hash.hash end |
#save(file) ⇒ Object
Saves ‘self’ to file
136 137 138 139 140 141 142 |
# File 'lib/arachni/audit_store.rb', line 136 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_hash ⇒ Hash Also known as: to_h
Returns ‘self’ and all objects in its instance vars as hashes
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/arachni/audit_store.rb', line 149 def to_hash hash = obj_to_hash( self ).deep_clone hash['issues'] = hash['issues'].map do |issue| issue.variations = issue.variations.map { |var| obj_to_hash( var ) } obj_to_hash( issue ) end hash['plugins'].each do |plugin, results| next if !results[:options] hash['plugins'][plugin][:options] = hash['plugins'][plugin][:options].map { |opt| opt.to_h } end hash end |