Skip to content
Merged
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
7 changes: 5 additions & 2 deletions src/services/remediation-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ export type RemediationPlanInput = {
}>;
};

const FORBIDDEN_PATTERN =
/\b(reward\w*|wallet|hotkey|coldkey|mnemonic|farming|payout|ranking|raw[-_\s]?trust|trust[-_\s]?score|private[-_\s]?reviewability|reviewability|private[-_\s]?scoreability|scoreability|score\w*|token[-_\s]?gate|token[-_\s]?score|base[-_\s]?score|multiplier|eligibility)\b|\/Users\/|\/home\/|\/tmp\/|[A-Z]:[\\/]Users[\\/]/i;
// #8886: exported so its forbidden-term coverage (specifically the plural `rankings`, unreachable through the
// public builder because sanitizePublicComment rewrites the term before this secondary gate ever sees it) can
// be asserted directly, matching how the issue itself verified the gap.
export const FORBIDDEN_PATTERN =
/\b(reward\w*|wallet|hotkey|coldkey|mnemonic|farming|payout|rankings?|raw[-_\s]?trust|trust[-_\s]?score|private[-_\s]?reviewability|reviewability|private[-_\s]?scoreability|scoreability|score\w*|token[-_\s]?gate|token[-_\s]?score|base[-_\s]?score|multiplier|eligibility)\b|\/Users\/|\/home\/|\/tmp\/|[A-Z]:[\\/]Users[\\/]/i;

const SOURCE_PRIORITY: Record<RemediationPlanSource, number> = {
account_state: 0,
Expand Down
11 changes: 10 additions & 1 deletion test/unit/remediation-plan.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { buildRemediationPlan } from "../../src/services/remediation-plan";
import { buildRemediationPlan, FORBIDDEN_PATTERN } from "../../src/services/remediation-plan";

const FORBIDDEN = /\b(wallet|hotkey|coldkey|mnemonic|farming|payout|raw[-_\s]?trust|score\w*|scoreability|token[-_\s]?score|base[-_\s]?score)\b/i;

Expand Down Expand Up @@ -188,6 +188,15 @@ describe("buildRemediationPlan", () => {
]);
});

it("FORBIDDEN_PATTERN catches both the singular 'ranking' and the plural 'rankings' (#8886)", () => {
// The bare singular `ranking` could never match inside "rankings" (no word boundary between "g" and "s"),
// so the plural leaked past this secondary gate; `rankings?` fixes it while still matching the singular.
expect(FORBIDDEN_PATTERN.test("this shows the ranking of contributors")).toBe(true);
expect(FORBIDDEN_PATTERN.test("this shows the rankings of contributors")).toBe(true);
// A benign word that merely starts the same must still pass through untouched.
expect(FORBIDDEN_PATTERN.test("the rankboard is empty")).toBe(false);
});

it("falls back to public-safe copy when every blocker string is fully redacted", () => {
const plan = buildRemediationPlan({
login: "miner",
Expand Down