Skip to content
Snippets Groups Projects

Fix GraphQL pipeline findings pagination

Merged Malcolm Locke requested to merge 441306-security-report-finding-pagination into master
All threads resolved!

What does this MR do and why?

Fix GraphQL pagination on the pipeline.securityReportFindings resolver.

This requires some fairly in depth reworking explained below:

Rework of SecurityFindingsFinder#limit calculation

This finder was implemented for a REST endpoint where pagination is implemented with page and per_page parameters. It uses offset pagination currently (conversion to keyset is planned). Because of this the pagination boundaries (OFFSET) always fall on equal divisions of per_page size.

                     REST pagination

      page:1 per_page:10           page:2 per_page:10
|----------------------------|-----------------------------|----
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 ..

The GraphQL cursor based pagination can use arbitrary offsets using first or last arguments to specify page size and before or after to determine the offset

                     GQL pagination

                         first:12 after:5
               |----------------------------------|
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 ..

The Security::FindingsFinder has undergone extensive customization over time to make it perform acceptably with large data sets. To facilitate this the finder needs to know some information about the current pagination position. Previously it was using the page and per_page parameters from the REST endpoint to determine this, but with this change it has needed to be modified.

Getting pagination information from the GQL resolver

The default GraphQL connection implementation removes the pagination arguments before calling resolve, so the pagination params are not available by default. Using connection_extension: ::Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension works around this.

Once these arguments are available they require some manipulation to read. The first and last arguments are plain integers, but before and after are base64 encoded strings. Usually they contain encoded JSON with the keyset pagination parameters, but when using offset_paginate before and after contain the base64 encoded first and last id of the returned record set.

Steps to reproduce

Ensure you have EE features and pipeline runners available on your GDK.

  • git switch master
  • Clone https://gitlab.com/gl-demo-ultimate-myacksmith/482983-test-group/graphql-vulnerability-findings-test into your GDK
  • In rails console set the feature flag to use GraphQL instead of REST on the pipeline security tab Feature.enable(:pipeline_security_dashboard_graphql)
  • Once the project's pipeline has completed, visit 'Pipeline -> Security'
  • The 'Scan details' section should show a count of 164 vulnerabilities'
  • Paginate through the vulnerability list. The full list of findings is not shown.
  • git switch 441306-security-report-finding-pagination
  • You should now be able to paginate through all of the findings.

Related to #441306 (closed)

Edited by Malcolm Locke

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • mentioned in issue #441306 (closed)

  • Malcolm Locke added 1930 commits

    added 1930 commits

    Compare with previous version

  • added 1 commit

    • 602c873e - Fix vuln findings pagination tests

    Compare with previous version

  • Malcolm Locke added 2 commits

    added 2 commits

    • 99a48452 - Fix GraphQL pipeline findings pagination
    • 0c232ade - Fix vuln findings pagination tests

    Compare with previous version

  • Malcolm Locke
  • Malcolm Locke
  • Malcolm Locke
  • Malcolm Locke
  • Malcolm Locke
  • Malcolm Locke
  • Malcolm Locke
  • Malcolm Locke
  • Malcolm Locke marked this merge request as ready

    marked this merge request as ready

  • requested review from @subashis, @bhrai, and @alberts-gitlab

  • Bishwa Hang Rai approved this merge request

    approved this merge request

  • requested review from @jon_jenkins

  • E2E Test Result Summary

    allure-report-publisher generated test report!

    e2e-test-on-gdk: test report for 62a313c8

    expand test summary
    +------------------------------------------------------------------+
    |                          suites summary                          |
    +-------------+--------+--------+---------+-------+-------+--------+
    |             | passed | failed | skipped | flaky | total | result |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Govern      | 66     | 0      | 0       | 0     | 66    | ✅     |
    | Monitor     | 4      | 0      | 0       | 0     | 4     | ✅     |
    | Create      | 8      | 0      | 3       | 0     | 11    | ✅     |
    | Package     | 0      | 0      | 1       | 0     | 1     | ➖     |
    | Data Stores | 2      | 0      | 0       | 0     | 2     | ✅     |
    | Plan        | 4      | 0      | 0       | 0     | 4     | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Total       | 84     | 0      | 4       | 0     | 88    | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+

    e2e-package-and-test: test report for 62a313c8

    expand test summary
    +------------------------------------------------------------------+
    |                          suites summary                          |
    +-------------+--------+--------+---------+-------+-------+--------+
    |             | passed | failed | skipped | flaky | total | result |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Govern      | 272    | 0      | 19      | 0     | 291   | ✅     |
    | Create      | 153    | 0      | 20      | 0     | 173   | ✅     |
    | Plan        | 8      | 0      | 0       | 0     | 8     | ✅     |
    | Package     | 0      | 0      | 2       | 0     | 2     | ➖     |
    | Monitor     | 8      | 0      | 0       | 0     | 8     | ✅     |
    | Data Stores | 4      | 0      | 0       | 0     | 4     | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Total       | 445    | 0      | 41      | 0     | 486   | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+
  • Malcolm Locke added 665 commits

    added 665 commits

    Compare with previous version

  • Malcolm Locke added 2 commits

    added 2 commits

    • 45a5c795 - Fix GraphQL pipeline findings pagination
    • 979b0c79 - Fix vuln findings pagination tests

    Compare with previous version

  • requested review from @minac

  • Subashis Chakraborty removed review request for @subashis

    removed review request for @subashis

  • Malcolm Locke changed the description

    changed the description

  • Albert approved this merge request

    approved this merge request

  • Albert removed review request for @alberts-gitlab

    removed review request for @alberts-gitlab

  • Mehmet Emin INAC approved this merge request

    approved this merge request

  • Mehmet Emin INAC removed review request for @minac

    removed review request for @minac

  • requested review from @eugielimpin

  • Matt Kasa requested review from @mattkasa

    requested review from @mattkasa

  • Matt Kasa approved this merge request

    approved this merge request

  • added databaseapproved label and removed databasereviewed label

  • mentioned in issue #328818 (closed)

  • Eugie Limpin
  • Eugie Limpin
  • Eugie Limpin approved this merge request

    approved this merge request

  • Eugie Limpin removed review request for @eugielimpin

    removed review request for @eugielimpin

  • added 1 commit

    • 77a2459a - Apply reviewer feedback fixes

    Compare with previous version

  • Malcolm Locke reset approvals from @mattkasa, @minac, @alberts-gitlab, and @eugielimpin by pushing to the branch

    reset approvals from @mattkasa, @minac, @alberts-gitlab, and @eugielimpin by pushing to the branch

  • requested review from @eugielimpin

  • added 1 commit

    • 62a313c8 - Add more robust handling of pagination args

    Compare with previous version

  • Eugie Limpin approved this merge request

    approved this merge request

  • Eugie Limpin resolved all threads

    resolved all threads

  • Matt Kasa requested review from @alberts-gitlab

    requested review from @alberts-gitlab

  • Matt Kasa resolved all threads

    resolved all threads

  • Matt Kasa approved this merge request

    approved this merge request

  • Pedro Pombeiro approved this merge request

    approved this merge request

  • Matt Kasa resolved all threads

    resolved all threads

  • Matt Kasa enabled an automatic merge when the pipeline for df9f4840 succeeds

    enabled an automatic merge when the pipeline for df9f4840 succeeds

  • merged

  • Hello @mallocke 👋

    The database team is looking for ways to improve the database review process and we would love your help!

    If you'd be open to someone on the database team reaching out to you for a chat, or if you'd like to leave some feedback asynchronously, just post a reply to this comment mentioning:

    @gitlab-org/database-team

    And someone will be by shortly!

    Thanks for your help!

    This message was generated automatically. You're welcome to improve it.

  • Matt Kasa mentioned in commit 07897be2

    mentioned in commit 07897be2

  • added workflowstaging label and removed workflowcanary label

  • Please register or sign in to reply
    Loading