Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 3878793

Browse files
authored
Trim whitespaces from options passed to executables (#2151)
* Trim whitespaces from options passed to executables * check for None * refactor to a function
1 parent 7d704a9 commit 3878793

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/cli/onefuzz/api.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,12 @@ def create_with_config(self, config: models.TaskConfig) -> models.Task:
800800

801801
return self._req_model("POST", models.Task, data=config)
802802

803+
def trim_options(self, options: Optional[List[str]]) -> Optional[List[str]]:
804+
# Trim any surrounding whitespace to allow users to quote multiple options with extra
805+
# whitespace as a workaround for CLI argument parsing limitations. Trimming is needed
806+
# to ensure that the binary eventually parses the arguments as options.
807+
return [o.strip() for o in options] if options else None
808+
803809
def create(
804810
self,
805811
job_id: UUID_EXPANSION,
@@ -886,7 +892,7 @@ def create(
886892
task=models.TaskDetails(
887893
analyzer_env=analyzer_env,
888894
analyzer_exe=analyzer_exe,
889-
analyzer_options=analyzer_options,
895+
analyzer_options=self.trim_options(analyzer_options),
890896
check_asan_log=check_asan_log,
891897
check_debugger=check_debugger,
892898
check_retry_count=check_retry_count,
@@ -895,18 +901,18 @@ def create(
895901
duration=duration,
896902
ensemble_sync_delay=ensemble_sync_delay,
897903
generator_exe=generator_exe,
898-
generator_options=generator_options,
904+
generator_options=self.trim_options(generator_options),
899905
reboot_after_setup=reboot_after_setup,
900906
rename_output=rename_output,
901907
stats_file=stats_file,
902908
stats_format=stats_format,
903909
supervisor_env=supervisor_env,
904910
supervisor_exe=supervisor_exe,
905911
supervisor_input_marker=supervisor_input_marker,
906-
supervisor_options=supervisor_options,
912+
supervisor_options=self.trim_options(supervisor_options),
907913
target_env=target_env,
908914
target_exe=target_exe,
909-
target_options=target_options,
915+
target_options=self.trim_options(target_options),
910916
target_options_merge=target_options_merge,
911917
target_timeout=target_timeout,
912918
target_workers=target_workers,

0 commit comments

Comments
 (0)