def test_get_cf_host_path(self): """Test get host path.""" os.environ['ROOT_DIR'] = '/host' os.environ['WORKER_ROOT_DIR'] = '/worker' worker_path = os.path.join(os.environ['WORKER_ROOT_DIR'], 'a', 'b', 'c') self.assertEqual(file_host.rebase_to_host_root(worker_path), '/host/a/b/c') worker_path = os.environ['WORKER_ROOT_DIR'] self.assertEqual(file_host.rebase_to_host_root(worker_path), '/host')
def engine_fuzz(engine_impl, target_name, sync_corpus_directory, testcase_directory): """Run engine fuzzer on untrusted worker.""" request = untrusted_runner_pb2.EngineFuzzRequest( engine=engine_impl.name, target_name=target_name, sync_corpus_directory=file_host.rebase_to_worker_root( sync_corpus_directory), testcase_directory=file_host.rebase_to_worker_root(testcase_directory)) response = host.stub().EngineFuzz(request) crashes = [ engine.Crash( input_path=file_host.rebase_to_host_root(crash.input_path), stacktrace=crash.stacktrace, reproduce_args=crash.reproduce_args, crash_time=crash.crash_time) for crash in response.crashes ] unpacked_stats = _unpack_values(response.stats) unpacked_strategies = _unpack_values(response.strategies) result = engine.FuzzResult( logs=response.logs, command=list(response.command), crashes=crashes, stats=unpacked_stats, time_executed=response.time_executed) file_host.pull_testcases_from_worker() return result, dict(response.fuzzer_metadata), unpacked_strategies
def engine_fuzz(engine_impl, target_name, sync_corpus_directory, testcase_directory): """Run engine fuzzer on untrusted worker.""" request = untrusted_runner_pb2.EngineFuzzRequest( engine=engine_impl.name, target_name=target_name, sync_corpus_directory=file_host.rebase_to_worker_root( sync_corpus_directory), testcase_directory=file_host.rebase_to_worker_root(testcase_directory)) response = host.stub().EngineFuzz(request) crashes = [ engine.Crash( input_path=file_host.rebase_to_host_root(crash.input_path), stacktrace=utils.decode_to_unicode(crash.stacktrace), reproduce_args=crash.reproduce_args, crash_time=crash.crash_time) for crash in response.crashes ] unpacked_stats = {} for key, packed_value in six.iteritems(response.stats): if packed_value.Is(wrappers_pb2.DoubleValue.DESCRIPTOR): value = wrappers_pb2.DoubleValue() elif packed_value.Is(wrappers_pb2.Int32Value.DESCRIPTOR): value = wrappers_pb2.Int32Value() elif packed_value.Is(wrappers_pb2.StringValue.DESCRIPTOR): value = wrappers_pb2.StringValue() else: raise ValueError('Unknown stat type for ' + key) packed_value.Unpack(value) unpacked_stats[key] = value.value result = engine.FuzzResult( logs=utils.decode_to_unicode(response.logs), command=list(response.command), crashes=crashes, stats=unpacked_stats, time_executed=response.time_executed) file_host.pull_testcases_from_worker() return result, dict(response.fuzzer_metadata)