Class: Relevance::Tarantula::BasicAttack

Inherits:
Object
  • Object
show all
Defined in:
lib/relevance/tarantula/basic_attack.rb

Constant Summary collapse

ATTRS =
[:name, :output, :description]

Instance Method Summary collapse

Constructor Details

#initializeBasicAttack

Returns a new instance of BasicAttack.



6
7
8
9
10
# File 'lib/relevance/tarantula/basic_attack.rb', line 6

def initialize
  @name = "Tarantula Basic Fuzzer"
  @output = nil
  @description = "Supplies purely random but simplistically generated form input."
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
# File 'lib/relevance/tarantula/basic_attack.rb', line 12

def ==(other)
  Relevance::Tarantula::BasicAttack === other && ATTRS.all? { |attr| send(attr) == other.send(attr)}
end

#big_numberObject



27
28
29
# File 'lib/relevance/tarantula/basic_attack.rb', line 27

def big_number
  10000   # arbitrary
end

#input(input_field) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/relevance/tarantula/basic_attack.rb', line 16

def input(input_field)
  case input_field['name']
    when /amount/         then random_int
    when /_id$/           then random_whole_number
    when /uploaded_data/  then nil
    when nil              then input['value']
    else
      random_int
  end
end

#random_intObject



31
32
33
# File 'lib/relevance/tarantula/basic_attack.rb', line 31

def random_int
  rand(big_number) - (big_number/2)
end

#random_whole_numberObject



35
36
37
# File 'lib/relevance/tarantula/basic_attack.rb', line 35

def random_whole_number
  rand(big_number)
end