Class: Arachni::Element::JSON
- Includes:
- Capabilities::Analyzable, Capabilities::Inputtable, Capabilities::Mutable, Capabilities::WithSource
- Defined in:
- lib/arachni/element/json.rb,
lib/arachni/element/json/capabilities/mutable.rb,
lib/arachni/element/json/capabilities/inputtable.rb
Overview
Represents an auditable JSON element
Defined Under Namespace
Modules: Capabilities
Constant Summary
Constants included from Capabilities::Mutable
Capabilities::Mutable::EXTRA_NAME, Capabilities::Mutable::FUZZ_NAME, Capabilities::Mutable::FUZZ_NAME_VALUE, Capabilities::Mutable::MUTATION_OPTIONS
Constants included from Capabilities::Inputtable
Capabilities::Inputtable::INPUTTABLE_CACHE
Constants included from Capabilities::Analyzable::Differential
Capabilities::Analyzable::Differential::DIFFERENTIAL_OPTIONS
Constants included from Capabilities::Analyzable::Timeout
Capabilities::Analyzable::Timeout::TIMEOUT_OPTIONS
Constants included from Capabilities::Analyzable::Taint
Capabilities::Analyzable::Taint::TAINT_CACHE, Capabilities::Analyzable::Taint::TAINT_OPTIONS
Constants included from Capabilities::Auditable
Capabilities::Auditable::OPTIONS
Constants inherited from Base
Instance Attribute Summary
Attributes included from Capabilities::Mutable
#affected_input_name, #format, #seed
Attributes included from Capabilities::Inputtable
Attributes included from Capabilities::WithSource
Attributes included from Capabilities::Analyzable::Differential
#differential_analysis_options
Attributes included from Capabilities::Analyzable::Timeout
Attributes included from Capabilities::Auditable
Attributes included from Capabilities::WithAuditor
Attributes inherited from Base
#initialization_options, #page
Class Method Summary collapse
-
.decode(v) ⇒ Object
No-op.
-
.encode(v) ⇒ Object
No-op.
-
.from_request(url, request) ⇒ JSON?
Extracts JSON elements from an HTTP request.
Instance Method Summary collapse
- #decode(*args) ⇒ Object
- #dup ⇒ Object
- #encode(*args) ⇒ Object
-
#initialize(options) ⇒ JSON
constructor
A new instance of JSON.
-
#simple ⇒ Hash
Simple representation of self in the form of ‘{ Capabilities::Submittable#action => Capabilities::Inputtable#inputs }`.
- #to_h ⇒ Object
-
#to_json ⇒ Object
JSON formatted Capabilities::Inputtable#inputs.
Methods included from Capabilities::Mutable
#affected_input_value, #affected_input_value=, #each_mutation, #immutables, #inspect, #mutation?, #mutations, #reset, #switch_method, #to_rpc_data
Methods included from Capabilities::Inputtable
#[], #[]=, #changes, #has_inputs?, #inputtable_id, #reset, #try_input, #update, #valid_input_data?, #valid_input_name?, #valid_input_name_data?, #valid_input_value?, #valid_input_value_data?
Methods included from Capabilities::WithSource
Methods included from Capabilities::Analyzable
has_timeout_candidates?, reset, timeout_audit_run
Methods included from Capabilities::Analyzable::Differential
#differential_analysis, reset, #to_rpc_data
Methods included from Capabilities::Analyzable::Timeout
add_phase_2_candidate, candidates_include?, deduplicate, deduplicate?, do_not_deduplicate, #ensure_responsiveness, has_candidates?, payload_delay_from_options, reset, run, #timeout_analysis, timeout_from_options, #timeout_id, #timing_attack_probe, #timing_attack_verify, #to_rpc_data
Methods included from Capabilities::Analyzable::Taint
Methods included from Capabilities::Auditable
#audit, #audit_id, #audit_status_message, #audit_status_message_action, #audit_verbose_message, #coverage_hash, #coverage_id, #matches_skip_like_blocks?, #reset, reset, #skip?, skip_like
Methods included from Capabilities::WithAuditor
#marshal_dump, #orphan?, #prepare_for_report, #remove_auditor
Methods included from Capabilities::Submittable
#action, #action=, #http, #id, #method, #method=, #platforms, #submit
Methods included from Utilities
#available_port, #bytes_to_kilobytes, #bytes_to_megabytes, #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, #full_and_absolute_url?, #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?, #regexp_array_match, #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 inherited from Base
#==, #action, from_rpc_data, #hash, #id, #marshal_dump, #marshal_load, #persistent_hash, #prepare_for_report, #reset, #to_hash, #to_rpc_data, too_big?, #type, type, #url, #url=
Methods included from Capabilities::WithScope
Constructor Details
#initialize(options) ⇒ JSON
Returns a new instance of JSON.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/arachni/element/json.rb', line 39 def initialize( ) self.http_method = [:method] || :post super( ) self.inputs = (self.inputs || {}).merge( [:inputs] || {} ) if @source && self.inputs.empty? self.inputs = ::JSON.load( self.source ) end @default_inputs = self.inputs.dup.freeze end |
Class Method Details
.decode(v) ⇒ Object
No-op
96 97 98 |
# File 'lib/arachni/element/json.rb', line 96 def decode( v ) v end |
.encode(v) ⇒ Object
No-op
91 92 93 |
# File 'lib/arachni/element/json.rb', line 91 def encode( v ) v end |
.from_request(url, request) ⇒ JSON?
Extracts JSON elements from an HTTP request.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/arachni/element/json.rb', line 105 def from_request( url, request ) return if !request.body.is_a?( String ) || request.body.empty? return if too_big?( request.body ) data = begin ::JSON.load( request.body ) rescue ::JSON::ParserError end return if !data || data.empty? new( url: url, action: request.url, method: request.method, inputs: data, source: request.body ) end |
Instance Method Details
#decode(*args) ⇒ Object
80 81 82 |
# File 'lib/arachni/element/json.rb', line 80 def decode( *args ) self.class.decode( *args ) end |
#dup ⇒ Object
84 85 86 |
# File 'lib/arachni/element/json.rb', line 84 def dup super.tap { |e| e.inputs = @inputs.deep_clone } end |
#encode(*args) ⇒ Object
72 73 74 |
# File 'lib/arachni/element/json.rb', line 72 def encode( *args ) self.class.encode( *args ) end |
#simple ⇒ Hash
Returns Simple representation of self in the form of ‘{ Capabilities::Submittable#action => Capabilities::Inputtable#inputs }`.
64 65 66 |
# File 'lib/arachni/element/json.rb', line 64 def simple { self.action => self.inputs } end |
#to_h ⇒ Object
58 59 60 |
# File 'lib/arachni/element/json.rb', line 58 def to_h super.merge( source: @source ) end |
#to_json ⇒ Object
JSON formatted Capabilities::Inputtable#inputs.
54 55 56 |
# File 'lib/arachni/element/json.rb', line 54 def to_json @inputs.to_json end |