Skip to content

Global search for staff - #81

Merged
summitt merged 2 commits into
mainfrom
feature/global-search
Nov 22, 2026
Merged

summitt merged 2 commits into
mainfrom
feature/global-search

Conversation

@summitt

@summitt summitt commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

What

A magnifying glass in the top bar, also opened with Ctrl/⌘+K. It searches vulnerabilities, assessments, applications, users and assessment types from one box and shows the results grouped by kind, each with a count. Results can be picked with the arrow keys and Enter.

Result Opens
Vulnerability its details panel (/vulnerabilities?vuln=<id>)
Assessment /assessments/<id>
Application /applications/<id>/edit
Assessment type /assessments/type/<id>
User the Users list filtered to that user
"See all N" the full list with the search filled in (?search=)

It is for staff only. The API refuses client-side (external) accounts, and the button is not shown to them.

Permissions

GET /api/v1/search?q= adds no access rules of its own. Each group runs the scoped search that already sits behind that record's list page, and only for callers who hold that list endpoint's permissions:

  • Vulnerabilities: GlobalVulnerabilityService / VulnerabilityScopeResolver, gated like GET /vulnerabilities.
  • Assessments: searchAssessmentsAdvanced, which forces resolveAssessmentScope.
  • Applications: searchApplications with the caller's authentication.
  • Users: searchUsersPaginated, gated by users:read:all|team.
  • Assessment types: any staff account, the same as GET /assessment-types.

So a team-scoped tester finds only their team's findings, and a kind the caller cannot list is not searched at all.

Matching and scale

  • Vulnerabilities match on their own name or tracking ID. The list's search also matches application, assessment and organization names, which would flood this group. An exact tracking ID comes first; the rest are newest first, and closed findings are included. VulnerabilityListDto now carries trackingId.
  • Indexes: a new SearchIndexInitializer enables pg_trgm and concurrently builds trigram GIN indexes on the LOWER(...) expressions the searches use: vulnerability name and tracking ID, assessment name, application name and app ID. A contains-search therefore doesn't scan the whole table. It works like the existing workflow and SLA index initializers. If the extension can't be created, the failure is logged and search still works, unindexed. It can be turned off with faction.search.index-initializer.enabled.
  • Limits: text under 2 characters returns nothing, text is capped at 100 characters, and each group returns at most 10 results (5 by default). A group that fails is logged and left out rather than failing the whole search.

Also

  • The Vulnerabilities, Assessments, Applications and Users pages take ?search= as their starting search.
  • The Vulnerabilities page now opens a ?vuln= link even when the page is already open. Before, only the first link per visit opened, so a second search result (or notification) did nothing.

Not in this PR

  • Searching descriptions, recommendations, notebooks and comments. That needs Postgres full-text search, which would be another group later.
  • Findings without an opened date, which matches the global Vulnerabilities list.

Testing

  • Full backend suite: 2,524 run, 0 failures, 47 skipped.
  • New tests:
    • GlobalSearchServiceTest, 9 tests: staff-only, minimum length, per-group permission gates, item mapping, limit cap, a failing group being left out.
    • GlobalVulnerabilityListTest, 5 tests against Postgres: own name/tracking only, closed included, exact tracking ID first, team scope including exact IDs, LIKE wildcards treated as text.
  • EndpointAuthorizationArchitectureTest and OpenApiDocsTest pass.
  • Manually checked in the enterprise build: Ctrl+K, grouped results, keyboard navigation, opening an assessment and a finding, and a second finding opened while already on the Vulnerabilities page.

🤖 Generated with Claude Code

A magnifying glass in the top bar, also opened with Ctrl/Cmd+K. It searches
vulnerabilities, assessments, applications, users and assessment types from one
box and shows the results grouped by kind.

Search adds no access rules of its own. GET /api/v1/search runs each group
through the scoped search that already sits behind that record's list page,
and only for callers who hold that page's permissions. A team-scoped tester
finds only their team's findings, an org-scoped manager only their
organization's, and a kind the caller cannot list is not searched. Client-side
(external) accounts are refused, and the button is not shown to them.

- Vulnerabilities match on their own name or tracking ID only. The list's
  search also matches application, assessment and organization names, which
  would flood this group. An exact tracking ID comes first; the rest are newest
  first, and closed findings are included. List rows now carry the tracking ID.
- Assessments, applications, users and assessment types use their lists'
  existing search unchanged.
- At startup the app enables pg_trgm and builds trigram GIN indexes on the
  LOWER(...) expressions the searches use (vulnerability name and tracking ID,
  assessment name, application name and app ID), so a contains-search does not
  scan the whole table. This works like the existing workflow and SLA index
  initializers. If the extension cannot be created, search still works,
  unindexed.
- Text under 2 characters returns nothing, text is capped at 100 characters,
  and each group returns at most 10 results (5 by default). A group that fails
  is logged and left out rather than failing the whole search.
- "See all" opens the full list with the search filled in (?search= on the
  Vulnerabilities, Assessments, Applications and Users pages). A user result
  opens the Users list filtered to that user.
- The Vulnerabilities page now opens a ?vuln= link even when the page is
  already open, so a second search result opens too; before, only the first
  link per visit did.

Signed-off-by: Josh <ascetik@gmail.com>
Code quality flagged GlobalSearchResultDto.getGroups() for exposing its
internal list, which GlobalSearchService then added to. The service now
collects the groups in its own list and builds the result once, and the
DTO copies its lists in and has no setters, so a holder of the answer
cannot change it. The JSON is unchanged.

Signed-off-by: Josh <ascetik@gmail.com>
@summitt
summitt merged commit 3dd834b into main Nov 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants