Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions bin/deepstate/core/fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def __init__(self) -> None:
self.blackbox: Optional[bool] = None
self.fuzzer_args: List[Any] = []
self.fuzzer_out: bool = False
self.abort_on_fail: bool = False

self.sync_cycle: int = 5
self.sync_out: bool = True
Expand Down Expand Up @@ -226,6 +227,10 @@ def parse_args(cls) -> Optional[argparse.Namespace]:
parser.add_argument(
"--fuzzer_args", default=[], nargs='*',
help="Flags to pass to the fuzzer. Format: `a arg1=val` -> `-a --arg val`.")

parser.add_argument(
"--abort_on_fail", action="store_true",
help="Fuzzer exits immediately on discovery of failiing input")


# Parallel / Ensemble Fuzzing
Expand Down Expand Up @@ -704,6 +709,18 @@ def run(self, runner: Optional[str] = None, no_exec: bool = False, skip_argparse
run_fuzzer = False
wait_time = 0
L.info("Timeout")

# abort on fail check
if self.abort_on_fail:
crash_path = os.path.join(self.output_test_dir, "the_fuzzer", "crashes")
path = Path(crash_path)
if os.path.exists(path):
if len(os.listdir(path)) > 0:
run_one_fuzzer_process = False
run_fuzzer = False
L.info("Crash discovered. Check directory for crashes")
return 1


try:
# sleep/communicate for `self.sync_cycle` time
Expand Down
1 change: 1 addition & 0 deletions docs/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Optional arguments:
--min_log_level - how much to log (0=DEBUG, 6=CRITICAL)
--blackbox - fuzz non-instrumented binary
--dictionary - file with words that may enhance fuzzing (fuzzer dependent format)
--abort_on_fail - fuzzers exits on first discovered crash
```

Each fuzzer creates following files/directories under output directory:
Expand Down