Public: anyone can read this; the crew can change it.
Issue search leaves out sealed security reports for a reader who may not see them #15006
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/14994-issue-search-leaves-out-sealed-security → main 1 commit fork
2 files
changed +22
−1
src/core/issues.ts +5 −1
| @@ -1281,7 +1281,7 @@ export interface IssueHit extends Issue { | ||
| 1281 | 1281 | |
| 1282 | 1282 | /** |
| 1283 | 1283 | * Titles matching `query`, across every repo the viewer can see, in one |
| 1284 | * query. | |
| 1284 | * query. Sealed security reports are left out for everyone. | |
| 1285 | 1285 | * |
| 1286 | 1286 | * The shape this replaces was a loop: take the twenty most recent visible |
| 1287 | 1287 | * repos, ask each of them for issues and again for pulls, forty queries for |
| @@ -1306,7 +1306,11 @@ export function searchIssuesVisibleTo( | ||
| 1306 | 1306 | viewer?.id ?? "", |
| 1307 | 1307 | `%${likeEscape(text)}%`, |
| 1308 | 1308 | ]; |
| 1309 | // Never a sealed row: who may see one is decided per repo (`sealed.ts`), | |
| 1310 | // and a search across every repo has no such scope. A writer reads them | |
| 1311 | // in the repo's own list. | |
| 1309 | 1312 | let where = `${repoVisible(viewer !== undefined)} |
| 1313 | AND issue.sealed = 0 | |
| 1310 | 1314 | AND issue.title LIKE ?2 ESCAPE '\\' COLLATE NOCASE`; |
| 1311 | 1315 | if (options.kind !== undefined) { |
| 1312 | 1316 | params.push(options.kind); |
test/scale.test.ts +17
| @@ -30,6 +30,7 @@ import { signUpProven as signUp } from "./helpers/verified.ts"; | ||
| 30 | 30 | import { |
| 31 | 31 | commentCounts, |
| 32 | 32 | countComments, |
| 33 | createIssue, | |
| 33 | 34 | getIssuesByRef, |
| 34 | 35 | issueCounts, |
| 35 | 36 | issueRefKey, |
| @@ -491,6 +492,22 @@ describe("visibility is enforced in SQL, not after the fact", () => { | ||
| 491 | 492 | expect(public_[0]?.repoName).toBe("open-book"); |
| 492 | 493 | }); |
| 493 | 494 | |
| 495 | test("search leaves out a sealed security report on a repo the viewer can read", () => { | |
| 496 | // Filed on the public repo, so `repoVisible` alone lets every reader — | |
| 497 | // signed-out included — find its title (`sealed.ts`). | |
| 498 | const report = createIssue(app.db, { | |
| 499 | repoId: mine.id, | |
| 500 | authorId: bob.id, | |
| 501 | title: "embargoed vulnerability in the login form", | |
| 502 | sealed: true, | |
| 503 | }); | |
| 504 | if (!report.ok) throw new Error("seed report"); | |
| 505 | expect(searchIssuesVisibleTo(app.db, alice, "embargoed")).toHaveLength(0); | |
| 506 | expect(searchIssuesVisibleTo(app.db, undefined, "embargoed")).toHaveLength(0); | |
| 507 | // Its neighbours on the same repo still answer. | |
| 508 | expect(searchIssuesVisibleTo(app.db, undefined, "the public one")).toHaveLength(1); | |
| 509 | }); | |
| 510 | ||
| 494 | 511 | test("an empty query is not a request for everything", () => { |
| 495 | 512 | expect(searchIssuesVisibleTo(app.db, bob, " ")).toHaveLength(0); |
| 496 | 513 | }); |
new above
offline