Skip to content

Commit

Permalink
Check::Auditor: Removed OPTIONS
Browse files Browse the repository at this point in the history
[Closes #848]
  • Loading branch information
Zapotek committed Mar 9, 2017
1 parent 2515528 commit dd35be6
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 230 deletions.
79 changes: 18 additions & 61 deletions lib/arachni/check/auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,27 +307,6 @@ def max_issues
Element::LinkTemplate::DOM, Element::UIInput::DOM, Element::UIForm::DOM
]

# Default audit options.
OPTIONS = {

# Elements to audit.
#
# If no elements have been passed to audit methods, candidates will be
# determined by {#each_candidate_element}.
elements: ELEMENTS_WITH_INPUTS,

dom_elements: DOM_ELEMENTS_WITH_INPUTS,

# If set to `true` the HTTP response will be analyzed for new elements.
# Be careful when enabling it, there'll be a performance penalty.
#
# If set to `false`, no training is going to occur.
#
# If set to `nil`, when the Auditor submits a form with original or
# sample values this option will be overridden to `true`
train: nil
}

# @return [Arachni::Page]
# Page object to be audited.
attr_reader :page
Expand Down Expand Up @@ -487,21 +466,15 @@ def skip?( element )

# Passes each element prepared for audit to the block.
#
# If no element types have been specified in `opts`, it will use the elements
# from the check's {Base.info} hash.
#
# If no elements have been specified in `opts` or {Base.info}, it will use the
# elements in {OPTIONS}.
#
# @param [Array] types
# Element types to audit (see {OPTIONS}`[:elements]`).
# It will use the elements from the check's {Base.info} hash.
# If no elements have been specified it will use {ELEMENTS_WITH_INPUTS}.
#
# @yield [element]
# Each candidate DOM element.
# @yieldparam [Arachni::Capabilities::Auditable::DOM]
def each_candidate_element( types = [], &block )
types = self.class.info[:elements] if types.empty?
types = OPTIONS[:elements] if types.empty?
# Each candidate element.
# @yieldparam [Arachni::Element]
def each_candidate_element( &block )
types = self.class.elements
types = ELEMENTS_WITH_INPUTS if types.empty?

types.each do |elem|
elem = elem.type
Expand Down Expand Up @@ -538,21 +511,15 @@ def each_candidate_element( types = [], &block )

# Passes each element prepared for audit to the block.
#
# If no element types have been specified in `opts`, it will use the elements
# from the check's {Base.info} hash.
#
# If no elements have been specified in `opts` or {Base.info}, it will use the
# elements in {OPTIONS}.
#
# @param [Array] types
# Element types to audit (see {OPTIONS}`[:elements]`).
# It will use the elements from the check's {Base.info} hash.
# If no elements have been specified it will use {DOM_ELEMENTS_WITH_INPUTS}.
#
# @yield [element]
# Each candidate element.
# @yieldparam [Arachni::Element]
def each_candidate_dom_element( types = [], &block )
types = self.class.info[:elements] if types.empty?
types = OPTIONS[:dom_elements] if types.empty?
# @yieldparam [Arachni::Element::DOM]
def each_candidate_dom_element( &block )
types = self.class.elements
types = DOM_ELEMENTS_WITH_INPUTS if types.empty?

types.each do |elem|
elem = elem.type
Expand Down Expand Up @@ -589,15 +556,13 @@ def each_candidate_dom_element( types = [], &block )
#
# Uses {#each_candidate_element} to decide which elements to audit.
#
# @see OPTIONS
# @see Arachni::Element::Capabilities::Auditable#audit
# @see #audit_signature
def audit( payloads, opts = {}, &block )
opts = OPTIONS.merge( opts )
if !block_given?
audit_signature( payloads, opts )
else
each_candidate_element( opts[:elements] ) do |e|
each_candidate_element do |e|
e.audit( payloads, opts, &block )
audited( e.coverage_id )
end
Expand All @@ -609,11 +574,9 @@ def audit( payloads, opts = {}, &block )
#
# Uses {#each_candidate_element} to decide which elements to audit.
#
# @see OPTIONS
# @see Arachni::Element::Capabilities::Auditable#buffered_audit
def buffered_audit( payloads, opts = {}, &block )
opts = OPTIONS.merge( opts )
each_candidate_element( opts[:elements] ) do |e|
each_candidate_element do |e|
e.buffered_audit( payloads, opts, &block )
audited( e.coverage_id )
end
Expand All @@ -624,11 +587,9 @@ def buffered_audit( payloads, opts = {}, &block )
#
# Uses {#each_candidate_element} to decide which elements to audit.
#
# @see OPTIONS
# @see Arachni::Element::Capabilities::Analyzable::Signature
def audit_signature( payloads, opts = {} )
opts = OPTIONS.merge( opts )
each_candidate_element( opts[:elements] )do |e|
each_candidate_element do |e|
e.signature_analysis( payloads, opts )
audited( e.coverage_id )
end
Expand All @@ -638,11 +599,9 @@ def audit_signature( payloads, opts = {} )
#
# Uses {#each_candidate_element} to decide which elements to audit.
#
# @see OPTIONS
# @see Arachni::Element::Capabilities::Analyzable::Differential
def audit_differential( opts = {}, &block )
opts = OPTIONS.merge( opts )
each_candidate_element( opts[:elements] ) do |e|
each_candidate_element do |e|
e.differential_analysis( opts, &block )
audited( e.coverage_id )
end
Expand All @@ -652,11 +611,9 @@ def audit_differential( opts = {}, &block )
#
# Uses {#each_candidate_element} to decide which elements to audit.
#
# @see OPTIONS
# @see Arachni::Element::Capabilities::Analyzable::Timeout
def audit_timeout( payloads, opts = {} )
opts = OPTIONS.merge( opts )
each_candidate_element( opts[:elements] ) do |e|
each_candidate_element do |e|
e.timeout_analysis( payloads, opts )
audited( e.coverage_id )
end
Expand Down
2 changes: 1 addition & 1 deletion lib/arachni/element/capabilities/analyzable/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module Signature
# {Element::Capabilities::Submittable#platforms applicable platforms}
# for the {Element::Capabilities::Submittable#action resource} to be audited.
# @param [Hash] opts
# Options as described in {Arachni::Check::Auditor::OPTIONS} and
# Options as described in {Arachni::Element::Auditable::OPTIONS} and
# {SIGNATURE_OPTIONS}.
#
# @return [Bool]
Expand Down
Loading

0 comments on commit dd35be6

Please sign in to comment.