From 8a73aa1d299fa6cdfd929847d1db82b8e818a3a4 Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Tue, 14 Aug 2018 15:41:53 +0100 Subject: [PATCH] [AIRFLOW-2899] Hide sensitive data when Exporting Variables --- airflow/www/views.py | 11 +++++++---- airflow/www_rbac/views.py | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/airflow/www/views.py b/airflow/www/views.py index 0c0dcff801a59..9051c0d793254 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -2566,10 +2566,13 @@ def action_varexport(self, ids, session=None): d = json.JSONDecoder() for var in qry: val = None - try: - val = d.decode(var.val) - except Exception: - val = var.val + if wwwutils.should_hide_value_for_key(var): + val = '*' * 8 + else: + try: + val = d.decode(var.val) + except Exception: + val = var.val var_dict[var.key] = val response = make_response(json.dumps(var_dict, sort_keys=True, indent=4)) diff --git a/airflow/www_rbac/views.py b/airflow/www_rbac/views.py index 629f488fc7218..b6dc5eb56a9da 100644 --- a/airflow/www_rbac/views.py +++ b/airflow/www_rbac/views.py @@ -2030,10 +2030,13 @@ def action_varexport(self, items): var_dict = {} d = json.JSONDecoder() for var in items: - try: - val = d.decode(var.val) - except Exception: - val = var.val + if wwwutils.should_hide_value_for_key(var): + val = '*' * 8 + else: + try: + val = d.decode(var.val) + except Exception: + val = var.val var_dict[var.key] = val response = make_response(json.dumps(var_dict, sort_keys=True, indent=4))