Module: Arachni::Framework::Parts::State
- Included in:
- Arachni::Framework
- Defined in:
- lib/arachni/framework/parts/state.rb
Overview
Provides access to State::Framework and helpers.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#abort(wait = true) ⇒ Object
Aborts the framework #run on a best effort basis.
-
#abort? ⇒ Bool
‘true` if the framework has been instructed to abort (i.e. is in the process of being aborted or has been aborted), `false` otherwise.
-
#aborted? ⇒ Bool
‘true` if the framework #run has been aborted, `false` otherwise.
-
#aborting? ⇒ Bool
‘true` if the framework is in the process of aborting, `false` otherwise.
-
#clean_up(shutdown_browsers = true) ⇒ Object
Cleans up the framework; should be called after running the audit or after canceling a running scan.
-
#done? ⇒ Bool
‘true` if the system has completed successfully, `false` otherwise.
- #initialize ⇒ Object
-
#pause(wait = true) ⇒ Integer
Pauses the framework on a best effort basis.
-
#pause? ⇒ Bool
‘true` if the framework has been instructed to pause (i.e. is in the process of being paused or has been paused), `false` otherwise.
-
#paused? ⇒ Bool
‘true` if the framework is paused, `false` otherwise.
-
#pausing? ⇒ Bool
‘true` if the framework is in the process of pausing, `false` otherwise.
-
#reset ⇒ Object
Resets everything and allows the framework to be re-used.
- #reset_trainer ⇒ Object
-
#restore(afs) ⇒ Framework
Restored instance.
-
#resume(id) ⇒ Object
Removes a #pause request for the current caller.
-
#running? ⇒ Bool
‘true` if the framework is running, `false` otherwise.
-
#scanning? ⇒ Bool
‘true` if the system is scanning, `false` otherwise.
-
#snapshot_path ⇒ String
Provisioned #suspend dump file for this instance.
- #state ⇒ State::Framework
-
#status ⇒ Symbol
Status of the instance, possible values are (in order):.
-
#status_messages ⇒ Array<String>
Messages providing more information about the current #status of the framework.
-
#suspend(wait = true) ⇒ String?
Writes a Snapshot.dump to disk and aborts the scan.
-
#suspend? ⇒ Bool
‘true` if the system is in the process of being suspended, `false` otherwise.
-
#suspended? ⇒ Bool
‘true` if the system has been suspended, `false` otherwise.
Class Method Details
.included(base) ⇒ Object
18 19 20 |
# File 'lib/arachni/framework/parts/state.rb', line 18 def self.included( base ) base.extend ClassMethods end |
Instance Method Details
#abort(wait = true) ⇒ Object
Aborts the framework #run on a best effort basis.
279 280 281 |
# File 'lib/arachni/framework/parts/state.rb', line 279 def abort( wait = true ) state.abort wait end |
#abort? ⇒ Bool
Returns ‘true` if the framework has been instructed to abort (i.e. is in the process of being aborted or has been aborted), `false` otherwise.
265 266 267 |
# File 'lib/arachni/framework/parts/state.rb', line 265 def abort? state.abort? end |
#aborted? ⇒ Bool
Returns ‘true` if the framework #run has been aborted, `false` otherwise.
258 259 260 |
# File 'lib/arachni/framework/parts/state.rb', line 258 def aborted? state.aborted? end |
#aborting? ⇒ Bool
Returns ‘true` if the framework is in the process of aborting, `false` otherwise.
271 272 273 |
# File 'lib/arachni/framework/parts/state.rb', line 271 def aborting? state.aborting? end |
#clean_up(shutdown_browsers = true) ⇒ Object
Cleans up the framework; should be called after running the audit or after canceling a running scan.
It stops the clock and waits for the plugins to finish up.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/arachni/framework/parts/state.rb', line 95 def clean_up( shutdown_browsers = true ) return if @cleaned_up @cleaned_up = true state.status = :cleanup sitemap.merge!( browser_sitemap ) if shutdown_browsers state. :browser_cluster_shutdown shutdown_browser_cluster end state. :clearing_queues page_queue.clear url_queue.clear @finish_datetime = Time.now @start_datetime ||= Time.now # Make sure this is disabled or it'll break reporter output. disable_only_positives state.running = false state. :waiting_for_plugins @plugins.block # Plugins may need the session right till the very end so save it for last. @session.clean_up @session = nil true end |
#done? ⇒ Bool
Returns ‘true` if the system has completed successfully, `false` otherwise.
235 236 237 |
# File 'lib/arachni/framework/parts/state.rb', line 235 def done? state.done? end |
#initialize ⇒ Object
65 66 67 68 69 |
# File 'lib/arachni/framework/parts/state.rb', line 65 def initialize super state.status = :ready end |
#pause(wait = true) ⇒ Integer
Each call from a unique caller is counted as a pause request and in order for the system to resume all pause callers need to #resume it.
Pauses the framework on a best effort basis.
250 251 252 253 254 |
# File 'lib/arachni/framework/parts/state.rb', line 250 def pause( wait = true ) id = generate_token.hash state.pause id, wait id end |
#pause? ⇒ Bool
Returns ‘true` if the framework has been instructed to pause (i.e. is in the process of being paused or has been paused), `false` otherwise.
224 225 226 |
# File 'lib/arachni/framework/parts/state.rb', line 224 def pause? state.pause? end |
#paused? ⇒ Bool
Returns ‘true` if the framework is paused, `false` otherwise.
217 218 219 |
# File 'lib/arachni/framework/parts/state.rb', line 217 def paused? state.paused? end |
#pausing? ⇒ Bool
Returns ‘true` if the framework is in the process of pausing, `false` otherwise.
230 231 232 |
# File 'lib/arachni/framework/parts/state.rb', line 230 def pausing? state.pausing? end |
#reset ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/arachni/framework/parts/state.rb', line 134 def reset @cleaned_up = false @browser_job = nil @failures.clear @retries.clear # This needs to happen before resetting the other components so they # will be able to put in their hooks. self.class.reset clear_observers reset_trainer reset_session @checks.clear @reporters.clear @plugins.clear end |
#reset_trainer ⇒ Object
322 323 324 |
# File 'lib/arachni/framework/parts/state.rb', line 322 def reset_trainer @trainer = Trainer.new( self ) end |
#restore(afs) ⇒ Framework
Returns Restored instance.
164 165 166 167 168 169 170 171 172 173 |
# File 'lib/arachni/framework/parts/state.rb', line 164 def restore( afs ) Snapshot.load afs browser_job_update_skip_states state.browser_skip_states checks.load Options.checks plugins.load Options.plugins.keys nil end |
#resume(id) ⇒ Object
291 292 293 |
# File 'lib/arachni/framework/parts/state.rb', line 291 def resume( id ) state.resume id end |
#running? ⇒ Bool
Returns ‘true` if the framework is running, `false` otherwise. This is `true` even if the scan is #paused?.
205 206 207 |
# File 'lib/arachni/framework/parts/state.rb', line 205 def running? state.running? end |
#scanning? ⇒ Bool
Returns ‘true` if the system is scanning, `false` otherwise.
211 212 213 |
# File 'lib/arachni/framework/parts/state.rb', line 211 def scanning? state.scanning? end |
#snapshot_path ⇒ String
Returns Provisioned #suspend dump file for this instance.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/arachni/framework/parts/state.rb', line 73 def snapshot_path return @state_archive if @state_archive default_filename = "#{URI(.url).host} #{Time.now.to_s.gsub( ':', '_' )} " << "#{generate_token}.afs" location = .snapshot.save_path if !location location = default_filename elsif File.directory? location location += "/#{default_filename}" end @state_archive ||= File.( location ) end |
#state ⇒ State::Framework
155 156 157 |
# File 'lib/arachni/framework/parts/state.rb', line 155 def state Arachni::State.framework end |
#status ⇒ Symbol
Returns Status of the instance, possible values are (in order):
-
‘:ready` – Initialised and waiting for instructions.
-
‘:preparing` – Getting ready to start (i.e. initializing plugins etc.).
-
‘:scanning` – The instance is currently auditing the webapp.
-
‘:pausing` – The instance is being paused (if applicable).
-
‘:paused` – The instance has been paused (if applicable).
-
‘:suspending` – The instance is being suspended (if applicable).
-
‘:suspended` – The instance has being suspended (if applicable).
-
‘:cleanup` – The scan has completed and the instance is
{Framework::Parts::State#clean_up cleaning up} after itself (i.e. waiting for plugins to finish etc.). -
‘:aborted` – The scan has been #abort, you can grab the
report and shutdown. -
‘:done` – The scan has completed, you can grab the report and shutdown.
198 199 200 |
# File 'lib/arachni/framework/parts/state.rb', line 198 def status state.status end |
#status_messages ⇒ Array<String>
Returns Messages providing more information about the current #status of the framework.
178 179 180 |
# File 'lib/arachni/framework/parts/state.rb', line 178 def state. end |
#suspend(wait = true) ⇒ String?
Writes a Snapshot.dump to disk and aborts the scan.
302 303 304 305 306 |
# File 'lib/arachni/framework/parts/state.rb', line 302 def suspend( wait = true ) state.suspend( wait ) return snapshot_path if wait nil end |
#suspend? ⇒ Bool
Returns ‘true` if the system is in the process of being suspended, `false` otherwise.
311 312 313 |
# File 'lib/arachni/framework/parts/state.rb', line 311 def suspend? state.suspend? end |
#suspended? ⇒ Bool
Returns ‘true` if the system has been suspended, `false` otherwise.
317 318 319 |
# File 'lib/arachni/framework/parts/state.rb', line 317 def suspended? state.suspended? end |