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

Make fuzz crashes uworker safe #4000

Merged
merged 7 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -783,11 +783,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 @@ -814,7 +816,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 @@ -856,16 +858,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 @@ -284,6 +284,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
Loading