go-fuzz
go-fuzz copied to clipboard
Minimize persistent corpus
currently go-fuzz minimizes the corpus in memory but this isn't reflected on disk
AFL has a few tools for this: afl-cmin and afl-tmin, but of course neither can be applied directly. It would be nice to have go-fuzz equivalents.
I think it should be done online, while go-fuzz runs, without separate tools and complex workflow.
If I spent a lot of effort to construct a corpus, I would be annoyed if go-fuzz deleted some of my samples. Removing files from a corpus on disk should be an explicit step.
fwiw I hacked this up for my own one-off use.
diff --git a/go-fuzz/hub.go b/go-fuzz/hub.go
index 9a07b16..cbdfff1 100644
--- a/go-fuzz/hub.go
+++ b/go-fuzz/hub.go
@@ -413,6 +413,7 @@ func (hub *Hub) updateScores() {
}
for ci, cand := range candidates {
if cand.score == 0 {
+ log.Printf("0 score corpus entry: %x\n", hash(corpus[cand.index].data))
continue
}
inp := &corpus[cand.index]
@@ -429,6 +430,7 @@ func (hub *Hub) updateScores() {
for i, inp := range corpus {
if !inp.favored {
inp.score = minScore
+ log.Printf("1.0 score corpus entry: %x\n", hash(inp.data))
}
scoreSum += inp.score
corpus[i].runningScoreSum = scoreSum