From 60ca0864c048ecc18877fac85621d152c5261979 Mon Sep 17 00:00:00 2001 From: Julie Zhu Date: Mon, 12 Jan 2026 13:50:59 +1100 Subject: [PATCH 1/2] mask output token --- src/image-copy/azext_imagecopy/cli_utils.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/image-copy/azext_imagecopy/cli_utils.py b/src/image-copy/azext_imagecopy/cli_utils.py index 3109dc15a37..4b98368ec4b 100644 --- a/src/image-copy/azext_imagecopy/cli_utils.py +++ b/src/image-copy/azext_imagecopy/cli_utils.py @@ -19,7 +19,7 @@ def run_cli_command(cmd, return_as_json=False): try: cmd_output = check_output(cmd, stderr=STDOUT, universal_newlines=True) - logger.debug('command: %s ended with output: %s', cmd, cmd_output) + logger.debug('command: %s ended with output: %s', _mask_output_token(cmd), cmd_output) if return_as_json: if cmd_output: @@ -40,15 +40,25 @@ def run_cli_command(cmd, return_as_json=False): raise CLIError("Command returned an unexpected empty string.") return cmd_output except CalledProcessError as ex: - logger.error('command failed: %s', cmd) + logger.error('command failed: %s', _mask_output_token(cmd)) logger.error('output: %s', ex.output) raise ex except Exception as ex: - logger.error('command ended with an error: %s', cmd) + logger.error('command ended with an error: %s', _mask_output_token(cmd)) logger.error('args: %s', ex.args) raise ex +def _mask_output_token(cmd): + output = cmd[:] + token_param_name = "--sas-token" + if token_param_name in output: + idx = output.index(token_param_name) + output[idx + 1] = "******" + + return output + + def prepare_cli_command(cmd, output_as_json=True, tags=None, subscription=None, only_show_errors=None): full_cmd = [sys.executable, '-m', 'azure.cli'] + cmd From 366033f033b5528734b3f25afd6698d9c507d3bc Mon Sep 17 00:00:00 2001 From: Julie Zhu Date: Mon, 12 Jan 2026 13:53:49 +1100 Subject: [PATCH 2/2] upgrade version --- src/image-copy/HISTORY.rst | 4 ++++ src/image-copy/setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/image-copy/HISTORY.rst b/src/image-copy/HISTORY.rst index 90f678c9418..26da7116295 100644 --- a/src/image-copy/HISTORY.rst +++ b/src/image-copy/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +1.0.4 +++++++ +* Mask the value of the `--sas-token` parameter when displaying it in the terminal + 1.0.3 ++++++ * Fix the issue for sasTokenParsing, removing python related warnings from the sasToken(cmd_output was unfiltered) diff --git a/src/image-copy/setup.py b/src/image-copy/setup.py index 7f9d39e1aa3..3081b8298e7 100644 --- a/src/image-copy/setup.py +++ b/src/image-copy/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import find_packages, setup -VERSION = "1.0.3" +VERSION = "1.0.4" CLASSIFIERS = [ 'Development Status :: 4 - Beta',