Skip to content

feat(vulnerability): add filter by region#1113

Open
kanstantsinbuklis-sap wants to merge 2 commits intomainfrom
kanstntsinbuklis-sap/issue-1077/add-region-to-vulnerabilityFilter
Open

feat(vulnerability): add filter by region#1113
kanstantsinbuklis-sap wants to merge 2 commits intomainfrom
kanstntsinbuklis-sap/issue-1077/add-region-to-vulnerabilityFilter

Conversation

@kanstantsinbuklis-sap
Copy link
Collaborator

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)

  • [+] 🍕 Feature

Related Tickets & Documents

Added tests?

  • [+] 👍 yes

Added to documentation?

  • [+] 🙅 no documentation needed

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 region for 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.

@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstntsinbuklis-sap/issue-1077/add-region-to-vulnerabilityFilter branch from 801a672 to 6831042 Compare March 9, 2026 14:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstntsinbuklis-sap/issue-1077/add-region-to-vulnerabilityFilter branch from 6831042 to 91d2250 Compare March 10, 2026 12:27
@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstntsinbuklis-sap/issue-1077/add-region-to-vulnerabilityFilter branch from 91d2250 to eda09bf Compare March 10, 2026 14:42

for _, entry := range entries {
for _, im := range entry.Issue.IssueMatches {
Expect(im.ComponentInstance.Region).To(Equal(region))
Copy link
Collaborator

Choose a reason for hiding this comment

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

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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])
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

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.

feat(api): add region to vulnerabilityFilter feat(vulnerability): filter by region

4 participants