Class: Arachni::Module::KeyFiller

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/module/key_filler.rb

Overview

KeyFiller class

Included by Auditor

Tries to fill in input parameters with values of proper type based on their name.

Author:

Constant Summary collapse

@@regexps =

Hash of regexps for the parameter keys and the values to to fill in

Returns:

  • (Hash)
{
    'name'    => 'arachni_name',
    'user'    => 'arachni_user',
    'usr'     => 'arachni_user',
    'pass'    => '5543!%arachni_secret',
    'txt'     => 'arachni_text',
    'num'     => '132',
    'amount'  => '100',
    'mail'    => '[email protected]',
    'account' => '12',
    'id'      => '1'
}

Class Method Summary collapse

Class Method Details

.fill(hash) ⇒ Hash

Tries to fill a hash with values of appropriate type<br/> based on the key of the parameter.

Parameters:

  • hash (Hash)

    hash of name=>value pairs

Returns:

  • (Hash)


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/arachni/module/key_filler.rb', line 61

def self.fill( hash )
    hash = hash.dup
    hash.keys.each do |key|
        next if hash[key] && !hash[key].empty?

        if val = self.match?( key )
            hash[key] = val
        end

        # moronic default value...
        # will figure  out something better in the future...
        hash[key] = '1' if( !hash[key] || hash[key].empty? )
    end

    hash
end

.regexpsObject



49
50
51
# File 'lib/arachni/module/key_filler.rb', line 49

def self.regexps
    @@regexps
end