Skip to content

Limit security policy project resolver suggestions

Dominic Bauer requested to merge spp-resolver-max-page-size into master

What does this MR do and why?

Sets max_page_size for the newly introduced SecurityPolicyProjectSuggestionsResolver. The resolver should return at most 20 suggestions, regardless of a provided first argument. See !145045 (comment 1804019659) for more context.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Issue a query that resolves to more than 1 project, e.g.:

query projectSuggestions {
  project(fullPath: "root/my-test-project") {
    securityPolicyProjectSuggestions(search: "sec", first: 42) {
      nodes {
        fullPath
      }
    }
  }
}

Set max_page_size to 1:

diff --git a/ee/app/graphql/resolvers/security_orchestration/security_policy_project_suggestions_resolver.rb b/ee/app/graphql/resolvers/security_orchestration/security_policy_project_suggestions_resolver.rb
index 4594711fefb3..bf616ed34fd2 100644
--- a/ee/app/graphql/resolvers/security_orchestration/security_policy_project_suggestions_resolver.rb
+++ b/ee/app/graphql/resolvers/security_orchestration/security_policy_project_suggestions_resolver.rb
@@ -18,7 +18,7 @@ class SecurityPolicyProjectSuggestionsResolver < BaseResolver
         default_value: false,
         description: 'Whether to suggest only projects already linked as security policy projects.'

-      max_page_size ::Security::SecurityPolicyProjectsFinder::SUGGESTION_LIMIT
+      max_page_size 1

       def resolve(**args)
         args[:search_globally] = !gitlab_com_subscription?

Verify the query now results in a single suggestion.

Edited by Dominic Bauer

Merge request reports