From 6d75b2e8e321c303d7795a7cfca34729dad31fa9 Mon Sep 17 00:00:00 2001 From: WangJL Date: Fri, 25 Sep 2020 20:17:02 +0800 Subject: [PATCH] Fix error caused by tabs in ENV This commit replace '\t' with '\\t' in the ENV command. This will allow 'export VAR=VAL' works properly when VAL contains '\t'. Fixes #812. Signed-off-by: WangJL --- tern/analyze/docker/helpers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tern/analyze/docker/helpers.py b/tern/analyze/docker/helpers.py index 143c64ee..a89d1355 100644 --- a/tern/analyze/docker/helpers.py +++ b/tern/analyze/docker/helpers.py @@ -207,4 +207,7 @@ def get_env_vars(image_obj): '''Given a docker image object, return the list of environment variables, if any, based on their values in the config.''' config = image_obj.get_image_config(image_obj.get_image_manifest()) + # replace '\t' with '\\t' in the ENV + for idx, env_str in enumerate(config['config']['Env']): + config['config']['Env'][idx] = env_str.replace('\t', '\\t') return config['config']['Env']