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
2 changes: 1 addition & 1 deletion src/signals/local-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ function firstCommitTitle(messages: string[] | undefined): string | undefined {

function safeRepoPath(path: string): string {
/* v8 ignore next -- Empty path fallback protects malformed local-git adapters; path redaction is covered by local branch tests. */
return /^(\/Users\/|\/home\/|\/tmp\/|[A-Z]:\/Users\/)/i.test(String(path).replace(/\\/g, "/")) ? "[local path hidden]" : String(path || "(unknown path)").replace(/\\/g, "/");
return /^(\/Users\/|\/home\/|\/root\/|\/tmp\/|[A-Z]:\/Users\/)/i.test(String(path).replace(/\\/g, "/")) ? "[local path hidden]" : String(path || "(unknown path)").replace(/\\/g, "/");
}

export function isTestFile(file: string): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/signals/redaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// intentionally NOT collapsed onto `PUBLIC_UNSAFE_TERMS`.
export const PUBLIC_UNSAFE_TERMS = String.raw`reward\w*|score\w*|wallet|hotkey|coldkey|mnemonic|farming|payout|ranking|raw[-_\s]?trust|trust[-_\s]?score|private[-_\s]?reviewability|reviewability`;

export const PUBLIC_UNSAFE_PATTERN = new RegExp(String.raw`\b(${PUBLIC_UNSAFE_TERMS})\b|/Users/|/home/|/tmp/|[A-Z]:[\\/]Users[\\/]`, "i");
export const PUBLIC_UNSAFE_PATTERN = new RegExp(String.raw`\b(${PUBLIC_UNSAFE_TERMS})\b|/Users/|/home/|/root/|/tmp/|[A-Z]:[\\/]Users[\\/]`, "i");

/** True iff `text` contains nothing that must stay private — i.e. it is safe to surface on a public GitHub surface. */
export function isPublicSafeText(text: string): boolean {
Expand Down
23 changes: 23 additions & 0 deletions test/unit/local-branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,29 @@ describe("local branch analysis", () => {
expect(analysis.prPacket.markdown).not.toMatch(/C:\\Users\\alice/i);
});

it("hides root-user home paths from public PR packet changed paths", () => {
const analysis = buildLocalBranchAnalysis({
input: {
login: "oktofeesh1",
repoFullName: repo.fullName,
body: "Fixes #7",
changedFiles: [{ path: "/root/work/src/cache.ts", additions: 12, deletions: 2, status: "modified" }],
validation: [{ command: "npm test -- cache", status: "passed" }],
},
repo,
issues: [{ repoFullName: repo.fullName, number: 7, title: "Cache refresh fails", state: "open", labels: ["bug"], linkedPrs: [] }],
pullRequests: [],
profile,
outcomeHistory,
scoringSnapshot,
scoringProfile,
});

expect(analysis.prPacket.markdown).toContain("## Changed Paths");
expect(analysis.prPacket.markdown).toContain("[local path hidden]");
expect(analysis.prPacket.markdown).not.toContain("/root/work");
});

it("removes snake_case private signals from public PR packet markdown", () => {
const analysis = buildLocalBranchAnalysis({
input: {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/redaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe("isPublicSafeText (#542 shared public/private boundary)", () => {
it("rejects local filesystem paths (posix and Windows)", () => {
expect(isPublicSafeText("/Users/alice/project")).toBe(false);
expect(isPublicSafeText("/home/bob/repo")).toBe(false);
expect(isPublicSafeText("/root/project/src")).toBe(false);
expect(isPublicSafeText("clone failed at /root/work/repo")).toBe(false);
expect(isPublicSafeText("/tmp/scratch")).toBe(false);
expect(isPublicSafeText("C:\\Users\\carol\\repo")).toBe(false);
expect(isPublicSafeText("C:/Users/carol/repo")).toBe(false);
Expand Down
Loading