Skip to content

Commit 3c26c6e

Browse files
committed
keep track of interesting fuzzing attempts
1 parent a237f24 commit 3c26c6e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

run.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'coverage'
4+
require 'base64'
45

56
# Is the `fuzz` function defined in the fuzz target?
67
def fuzz_function_exists?(file_path)
@@ -33,8 +34,15 @@ def fuzz_function_exists?(file_path)
3334
reader, writer = IO.pipe
3435

3536
fork do
37+
seen = {}
3638
loop do
37-
puts "reading from IO pipe: #{reader.gets.strip}"
39+
encoded_bytes, cov_hash = reader.gets.strip.split('_')
40+
decoded_bytes = Base64.strict_decode64(encoded_bytes)
41+
42+
if !seen.include?(cov_hash)
43+
seen[cov_hash] = Base64.strict_decode64(encoded_bytes)
44+
puts(seen)
45+
end
3846
end
3947
end
4048

@@ -45,15 +53,17 @@ def fuzz_function_exists?(file_path)
4553

4654
Coverage.start(:all)
4755

56+
bytes = Random.new.bytes(10)
57+
4858
begin
4959
load(file_path)
50-
fuzz(Random.new.bytes(10))
60+
fuzz(bytes)
5161
rescue => e
5262
puts "Encountered an exception: #{e}"
5363
exit(1)
5464
end
5565

56-
writer.puts(Coverage.result.hash)
66+
writer.puts(Base64.strict_encode64(bytes) + '_' + Coverage.result.hash.to_s)
5767
end
5868
Process.wait
5969
end

0 commit comments

Comments
 (0)