Skip to content

Commit

Permalink
More idiomatic example
Browse files Browse the repository at this point in the history
  • Loading branch information
emboss committed Mar 5, 2013
1 parent 70471b3 commit 23ad92d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fuzz "My Web App" do
data "JSON generated from a template" do
t = FuzzBert::Template.new '{ user: { id: ${id}, name: "${name}" } }'
t.set(:id, FuzzBert::Generators.cycle(1..10000))
t.set(:name) { "fixed" + FuzzBert::Generators.random_fixlen(2).call }
t.set(:name) { "Fixed text plus two random bytes: #{FuzzBert::Generators.random_fixlen(2).call}" }
t.generator
end

Expand Down
13 changes: 4 additions & 9 deletions examples/custom_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,16 @@ def handle(error_data)
end
end

fuzz "OpenSSL command line (asn1parse)" do
fuzz "Some application" do

deploy do |data|
IO.popen("openssl asn1parse -inform DER -noout", "w") do |io|
io.write(data)
end
status = $?
unless status.exited? && status.success?
raise RuntimeError.new("bug!")
end
#send the generated data to your application here instead
p data
end

data("completely random") { FuzzBert::Generators.random }

data "Indefinite length sequence" do
data "Payload" do
c = FuzzBert::Container.new
c << FuzzBert::Generators.fixed("\x30\x80")
c << FuzzBert::Generators.random
Expand Down
10 changes: 7 additions & 3 deletions examples/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

fuzz "Web App" do
deploy do |data|
#send JSON data via HTTP
#send JSON data via HTTP here instead
p data
end

data "template" do
t = FuzzBert::Template.new <<-EOS
{ user: { id: ${id}, name: "${name}", text: "${text}" } }
EOS
t.set(:id, FuzzBert::Generators.cycle(1..10000))
t.set(:name) { "fixed" + FuzzBert::Generators.random.call }
t.set(:text, FuzzBert::Generators.random)
name = FuzzBert::Container.new
name << FuzzBert::Generators.fixed("fixed")
name << FuzzBert::Generators.random_fixlen(2)
t.set(:name, name.generator)
t.set(:text) { "Fixed text plus two random bytes: #{FuzzBert::Generators.random_fixlen(2).call}" }
t.generator
end
end

0 comments on commit 23ad92d

Please sign in to comment.