Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --runs #19

Merged
merged 1 commit into from Dec 28, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add support for --runs

This options allows to limit the number of fuzzing
rounds.
  • Loading branch information
jvoisin committed Dec 26, 2019
commit 9825bee72cfd094da8eaacbb31ee2e3ae7b166a3
@@ -79,7 +79,8 @@ def __init__(self,
timeout=120,
regression=False,
max_input_size=4096,
close_fd_mask=0):
close_fd_mask=0,
runs=-1):
self._target = target
self._dirs = [] if dirs is None else dirs
self._exact_artifact_path = exact_artifact_path
@@ -93,6 +94,7 @@ def __init__(self,
self._last_sample_time = time.time()
self._total_coverage = 0
self._p = None
self.runs = runs

def log_stats(self, log_type):
rss = (psutil.Process(self._p.pid).memory_info().rss + psutil.Process(os.getpid()).memory_info().rss) / 1024 / 1024
@@ -125,8 +127,12 @@ def start(self):
self._p = mp.Process(target=worker, args=(self._target, child_conn, self._close_fd_mask))
self._p.start()


while True:
if self.runs != -1 and self._total_executions >= self.runs:
self._p.terminate()
logging.info('did %d runs, stopping now.', self.runs)
break

buf = self._corpus.generate_input()
parent_conn.send_bytes(buf)
if not parent_conn.poll(self._timeout):
@@ -21,12 +21,13 @@ def __call__(self, *args, **kwargs):
parser.add_argument('--rss-limit-mb', type=int, default=2048, help='Memory usage in MB')
parser.add_argument('--max-input-size', type=int, default=4096, help='Max input size in bytes')
parser.add_argument('--close-fd-mask', type=int, default=0, help='Indicate output streams to close at startup')
parser.add_argument('--runs', type=int, default=-1, help='Number of individual test runs, -1 (the default) to run indefinitely.')
parser.add_argument('--timeout', type=int, default=30,
help='If input takes longer then this timeout the process is treated as failure case')
args = parser.parse_args()
f = fuzzer.Fuzzer(self.function, args.dirs, args.exact_artifact_path,
args.rss_limit_mb, args.timeout, args.regression, args.max_input_size,
args.close_fd_mask)
args.close_fd_mask, args.runs)
f.start()


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.