Add readonly_inputs to dotnet & dotnet_dll templates (#2740)

Closes #2739
This commit is contained in:
George Pollard
2023-02-07 09:15:21 +13:00
committed by GitHub
parent c1f6dfc366
commit 80e9b737e8

View File

@ -376,13 +376,11 @@ class Libfuzzer(Command):
) )
if existing_inputs: if existing_inputs:
self.onefuzz.containers.get(existing_inputs)
helper.containers[ContainerType.inputs] = existing_inputs helper.containers[ContainerType.inputs] = existing_inputs
else: else:
helper.define_containers(ContainerType.inputs) helper.define_containers(ContainerType.inputs)
if readonly_inputs: if readonly_inputs:
self.onefuzz.containers.get(readonly_inputs)
helper.containers[ContainerType.readonly_inputs] = readonly_inputs helper.containers[ContainerType.readonly_inputs] = readonly_inputs
if analyzer_exe is not None: if analyzer_exe is not None:
@ -579,6 +577,7 @@ class Libfuzzer(Command):
wait_for_running: bool = False, wait_for_running: bool = False,
wait_for_files: Optional[List[ContainerType]] = None, wait_for_files: Optional[List[ContainerType]] = None,
existing_inputs: Optional[Container] = None, existing_inputs: Optional[Container] = None,
readonly_inputs: Optional[Container] = None,
debug: Optional[List[TaskDebugFlag]] = None, debug: Optional[List[TaskDebugFlag]] = None,
ensemble_sync_delay: Optional[int] = None, ensemble_sync_delay: Optional[int] = None,
check_fuzzer_help: bool = True, check_fuzzer_help: bool = True,
@ -588,6 +587,13 @@ class Libfuzzer(Command):
libfuzzer-dotnet task libfuzzer-dotnet task
""" """
# ensure containers exist
if existing_inputs:
self.onefuzz.containers.get(existing_inputs)
if readonly_inputs:
self.onefuzz.containers.get(readonly_inputs)
harness = "libfuzzer-dotnet" harness = "libfuzzer-dotnet"
pool = self.onefuzz.pools.get(pool_name) pool = self.onefuzz.pools.get(pool_name)
@ -628,11 +634,13 @@ class Libfuzzer(Command):
) )
if existing_inputs: if existing_inputs:
self.onefuzz.containers.get(existing_inputs)
helper.containers[ContainerType.inputs] = existing_inputs helper.containers[ContainerType.inputs] = existing_inputs
else: else:
helper.define_containers(ContainerType.inputs) helper.define_containers(ContainerType.inputs)
if readonly_inputs:
helper.containers[ContainerType.readonly_inputs] = readonly_inputs
fuzzer_containers = [ fuzzer_containers = [
(ContainerType.setup, helper.containers[ContainerType.setup]), (ContainerType.setup, helper.containers[ContainerType.setup]),
(ContainerType.crashes, helper.containers[ContainerType.crashes]), (ContainerType.crashes, helper.containers[ContainerType.crashes]),
@ -702,6 +710,7 @@ class Libfuzzer(Command):
wait_for_running: bool = False, wait_for_running: bool = False,
wait_for_files: Optional[List[ContainerType]] = None, wait_for_files: Optional[List[ContainerType]] = None,
existing_inputs: Optional[Container] = None, existing_inputs: Optional[Container] = None,
readonly_inputs: Optional[Container] = None,
debug: Optional[List[TaskDebugFlag]] = None, debug: Optional[List[TaskDebugFlag]] = None,
ensemble_sync_delay: Optional[int] = None, ensemble_sync_delay: Optional[int] = None,
colocate_all_tasks: bool = False, colocate_all_tasks: bool = False,
@ -710,6 +719,13 @@ class Libfuzzer(Command):
) -> Optional[Job]: ) -> Optional[Job]:
pool = self.onefuzz.pools.get(pool_name) pool = self.onefuzz.pools.get(pool_name)
# verify containers exist
if existing_inputs:
self.onefuzz.containers.get(existing_inputs)
if readonly_inputs:
self.onefuzz.containers.get(readonly_inputs)
# We _must_ proactively specify the OS based on pool. # We _must_ proactively specify the OS based on pool.
# #
# This is because managed DLLs are always (Windows-native) PE files, so the job # This is because managed DLLs are always (Windows-native) PE files, so the job
@ -756,11 +772,13 @@ class Libfuzzer(Command):
containers = helper.containers containers = helper.containers
if existing_inputs: if existing_inputs:
self.onefuzz.containers.get(existing_inputs)
helper.containers[ContainerType.inputs] = existing_inputs helper.containers[ContainerType.inputs] = existing_inputs
else: else:
helper.define_containers(ContainerType.inputs) helper.define_containers(ContainerType.inputs)
if readonly_inputs:
helper.containers[ContainerType.readonly_inputs] = readonly_inputs
# Assumes that `libfuzzer-dotnet` and supporting tools were uploaded upon deployment. # Assumes that `libfuzzer-dotnet` and supporting tools were uploaded upon deployment.
fuzzer_tools_container = Container( fuzzer_tools_container = Container(
"dotnet-fuzzing-linux" if platform == OS.linux else "dotnet-fuzzing-windows" "dotnet-fuzzing-linux" if platform == OS.linux else "dotnet-fuzzing-windows"