From 80e9b737e8ee6b5ef7bf086acd31dde917a832c8 Mon Sep 17 00:00:00 2001 From: George Pollard Date: Tue, 7 Feb 2023 09:15:21 +1300 Subject: [PATCH] Add readonly_inputs to dotnet & dotnet_dll templates (#2740) Closes #2739 --- src/cli/onefuzz/templates/libfuzzer.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/cli/onefuzz/templates/libfuzzer.py b/src/cli/onefuzz/templates/libfuzzer.py index 4b228252d..d842176ad 100644 --- a/src/cli/onefuzz/templates/libfuzzer.py +++ b/src/cli/onefuzz/templates/libfuzzer.py @@ -376,13 +376,11 @@ class Libfuzzer(Command): ) if existing_inputs: - self.onefuzz.containers.get(existing_inputs) helper.containers[ContainerType.inputs] = existing_inputs else: helper.define_containers(ContainerType.inputs) if readonly_inputs: - self.onefuzz.containers.get(readonly_inputs) helper.containers[ContainerType.readonly_inputs] = readonly_inputs if analyzer_exe is not None: @@ -579,6 +577,7 @@ class Libfuzzer(Command): wait_for_running: bool = False, wait_for_files: Optional[List[ContainerType]] = None, existing_inputs: Optional[Container] = None, + readonly_inputs: Optional[Container] = None, debug: Optional[List[TaskDebugFlag]] = None, ensemble_sync_delay: Optional[int] = None, check_fuzzer_help: bool = True, @@ -588,6 +587,13 @@ class Libfuzzer(Command): 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" pool = self.onefuzz.pools.get(pool_name) @@ -628,11 +634,13 @@ class Libfuzzer(Command): ) if existing_inputs: - self.onefuzz.containers.get(existing_inputs) helper.containers[ContainerType.inputs] = existing_inputs else: helper.define_containers(ContainerType.inputs) + if readonly_inputs: + helper.containers[ContainerType.readonly_inputs] = readonly_inputs + fuzzer_containers = [ (ContainerType.setup, helper.containers[ContainerType.setup]), (ContainerType.crashes, helper.containers[ContainerType.crashes]), @@ -702,6 +710,7 @@ class Libfuzzer(Command): wait_for_running: bool = False, wait_for_files: Optional[List[ContainerType]] = None, existing_inputs: Optional[Container] = None, + readonly_inputs: Optional[Container] = None, debug: Optional[List[TaskDebugFlag]] = None, ensemble_sync_delay: Optional[int] = None, colocate_all_tasks: bool = False, @@ -710,6 +719,13 @@ class Libfuzzer(Command): ) -> Optional[Job]: 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. # # This is because managed DLLs are always (Windows-native) PE files, so the job @@ -756,11 +772,13 @@ class Libfuzzer(Command): containers = helper.containers if existing_inputs: - self.onefuzz.containers.get(existing_inputs) helper.containers[ContainerType.inputs] = existing_inputs else: 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. fuzzer_tools_container = Container( "dotnet-fuzzing-linux" if platform == OS.linux else "dotnet-fuzzing-windows"