Class: Arachni::Element::Base Abstract
- Extended by:
- Utilities
- Includes:
- Capabilities::WithScope, Utilities
- Defined in:
- lib/arachni/element/base.rb
Overview
Base class for all element types.
Direct Known Subclasses
Body, Cookie, Cookie::DOM, Form, Form::DOM, GenericDOM, Header, Link, Link::DOM, LinkTemplate, LinkTemplate::DOM, Path, Server
Instance Attribute Summary collapse
-
#initialization_options ⇒ Object
readonly
Options used to initialize an identical element.
-
#page ⇒ Page
Page this element belongs to.
Class Method Summary collapse
- .from_rpc_data(data) ⇒ Base
-
.type ⇒ Symbol
Element type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #action ⇒ Object
- #dup ⇒ Object
- #hash ⇒ Object
-
#id ⇒ String
String uniquely identifying self.
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
- #marshal_dump ⇒ Object
- #marshal_load(h) ⇒ Object
- #persistent_hash ⇒ Object
- #prepare_for_report ⇒ Object abstract
-
#reset ⇒ Element::Base
abstract
Reset the element to its original state.
-
#to_h ⇒ Hash
Simple representation of self.
- #to_hash ⇒ Object
-
#to_rpc_data ⇒ Hash
Data representing this instance that are suitable the RPC transmission.
-
#type ⇒ Symbol
Element type.
-
#url ⇒ String
URL of the page that owns the element.
- #url=(url) ⇒ Object
Methods included from Utilities
available_port, caller_name, caller_path, cookie_decode, cookie_encode, cookies_from_document, cookies_from_file, cookies_from_response, exception_jail, exclude_path?, follow_protocol?, form_decode, form_encode, forms_from_document, forms_from_response, generate_token, get_path, hms_to_seconds, html_decode, html_encode, include_path?, links_from_document, links_from_response, normalize_url, page_from_response, page_from_url, parse_set_cookie, path_in_domain?, path_too_deep?, port_available?, rand_port, random_seed, redundant_path?, remove_constants, request_parse_body, seconds_to_hms, skip_page?, skip_path?, skip_resource?, skip_response?, to_absolute, uri_decode, uri_encode, uri_parse, uri_parse_query, uri_parser, uri_rewrite
Methods included from Capabilities::WithScope
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/arachni/element/base.rb', line 50 def initialize( ) = .my_symbolize_keys( false ) if !([:url] || [:action]) fail 'Needs :url or :action option.' end @initialization_options = .dup self.url = [:url] || [:action] end |
Instance Attribute Details
#initialization_options ⇒ Object (readonly)
Returns Options used to initialize an identical element.
48 49 50 |
# File 'lib/arachni/element/base.rb', line 48 def @initialization_options end |
#page ⇒ Page
Returns Page this element belongs to.
44 45 46 |
# File 'lib/arachni/element/base.rb', line 44 def page @page end |
Class Method Details
.from_rpc_data(data) ⇒ Base
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/arachni/element/base.rb', line 161 def self.from_rpc_data( data ) instance = allocate data.each do |name, value| value = case name when 'dom' self::DOM.from_rpc_data( value ) when 'initialization_options' value.is_a?( Hash ) ? value.my_symbolize_keys( false ) : value when 'method' value.to_sym else value end instance.instance_variable_set( "@#{name}", value ) end instance.instance_variable_set( :@audit_options, {} ) instance end |
.type ⇒ Symbol
Returns Element type.
127 128 129 |
# File 'lib/arachni/element/base.rb', line 127 def self.type name.split( ':' ).last.downcase.to_sym end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
99 100 101 |
# File 'lib/arachni/element/base.rb', line 99 def ==( other ) hash == other.hash end |
#action ⇒ Object
110 111 112 |
# File 'lib/arachni/element/base.rb', line 110 def action url end |
#dup ⇒ Object
131 132 133 134 135 |
# File 'lib/arachni/element/base.rb', line 131 def dup dupped = self.class.new( self. ) dupped.page = page dupped end |
#hash ⇒ Object
91 92 93 |
# File 'lib/arachni/element/base.rb', line 91 def hash id.hash end |
#id ⇒ String
Returns String uniquely identifying self.
74 75 76 |
# File 'lib/arachni/element/base.rb', line 74 def id defined? super ? super : "#{action}:#{type}" end |
#marshal_dump ⇒ Object
137 138 139 140 141 142 143 |
# File 'lib/arachni/element/base.rb', line 137 def marshal_dump instance_variables.inject({}) do |h, iv| next h if [:@page].include? iv h[iv] = instance_variable_get( iv ) h end end |
#marshal_load(h) ⇒ Object
145 146 147 |
# File 'lib/arachni/element/base.rb', line 145 def marshal_load( h ) h.each { |k, v| instance_variable_set( k, v ) } end |
#persistent_hash ⇒ Object
95 96 97 |
# File 'lib/arachni/element/base.rb', line 95 def persistent_hash id.persistent_hash end |
#prepare_for_report ⇒ Object
69 70 |
# File 'lib/arachni/element/base.rb', line 69 def prepare_for_report end |
#reset ⇒ Element::Base
Returns Reset the element to its original state.
64 65 66 |
# File 'lib/arachni/element/base.rb', line 64 def reset self end |
#to_h ⇒ Hash
Returns Simple representation of self.
80 81 82 83 84 85 86 |
# File 'lib/arachni/element/base.rb', line 80 def to_h { class: self.class.to_s, type: type, url: url } end |
#to_hash ⇒ Object
87 88 89 |
# File 'lib/arachni/element/base.rb', line 87 def to_hash to_h end |
#to_rpc_data ⇒ Hash
Returns Data representing this instance that are suitable the RPC transmission.
151 152 153 154 155 156 157 |
# File 'lib/arachni/element/base.rb', line 151 def to_rpc_data data = marshal_dump.inject({}) { |h, (k, v)| h[k.to_s.gsub('@', '')] = v.to_rpc_data_or_self; h } data.delete 'audit_options' data.delete 'scope' data['class'] = self.class.to_s data end |
#type ⇒ Symbol
Returns Element type.
121 122 123 |
# File 'lib/arachni/element/base.rb', line 121 def type self.class.type end |
#url ⇒ String
Returns URL of the page that owns the element.
106 107 108 |
# File 'lib/arachni/element/base.rb', line 106 def url @url end |
#url=(url) ⇒ Object
115 116 117 |
# File 'lib/arachni/element/base.rb', line 115 def url=( url ) @url = normalize_url( url ).freeze end |