From 5f35986e66b569a5dc8aae2bee14d50c53aa419e Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 09:36:56 +0100 Subject: [PATCH] Redact credentials in terminal check headings Architecture-Review: unchanged; terminal rendering uses the existing command redactor without changing execution or receipt identity. Co-Authored-By: Codex --- src/loopzero/cli.py | 5 +++-- tests/test_cli.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/loopzero/cli.py b/src/loopzero/cli.py index f3c59c09..03c649cb 100644 --- a/src/loopzero/cli.py +++ b/src/loopzero/cli.py @@ -630,7 +630,7 @@ def cmd_check(args: argparse.Namespace) -> int: raise config_mod.ConfigError("checks.commands must list at least one command to run checks") try: report = sandbox.run_checks(config, wt, progress=lambda command: print( - f"running: {command}", flush=True), + f"running: {github.redact_credentials(command)}", flush=True), status=lambda message: print(message, flush=True), checkpoint=lambda partial: _save_report(wt, partial), workflow=args.config or f"origin/{config.base_branch}:workflow.toml") @@ -639,7 +639,8 @@ def cmd_check(args: argparse.Namespace) -> int: return 2 for result in report.results: if result.exit_code != 0: - print(f"--- {result.command} (exit {result.exit_code}) ---", file=sys.stderr) + heading = github.redact_credentials(result.command) + print(f"--- {heading} (exit {result.exit_code}) ---", file=sys.stderr) tail = _proc.tail(result.tail) print(tail, file=sys.stderr) if not config.network and (result.command.startswith("uv sync --offline --locked") diff --git a/tests/test_cli.py b/tests/test_cli.py index f679c279..d7ff2d9c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -544,7 +544,7 @@ def test_malformed_live_markers_do_not_mask_check_verdict( @pytest.mark.parametrize("command,exit_code,tail", [ - ("echo no; exit 3", 3, "no\n"), + ("echo no; exit 3 # https://fake-heading-secret@example.invalid", 3, "no\n"), ("seq 1 50; exit 1", 1, "".join(f"{i}\n" for i in range(11, 51)))]) def test_check_failure_reports_verdict_and_capped_tail(wt, capsys, command, exit_code, tail): (wt / "workflow.toml").write_text(WORKFLOW.replace( @@ -552,10 +552,10 @@ def test_check_failure_reports_verdict_and_capped_tail(wt, capsys, command, exit code, out, err = run(capsys, "--config", str(wt / "workflow.toml"), "check") assert code == 1 and out.endswith("FAIL\n") assert out.startswith("checks are unpinned because --config was provided\n") - assert sum(line.startswith(("stage 1/2: exit ", "exit ")) - for line in out.splitlines()) == 1 + heading = command.replace("fake-heading-secret", "[REDACTED]") + assert out.count(f"running: {heading}\n") == out.count("stage 1/2: exit ") == 1 assert f"stage 1/2: exit {exit_code} (" in out and "README.md" not in out - assert err == f"--- {command} (exit {exit_code}) ---\n{tail}" + assert err == f"--- {heading} (exit {exit_code}) ---\n{tail}" report = json.loads((wt / ".loopzero/checks.json").read_text()) assert [result["command"] for result in report["results"]] == [command]