From d590b98432fdd48bbdae3761122bee790cbcb33e Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Sun, 12 Dec 2021 14:18:15 -0600 Subject: [PATCH] runner: make env string safe before substitution The environment cannot always be used safely with string.Template as not all environment variables are string safe. Before substituting environment vars in the command and args, sanitized to string safe values. --- run.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index cac453093..522d953cd 100755 --- a/run.py +++ b/run.py @@ -610,6 +610,10 @@ class TestRunner: env = self.build_env() + safe_env = {} + for key in env: + safe_env[key] = str(env[key]) + if "count" in self.config: count = self.config["count"] else: @@ -633,10 +637,10 @@ class TestRunner: if shell: template = string.Template(args) - cmdline = template.substitute(env) + cmdline = template.substitute(safe_env) else: for a in range(len(args)): - args[a] = string.Template(args[a]).substitute(env) + args[a] = string.Template(args[a]).substitute(safe_env) cmdline = " ".join(args) + "\n" open(os.path.join(self.output, "cmdline"), "w").write(cmdline) -- 2.47.2