Skip to content

Commit

Permalink
Refactor fuzzingsession
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmetzman committed Nov 1, 2024
1 parent 9f8bbab commit 22a2d5d
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/clusterfuzz/_internal/bot/tasks/utasks/fuzz_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,13 @@ def generate_blackbox_testcases(

def do_engine_fuzzing(self, engine_impl):
"""Run fuzzing engine."""
# Centipede requires separate binaries for sanitized targets.
if environment.is_centipede_fuzzer_job():
sanitized_target_bucket_path = environment.get_value(
'SANITIZED_TARGET_BUILD_BUCKET_PATH')
if sanitized_target_bucket_path:
logs.error('Failed to set up sanitized_target_build.')

environment.set_value('FUZZER_NAME',
self.fuzz_target.fully_qualified_name())

Expand Down Expand Up @@ -1716,9 +1723,7 @@ def do_blackbox_fuzzing(self, fuzzer, fuzzer_directory, job_type):
return (generate_result.fuzzer_metadata, testcase_file_paths,
testcases_metadata, crashes)

def run(self):
"""Run the fuzzing session."""
start_time = time.time()
def run_common(self):
# Update LSAN local blacklist with global blacklist.
global_blacklisted_functions = (
self.uworker_input.fuzz_task_input.global_blacklisted_functions)
Expand All @@ -1737,11 +1742,21 @@ def run(self):
# is using command override for task execution.
failure_wait_interval = environment.get_value('FAIL_WAIT')
time.sleep(failure_wait_interval)
return uworker_msg_pb2.Output( # pylint: disable=no-member
return uworker_msg_pb2.Output( # pylint: disable=no-memberp
error_type=uworker_msg_pb2.ErrorType.FUZZ_NO_FUZZER) # pylint: disable=no-member

self.testcase_directory = environment.get_value('FUZZ_INPUTS')
return None

def run(self):
"""Run the fuzzing session."""
start_time = time.time()
result = self._run_common()
if result:
return result

# TODO(metzman): Move this section into seperate functions for engine and
# blackbox fuzzing instead of sandwhiching with ifs for engine fuzzing.
fuzz_target = self.fuzz_target.binary if self.fuzz_target else None
build_setup_result = build_manager.setup_build(
environment.get_value('APP_REVISION'), fuzz_target=fuzz_target)
Expand All @@ -1765,13 +1780,6 @@ def run(self):
return uworker_msg_pb2.Output( # pylint: disable=no-member
error_type=uworker_msg_pb2.ErrorType.FUZZ_BUILD_SETUP_FAILURE) # pylint: disable=no-member

# Centipede requires separate binaries for sanitized targets.
if environment.is_centipede_fuzzer_job():
sanitized_target_bucket_path = environment.get_value(
'SANITIZED_TARGET_BUILD_BUCKET_PATH')
if sanitized_target_bucket_path:
logs.error('Failed to set up sanitized_target_build.')

# Check if we have a bad build, i.e. one that crashes on startup.
# If yes, bail out.
logs.info('Checking for bad build.')
Expand Down

0 comments on commit 22a2d5d

Please sign in to comment.