Skip to content

Commit

Permalink
Make sure no sensitive info is surfaced in subprocess error
Browse files Browse the repository at this point in the history
  • Loading branch information
irenedea committed Jan 11, 2024
1 parent 785b938 commit 0e46f94
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/misc/download_hf_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ def get_oras_cmd_to_run(password: str):
f'{hostname}/{path}'
]

cmd_to_run = get_oras_cmd_to_run(ORAS_PASSWD_PLACEHOLDER)
log.info(f'CMD for oras cli to run: {cmd_to_run}')
cmd_to_run_no_password = get_oras_cmd_to_run(ORAS_PASSWD_PLACEHOLDER)
log.info(f'CMD for oras cli to run: {cmd_to_run_no_password}')

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
cmd_to_run = get_oras_cmd_to_run(secrets['password'])
subprocess.run(cmd_to_run, check=True)
try:
subprocess.run(cmd_to_run, check=True)
except subprocess.CalledProcessError as e:
# Intercept the error and replace the cmd, which may have sensitive info.
raise subprocess.CalledProcessError(e.returncode, cmd_to_run_no_password, e.output, e.stderr)


def parse_args() -> argparse.Namespace:
Expand Down

0 comments on commit 0e46f94

Please sign in to comment.