Class: Watobo::FuzzFile

Inherits:
FuzzGenerator show all
Defined in:
lib/watobo/core/fuzz_gen.rb

Instance Attribute Summary

Attributes inherited from FuzzGenerator

#actions, #genType, #info, #name, #numRequests

Instance Method Summary collapse

Methods inherited from FuzzGenerator

#addAction, #is_generator?, #removeAction, #run

Constructor Details

#initialize(fuzzer_tag, filename) ⇒ FuzzFile

Returns a new instance of FuzzFile.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/watobo/core/fuzz_gen.rb', line 64

def initialize(fuzzer_tag, filename)
  super(fuzzer_tag)
  @genType = "File-Input"
  @filename = ""
  @numRequests = 0
  if File.exists?(filename) then
    @filename = filename
    File.open(filename) do |fh|
      fh.each_line do |l|
        @numRequests += 1
      end
    end
  else
    @numRequests = 0
  end

  @info = "Filename: #{@filename}"

end

Instance Method Details

#generateObject



55
56
57
58
59
60
61
62
# File 'lib/watobo/core/fuzz_gen.rb', line 55

def generate
  return if not @filename
  fh = File.open(@filename)
  fh.each_line do |line|
    line.chomp!
    yield line if not line.empty?
  end
end