Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self._abort_hung_proc()
# give the process a moment to start dump
self._puppet.wait(timeout=1)
self.close()
# if something has happened figure out what
if not is_healthy:
if self._puppet.reason == FFPuppet.RC_CLOSED:
log.info("target.close() was called")
elif self._puppet.reason == FFPuppet.RC_EXITED:
log.info("Target closed itself")
elif (self._puppet.reason == FFPuppet.RC_WORKER
and "memory" in ignored
and "ffp_worker_memory_usage" in self._puppet.available_logs()):
status = self.RESULT_IGNORED
log.info("Memory limit exceeded")
elif (self._puppet.reason == FFPuppet.RC_WORKER
and "log-limit" in ignored
and "ffp_worker_log_size" in self._puppet.available_logs()):
status = self.RESULT_IGNORED
log.info("Log size limit exceeded")
else:
log.debug("failure detected, ffpuppet return code: %r", self._puppet.reason)
status = self.RESULT_FAILURE
elif was_timeout:
log.info("Timeout detected")
status = self.RESULT_IGNORED if "timeout" in ignored else self.RESULT_FAILURE
return status
def __init__(self, binary, extension, launch_timeout, log_limit, memory_limit, prefs, relaunch, **kwds):
super(PuppetTarget, self).__init__(binary, extension, launch_timeout, log_limit,
memory_limit, prefs, relaunch)
self.use_rr = kwds.pop("rr", False)
self.use_valgrind = kwds.pop("valgrind", False)
use_xvfb = kwds.pop("xvfb", False)
if kwds:
log.warning("PuppetTarget ignoring unsupported arguments: %s", ", ".join(kwds))
# create Puppet object
self._puppet = FFPuppet(
use_rr=self.use_rr,
use_valgrind=self.use_valgrind,
use_xvfb=use_xvfb)
def reduce_main(args):
if len(logging.getLogger().handlers) == 0:
logging.basicConfig()
if args.verbose:
logging.getLogger().setLevel(logging.DEBUG)
else:
logging.getLogger().setLevel(logging.INFO)
if HAVE_FUZZMANAGER:
program_cfg = ProgramConfiguration.fromBinary(args.binary)
else:
program_cfg = None
timeout = args.timeout
ffp = FFPuppet(
use_gdb=args.gdb,
use_valgrind=args.valgrind,
use_xvfb=args.xvfb)
if args.asserts:
ffp.add_abort_token("###!!! ASSERTION:")
try:
iters = 0
start_time = time.time()
# get initial stack
log.info("Running %s for initial crash", args.testcase)
ffp.launch(
args.binary,
location=os.path.abspath(args.testcase),
launch_timeout=args.launch_timeout,
log_limit=args.log_limit * 1024 * 1024 if args.log_limit else 0,
memory_limit=args.memory * 1024 * 1024 if args.memory else 0,