Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/channel-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,16 @@ describe("userFacingRunError", () => {
expect(text).not.toContain("ghp_LIVESECRET99");
expect(text).toContain("ghp_[redacted]");
});

it.each(["ghs", "ghu", "ghr"])(
"redacts a %s_ GitHub App token from the reason",
(prefix) => {
const secret = `${prefix}_LIVESECRET99`;
const text = userFacingRunError(
new Error(`git push failed for https://x-access-token:${secret}@github.com/o/r`),
);
expect(text).not.toContain(secret);
expect(text).toContain(`${prefix}_[redacted]`);
},
);
});
4 changes: 3 additions & 1 deletion app/channel-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export function reportRecoverableError(
});
}

const TOKEN_RE = /(ghp|github_pat|gho)_[A-Za-z0-9_]+/g;
// Same families as `agent/coding/sandbox.py`. GitHub App auth mints `ghs_`
// installation tokens, so the narrower pattern let those through to Slack.
const TOKEN_RE = /(ghp|github_pat|gho|ghs|ghu|ghr)_[A-Za-z0-9_]+/g;

function errorText(error: unknown): string {
if (error instanceof AggregateError) {
Expand Down