Skip to content

Commit

Permalink
[8.x] [Security Solution] List all policies to display integrations p…
Browse files Browse the repository at this point in the history
…roperly (#205103) (#205891)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution] List all policies to display integrations
properly (#205103)](#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":"[email protected]"},"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 <[email protected]>
  • Loading branch information
kibanamachine and jkelas authored Jan 9, 2025
1 parent 1673671 commit ac65ee0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -43,7 +44,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(
Expand Down

0 comments on commit ac65ee0

Please sign in to comment.