Repository navigation
Redact credentials from reviewer authentication errors #1380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
36aac2b
affa394
c05a3eb
5d2cd75
caf666c
8057285
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,16 @@ def _tail(text: str) -> str: | |
| return text[-TAIL_CHARS:] | ||
|
|
||
|
|
||
| def _auth_failure(family: str, diagnostic: str) -> RunnerAuthFailed: | ||
| names = CLAUDE_AUTH_ENV if family == "claude" else CODEX_AUTH_ENV | ||
| env = _proc.build_env(names) | ||
| values = {variant for value in env.values() if value for variant in (value, json.dumps(value)[1:-1])} | ||
| patterns = [*map(re.escape, sorted(values, key=len, reverse=True)), r"\bsk-[A-Za-z0-9_-]{8,}", | ||
| r"\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+"] | ||
| diagnostic = re.sub("|".join(patterns), "[REDACTED]", diagnostic) | ||
| return RunnerAuthFailed(f"{family}: CLI is not authenticated\n{_tail(diagnostic)}") | ||
|
|
||
|
|
||
| def _looks_like_auth_failure(text: str) -> bool: | ||
| return _AUTH_FAILURE.search(text) is not None | ||
|
|
||
|
|
@@ -270,7 +280,7 @@ def _run( | |
| with contextlib.suppress(json.JSONDecodeError, ValueError): | ||
| envelope = _extract_json_object(done.stdout) | ||
| if _claude_envelope_auth_failure(envelope) or _looks_like_auth_failure(combined): | ||
| raise RunnerAuthFailed(f"{family}: CLI is not authenticated\n{_tail(combined)}") | ||
| raise _auth_failure(family, combined) | ||
| if _subscription_exhausted(combined, envelope): | ||
| raise RunnerUsageLimit(f"{family}: usage limit reached", _tail(combined)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Native diagnostics on non-auth failure paths are still forwarded without redaction Only the |
||
| if _looks_too_long(combined): | ||
|
|
@@ -1050,13 +1060,13 @@ def _review_claude( | |
| if not isinstance(envelope, dict): | ||
| raise RunnerMalformedOutput("claude: result envelope is not an object", _tail(raw)) | ||
| if _claude_envelope_auth_failure(envelope): | ||
| raise RunnerAuthFailed(f"claude: CLI is not authenticated\n{_tail(raw)}") | ||
| raise _auth_failure("claude", raw) | ||
| if envelope.get("is_error") and _subscription_exhausted(raw, envelope): | ||
| raise RunnerUsageLimit("claude: usage limit reached", _tail(raw)) | ||
| if envelope.get("is_error") or envelope.get("subtype", "success") != "success": | ||
| text = str(envelope.get("result", "")) | ||
| if _looks_like_auth_failure(text): | ||
| raise RunnerAuthFailed(f"claude: CLI is not authenticated\n{_tail(text)}") | ||
| raise _auth_failure("claude", text) | ||
| if _looks_too_long(text) or _looks_too_long(raw): | ||
| raise RunnerPromptTooLong("claude: prompt is too long", _tail(raw)) | ||
| raise RunnerBadOutput(f"claude: {envelope.get('subtype', 'error')}", _tail(raw)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Very short forwarded env values redact unrelated text
Every non-empty forwarded value becomes a literal redaction pattern. If someone sets
ANTHROPIC_API_KEYorCLAUDE_CODE_OAUTH_TOKENto a placeholder such as1,xortest, every occurrence of that substring is replaced. This can mangle the failure text the acceptance criteria say must be preserved, e.g.Not logged inbecomesNo[REDACTED] logged inwhen the value ist. Smallest fix: skip values below a minimum length, e.g.len(value) >= 8. The provider-shapedsk-/JWT patterns still cover real credentials.