Skip to content

Remove untrusted_runner from misc files. #4551

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

Open
wants to merge 4 commits into
base: oss-fuzz
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
4 changes: 0 additions & 4 deletions src/clusterfuzz/_internal/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,6 @@ def is_valid_testcase_file(file_path,
def maximum_parallel_processes_allowed():
"""Return maximum number of parallel processes allowed. Adjust it based
on thread multiplier."""
if environment.is_trusted_host():
# gRPC only supports 1 thread/process.
return 1

max_parallel_process_count = environment.get_value('MAX_FUZZ_THREADS', 1)
thread_multiplier = environment.get_value('THREAD_MULTIPLIER', 1)

Expand Down
7 changes: 1 addition & 6 deletions src/clusterfuzz/_internal/bot/fuzzers/afl/fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from clusterfuzz._internal.base import utils
from clusterfuzz._internal.bot.fuzzers import builtin
from clusterfuzz._internal.system import environment

# The name of the file that run.py puts in the input directory so AFL doesn't
# complain, since it needs at least one input file.
Expand All @@ -30,11 +29,7 @@ def write_dummy_file(input_dir):
files. So write the bare minimum to get afl to run if there is no corpus
yet."""
dummy_input_path = os.path.join(input_dir, AFL_DUMMY_INPUT)
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import file_host
file_host.write_data_to_worker(b' ', dummy_input_path)
else:
utils.write_data_to_file(' ', dummy_input_path)
utils.write_data_to_file(' ', dummy_input_path)


class Afl(builtin.EngineFuzzer):
Expand Down
10 changes: 1 addition & 9 deletions src/clusterfuzz/_internal/bot/fuzzers/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,8 @@ def fuzzer_directory(self):
def get_corpus_directory(input_directory, project_qualified_name):
"""Get the corpus directory given a project qualified fuzz target name."""
corpus_directory = os.path.join(input_directory, project_qualified_name)
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import file_host
corpus_directory = file_host.rebase_to_worker_root(corpus_directory)

# Create corpus directory if it does not exist already.
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import file_host
file_host.create_directory(corpus_directory, create_intermediates=True)
else:
shell.create_directory(corpus_directory)
shell.create_directory(corpus_directory)
return corpus_directory


Expand Down
20 changes: 0 additions & 20 deletions src/clusterfuzz/_internal/bot/fuzzers/engine_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,6 @@ def get_issue_owners(fuzz_target_path):
"""
owners_file_path = fuzzer_utils.get_supporting_file(fuzz_target_path,
OWNERS_FILE_EXTENSION)

if environment.is_trusted_host():
owners_file_path = fuzzer_utils.get_file_from_untrusted_worker(
owners_file_path)

if not os.path.exists(owners_file_path):
return []

Expand Down Expand Up @@ -381,11 +376,6 @@ def get_issue_metadata(fuzz_target_path, extension):
"""Get issue metadata."""
metadata_file_path = fuzzer_utils.get_supporting_file(fuzz_target_path,
extension)

if environment.is_trusted_host():
metadata_file_path = fuzzer_utils.get_file_from_untrusted_worker(
metadata_file_path)

if not os.path.exists(metadata_file_path):
return []

Expand All @@ -409,11 +399,6 @@ def get_additional_issue_metadata(fuzz_target_path):
will be a JSON-formatted dictionary."""
metadata_file_path = fuzzer_utils.get_supporting_file(
fuzz_target_path, METADATA_FILE_EXTENSION)

if environment.is_trusted_host():
metadata_file_path = fuzzer_utils.get_file_from_untrusted_worker(
metadata_file_path)

if not os.path.exists(metadata_file_path):
return {}

Expand Down Expand Up @@ -452,11 +437,6 @@ def get_fuzz_target_issue_metadata(fuzz_target):
"""Get issue related metadata given a testcase."""
if fuzz_target is None:
return None

if environment.is_trusted_host():
# Not applicable.
return None

build_dir = environment.get_value('BUILD_DIR')
target_path = find_fuzzer_path(build_dir, fuzz_target.binary)
if not target_path:
Expand Down
6 changes: 0 additions & 6 deletions src/clusterfuzz/_internal/bot/fuzzers/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from clusterfuzz._internal.bot.fuzzers import utils as fuzzer_utils
from clusterfuzz._internal.bot.fuzzers.afl import constants as afl_constants
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment

OPTIONS_FILE_EXTENSION = '.options'

Expand Down Expand Up @@ -179,11 +178,6 @@ def get_fuzz_target_options(fuzz_target_path):
exist."""
options_file_path = fuzzer_utils.get_supporting_file(fuzz_target_path,
OPTIONS_FILE_EXTENSION)

if environment.is_trusted_host():
options_file_path = fuzzer_utils.get_file_from_untrusted_worker(
options_file_path)

if not os.path.exists(options_file_path):
return None

Expand Down
3 changes: 0 additions & 3 deletions src/clusterfuzz/_internal/bot/fuzzers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ def get_fuzz_targets_local(path):

def get_fuzz_targets(path):
"""Get list of fuzz targets paths."""
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import file_host
return file_host.get_fuzz_targets(path)
return get_fuzz_targets_local(path)


Expand Down
6 changes: 0 additions & 6 deletions src/clusterfuzz/_internal/bot/tasks/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ def update_environment_for_job(environment_string):
uworker_env['MAX_TESTCASES'] = max_testcases_override

uworker_env['JOB_NAME'] = environment.get_value('JOB_NAME')
if environment.is_trusted_host():
env['JOB_NAME'] = environment.get_value('JOB_NAME')
from clusterfuzz._internal.bot.untrusted_runner import \
environment as worker_environment
worker_environment.update_environment(env)
return uworker_env


Expand Down Expand Up @@ -322,7 +317,6 @@ def process_command_impl(task_name, task_argument, job_name, high_end,
# old untrusted worker architecture.
if (not environment.get_value('DEBUG_TASK') and
not environment.is_tworker() and
not environment.is_trusted_host(ensure_connected=False) and
job_base_queue_suffix != bot_base_queue_suffix):
# This happens rarely, store this as a hard exception.
logs.error('Wrong platform for job %s: job queue [%s], bot queue [%s].' %
Expand Down
52 changes: 3 additions & 49 deletions src/clusterfuzz/_internal/bot/tasks/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,6 @@ def setup_testcase(testcase: data_types.Testcase, job_type: str,
if environment.is_android():
_copy_testcase_to_device_and_setup_environment(testcase, testcase_file_path)

# Push testcases to worker.
if take_trusted_host_path():
from clusterfuzz._internal.bot.untrusted_runner import file_host
file_host.push_testcases_to_worker()

# Copy global blacklist into local blacklist.
if setup_input.global_blacklisted_functions:
# Get local blacklist without this testcase's entry.
Expand Down Expand Up @@ -467,12 +462,6 @@ def _prepare_update_data_bundle(fuzzer, data_bundle):
return data_bundle_directory


def take_trusted_host_path():
if environment.is_uworker():
return False
return environment.is_trusted_host()


def update_data_bundle(
fuzzer: data_types.Fuzzer,
data_bundle_corpus: uworker_msg_pb2.DataBundleCorpus) -> bool: # pylint: disable=no-member
Expand All @@ -491,26 +480,9 @@ def update_data_bundle(
# case, the fuzzer will generate testcases from a gcs bucket periodically.
if not _is_search_index_data_bundle(data_bundle.name):

if not (take_trusted_host_path() and data_bundle.sync_to_worker):
logs.info('Data bundles: normal path.')
result = corpus_manager.sync_data_bundle_corpus_to_disk(
data_bundle_corpus, data_bundle_directory)
else:
logs.info('Data bundles: untrusted runner path.')
from clusterfuzz._internal.bot.untrusted_runner import \
corpus_manager as untrusted_corpus_manager
from clusterfuzz._internal.bot.untrusted_runner import file_host
worker_data_bundle_directory = file_host.rebase_to_worker_root(
data_bundle_directory)

file_host.create_directory(
worker_data_bundle_directory, create_intermediates=True)
result = untrusted_corpus_manager.RemoteGSUtilRunner().rsync(
data_bundle_corpus.gcs_url,
worker_data_bundle_directory,
delete=False)
result = result.return_code == 0

logs.info('Data bundles: normal path.')
result = corpus_manager.sync_data_bundle_corpus_to_disk(
data_bundle_corpus, data_bundle_directory)
if not result:
logs.error(f'Failed to sync data bundle {data_bundle.name}.')
return False
Expand All @@ -522,11 +494,6 @@ def update_data_bundle(
# Write last synced time in the sync file.
sync_file_path = _get_data_bundle_sync_file_path(data_bundle_directory)
utils.write_data_to_file(time_before_sync_start, sync_file_path)
if take_trusted_host_path() and data_bundle.sync_to_worker:
from clusterfuzz._internal.bot.untrusted_runner import file_host
worker_sync_file_path = file_host.rebase_to_worker_root(sync_file_path)
file_host.copy_file_to_worker(sync_file_path, worker_sync_file_path)

return True


Expand Down Expand Up @@ -697,13 +664,6 @@ def update_fuzzer_and_data_bundles(

# For launcher script usecase, we need the entire fuzzer directory on the
# worker.
if take_trusted_host_path():
from clusterfuzz._internal.bot.untrusted_runner import file_host
worker_fuzzer_directory = file_host.rebase_to_worker_root(
fuzzer_directory)
file_host.copy_directory_to_worker(
fuzzer_directory, worker_fuzzer_directory, replace=True)

return fuzzer


Expand All @@ -717,12 +677,6 @@ def _is_data_bundle_up_to_date(data_bundle, data_bundle_directory):
"""Return true if the data bundle is up to date, false otherwise."""
sync_file_path = _get_data_bundle_sync_file_path(data_bundle_directory)

if take_trusted_host_path() and data_bundle.sync_to_worker:
from clusterfuzz._internal.bot.untrusted_runner import file_host
worker_sync_file_path = file_host.rebase_to_worker_root(sync_file_path)
shell.remove_file(sync_file_path)
file_host.copy_file_from_worker(worker_sync_file_path, sync_file_path)

if not os.path.exists(sync_file_path):
return False

Expand Down
4 changes: 0 additions & 4 deletions src/clusterfuzz/_internal/bot/tasks/update_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,6 @@ def run():
try:
# If there is a newer revision, exit and let run.py update the source code.
if get_newer_source_revision() is not None:
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import host
host.update_worker()

sys.exit(0)

# Run platform specific initialization scripts.
Expand Down
15 changes: 0 additions & 15 deletions src/clusterfuzz/_internal/bot/testcase_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,6 @@ def _do_run_testcase_and_return_result_in_queue(crash_queue,
return_code, crash_time, output = run_testcase(thread_index, file_path,
gestures, env_copy)

# Pull testcase directory to host to get any stats files.
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import file_host
file_host.pull_testcases_from_worker()

# Analyze the crash.
crash_output = _get_crash_output(output)
crash_result = CrashResult(return_code, crash_time, crash_output)
Expand Down Expand Up @@ -549,10 +544,6 @@ def _do_run_testcase_and_return_result_in_queue(crash_queue,
def engine_reproduce(engine_impl: engine.Engine, target_name, testcase_path,
arguments, timeout) -> engine.ReproduceResult:
"""Do engine reproduction."""
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import tasks_host
return tasks_host.engine_reproduce(engine_impl, target_name, testcase_path,
arguments, timeout)
build_dir = environment.get_value('BUILD_DIR')
target_path = engine_common.find_fuzzer_path(build_dir, target_name)
if not target_path:
Expand Down Expand Up @@ -955,12 +946,6 @@ def get_command_line_for_application(file_to_run='',
# Start creating the command line.
command = ''

# Rebase the file_to_run and launcher paths to the worker's root.
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import file_host
file_to_run = file_host.rebase_to_worker_root(file_to_run)
launcher = file_host.rebase_to_worker_root(launcher)

# Default case.
testcase_path = file_to_run
testcase_filename = os.path.basename(testcase_path)
Expand Down
15 changes: 3 additions & 12 deletions src/clusterfuzz/_internal/build_management/build_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1315,10 +1315,7 @@ def setup_regular_build(revision,
base_build_dir = _base_build_dir(bucket_path)

build_class = RegularBuild
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import build_setup_host
build_class = build_setup_host.RemoteRegularBuild
elif environment.platform() == 'FUCHSIA':
if environment.platform() == 'FUCHSIA':
build_class = FuchsiaBuild
elif get_bucket_path('FUZZ_TARGET_BUILD_BUCKET_PATH'):
build_class = SplitTargetBuild
Expand Down Expand Up @@ -1382,14 +1379,8 @@ def setup_symbolized_builds(revision):
sym_debug_build_urls, revision)

base_build_dir = _base_build_dir(sym_release_build_bucket_path)

build_class = SymbolizedBuild
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import build_setup_host
build_class = build_setup_host.RemoteSymbolizedBuild # pylint: disable=no-member

build = build_class(base_build_dir, revision, sym_release_build_url,
sym_debug_build_url)
build = SymbolizedBuild(base_build_dir, revision, sym_release_build_url,
sym_debug_build_url)
if build.setup():
return build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,6 @@ def filter_binary_path(binary_path):
def symbolize_stacktrace(unsymbolized_crash_stacktrace,
enable_inline_frames=True):
"""Symbolize a crash stacktrace."""
if environment.is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import symbolize_host
return symbolize_host.symbolize_stacktrace(unsymbolized_crash_stacktrace,
enable_inline_frames)

platform = environment.platform()
if platform == 'WINDOWS':
# Windows Clang ASAN provides symbolized stacktraces anyway.
Expand Down
3 changes: 0 additions & 3 deletions src/clusterfuzz/_internal/fuzzing/corpus_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ def rename_file_to_sha(filepath, directory=None):
def legalize_filenames(filepaths):
"""Convert the name of every file in |filepaths| a name that is legal on
Windows. Returns list of legally named files."""
if environment.is_trusted_host():
return filepaths

illegal_chars = {'<', '>', ':', '\\', '|', '?', '*'}
legally_named = []
failed_to_move_filepaths = []
Expand Down
23 changes: 1 addition & 22 deletions src/clusterfuzz/_internal/system/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,12 +705,6 @@ def is_posix():
return os.name == 'posix'


def is_trusted_host(ensure_connected=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a test file for this, environment_test.py. It should also be changed, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same goes for UntrustedRunnerIntegrationTest

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with these PRs is that I think the untrusted runner tests provide coverage for non-untrusted code that is otherwise not covered. I should try to convert these to normal tests rather than get rid of them.

"""Return whether or not the current bot is a trusted host."""
return get_value('TRUSTED_HOST') and (not ensure_connected or
get_value('WORKER_BOT_NAME'))


def is_untrusted_worker():
"""Return whether or not the current bot is an untrusted worker."""
return get_value('UNTRUSTED_WORKER')
Expand Down Expand Up @@ -815,11 +809,6 @@ def reset_environment():
# Add shared variables with values from _initial_environment.
os.environ.update(_initial_environment)

if is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import \
environment as untrusted_env
untrusted_env.reset_environment()


def set_common_environment_variables():
"""Sets environment variables common for different memory debugging tools."""
Expand Down Expand Up @@ -943,11 +932,7 @@ def set_bot_environment():

# Set some default directories. These can be overriden by config files below.
bot_dir = os.path.join(root_dir, 'bot')
if is_trusted_host(ensure_connected=False):
worker_root_dir = os.environ['WORKER_ROOT_DIR']
os.environ['BUILDS_DIR'] = os.path.join(worker_root_dir, 'bot', 'builds')
else:
os.environ['BUILDS_DIR'] = os.path.join(bot_dir, 'builds')
os.environ['BUILDS_DIR'] = os.path.join(bot_dir, 'builds')

os.environ['BUILD_URLS_DIR'] = os.path.join(bot_dir, 'build-urls')
os.environ['LOG_DIR'] = os.path.join(bot_dir, 'logs')
Expand Down Expand Up @@ -1021,12 +1006,6 @@ def set_value(environment_variable, value, env=None):
value_str = value_str.replace('%ROOT_DIR%', os.getenv('ROOT_DIR', ''))
env[environment_variable_str] = value_str

if is_trusted_host():
from clusterfuzz._internal.bot.untrusted_runner import \
environment as untrusted_env
untrusted_env.forward_environment_variable(environment_variable_str,
value_str)


def get_initial_task_name():
"""Returns the name of the task that this task (postprocess or utask_main) is
Expand Down
2 changes: 0 additions & 2 deletions src/clusterfuzz/_internal/system/new_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ def run(self,
stdout_file=stdout_file,
interactive=interactive)

# Note: changes to this function may require changes to
# untrusted_runner.proto.
def run_and_wait(self,
additional_args=None,
timeout=None,
Expand Down
Loading
Loading