fix(orb): one shared token-redaction pattern across the five public surfaces (#9697) - #9918
Merged
Merged
Conversation
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 LoopOver is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
…urfaces (JSONbored#9697) Four hand-written token-redaction patterns guarded public-facing text in src/services/**, and every one missed something another caught. The worst gap: three surfaces (miner-dashboard-recommendations, control-panel-roles, weekly-value-report) matched only `ghp_`, so `ghs_` -- the GitHub App INSTALLATION token this Worker mints on every pass -- passed through a public dashboard string, role summary, and weekly report verbatim. The two path surfaces (score-breakdown, agent-action-explanation-card) matched the correct `gh[pousr]_` GitHub class but not the Orb/GitLab/Slack prefixes the others caught. - src/signals/redaction.ts: add PUBLIC_TOKEN_INLINE (the alternation source of every prefix -- `gh[pousr]_`, github_pat_, gts_, orbenr_, orbsec_, glpat-, sk-, xox[baprs]-) and publicTokenPattern() returning a FRESH /g RegExp each call, the credential analogue of the existing PUBLIC_LOCAL_PATH_INLINE / PUBLIC_LOCAL_PATH_SCRUB_PATTERN. - All five surfaces now compose from that single source, each keeping its own replacement string and its own trailing body class / path alternation; no hand-written prefix literal remains under src/services/. Tests: a REGRESSION ghs_ case on miner-dashboard; an it.each over every prefix on control-panel-roles, weekly-value-report, score-breakdown, and a new agent-action-explanation-card test file; publicTokenPattern() fresh- object + repeated-.replace() idempotency in redaction.test. Each site also asserts a non-token string is left unmodified. Closes JSONbored#9697 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9918 +/- ##
===========================================
- Coverage 91.86% 79.71% -12.16%
===========================================
Files 921 287 -634
Lines 113263 59130 -54133
Branches 27300 8873 -18427
===========================================
- Hits 104046 47133 -56913
- Misses 7929 11706 +3777
+ Partials 1288 291 -997
Flags with carried forward coverage won't be shown. Click here to find out more.
|
JSONbored
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Four hand-written token-redaction patterns guarded public-facing text in
src/services/**, and every one missed something another caught. The worst gap: three surfaces (miner-dashboard-recommendations,control-panel-roles,weekly-value-report) matched onlyghp_, soghs_— the GitHub App installation token this Worker mints on every pass viacreateInstallationToken— passed through a public dashboard string, role summary, and weekly report verbatim. The two path surfaces (score-breakdown,agent-action-explanation-card) matched the correctgh[pousr]_GitHub class but not the Orb/GitLab/Slack prefixes the others caught.How
src/signals/redaction.ts: addPUBLIC_TOKEN_INLINE(the alternation source of every prefix —gh[pousr]_,github_pat_,gts_,orbenr_,orbsec_,glpat-,sk-,xox[baprs]-) andpublicTokenPattern()returning a fresh/gRegExpon each call — the credential analogue of the existingPUBLIC_LOCAL_PATH_INLINE/PUBLIC_LOCAL_PATH_SCRUB_PATTERN.gh[pousr]_is the correct GitHub class (same assrc/review/secret-patterns.ts), coveringghp_/gho_/ghu_/ghs_/ghr_at once."private context","<redacted-token>","<redacted>") and its own trailing body class / path alternation. No hand-written prefix literal remains undersrc/services/.Tests
miner-dashboard-recommendations: a namedREGRESSIONcase for theghs_installation-token gap.control-panel-roles,weekly-value-report,score-breakdown, and a newagent-action-explanation-cardtest file: oneit.eachover every prefix inPUBLIC_TOKEN_INLINE, plus a non-token string left unmodified per site.redaction.test:publicTokenPattern()returns a fresh object each call and a repeated.replace()is idempotent (guards the shared-lastIndexregression).134 tests pass across the six files; the old patterns provably miss
ghs_/xoxb-(non-vacuous).Closes #9697