Skip to content

Commit 23ad92d

Browse files
committed
More idiomatic example
1 parent 70471b3 commit 23ad92d

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fuzz "My Web App" do
190190
data "JSON generated from a template" do
191191
t = FuzzBert::Template.new '{ user: { id: ${id}, name: "${name}" } }'
192192
t.set(:id, FuzzBert::Generators.cycle(1..10000))
193-
t.set(:name) { "fixed" + FuzzBert::Generators.random_fixlen(2).call }
193+
t.set(:name) { "Fixed text plus two random bytes: #{FuzzBert::Generators.random_fixlen(2).call}" }
194194
t.generator
195195
end
196196

examples/custom_handler.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,16 @@ def handle(error_data)
1515
end
1616
end
1717

18-
fuzz "OpenSSL command line (asn1parse)" do
18+
fuzz "Some application" do
1919

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

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

32-
data "Indefinite length sequence" do
27+
data "Payload" do
3328
c = FuzzBert::Container.new
3429
c << FuzzBert::Generators.fixed("\x30\x80")
3530
c << FuzzBert::Generators.random

examples/template.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
fuzz "Web App" do
44
deploy do |data|
5-
#send JSON data via HTTP
5+
#send JSON data via HTTP here instead
6+
p data
67
end
78

89
data "template" do
910
t = FuzzBert::Template.new <<-EOS
1011
{ user: { id: ${id}, name: "${name}", text: "${text}" } }
1112
EOS
1213
t.set(:id, FuzzBert::Generators.cycle(1..10000))
13-
t.set(:name) { "fixed" + FuzzBert::Generators.random.call }
14-
t.set(:text, FuzzBert::Generators.random)
14+
name = FuzzBert::Container.new
15+
name << FuzzBert::Generators.fixed("fixed")
16+
name << FuzzBert::Generators.random_fixlen(2)
17+
t.set(:name, name.generator)
18+
t.set(:text) { "Fixed text plus two random bytes: #{FuzzBert::Generators.random_fixlen(2).call}" }
1519
t.generator
1620
end
1721
end

0 commit comments

Comments
 (0)