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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/14994-issue-search-leaves-out-sealed-security → main 1 commit fork

  • Merged. mason/14994-issue-search-leaves-out-sealed-security was merged into main as 29cc84e.

Review

Sign in to review this change.
2 files changed +22 −1
src/core/issues.ts +5 −1
@@ -1281,7 +1281,7 @@ export interface IssueHit extends Issue {
12811281
12821282 /**
12831283 * Titles matching `query`, across every repo the viewer can see, in one
1284 * query.
1284 * query. Sealed security reports are left out for everyone.
12851285 *
12861286 * The shape this replaces was a loop: take the twenty most recent visible
12871287 * repos, ask each of them for issues and again for pulls, forty queries for
@@ -1306,7 +1306,11 @@ export function searchIssuesVisibleTo(
13061306 viewer?.id ?? "",
13071307 `%${likeEscape(text)}%`,
13081308 ];
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.
13091312 let where = `${repoVisible(viewer !== undefined)}
1313 AND issue.sealed = 0
13101314 AND issue.title LIKE ?2 ESCAPE '\\' COLLATE NOCASE`;
13111315 if (options.kind !== undefined) {
13121316 params.push(options.kind);
test/scale.test.ts +17
@@ -30,6 +30,7 @@ import { signUpProven as signUp } from "./helpers/verified.ts";
3030 import {
3131 commentCounts,
3232 countComments,
33 createIssue,
3334 getIssuesByRef,
3435 issueCounts,
3536 issueRefKey,
@@ -491,6 +492,22 @@ describe("visibility is enforced in SQL, not after the fact", () => {
491492 expect(public_[0]?.repoName).toBe("open-book");
492493 });
493494
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
494511 test("an empty query is not a request for everything", () => {
495512 expect(searchIssuesVisibleTo(app.db, bob, " ")).toHaveLength(0);
496513 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs