Skip to content

Commit

Permalink
Make fuzz crashes uworker safe
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmetzman committed May 20, 2024
1 parent 9fd282c commit d3f9c80
Show file tree
Hide file tree
Showing 8 changed files with 1,120 additions and 512 deletions.
19 changes: 12 additions & 7 deletions src/clusterfuzz/_internal/bot/tasks/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,11 +779,13 @@ def get_fuzzer_directory(fuzzer_name):
return fuzzer_directory


def archive_testcase_and_dependencies_in_gcs(resource_list, testcase_path):
"""Archive testcase and its dependencies, and store in blobstore."""
def archive_testcase_and_dependencies_in_gcs(resource_list, testcase_path: str,
upload_url: str):
"""Archive testcase and its dependencies, and store in blobstore. Returns
whether it is archived, the absolute_filename, and the zip_filename."""
if not os.path.exists(testcase_path):
logs.log_error('Unable to find testcase %s.' % testcase_path)
return None, None, None, None
return None, None, None

absolute_filename = testcase_path
archived = False
Expand All @@ -810,7 +812,7 @@ def archive_testcase_and_dependencies_in_gcs(resource_list, testcase_path):
file_handle = open(testcase_path, 'rb')
except OSError:
logs.log_error('Unable to open testcase %s.' % testcase_path)
return None, None, None, None
return None, None, None
else:
# If there are resources, create an archive.

Expand Down Expand Up @@ -852,16 +854,19 @@ def archive_testcase_and_dependencies_in_gcs(resource_list, testcase_path):
file_handle = open(zip_path, 'rb')
except OSError:
logs.log_error('Unable to open testcase archive %s.' % zip_path)
return None, None, None, None
return None, None, None

archived = True
absolute_filename = testcase_path[base_len:]

fuzzed_key = blobs.write_blob(file_handle)
if not storage.upload_signed_url(file_handle, upload_url):
logs.log_error('Failed to upload testcase.')
return None, None, None

file_handle.close()

# Don't need the archive after writing testcase to blobstore.
if zip_path:
shell.remove_file(zip_path)

return fuzzed_key, archived, absolute_filename, zip_filename
return archived, absolute_filename, zip_filename
2 changes: 2 additions & 0 deletions src/clusterfuzz/_internal/bot/tasks/utasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ def uworker_main(input_download_url) -> None:

logs.log('Starting utask_main: %s.' % utask_module)
uworker_output = utask_module.utask_main(uworker_input)
uworker_output.bot_name = environment.get_value('BOT_NAME', '')
uworker_output.platform_id = environment.get_platform_id()
uworker_io.serialize_and_upload_uworker_output(uworker_output,
uworker_output_upload_url)
logs.log('Finished uworker_main.')
Expand Down
Loading

0 comments on commit d3f9c80

Please sign in to comment.