Skip to content

Commit 7bd44c2

Browse files
[RHOAIENG-34678] Mask auth tokens (#636)
* mask token in python logs * mask token in error output * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2af0f0b commit 7bd44c2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

utilities/inference_utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,14 @@ def run_inference(
462462
from_port=port,
463463
to_port=port,
464464
):
465-
res, out, err = run_command(command=shlex.split(cmd), verify_stderr=False, check=False)
465+
res, out, err = run_command(
466+
command=shlex.split(cmd), verify_stderr=False, check=False, hide_log_command=True
467+
)
466468

467469
else:
468-
res, out, err = run_command(command=shlex.split(cmd), verify_stderr=False, check=False)
470+
res, out, err = run_command(
471+
command=shlex.split(cmd), verify_stderr=False, check=False, hide_log_command=True
472+
)
469473

470474
if res:
471475
if f"http/1.0 {HTTPStatus.SERVICE_UNAVAILABLE}" in out.lower():
@@ -475,7 +479,8 @@ def run_inference(
475479
)
476480

477481
else:
478-
raise ValueError(f"Inference failed with error: {err}\nOutput: {out}\nCommand: {cmd}")
482+
sanitized_cmd = re.sub(r"('Authorization: Bearer ).*?(')", r"\1***REDACTED***2", cmd)
483+
raise ValueError(f"Inference failed with error: {err}\nOutput: {out}\nCommand: {sanitized_cmd}")
479484

480485
LOGGER.info(f"Inference output:\n{out}")
481486

0 commit comments

Comments
 (0)