Skip to content

Add threshold performance check on security helper

Artur Fedorov requested to merge 468974-policies-helper-threshold-limit into master

What does this MR do and why?

For scan execution policy scheduled rules we need to add check if number of projects in a group exceeds

performance Threshold 1000 projects in a group

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.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
policy_data = {
      assigned_policy_project: assigned_policy_project(container).to_json,
      disable_scan_policy_update: disable_scan_policy_update.to_s,
      namespace_id: container.id,
      namespace_path: container.full_path,
      policies_path: security_policies_path(container),
      policy: policy&.to_json,
      policy_editor_empty_state_svg_path: image_path('illustrations/monitoring/unable_to_connect.svg'),
      policy_type: policy_type,
      role_approver_types: Security::ScanResultPolicy::ALLOWED_ROLES,
      scan_policy_documentation_path: help_page_path('user/application_security/policies/index'),
      scan_result_approvers: approvers&.to_json,
      software_licenses: SoftwareLicense.all_license_names,
      global_group_approvers_enabled: Gitlab::CurrentSettings.security_policy_global_group_approvers_enabled.to_json,
      root_namespace_path: container.root_ancestor&.full_path,
      timezones: timezone_data(format: :full).to_json,
      max_active_scan_execution_policies_reached: max_active_scan_execution_policies_reached?(container).to_s,
      max_active_scan_result_policies_reached: max_active_scan_result_policies_reached?(container).to_s,
      max_scan_result_policies_allowed: scan_result_policies_limit,
      max_scan_execution_policies_allowed: Security::ScanExecutionPolicy::POLICY_LIMIT,
      custom_ci_toggle_enabled: custom_ci_toggle_enabled?(container).to_s
    }
policy_data = {
      assigned_policy_project: assigned_policy_project(container).to_json,
      disable_scan_policy_update: disable_scan_policy_update.to_s,
      namespace_id: container.id,
      namespace_path: container.full_path,
      policies_path: security_policies_path(container),
      policy: policy&.to_json,
      policy_editor_empty_state_svg_path: image_path('illustrations/monitoring/unable_to_connect.svg'),
      policy_type: policy_type,
      role_approver_types: Security::ScanResultPolicy::ALLOWED_ROLES,
      scan_policy_documentation_path: help_page_path('user/application_security/policies/index'),
      scan_result_approvers: approvers&.to_json,
      software_licenses: SoftwareLicense.all_license_names,
      global_group_approvers_enabled: Gitlab::CurrentSettings.security_policy_global_group_approvers_enabled.to_json,
      root_namespace_path: container.root_ancestor&.full_path,
      timezones: timezone_data(format: :full).to_json,
      max_active_scan_execution_policies_reached: max_active_scan_execution_policies_reached?(container).to_s,
      max_active_scan_result_policies_reached: max_active_scan_result_policies_reached?(container).to_s,
      max_scan_result_policies_allowed: scan_result_policies_limit,
      max_scan_execution_policies_allowed: Security::ScanExecutionPolicy::POLICY_LIMIT,
      custom_ci_toggle_enabled: custom_ci_toggle_enabled?(container).to_s,
      projects_performance_limit_reached: projects_performance_limit_reached?(container).to_s
    }

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Go to Group with at least 2 projects
  2. Set security_orchestration_helper.rb:4 to 1.
  3. projects_performance_limit_reached should be true
  4. Set it back to 1000
  5. projects_performance_limit_reached should be false

Related to #468974

Edited by Artur Fedorov

Merge request reports