feat(vulnerability): add filter by region#1113
feat(vulnerability): add filter by region#1113kanstantsinbuklis-sap wants to merge 2 commits intomainfrom
Conversation
0d758a9 to
801a672
Compare
There was a problem hiding this comment.
Pull request overview
Adds region as a first-class filter for vulnerabilities/issues across the GraphQL API, DB filtering, and “issue counts by severity” materialized views used for counters in the UI.
Changes:
- Extend GraphQL schemas/resolvers and entity filters to accept
regionfor vulnerabilities/issues and vulnerability filter-values. - Add MariaDB filtering for issues by region and introduce a new region-based issue-severity counter MV + tests.
- Add E2E/API tests and testdata to validate region filter values and region-based counts.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/entity/issue.go | Adds Region to IssueFilter. |
| internal/api/graphql/graph/schema/vulnerability_filter.graphqls | Adds region to VulnerabilityFilterValue. |
| internal/api/graphql/graph/schema/vulnerability.graphqls | Adds region to VulnerabilityFilter input. |
| internal/api/graphql/graph/schema/issue.graphqls | Adds region to IssueFilter input. |
| internal/api/graphql/graph/baseResolver/common.go | Defines VulnerabilityFilterRegion constant. |
| internal/api/graphql/graph/baseResolver/vulnerability.go | Maps GraphQL vulnerability filter region into IssueFilter + counts filter. |
| internal/api/graphql/graph/baseResolver/issue.go | Maps GraphQL issue-counts filter region into IssueFilter. |
| internal/api/graphql/graph/resolver/vulnerability_filter.go | Adds resolver for region filter-values. |
| internal/api/graphql/gqlgen.yml | Enables resolver for VulnerabilityFilterValue.region. |
| internal/api/graphql/graph/queryCollection/vulnerabilityFilter/region.graphql | Adds query fixture for region filter-values. |
| internal/database/mariadb/issue.go | Adds region filter property and ensures required joins when filtering by region. |
| internal/database/mariadb/issue_test.go | Adds DB test asserting region filtering returns results. |
| internal/database/mariadb/mv_vulnerabilities.go | Adds region handling for issue-severity counter MV selection and query filtering. |
| internal/database/mariadb/mv_vulnerabilities_test.go | Adds region counter test using the new region MV. |
| internal/database/mariadb/migrations/20260304131355_add_count_issue_ratings_region.up.sql | Introduces mvCountIssueRatingsRegion + refresh procedure/event. |
| internal/database/mariadb/migrations/20260304131355_add_count_issue_ratings_region.down.sql | Drops the region MV/proc/event. |
| internal/database/mariadb/migrations/20260211213443_extend_mv_schedules.up.sql | Formatting-only change to event schedule statement. |
| internal/database/mariadb/test/common.go | Updates issue-counts testdata loader to support string keys (region) via map[string]any. |
| internal/database/mariadb/testdata/issue_counts/issue_counts_per_region.json | Adds expected region severity counts testdata. |
| internal/e2e/vulnerability_filter_query_test.go | Adds E2E test validating region filter-values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/database/mariadb/migrations/20260304131355_add_count_issue_ratings_region.up.sql
Outdated
Show resolved
Hide resolved
internal/database/mariadb/migrations/20260304131355_add_count_issue_ratings_region.up.sql
Show resolved
Hide resolved
801a672 to
6831042
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 21 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
internal/database/mariadb/migrations/20260304131355_add_count_issue_ratings_region.up.sql
Show resolved
Hide resolved
6831042 to
91d2250
Compare
91d2250 to
eda09bf
Compare
…o-vulnerabilityFilter
|
|
||
| for _, entry := range entries { | ||
| for _, im := range entry.Issue.IssueMatches { | ||
| Expect(im.ComponentInstance.Region).To(Equal(region)) |
There was a problem hiding this comment.
The database doesn't resolve the relations, so this check will never be executed. You need to collect the entities from the seedCollection
| } else if len(filter.ServiceCCRN) > 0 || len(filter.ServiceId) > 0 { | ||
| // Count issues that appear in single service | ||
| return "mvCountIssueRatingsServiceId" | ||
| } else if len(filter.Region) > 0 { |
There was a problem hiding this comment.
The region filter can be used by itself to get the number of vulnerabilities, but most likely it'll be used in combination with the support group filter. This combination is currently not possible. In order to support this, we need an additional mvCountIssueRatingsSupportGroupPerRegion table
| Region: []*string{&cir.Region.String}, | ||
| } | ||
|
|
||
| testIssueSeverityCount(filter, counts[cir.Region.String]) |
There was a problem hiding this comment.
This test is not working as intended. All items in ComponentInstanceRows have an empty region. counts[cir.Region.String] will always return 0 for all counts. Same will be returned from the db for an empty region.
Description
In this PR I've added filter by region for vulnerability (as a parent task). Also I've added region to the VulnerabilityFilter that is used to populate filters and its values in the UI
What type of PR is this? (check all applicable)
Related Tickets & Documents
feat(api): add region to vulnerabilityFilter #1077
feat(vulnerability): filter by region #1061
Added tests?
Added to documentation?