Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions controllers/dependency_vuln_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"log/slog"
"slices"
"strings"
"time"

"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -81,7 +82,7 @@ func (controller DependencyVulnController) ListByOrgPaged(ctx shared.Context) er
return p.GetID().String()
}),
shared.GetPageInfo(ctx),
ctx.QueryParam("search"),
strings.TrimSpace(ctx.QueryParam("search")),
shared.GetFilterQuery(ctx),
shared.GetSortQuery(ctx),
)
Expand All @@ -102,7 +103,7 @@ func (controller DependencyVulnController) ListByProjectPaged(ctx shared.Context
project.ID,

shared.GetPageInfo(ctx),
ctx.QueryParam("search"),
strings.TrimSpace(ctx.QueryParam("search")),
shared.GetFilterQuery(ctx),
shared.GetSortQuery(ctx),
)
Expand All @@ -129,11 +130,12 @@ func (controller DependencyVulnController) ListByProjectPaged(ctx shared.Context
// @Success 200 {object} object
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/dependency-vulns [get]
func (controller DependencyVulnController) ListPaged(ctx shared.Context) error {
formattedSearch := strings.TrimSpace(ctx.QueryParam("search"))
// get the asset
assetVersion := shared.GetAssetVersion(ctx)
// check if we should list flat - this means not grouped by package
if ctx.QueryParam("flat") == "true" {
dependencyVulns, err := controller.dependencyVulnRepository.GetDependencyVulnsByAssetVersionPagedAndFlat(ctx.Request().Context(), nil, assetVersion.Name, assetVersion.AssetID, shared.GetPageInfo(ctx), ctx.QueryParam("search"), shared.GetFilterQuery(ctx), shared.GetSortQuery(ctx))
dependencyVulns, err := controller.dependencyVulnRepository.GetDependencyVulnsByAssetVersionPagedAndFlat(ctx.Request().Context(), nil, assetVersion.Name, assetVersion.AssetID, shared.GetPageInfo(ctx), formattedSearch, shared.GetFilterQuery(ctx), shared.GetSortQuery(ctx))
if err != nil {
return echo.NewHTTPError(500, "could not get dependencyVulns").WithInternal(err)
}
Expand All @@ -148,7 +150,7 @@ func (controller DependencyVulnController) ListPaged(ctx shared.Context) error {
assetVersion.Name,
assetVersion.AssetID,
shared.GetPageInfo(ctx),
ctx.QueryParam("search"),
formattedSearch,
shared.GetFilterQuery(ctx),
Comment on lines 152 to 154
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The trimmed search expression is duplicated in both branches (flat and non-flat). Consider reading search := strings.TrimSpace(ctx.QueryParam("search")) once before the if, and reusing it. Also, this controller’s other list endpoints still pass the raw ctx.QueryParam("search"), which makes search behavior inconsistent across routes.

Copilot uses AI. Check for mistakes.
shared.GetSortQuery(ctx),
)
Expand Down
Loading