Skip to content

added changes to fix affected project search in vulnerabilities page#1944

Open
mehab wants to merge 3 commits intomainfrom
fix/affected-projects-search-filter
Open

added changes to fix affected project search in vulnerabilities page#1944
mehab wants to merge 3 commits intomainfrom
fix/affected-projects-search-filter

Conversation

@mehab
Copy link
Copy Markdown
Collaborator

@mehab mehab commented Mar 27, 2026

Description

This PR fixes the affected project search on the vulnerability detail page. Currently this search does not refresh if project name is provided in the search bar

Addressed Issue

If the number of affected projects is too many for a vulnerability, the search box should help us search specific project as needed. Currently even if we type something in the search box, the list does not get refreshed.

Additional Details

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have updated the migration changelog accordingly
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

Signed-off-by: Meha Bhargava <meha.bhargava2@gmail.com>
@mehab mehab requested a review from nscuro March 27, 2026 15:17
@mehab mehab added the defect Something isn't working label Mar 27, 2026
Signed-off-by: Meha Bhargava <meha.bhargava2@gmail.com>
@mehab mehab requested a review from sahibamittal March 30, 2026 12:48
AND (
LOWER("PROJECT"."NAME") LIKE ('%' || LOWER(:searchText) || '%')
OR LOWER(COALESCE("PROJECT"."VERSION", '')) LIKE ('%' || LOWER(:searchText) || '%')
OR CAST("PROJECT"."UUID" AS TEXT) LIKE ('%' || :searchText || '%')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is searching by UUID a requirement? I think no other endpoint uses searchText for UUID columns.

None of these expressions are indexed, so the fewer we can use the better.

Comment on lines +281 to +282
@Parameter(description = "Optionally filters affected projects by name, version, or UUID", required = false)
@QueryParam("searchText") String searchText) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: searchText is an implicit parameter defined at the framework-level, no need to define an explicit one. You can access it directly via getAlpineRequest().getFilter().

@nscuro nscuro added this to the 5.7.0 milestone Mar 30, 2026
Signed-off-by: Meha Bhargava <meha.bhargava2@gmail.com>
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage 85.71% diff coverage

Metric Results
Coverage variation Report missing for d89d8951
Diff coverage 85.71% diff coverage (70.00%)

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d89d895) Report Missing Report Missing Report Missing
Head commit (2f648d3) 25831 22096 85.54%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1944) 7 6 85.71%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

TIP This summary will be updated as you push new changes. Give us feedback

Copy link
Copy Markdown
Member

@nscuro nscuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the API docs cleaned up, otherwise looks good.

description = """
<p>Requires permission <strong>VIEW_PORTFOLIO</strong></p>\
<p>Optional query parameters <code>searchText</code> or <code>filter</code> narrow the list; \
both are provided by the Alpine request filter and match the same value.</p>""",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an implementation detail that doesn't belong in public API documentation.

description = "<p>Requires permission <strong>VIEW_PORTFOLIO</strong></p>"
description = """
<p>Requires permission <strong>VIEW_PORTFOLIO</strong></p>\
<p>Optional query parameters <code>searchText</code> or <code>filter</code> narrow the list; \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's commit to only searchText to avoid confusion. Also, when we explicitly mention it, we should also note what it searches (i.e. project name, case-insensitive, "contains" semantics).

Comment on lines +298 to +300
final AlpineRequest alpineRequest = getAlpineRequest();
final String affectedProjectsFilter;
if (alpineRequest == null) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAlpineRequest should never return null, no need to handle that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

defect Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants