summaryrefslogtreecommitdiff
path: root/.gitlab-ci/lava
diff options
context:
space:
mode:
authorGuilherme Gallo <guilherme.gallo@collabora.com>2023-05-17 01:12:28 -0300
committerMarge Bot <emma+marge@anholt.net>2023-05-19 14:45:17 +0000
commit4173e4b18f255886aafc689c2e0010a52d4babba (patch)
tree0a321f3c5e08d563fb3cc5285f90fd33d39c850b /.gitlab-ci/lava
parent703635f0595e1f1a27ce374121046b26804183bf (diff)
downloadmesa-4173e4b18f255886aafc689c2e0010a52d4babba.tar.gz
mesa-4173e4b18f255886aafc689c2e0010a52d4babba.tar.bz2
mesa-4173e4b18f255886aafc689c2e0010a52d4babba.zip
ci/lava: Hide JWT block during YAML dump
Make hide_sensitive_data work in a block fashion, not only hiding the JWT line, since these tokens are huge, it may break the line when it extrapolates the YAML dump width. Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22870>
Diffstat (limited to '.gitlab-ci/lava')
-rw-r--r--.gitlab-ci/lava/utils/lava_job_definition.py6
-rw-r--r--.gitlab-ci/lava/utils/log_follower.py17
2 files changed, 18 insertions, 5 deletions
diff --git a/.gitlab-ci/lava/utils/lava_job_definition.py b/.gitlab-ci/lava/utils/lava_job_definition.py
index b05961dfb53..55dbb902dac 100644
--- a/.gitlab-ci/lava/utils/lava_job_definition.py
+++ b/.gitlab-ci/lava/utils/lava_job_definition.py
@@ -127,9 +127,9 @@ def artifact_download_steps(args):
if args.jwt_file:
with open(args.jwt_file) as jwt_file:
download_steps += [
- "set +x",
- f'echo -n "{jwt_file.read()}" > "{args.jwt_file}" # HIDEME',
- "set -x",
+ "set +x # HIDE_START",
+ f'echo -n "{jwt_file.read()}" > "{args.jwt_file}"',
+ "set -x # HIDE_END",
f'echo "export CI_JOB_JWT_FILE={args.jwt_file}" >> /set-job-env-vars.sh',
]
else:
diff --git a/.gitlab-ci/lava/utils/log_follower.py b/.gitlab-ci/lava/utils/log_follower.py
index 19837543833..1fdf490bcb8 100644
--- a/.gitlab-ci/lava/utils/log_follower.py
+++ b/.gitlab-ci/lava/utils/log_follower.py
@@ -293,5 +293,18 @@ def fatal_err(msg, exception=None):
sys.exit(1)
-def hide_sensitive_data(yaml_data: str, hide_tag: str ="HIDEME"):
- return "".join(line for line in yaml_data.splitlines(True) if hide_tag not in line)
+def hide_sensitive_data(yaml_data: str, start_hide: str = "HIDE_START", end_hide: str = "HIDE_END") -> str:
+ skip_line = False
+ dump_data: list[str] = []
+ for line in yaml_data.splitlines(True):
+ if start_hide in line:
+ skip_line = True
+ elif end_hide in line:
+ skip_line = False
+
+ if skip_line:
+ continue
+
+ dump_data.append(line)
+
+ return "".join(dump_data)