Skip to content

Commit

Permalink
Zest: Optionally save ALL inputs ever generated while fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanpadhye committed Apr 6, 2020
1 parent 494319f commit 5fd1732
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestGuidance.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public class ZestGuidance implements Guidance {
/** The directory where saved inputs are saved. */
protected File savedFailuresDirectory;

/** The directory where all inputs are saved (if enabled). */
protected File savedAllDirectory;

/** Set of saved inputs to fuzz. */
protected ArrayList<Input> savedInputs = new ArrayList<>();

Expand Down Expand Up @@ -328,6 +331,10 @@ private void prepareOutputDirectory() throws IOException {
this.savedCorpusDirectory.mkdirs();
this.savedFailuresDirectory = new File(outputDirectory, "failures");
this.savedFailuresDirectory.mkdirs();
if (Boolean.getBoolean("jqf.ei.SAVE_ALL_INPUTS")) {
this.savedAllDirectory = new File(outputDirectory, "all");
this.savedAllDirectory.mkdirs();
}
this.statsFile = new File(outputDirectory, "plot_data");
this.logFile = new File(outputDirectory, "fuzz.log");
this.currentInputFile = new File(outputDirectory, ".cur_input");
Expand Down Expand Up @@ -758,6 +765,13 @@ public void handleResult(Result result, Throwable error) throws GuidanceExceptio
displayStats();
}

// Save input unconditionally if such a setting is enabled
if (savedAllDirectory != null) {
String saveFileName = String.format("id_%09d", numTrials);
File saveFile = new File(savedAllDirectory, saveFileName);
GuidanceException.wrap(() -> writeCurrentInputToFile(saveFile));
}

}


Expand Down

0 comments on commit 5fd1732

Please sign in to comment.