Skip to content

feat(vulnerability): add filter by region#1113

Merged
MR2011 merged 2 commits intomainfrom
kanstntsinbuklis-sap/issue-1077/add-region-to-vulnerabilityFilter
Mar 25, 2026
Merged

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

Conversation

@kanstantsinbuklis-sap
Copy link
Copy Markdown
Collaborator

@kanstantsinbuklis-sap kanstantsinbuklis-sap commented Mar 6, 2026

Description

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
Copy Markdown
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.

Comment thread internal/database/mariadb/mv_vulnerabilities.go
Comment thread internal/database/mariadb/mv_vulnerabilities_test.go Outdated
Comment thread internal/api/graphql/graph/resolver/vulnerability_filter.go
Comment thread internal/database/mariadb/test/common.go Outdated
@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
Copy Markdown
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.

Comment thread internal/api/graphql/graph/baseResolver/vulnerability.go
Comment thread internal/database/mariadb/issue_test.go Outdated
@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstntsinbuklis-sap/issue-1077/add-region-to-vulnerabilityFilter branch 2 times, most recently from 91d2250 to eda09bf Compare March 10, 2026 14:42
michalkrzyz
michalkrzyz previously approved these changes Mar 11, 2026
Comment thread internal/database/mariadb/issue_test.go Outdated

for _, entry := range entries {
for _, im := range entry.Issue.IssueMatches {
Expect(im.ComponentInstance.Region).To(Equal(region))
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@MR2011 MR2011 merged commit d0389c2 into main Mar 25, 2026
9 checks passed
@MR2011 MR2011 deleted the kanstntsinbuklis-sap/issue-1077/add-region-to-vulnerabilityFilter branch March 25, 2026 09:12
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

4 participants