Repository navigation
Global search for staff - #81
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
/vulnerabilities?vuln=<id>)/assessments/<id>/applications/<id>/edit/assessments/type/<id>?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:GlobalVulnerabilityService/VulnerabilityScopeResolver, gated likeGET /vulnerabilities.searchAssessmentsAdvanced, which forcesresolveAssessmentScope.searchApplicationswith the caller's authentication.searchUsersPaginated, gated byusers:read:all|team.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
searchalso 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.VulnerabilityListDtonow carriestrackingId.SearchIndexInitializerenablespg_trgmand concurrently builds trigram GIN indexes on theLOWER(...)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 withfaction.search.index-initializer.enabled.Also
?search=as their starting search.?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
Testing
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.EndpointAuthorizationArchitectureTestandOpenApiDocsTestpass.🤖 Generated with Claude Code