diff --git a/src/services/weekly-value-report.ts b/src/services/weekly-value-report.ts index 2f831ef562..8b9cbaa650 100644 --- a/src/services/weekly-value-report.ts +++ b/src/services/weekly-value-report.ts @@ -411,7 +411,7 @@ function normalizeReportDays(value: number | null | undefined): number { function sanitizeReportText(value: string): string { const redacted = value .replace(PUBLIC_LOCAL_PATH_SCRUB_PATTERN, "") - .replace(/\b(?:ghp_|github_pat_|gts_|glpat-|sk-)[A-Za-z0-9_=-]{8,}/g, "") + .replace(/\b(?:ghp_|github_pat_|gts_|glpat-|sk-|xox[baprs]-)[A-Za-z0-9_=-]{8,}/g, "") .replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, "Bearer "); if ( /\b(seed phrase|mnemonic|private key|raw[-\s]?trust|trust[-\s]?score|wallet|hotkey|coldkey|payout|reward(?:[-\s]?(?:estimate|prediction|claim|score|payout|risk))?|farming|private[-\s]?reviewability|private[-\s]?scoreability|scoreability|public[-\s]?score[-\s]?(?:estimate|prediction|claim)|score[-\s]?(?:estimate|prediction|preview))\b/i.test( diff --git a/test/unit/weekly-value-report.test.ts b/test/unit/weekly-value-report.test.ts index 2a0b0514d8..483bcb0860 100644 --- a/test/unit/weekly-value-report.test.ts +++ b/test/unit/weekly-value-report.test.ts @@ -211,6 +211,38 @@ describe("weekly value reports", () => { expect(JSON.stringify(report)).not.toMatch(/\/root\/work|\/var\/folders/); }); + it("redacts Slack bot tokens in operator rollup dimensions", () => { + const slackToken = ["xoxb", "1234567890", "ABCDEFabcdef"].join("-"); + const report = buildWeeklyValueReport({ + generatedAt: "2026-06-01T12:00:00.000Z", + variant: "operator", + days: 7, + repositories: [repo("JSONbored/gittensory", true, true)], + installations: [installation(1)], + health: [health(1, "healthy")], + registry: registry([]), + scoring: scoring([]), + upstreamDrift: upstream({ status: "current", openReportCount: 0 }), + usageSummary: usageSummary({ totalEvents: 1, activeActors: 1 }), + usageRollups: [ + rollup("2026-05-31", { + totalEvents: 1, + activeActors: 1, + activeRepos: 1, + repos: [{ key: slackToken, count: 1 }], + events: [], + surfaces: [], + commands: [], + tools: [], + }), + ], + usageRollupStatus: rollupStatus({ status: "ready" }), + }); + + expect(report.operatorDetails?.topRepos).toEqual([{ key: "", count: 1 }]); + expect(JSON.stringify(report)).not.toMatch(new RegExp(slackToken.slice(0, 4), "i")); + }); + it("keeps clean complete windows marked ready", () => { const report = buildWeeklyValueReport({ generatedAt: "2026-06-01T12:00:00.000Z",