Skip to content

GraphQL changes to support limited vulnerability severities count

Bala Kumar requested to merge 438303-be-graphql-changes into master

What does this MR do and why?

Part 2 MR, to introduce GraphQL changes to support capped counts for vulnerability severities. We are introducing capped argument to the vulnerabilitySeveritiesCount GraphQL API and by default it is set to false, when true it returns the capped count. capped: true will be used by the UI and it is tracked #463387 (closed)

Part 1 MR, related to the DB query changes on the model is already database approved and merged.

Screenshots or screen recordings

API Without capped With capped: true
project.vulnerabilitySeveritiesCount Screenshot_2024-06-08_at_3.40.25_PM Screenshot_2024-06-08_at_3.41.02_PM
group.vulnerabilitySeveritiesCount Screenshot_2024-06-08_at_3.41.41_PM Screenshot_2024-06-08_at_3.42.20_PM
instanceSecurityDashboard.vulnerabilitySeveritiesCount Screenshot_2024-06-08_at_3.36.16_PM Screenshot_2024-06-08_at_3.36.02_PM

How to set up and validate locally

  1. Import project from https://gitlab.com/gitlab-org/govern/threat-insights-demos/verification-projects/438303-limit-vulnerabiility-severity-counts into local and run the pipeline on the main branch. This will populate the vulnerabilities, this project has 1100 vulnerabilities (low: 1045 and critical: 55).
  2. Run the GraphQL queries for project.vulnerabilitySeveritiesCount, group.vulnerabilitySeveritiesCount and instanceSecurityDashboard.vulnerabilitySeveritiesCount with fullPath corresponding to the imported project above and we should observe that maximum count returned does not exceed 1001 as shown in screenshots above.
query {
  project(fullPath: "bala-test-group/438303-limit-vulnerabiility-severity-counts") {
    vulnerabilitySeveritiesCount(state: [DETECTED]) {
      critical
      high
      info
      low
      medium
      unknown
    }
  }
}
query {
  group(fullPath: "bala-test-group") {
    vulnerabilitySeveritiesCount(state: [DETECTED]) {
      critical
      high
      info
      low
      medium
      unknown
    }
  }
}
query {
  instanceSecurityDashboard {
    vulnerabilitySeveritiesCount(state: [DETECTED]) {
      critical
      high
      info
      low
      medium
      unknown
    }
  }
}

Related to #438303 (closed)

Edited by Bala Kumar

Merge request reports