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

Commit

Permalink
Trim whitespaces from options passed to executables (#2151)
Browse files Browse the repository at this point in the history
* Trim whitespaces from options passed to executables

* check for None

* refactor to a function
  • Loading branch information
chkeita authored Jul 11, 2022
1 parent 7d704a9 commit 3878793
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cli/onefuzz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,12 @@ def create_with_config(self, config: models.TaskConfig) -> models.Task:

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

def trim_options(self, options: Optional[List[str]]) -> Optional[List[str]]:
# Trim any surrounding whitespace to allow users to quote multiple options with extra
# whitespace as a workaround for CLI argument parsing limitations. Trimming is needed
# to ensure that the binary eventually parses the arguments as options.
return [o.strip() for o in options] if options else None

def create(
self,
job_id: UUID_EXPANSION,
Expand Down Expand Up @@ -886,7 +892,7 @@ def create(
task=models.TaskDetails(
analyzer_env=analyzer_env,
analyzer_exe=analyzer_exe,
analyzer_options=analyzer_options,
analyzer_options=self.trim_options(analyzer_options),
check_asan_log=check_asan_log,
check_debugger=check_debugger,
check_retry_count=check_retry_count,
Expand All @@ -895,18 +901,18 @@ def create(
duration=duration,
ensemble_sync_delay=ensemble_sync_delay,
generator_exe=generator_exe,
generator_options=generator_options,
generator_options=self.trim_options(generator_options),
reboot_after_setup=reboot_after_setup,
rename_output=rename_output,
stats_file=stats_file,
stats_format=stats_format,
supervisor_env=supervisor_env,
supervisor_exe=supervisor_exe,
supervisor_input_marker=supervisor_input_marker,
supervisor_options=supervisor_options,
supervisor_options=self.trim_options(supervisor_options),
target_env=target_env,
target_exe=target_exe,
target_options=target_options,
target_options=self.trim_options(target_options),
target_options_merge=target_options_merge,
target_timeout=target_timeout,
target_workers=target_workers,
Expand Down

0 comments on commit 3878793

Please sign in to comment.