You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by jh...@apache.org on 2021/08/09 22:52:29 UTC
[airflow] 31/39: Fix unchecked indexing in _build_metrics (#16744)
This is an automated email from the ASF dual-hosted git repository.
jhtimmins pushed a commit to branch v2-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 479a34d5f97aa4a92fbb324caa7ea0abc4fa98da
Author: Emil Ejbyfeldt <ee...@liveintent.com>
AuthorDate: Thu Jul 1 09:24:16 2021 +0200
Fix unchecked indexing in _build_metrics (#16744)
I am not sure if this can happend in regular uses, but when running test
cases `sys.argv` can be that args passed to the pytest. When this is the
case it is definently possible for argv to only contain a single
element.
(cherry picked from commit a2d6aa07c9de83278eef14a228eb4a02ad43205c)
---
airflow/utils/cli.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/airflow/utils/cli.py b/airflow/utils/cli.py
index 2b5eb59..acdb291 100644
--- a/airflow/utils/cli.py
+++ b/airflow/utils/cli.py
@@ -115,7 +115,8 @@ def _build_metrics(func_name, namespace):
sub_commands_to_check = {'users', 'connections'}
sensitive_fields = {'-p', '--password', '--conn-password'}
full_command = list(sys.argv)
- if full_command[1] in sub_commands_to_check:
+ sub_command = full_command[1] if len(full_command) > 1 else None
+ if sub_command in sub_commands_to_check:
for idx, command in enumerate(full_command):
if command in sensitive_fields:
# For cases when password is passed as "--password xyz" (with space between key and value)