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.
292 293 294 |
# File 'lib/arachni/framework/parts/state.rb', line 292 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.
278 279 280 |
# File 'lib/arachni/framework/parts/state.rb', line 278 def abort? state.abort? end |
#aborted? ⇒ Bool
Returns `true` if the framework #run has been aborted, `false` otherwise.
271 272 273 |
# File 'lib/arachni/framework/parts/state.rb', line 271 def aborted? state.aborted? end |
#aborting? ⇒ Bool
Returns `true` if the framework is in the process of aborting, `false` otherwise.
284 285 286 |
# File 'lib/arachni/framework/parts/state.rb', line 284 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.
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 129 130 131 132 133 134 135 136 |
# File 'lib/arachni/framework/parts/state.rb', line 103 def clean_up( shutdown_browsers = true ) return if @cleaned_up @cleaned_up = true state.force_resume state.status = :cleanup 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.
248 249 250 |
# File 'lib/arachni/framework/parts/state.rb', line 248 def done? state.done? end |
#initialize ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/arachni/framework/parts/state.rb', line 65 def initialize super Element::Capabilities::Auditable.skip_like do |element| if pause? print_debug "Blocking on element audit: #{element.audit_id}" end wait_if_paused end 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.
263 264 265 266 267 |
# File 'lib/arachni/framework/parts/state.rb', line 263 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.
237 238 239 |
# File 'lib/arachni/framework/parts/state.rb', line 237 def pause? state.pause? end |
#paused? ⇒ Bool
Returns `true` if the framework is paused, `false` otherwise.
230 231 232 |
# File 'lib/arachni/framework/parts/state.rb', line 230 def paused? state.paused? end |
#pausing? ⇒ Bool
Returns `true` if the framework is in the process of pausing, `false` otherwise.
243 244 245 |
# File 'lib/arachni/framework/parts/state.rb', line 243 def pausing? state.pausing? end |
#reset ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/arachni/framework/parts/state.rb', line 147 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
139 140 141 |
# File 'lib/arachni/framework/parts/state.rb', line 139 def reset_trainer @trainer = Trainer.new( self ) end |
#restore(afs) ⇒ Framework
Returns Restored instance.
177 178 179 180 181 182 183 184 185 186 |
# File 'lib/arachni/framework/parts/state.rb', line 177 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
304 305 306 |
# File 'lib/arachni/framework/parts/state.rb', line 304 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?.
218 219 220 |
# File 'lib/arachni/framework/parts/state.rb', line 218 def running? state.running? end |
#scanning? ⇒ Bool
Returns `true` if the system is scanning, `false` otherwise.
224 225 226 |
# File 'lib/arachni/framework/parts/state.rb', line 224 def scanning? state.scanning? end |
#snapshot_path ⇒ String
Returns Provisioned #suspend dump file for this instance.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/arachni/framework/parts/state.rb', line 81 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
168 169 170 |
# File 'lib/arachni/framework/parts/state.rb', line 168 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.
211 212 213 |
# File 'lib/arachni/framework/parts/state.rb', line 211 def status state.status end |
#status_messages ⇒ Array<String>
Returns Messages providing more information about the current #status of the framework.
191 192 193 |
# File 'lib/arachni/framework/parts/state.rb', line 191 def state. end |
#suspend(wait = true) ⇒ String?
Writes a Snapshot.dump to disk and aborts the scan.
315 316 317 318 319 |
# File 'lib/arachni/framework/parts/state.rb', line 315 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.
324 325 326 |
# File 'lib/arachni/framework/parts/state.rb', line 324 def suspend? state.suspend? end |
#suspended? ⇒ Bool
Returns `true` if the system has been suspended, `false` otherwise.
330 331 332 |
# File 'lib/arachni/framework/parts/state.rb', line 330 def suspended? state.suspended? end |