Skip to content

Redact credentials in GitHub review findings - #1312

Merged
mergify[bot] merged 6 commits into
mainfrom
lean178/1256-redact-review
Nov 26, 2026
Merged

mergify[bot] merged 6 commits into
mainfrom
lean178/1256-redact-review

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Redact credentials in GitHub review findings

Context and goal

  • Goal: Keep credential-shaped values out of the review prose and inline comments published from findings.
  • Problem: A reviewer can repeat a credential in a finding title or description that is then shared with PR readers.
  • Context: Loop-zero rebuilds the public payload from its saved review when confirming publication after a lost response.

Closes #1256

Acceptance

  • Synthetic credentials in a title and description produce redaction markers in the public review and inline comment.
  • Explanatory text, locations, severity, and original finding IDs survive. A lost POST response can be recovered with review --repost.

Notes

Treat model-written finding prose as potentially sensitive. Apply shared credential recognition to prose rendering while the saved result and finding IDs continue to use original fields. The existing payload generator serves both publication and recovery.

The lost-response test reproduces fake token exposure on the base and passes with redaction. The focused GitHub tests and full recovery test file pass. Security review traced the GitHub payload, preserved finding IDs and checked exact read-back. The architecture guide still describes those boundaries.

The exact source head passed the local gate and both required hosted checks. Mergify candidate #1364 stopped at 13,507 test lines against the 13,500-line cap. The approved head is parked on that cap.

Base

Base: fa78ebb

Validation

Recorded for 2652547af15b

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Review

  • primary, claude, ffdcdbf, approve

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Architecture-Review: unchanged; publication and recovery still use the same GitHub payload and original finding identities.
Co-Authored-By: Codex <noreply@openai.com>
@eowca
eowca marked this pull request as draft November 26, 2026 01:34

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on ffdcdbf34d3e1937ac6baec071b26ed5bb283078, 50.3s: approve (0 critical, 0 important, 4 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Findings without a file location:

  • suggestion: Read-back of reviews published before this change can no longer match if their findings contained credential-shaped text — Recovery (cli.py:941-944) regenerates review_payloads for every format, including legacy layouts, and requires the body to match exactly. Findings are now always redacted, even in legacy_display formats. A review published before this change whose finding prose contained sk-… or ghp_… therefore no longer matches its own read-back. This fails closed and affects few reviews, so it isn't blocking. If that history matters, render legacy formats without redaction, or document the mismatch.

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/github.py

def _comment_body(f: Finding, head_sha: str, prefix: str = "") -> str:
text = f"{prefix}**{f.severity}: {f.title}**\n\n{f.body}".rstrip()
text = prefix + _CREDENTIAL_TOKEN_RE.sub("[REDACTED]", f"**{f.severity}: {f.title}**\n\n{f.body}").rstrip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Finding prose uses a narrower credential recogniser than the shared _redact_tokens

The task says to apply the shared credential recognition to finding prose. _comment_body and _review_body only apply _CREDENTIAL_TOKEN_RE. They don't use the rest of _redact_tokens (github.py:199): exact matches for the live GH_TOKEN/GITHUB_TOKEN/app token, Authorization: ... values and Bearer <value>. So a finding that quotes Authorization: Bearer eyJ..., or a token whose format isn't gh*_, github_pat_ or sk-, is still published as written. The URL-query and token= rules in _redact_tokens would damage normal explanatory text like token: str, so I wouldn't use the whole function. Smallest fix: add one _redact_prose(text) helper that applies the exact-secret replacements, the Bearer/Authorization rules and _CREDENTIAL_TOKEN_RE. Call it from both places and from _redact_tokens, so the two recognisers can't drift apart.

Comment thread src/loopzero/github.py
if unplaced:
lines.append("\nFindings without a file location:\n")
lines += [f"- **{f.severity}**: {f.title} — {f.body}".rstrip(" —") for f in unplaced]
lines += [_CREDENTIAL_TOKEN_RE.sub("[REDACTED]", f"- **{f.severity}**: {f.title} — {f.body}".rstrip(" —")) for f in unplaced]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The same inline redaction call is duplicated at two publication sites

_CREDENTIAL_TOKEN_RE.sub("[REDACTED]", ...) is written out at line 718 (inline comment) and line 770 (unplaced findings). If someone later adds a third place that renders finding prose, or changes the marker, these will drift. Line 770 is also now a long nested expression. Move it into a small named helper (for example _public_text(s)) and call it from both sites. This also gives later rendering paths, such as the cannot anchor '{f.title}' message at line 890, an obvious function to reuse.

Comment thread src/loopzero/github.py
_GITHUB_TOKEN_RE = re.compile(
r"\b(?:github_pat_[A-Za-z0-9_]+|gh[pousr]_[A-Za-z0-9_]{10,})\b"
_CREDENTIAL_TOKEN_RE = re.compile(
r"\b(?:github_pat_[A-Za-z0-9_]+\b|gh[pousr]_[A-Za-z0-9_]{10,}\b|sk-[A-Za-z0-9_-]{8,})"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The broader sk- pattern can redact ordinary hyphenated words in both prose and API error diagnostics

\bsk-[A-Za-z0-9_-]{8,} matches any standalone word that starts with sk- and has 8 or more following characters, including hyphens. Ordinary text like sk-learn-compatible or a branch name like sk-refactor-loader becomes [REDACTED]. This works against the acceptance item that explanatory text must survive. The regex is shared with _redact_tokens, so the same applies to GhError diagnostics. If false positives matter, require a longer body or a known prefix, for example sk-(?:ant-|proj-)?[A-Za-z0-9_-]{20,}. The tests use short fake values, so they would need longer ones.

@eowca
eowca marked this pull request as ready for review November 26, 2026 02:01
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

❌ Left the queue · checks fails with this pull request

2 min in the queue, less than a minute of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 02:02 · rule main · triggered by @eowca with the @mergifyio queue command
  • ❌ Checks failed · draft #1364
  • 🚫 Left the queue 02:04 · ffdcdbf

The failure is in this pull request. It failed tested alone on top of main.

Reason

The merge conditions cannot be satisfied due to failing checks

  • checks

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, comment @mergifyio queue to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = checks
    • check-skipped = checks
    • check-success = checks
2 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify mergify Bot mentioned this pull request Nov 26, 2026
10 of 30 tasks
@mergify mergify Bot added dequeued and removed queued labels Nov 26, 2026
@mergify mergify Bot removed the dequeued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

❌ Left the queue · checks fails with this pull request

4 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 02:59 · rule main · triggered by @eowca with the @mergifyio queue command
  • ❌ Checks failed · draft #1448
  • 🚫 Left the queue 03:03 · 9103ee0

The failure is in this pull request. It failed tested alone on top of main.

Reason

The merge conditions cannot be satisfied due to failing checks

  • checks

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, comment @mergifyio queue to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = checks
    • check-skipped = checks
    • check-success = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility
    • check-success = Loop-zero Eligibility
1 merge condition met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify mergify Bot mentioned this pull request Nov 26, 2026
10 of 30 tasks
@mergify mergify Bot added dequeued and removed queued labels Nov 26, 2026
@mergify mergify Bot removed the dequeued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🛑 Queue command cancelled

Queue requested — the merge queue status continues in this comment ↓.

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero delta review by codex on 2652547af15b326f504935b9f9af982e29e7cff7, 6.6s: approve (0 critical, 0 important, 0 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: 58145cd10e30f0a9633a495091bc58495bc5714a9d44a2f97d51c8b24f971b91

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as dd73a0f at 10:59 UTC

5 min in the queue, 3 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 10:54 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1823
  • ✅ Merged 10:59 · dd73a0f · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit dd73a0f into main Nov 26, 2026
14 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1256-redact-review branch November 26, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: Redact credentials from published reviewer findings

1 participant