test(auth): regression-guard no unredacted secret in login/whoami/set-key/auth-set output (BE-3363)#555
test(auth): regression-guard no unredacted secret in login/whoami/set-key/auth-set output (BE-3363)#555mattmillerai wants to merge 2 commits into
Conversation
…-key/auth-set output (BE-3363)
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds regression coverage for unredacted secrets across ChangesSecret redaction tests
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/comfy_cli/test_secret_redaction.py`:
- Around line 145-149: Run Ruff formatting on the assertions in the test cases
around the combined-output secret checks and return-code failure messages,
including the additional block around lines 211–213. Preserve the existing
assertions and behavior while applying Ruff’s standard line wrapping and
formatting.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2752a09a-c50e-492f-8923-3a16bc982611
📒 Files selected for processing (1)
tests/comfy_cli/test_secret_redaction.py
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
Found 1 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 1 |
Panel: 6/8 reviewers contributed findings.
Reviewers that did not contribute: kimi-k2.5:adversarial (empty), kimi-k2.5:edge-case (empty)
…st output (BE-3363) The subprocess-based cases fold stdout+stderr before checking for a leaked sentinel, but the in-process `cloud login` test asserted only against `result.output`. Under Click 8.1 that is fine (mix_stderr=True merges the streams), but Click >= 8.2 dropped mix_stderr and captures stderr separately, making result.output stdout-only — a secret leaked to stderr would slip past. Fold stderr back in when it is a separate stream, honoring the module's stated 'stdout OR stderr' invariant across Click versions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ELI-5
A while back someone reported that signing in to Comfy Cloud printed their secret API key on screen in plain text. Today that doesn't happen — every command that touches a secret already scrambles it to
sk-S…cdefbefore printing. But nothing guarantees it stays that way: each command just happens to call the redacting version, and one careless refactor (or a new secret-bearing command) could quietly start leaking again.This PR adds a test that stands guard: it runs each secret-printing command with a fake secret and fails the build if the full secret ever shows up in what the command prints. No product code changes — it just locks in the good behavior we already have.
What & why
Test-only regression guard (
tests/comfy_cli/test_secret_redaction.py) for BE-3363. For every secret-bearing command, in both pretty and--jsonoutput modes, it feeds a long sentinel secret and asserts the full sentinel never appears in captured stdout or stderr (the redactedsk-S…cdefform is expected and fine):comfy auth set civitai --key <sentinel>comfy cloud set-key --key <sentinel>comfy cloud whoami(with a session seeded viastore.save_cloud_session, tokens = sentinels)comfy cloud loginsuccess path (comfy_cli.cloud.command.run_loginmocked to return sentinel tokens; runs in-process via Typer'sCliRunnerbecause a subprocess can't patchrun_login)Sentinels are >16 chars so they take the
sk-S…cdefredaction branch, not the<=16 → ***one. The module is structured so a new secret-bearing command is a single_Caselist entry (or a sibling of the login test when a network handshake must be mocked).Two positive controls prove the guard observes redaction rather than vacuously passing on empty/errored output:
test_auth_set_json_carries_only_the_redacted_keyasserts the JSON envelope carries exactlystore._redact(...), and the login test asserts a real session was persisted to disk.Out of scope
No redaction behavior changes (redaction on current
mainalready works — verified while writing this); the cloud web page's own server-side display of keys.Testing
pytest tests/comfy_cli/test_secret_redaction.py→ 9 passed.ruff format --check+ruff checkon the new file → clean.--no-jsonforcesOutputMode.PRETTYeven in a non-tty subprocess (renderer.py:120-121), so the "pretty" cases genuinely exercise the banner-rendering path; eyeballedauth set/whoamipretty output (redacted key / expiry shown, never the raw token).Notes for the reviewer
tests/comfy_cli/auth/test_where.py(2) andtests/comfy_cli/cloud/test_client.py(5); confirmed present on a cleanorigin/maincheckout, so they are not introduced here.whoami/loginuse a subprocess vs. in-processCliRunnersplit respectively — the login handshake must be mocked, which a subprocess boundary can't reach.