Module: Arachni::RPC::Server::Framework::Master
- Included in:
- MultiInstance
- Defined in:
- lib/arachni/rpc/server/framework/master.rb
Overview
Holds methods for master Instances, both for remote management and utility ones.
Instance Method Summary collapse
-
#enslave(instance_info, &block) ⇒ Bool
Enslaves another instance and subsequently becomes the master of the group.
- #has_slaves? ⇒ Boolean
-
#master? ⇒ Bool
`true` if running in HPG (High Performance Grid) mode and instance is the master, false otherwise.
-
#set_as_master ⇒ Bool
Sets this instance as the master.
-
#slave_sitrep(data, url, token = nil) ⇒ Bool
Used by slaves to impart the knowledge they've gained during the scan to the master as well as for signaling.
Instance Method Details
#enslave(instance_info, &block) ⇒ Bool
Enslaves another instance and subsequently becomes the master of the group.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/arachni/rpc/server/framework/master.rb', line 65 def enslave( instance_info, &block ) # Slaves can't have slaves of their own. if slave? block.call false return false end instance_info = instance_info.my_symbolize_keys fail "Instance info does not contain a 'url' key." if !instance_info[:url] fail "Instance info does not contain a 'token' key." if !instance_info[:token] # Since we have slaves we must be a master. set_as_master # Take charge of the Instance we were given. instance = connect_to_instance( instance_info ) instance..set( ) do instance.framework.set_master( multi_self_url, token ) do @slaves << instance_info print_status "Enslaved: #{instance_info[:url]}" block.call true if block_given? end end true end |
#has_slaves? ⇒ Boolean
45 46 47 |
# File 'lib/arachni/rpc/server/framework/master.rb', line 45 def has_slaves? @slaves && @slaves.any? end |
#master? ⇒ Bool
Returns `true` if running in HPG (High Performance Grid) mode and instance is the master, false otherwise.
52 53 54 55 |
# File 'lib/arachni/rpc/server/framework/master.rb', line 52 def master? # Only master needs a local token. !!@local_token end |
#set_as_master ⇒ Bool
Sets this instance as the master.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/arachni/rpc/server/framework/master.rb', line 21 def set_as_master return false if !solo? return true if master? # Holds info for our slave Instances -- if we have any. @slaves = [] # Instances which have completed their scan. @done_slaves = Set.new # Some methods need to be accessible over RPC for instance management, # restricting elements, adding more pages etc. # # However, when in multi-Instance mode, the master should not be tampered # with, so we generate a local token (which is not known to regular API clients) # to be used server side by self to facilitate access control and only # allow slaves to update our runtime data. @local_token = Utilities.generate_token print_status 'Became master.' true end |
#slave_sitrep(data, url, token = nil) ⇒ Bool
Used by slaves to impart the knowledge they've gained during the scan to the master as well as for signaling.
113 114 115 116 117 118 119 120 121 |
# File 'lib/arachni/rpc/server/framework/master.rb', line 113 def slave_sitrep( data, url, token = nil ) return false if master? && !valid_token?( token ) issues = (data['issues'] || []).map { |i| Arachni::Issue.from_rpc_data i } update_issues( issues ) slave_done( url ) if data['audit_done'] true end |