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
Instance Method Summary collapse
-
#abort(wait = true) ⇒ Object
Aborts the framework #run on a best effort basis.
-
#abort? ⇒ Bool
trueif the framework has been instructed to abort (i.e. is in the process of being aborted or has been aborted),falseotherwise. -
#aborted? ⇒ Bool
trueif the framework #run has been aborted,falseotherwise. -
#aborting? ⇒ Bool
trueif the framework is in the process of aborting,falseotherwise. -
#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
trueif the system has completed successfully,falseotherwise. - #initialize ⇒ Object
-
#pause(wait = true) ⇒ Integer
Pauses the framework on a best effort basis.
-
#pause? ⇒ Bool
trueif the framework has been instructed to pause (i.e. is in the process of being paused or has been paused),falseotherwise. -
#paused? ⇒ Bool
trueif the framework is paused,falseotherwise. -
#pausing? ⇒ Bool
trueif the framework is in the process of pausing,falseotherwise. -
#reset ⇒ Object
Resets everything and allows the framework to be re-used.
-
#restore(afs) ⇒ Framework
Restored instance.
-
#resume(id) ⇒ Object
Removes a #pause request for the current caller.
-
#running? ⇒ Bool
trueif the framework is running,falseotherwise. -
#scanning? ⇒ Bool
trueif the system is scanning,falseotherwise. -
#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
trueif the system is in the process of being suspended,falseotherwise. -
#suspended? ⇒ Bool
trueif the system has been suspended,falseotherwise.
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
278 279 280 |
# File 'lib/arachni/framework/parts/state.rb', line 278 def abort? state.abort? end |
#aborted? ⇒ Bool
271 272 273 |
# File 'lib/arachni/framework/parts/state.rb', line 271 def aborted? state.aborted? end |
#aborting? ⇒ Bool
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
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
237 238 239 |
# File 'lib/arachni/framework/parts/state.rb', line 237 def pause? state.pause? end |
#paused? ⇒ Bool
230 231 232 |
# File 'lib/arachni/framework/parts/state.rb', line 230 def paused? state.paused? end |
#pausing? ⇒ Bool
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 |
#restore(afs) ⇒ Framework
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
218 219 220 |
# File 'lib/arachni/framework/parts/state.rb', line 218 def running? state.running? end |
#scanning? ⇒ Bool
224 225 226 |
# File 'lib/arachni/framework/parts/state.rb', line 224 def scanning? state.scanning? end |
#snapshot_path ⇒ String
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(options.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
211 212 213 |
# File 'lib/arachni/framework/parts/state.rb', line 211 def status state.status end |
#status_messages ⇒ Array<String>
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
324 325 326 |
# File 'lib/arachni/framework/parts/state.rb', line 324 def suspend? state.suspend? end |
#suspended? ⇒ Bool
330 331 332 |
# File 'lib/arachni/framework/parts/state.rb', line 330 def suspended? state.suspended? end |