[8.16] [Security Solution] List all policies to display integrations properly (#205103) (#205889)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Security Solution] List all policies to display integrations
properly (#205103)](https://github.com/elastic/kibana/pull/205103)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jacek
Kolezynski","email":"jacek.kolezynski@elastic.co"},"sourceCommit":{"committedDate":"2025-01-08T13:26:32Z","message":"[Security
Solution] List all policies to display integrations properly
(#205103)\n\n**Resolves: #200167**\n\n## Summary\n\nIncrease number of
fetched package policies to the maximum. Currently\nonly the first 20
policies (the first page) are returned, which results\nin treating all
remaining ones as disabled.\nI am proposing the simplest change of
increasing the limit here to the\nmaximum. There shouldn't be too many
policies there, e.g. in the\nreproduction I am running there are 23
instead of 20.\nIf that is not enough, however, the alternative would be
to discover\nthat there are more policies than the specified limit and
the next\npage(s) would have to be collected and the results added to
the
final\nlist.\n\n#BEFORE\n\n![image](https://github.com/user-attachments/assets/c98ab5a5-e822-459e-8abc-b45a963e93d7)\n\n#AFTER
\n\n![image](https://github.com/user-attachments/assets/ac519ec2-5674-4d17-bea3-7b6df72078dc)\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"6d49348db89302cf658637e8e8bd9e33760a2cad","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rule
Management","Feature:Prebuilt Detection
Rules","backport:version","v8.18.0","v8.16.3","v8.17.1"],"title":"[Security
Solution] List all policies to display integrations
properly","number":205103,"url":"https://github.com/elastic/kibana/pull/205103","mergeCommit":{"message":"[Security
Solution] List all policies to display integrations properly
(#205103)\n\n**Resolves: #200167**\n\n## Summary\n\nIncrease number of
fetched package policies to the maximum. Currently\nonly the first 20
policies (the first page) are returned, which results\nin treating all
remaining ones as disabled.\nI am proposing the simplest change of
increasing the limit here to the\nmaximum. There shouldn't be too many
policies there, e.g. in the\nreproduction I am running there are 23
instead of 20.\nIf that is not enough, however, the alternative would be
to discover\nthat there are more policies than the specified limit and
the next\npage(s) would have to be collected and the results added to
the
final\nlist.\n\n#BEFORE\n\n![image](https://github.com/user-attachments/assets/c98ab5a5-e822-459e-8abc-b45a963e93d7)\n\n#AFTER
\n\n![image](https://github.com/user-attachments/assets/ac519ec2-5674-4d17-bea3-7b6df72078dc)\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"6d49348db89302cf658637e8e8bd9e33760a2cad"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.16","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205103","number":205103,"mergeCommit":{"message":"[Security
Solution] List all policies to display integrations properly
(#205103)\n\n**Resolves: #200167**\n\n## Summary\n\nIncrease number of
fetched package policies to the maximum. Currently\nonly the first 20
policies (the first page) are returned, which results\nin treating all
remaining ones as disabled.\nI am proposing the simplest change of
increasing the limit here to the\nmaximum. There shouldn't be too many
policies there, e.g. in the\nreproduction I am running there are 23
instead of 20.\nIf that is not enough, however, the alternative would be
to discover\nthat there are more policies than the specified limit and
the next\npage(s) would have to be collected and the results added to
the
final\nlist.\n\n#BEFORE\n\n![image](https://github.com/user-attachments/assets/c98ab5a5-e822-459e-8abc-b45a963e93d7)\n\n#AFTER
\n\n![image](https://github.com/user-attachments/assets/ac519ec2-5674-4d17-bea3-7b6df72078dc)\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"6d49348db89302cf658637e8e8bd9e33760a2cad"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jacek Kolezynski <jacek.kolezynski@elastic.co>
This commit is contained in:
Kibana Machine 2025-01-09 20:34:25 +11:00 committed by GitHub
parent 56aebad97e
commit 8acffa7873
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,6 +6,7 @@
*/
import { transformError } from '@kbn/securitysolution-es-utils';
import { SO_SEARCH_LIMIT } from '@kbn/fleet-plugin/common/constants';
import { PREBUILT_RULES_PACKAGE_NAME } from '../../../../../../common/detection_engine/constants';
import { buildSiemResponse } from '../../../routes/utils';
import type { SecuritySolutionPluginRouter } from '../../../../../types';
@ -41,7 +42,9 @@ export const getAllIntegrationsRoute = (router: SecuritySolutionPluginRouter) =>
const [packages, packagePolicies] = await Promise.all([
fleet.packages.getPackages(),
fleet.packagePolicy.list(fleet.savedObjects.createInternalScopedSoClient(), {}),
fleet.packagePolicy.list(fleet.savedObjects.createInternalScopedSoClient(), {
perPage: SO_SEARCH_LIMIT,
}),
]);
// Elastic prebuilt rules is a special package and should be skipped
const packagesWithoutPrebuiltSecurityRules = packages.filter(