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

Explain uworker unsafety in fuzz_task #4236

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions src/clusterfuzz/_internal/bot/tasks/utasks/fuzz_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,12 @@ def run(self):

# Data bundle directories can also have testcases which are kept in-place
# because of dependencies.
self.data_directory = setup.trusted_get_data_bundle_directory(self.fuzzer)
if self.uworker_input.setup_input.data_bundle_corpuses:
data_bundle = self.uworker_input.setup_input.data_bundle_corpuses[0]
else:
data_bundle = None
self.data_directory = setup.get_data_bundle_directory(
self.fuzzer, data_bundle)
if not self.data_directory:
logs.error(
'Unable to setup data bundle %s.' % self.fuzzer.data_bundle_name)
Expand Down Expand Up @@ -1924,7 +1929,7 @@ def handle_fuzz_no_fuzz_target_selected(output):
output.uworker_input.uworker_env)


def _make_session(uworker_input):
def _make_session(uworker_input: uworker_msg_pb2.Input) -> FuzzingSession:
test_timeout = environment.get_value('TEST_TIMEOUT')
return FuzzingSession(
uworker_input,
Expand Down
9 changes: 6 additions & 3 deletions src/clusterfuzz/_internal/datastore/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import re
import shlex
import time
from typing import List

from google.cloud import ndb

Expand Down Expand Up @@ -1600,7 +1601,8 @@ def get_testcase_variant(testcase_id, job_type):
FUZZ_TARGET_UPDATE_FAIL_DELAY = 2


def record_fuzz_target(engine_name, binary_name, job_type):
def record_fuzz_target(engine_name: str, binary_name: str,
job_type: str) -> data_types.FuzzTarget:
"""Records exsistence of fuzz target to the DB."""
result = record_fuzz_targets(engine_name, [binary_name], job_type)[0]

Expand Down Expand Up @@ -1636,7 +1638,8 @@ def get_or_create_multi_entities_from_keys(mapping):
retries=FUZZ_TARGET_UPDATE_FAIL_RETRIES,
delay=FUZZ_TARGET_UPDATE_FAIL_DELAY,
function='datastore.data_handler.record_fuzz_targets')
def record_fuzz_targets(engine_name, binaries, job_type):
def record_fuzz_targets(engine_name: str, binaries: List[str],
job_type: str) -> List[data_types.FuzzTarget]:
"""Record existence of fuzz targets to the DB."""
# TODO(metzman): All of this code assumes that fuzzing jobs are behaving
# reasonably and won't try to DoS us by putting bogus fuzzers in the db.
Expand Down Expand Up @@ -1669,7 +1672,7 @@ def record_fuzz_targets(engine_name, binaries, job_type):
jobs = get_or_create_multi_entities_from_keys(job_mapping)

for job in jobs:
# TODO(metzman): Decide if we want to handle unused fuzzers differentlyo.
# TODO(metzman): Decide if we want to handle unused fuzzers differently.
job.last_run = utils.utcnow()

ndb_utils.put_multi(jobs)
Expand Down
Loading