Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Prebuilt rules' Related Integrations: Azure and GCP are shown as not installed #142081

Closed
banderror opened this issue Sep 28, 2022 · 8 comments · Fixed by #152055
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area Feature:Related Integrations Security Solution Detection Rules Related Integrations feature fixed impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. QA:Validated Issue has been validated by QA Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.7.0

Comments

@banderror
Copy link
Contributor

Epic: https://github.com/elastic/security-team/issues/2108 (internal)

Summary

If a prebuilt rule in one of its related integrations references the whole composite package (e.g. azure) without specifying a concrete integration (e.g. activitylogs)

Screenshot 2022-09-28 at 12 48 03

and this integration (activitylogs) is installed in Fleet, on the Rules page this related integration will be shown as not installed:

Screenshot 2022-09-28 at 12 47 46

We need to determine the path forward: either support it in Kibana or fix the prebuilt rules.

Details

Background

Fleet integrations like AWS and Azure are known to be distributed via composite packages that contain multiple integrations inside. For example:

  • azure package contains activitylogs, platformlogs, adlogs and other integrations
  • aws package contains integrations like cloudfront, cloudtrail, cloudwatch, dynamodb, etc
  • gcp contains compute, gke, etc

NOTE: Some of the cloud integrations are shipped via their own packages, for example Custom Google Pub/Sub Logs integration is shipped via a separate gcp_pubsub package, not the gcp one.

When the user installs integrations like Azure activity logs through the UI, Fleet actually installs its parent package (azure) with all the integrations that it contains: activitylogs, platformlogs, adlogs, etc. But we're able to distinguish enabled integrations from the disabled ones:

Screenshot 2022-09-28 at 13 31 53

This doesn't work

What doesn't work in the app is: if a rule references the whole composite package (e.g. azure) without specifying a concrete integration (e.g. activitylogs), we show such related integration as not installed. Example:

Screenshot 2022-09-28 at 12 48 03

Screenshot 2022-09-28 at 12 47 46

This works

There's an exception from this: if a rule references the whole package that only contains a single integration of the same name (e.g. system), then it works and we show it as installed:

Screenshot 2022-09-28 at 13 53 17

Screenshot 2022-09-28 at 13 53 42

Schema of a related integration

/**
 * Related integration is a potential dependency of a rule. It's assumed that if the user installs
 * one of the related integrations of a rule, the rule might start to work properly because it will
 * have source events (generated by this integration) potentially matching the rule's query.
 *
 *   NOTE: Proper work is not guaranteed, because a related integration, if installed, can be
 *   configured differently or generate data that is not necessarily relevant for this rule.
 *
 * Related integration is a combination of a Fleet package and (optionally) one of the
 * package's "integrations" that this package contains. It is represented by 3 properties:
 *
 *   - `package`: name of the package (required, unique id)
 *   - `version`: version of the package (required, semver-compatible)
 *   - `integration`: name of the integration of this package (optional, id within the package)
 *
 * There are Fleet packages like `windows` that contain only one integration; in this case,
 * `integration` should be unspecified. There are also packages like `aws` and `azure` that contain
 * several integrations; in this case, `integration` should be specified.
 *
 * @example
 * const x: RelatedIntegration = {
 *   package: 'windows',
 *   version: '1.5.x',
 * };
 *
 * @example
 * const x: RelatedIntegration = {
 *   package: 'azure',
 *   version: '~1.1.6',
 *   integration: 'activitylogs',
 * };
 */
export type RelatedIntegration = t.TypeOf<typeof RelatedIntegration>;
export const RelatedIntegration = t.exact(
  t.intersection([
    t.type({
      package: NonEmptyString,
      version: NonEmptyString,
    }),
    t.partial({
      integration: NonEmptyString,
    }),
  ])
);

When we built the related integrations feature, we added support for single-integration packages like windows and system, but not composite integrations like aws and azure:

 * There are Fleet packages like `windows` that contain only one integration; in this case,
 * `integration` should be unspecified. There are also packages like `aws` and `azure` that contain
 * several integrations; in this case, `integration` should be specified.
 *
 * @example
 * const x: RelatedIntegration = {
 *   package: 'windows',
 *   version: '1.5.x',
 * };
 *
 * @example
 * const x: RelatedIntegration = {
 *   package: 'azure',
 *   version: '~1.1.6',
 *   integration: 'activitylogs',
 * };
@banderror banderror added bug Fixes for quality problems that affect the customer experience discuss impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team needs product Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area labels Sep 28, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@terrancedejesus
Copy link
Contributor

@banderror - TRaDE may be able to help with this based on some changes we did for this release regarding the following PR below:

In short, we are only suggesting the least "major" compatible now instead of least compatible in general based on Kibana version. When we build the related_integrations field, it references the queries in the rule for event.dataset and parses this to determine package and integration, for example, event.dataset: gcp.audit -> package:gcp, integration:audit. If audit is parsed we check against the compatible version package's manifest and it's policy templates to determine if this is an actual integration that exists. If not, package:gcp, version:x.x.x is only given.

Before with these, it could have been a case where we did the least compatible, instead of least major compatible and that manifest reference did not have activitylogs in the policy templates and thus we only set package:azure, version:x.x.x.

I need to spend some more time looking at this on our side to determine if there is a way to be more accurate with this.

@banderror
Copy link
Contributor Author

@terrancedejesus Thank you, it would be great if we could specify a package + integration instead of only a package in prebuilt rules. But if it's not possible or very hard to do in all cases, we could support this edge case in the app.

I'm still wondering, is there a legitimate situation when a concrete integration doesn't make sense or couldn't be picked due to any non-technical / product-related reasons? cc @jethr0null

@banderror banderror added the Feature:Related Integrations Security Solution Detection Rules Related Integrations feature label Feb 22, 2023
spong added a commit that referenced this issue Mar 1, 2023
…ed or enabled when they actually are (#152055)

## Summary

Resolves: #142081
#149970
#150968

By adding an initial query for installed integrations and augments the
existing `InstalledIntegrationArray` constructed using
`PackagePolicy`'s. Also removes `version` from the `packageKey` when
calculating installed integrations as there can be mis-matches between
different policy versions and the integration itself, and I believe the
intended behavior here is to not have multiple `relatedIntegrations`
returned for different versions. We may want to expand the response here
to include all the different policy versions that exist (and perhaps #
of agents assigned the policy).

Lastly, updates `getIntegrationsInfoFromPolicy()` to also pull the base
`package` details in addition to the policy_template details, as this is
what ensure base packages show as `Installed: enabled` if they have an
integration policy assigned (vs just showing as `Installed` like when
there isn't an integration policy).

Note: This PR also adds the `getPackages()` method to the
`PackageClient` as it didn't currently exist, and was only available via
the fleet API via the `/api/fleet/epm/packages` route.


### Before:
<p align="center">
<img width="500"
src="https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png"
/>
</p>



### After
<p align="center">
<img width="500"
src="https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png"
/>
</p>


---------

Co-authored-by: Georgii Gorbachev <[email protected]>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Mar 1, 2023
…ed or enabled when they actually are (elastic#152055)

## Summary

Resolves: elastic#142081
elastic#149970
elastic#150968

By adding an initial query for installed integrations and augments the
existing `InstalledIntegrationArray` constructed using
`PackagePolicy`'s. Also removes `version` from the `packageKey` when
calculating installed integrations as there can be mis-matches between
different policy versions and the integration itself, and I believe the
intended behavior here is to not have multiple `relatedIntegrations`
returned for different versions. We may want to expand the response here
to include all the different policy versions that exist (and perhaps #
of agents assigned the policy).

Lastly, updates `getIntegrationsInfoFromPolicy()` to also pull the base
`package` details in addition to the policy_template details, as this is
what ensure base packages show as `Installed: enabled` if they have an
integration policy assigned (vs just showing as `Installed` like when
there isn't an integration policy).

Note: This PR also adds the `getPackages()` method to the
`PackageClient` as it didn't currently exist, and was only available via
the fleet API via the `/api/fleet/epm/packages` route.

### Before:
<p align="center">
<img width="500"
src="https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png"
/>
</p>

### After
<p align="center">
<img width="500"
src="https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png"
/>
</p>

---------

Co-authored-by: Georgii Gorbachev <[email protected]>
(cherry picked from commit b833b10)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Mar 1, 2023
…ed or enabled when they actually are (elastic#152055)

## Summary

Resolves: elastic#142081
elastic#149970
elastic#150968

By adding an initial query for installed integrations and augments the
existing `InstalledIntegrationArray` constructed using
`PackagePolicy`'s. Also removes `version` from the `packageKey` when
calculating installed integrations as there can be mis-matches between
different policy versions and the integration itself, and I believe the
intended behavior here is to not have multiple `relatedIntegrations`
returned for different versions. We may want to expand the response here
to include all the different policy versions that exist (and perhaps #
of agents assigned the policy).

Lastly, updates `getIntegrationsInfoFromPolicy()` to also pull the base
`package` details in addition to the policy_template details, as this is
what ensure base packages show as `Installed: enabled` if they have an
integration policy assigned (vs just showing as `Installed` like when
there isn't an integration policy).

Note: This PR also adds the `getPackages()` method to the
`PackageClient` as it didn't currently exist, and was only available via
the fleet API via the `/api/fleet/epm/packages` route.

### Before:
<p align="center">
<img width="500"
src="https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png"
/>
</p>

### After
<p align="center">
<img width="500"
src="https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png"
/>
</p>

---------

Co-authored-by: Georgii Gorbachev <[email protected]>
(cherry picked from commit b833b10)
kibanamachine referenced this issue Mar 1, 2023
…nstalled or enabled when they actually are (#152055) (#152411)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Security Solution] Fixes Related Integrations showing as not
installed or enabled when they actually are
(#152055)](#152055)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Garrett
Spong","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-03-01T01:47:28Z","message":"[Security
Solution] Fixes Related Integrations showing as not installed or enabled
when they actually are (#152055)\n\n## Summary\r\n\r\nResolves:
https://github.com/elastic/kibana/issues/142081\r\nhttps://github.com/elastic/kibana/issues/149970\r\nhttps://github.com/elastic/kibana/issues/150968\r\n\r\nBy
adding an initial query for installed integrations and augments
the\r\nexisting `InstalledIntegrationArray` constructed
using\r\n`PackagePolicy`'s. Also removes `version` from the `packageKey`
when\r\ncalculating installed integrations as there can be mis-matches
between\r\ndifferent policy versions and the integration itself, and I
believe the\r\nintended behavior here is to not have multiple
`relatedIntegrations`\r\nreturned for different versions. We may want to
expand the response here\r\nto include all the different policy versions
that exist (and perhaps #\r\nof agents assigned the
policy).\r\n\r\nLastly, updates `getIntegrationsInfoFromPolicy()` to
also pull the base\r\n`package` details in addition to the
policy_template details, as this is\r\nwhat ensure base packages show as
`Installed: enabled` if they have an\r\nintegration policy assigned (vs
just showing as `Installed` like when\r\nthere isn't an integration
policy).\r\n\r\nNote: This PR also adds the `getPackages()` method to
the\r\n`PackageClient` as it didn't currently exist, and was only
available via\r\nthe fleet API via the `/api/fleet/epm/packages`
route.\r\n\r\n\r\n### Before:\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png\"\r\n/>\r\n</p>\r\n\r\n\r\n\r\n###
After\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png\"\r\n/>\r\n</p>\r\n\r\n\r\n---------\r\n\r\nCo-authored-by:
Georgii Gorbachev
<[email protected]>","sha":"b833b108215c858177535fd3feee406cc628bca8","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Fleet","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection
Rules","v8.7.0","v8.8.0","v8.6.3","Feature:Related
Integrations"],"number":152055,"url":"https://github.com/elastic/kibana/pull/152055","mergeCommit":{"message":"[Security
Solution] Fixes Related Integrations showing as not installed or enabled
when they actually are (#152055)\n\n## Summary\r\n\r\nResolves:
https://github.com/elastic/kibana/issues/142081\r\nhttps://github.com/elastic/kibana/issues/149970\r\nhttps://github.com/elastic/kibana/issues/150968\r\n\r\nBy
adding an initial query for installed integrations and augments
the\r\nexisting `InstalledIntegrationArray` constructed
using\r\n`PackagePolicy`'s. Also removes `version` from the `packageKey`
when\r\ncalculating installed integrations as there can be mis-matches
between\r\ndifferent policy versions and the integration itself, and I
believe the\r\nintended behavior here is to not have multiple
`relatedIntegrations`\r\nreturned for different versions. We may want to
expand the response here\r\nto include all the different policy versions
that exist (and perhaps #\r\nof agents assigned the
policy).\r\n\r\nLastly, updates `getIntegrationsInfoFromPolicy()` to
also pull the base\r\n`package` details in addition to the
policy_template details, as this is\r\nwhat ensure base packages show as
`Installed: enabled` if they have an\r\nintegration policy assigned (vs
just showing as `Installed` like when\r\nthere isn't an integration
policy).\r\n\r\nNote: This PR also adds the `getPackages()` method to
the\r\n`PackageClient` as it didn't currently exist, and was only
available via\r\nthe fleet API via the `/api/fleet/epm/packages`
route.\r\n\r\n\r\n### Before:\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png\"\r\n/>\r\n</p>\r\n\r\n\r\n\r\n###
After\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png\"\r\n/>\r\n</p>\r\n\r\n\r\n---------\r\n\r\nCo-authored-by:
Georgii Gorbachev
<[email protected]>","sha":"b833b108215c858177535fd3feee406cc628bca8"}},"sourceBranch":"main","suggestedTargetBranches":["8.7","8.6"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/152055","number":152055,"mergeCommit":{"message":"[Security
Solution] Fixes Related Integrations showing as not installed or enabled
when they actually are (#152055)\n\n## Summary\r\n\r\nResolves:
https://github.com/elastic/kibana/issues/142081\r\nhttps://github.com/elastic/kibana/issues/149970\r\nhttps://github.com/elastic/kibana/issues/150968\r\n\r\nBy
adding an initial query for installed integrations and augments
the\r\nexisting `InstalledIntegrationArray` constructed
using\r\n`PackagePolicy`'s. Also removes `version` from the `packageKey`
when\r\ncalculating installed integrations as there can be mis-matches
between\r\ndifferent policy versions and the integration itself, and I
believe the\r\nintended behavior here is to not have multiple
`relatedIntegrations`\r\nreturned for different versions. We may want to
expand the response here\r\nto include all the different policy versions
that exist (and perhaps #\r\nof agents assigned the
policy).\r\n\r\nLastly, updates `getIntegrationsInfoFromPolicy()` to
also pull the base\r\n`package` details in addition to the
policy_template details, as this is\r\nwhat ensure base packages show as
`Installed: enabled` if they have an\r\nintegration policy assigned (vs
just showing as `Installed` like when\r\nthere isn't an integration
policy).\r\n\r\nNote: This PR also adds the `getPackages()` method to
the\r\n`PackageClient` as it didn't currently exist, and was only
available via\r\nthe fleet API via the `/api/fleet/epm/packages`
route.\r\n\r\n\r\n### Before:\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png\"\r\n/>\r\n</p>\r\n\r\n\r\n\r\n###
After\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png\"\r\n/>\r\n</p>\r\n\r\n\r\n---------\r\n\r\nCo-authored-by:
Georgii Gorbachev
<[email protected]>","sha":"b833b108215c858177535fd3feee406cc628bca8"}},{"branch":"8.6","label":"v8.6.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Garrett Spong <[email protected]>
kibanamachine referenced this issue Mar 1, 2023
…nstalled or enabled when they actually are (#152055) (#152412)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[Security Solution] Fixes Related Integrations showing as not
installed or enabled when they actually are
(#152055)](#152055)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Garrett
Spong","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-03-01T01:47:28Z","message":"[Security
Solution] Fixes Related Integrations showing as not installed or enabled
when they actually are (#152055)\n\n## Summary\r\n\r\nResolves:
https://github.com/elastic/kibana/issues/142081\r\nhttps://github.com/elastic/kibana/issues/149970\r\nhttps://github.com/elastic/kibana/issues/150968\r\n\r\nBy
adding an initial query for installed integrations and augments
the\r\nexisting `InstalledIntegrationArray` constructed
using\r\n`PackagePolicy`'s. Also removes `version` from the `packageKey`
when\r\ncalculating installed integrations as there can be mis-matches
between\r\ndifferent policy versions and the integration itself, and I
believe the\r\nintended behavior here is to not have multiple
`relatedIntegrations`\r\nreturned for different versions. We may want to
expand the response here\r\nto include all the different policy versions
that exist (and perhaps #\r\nof agents assigned the
policy).\r\n\r\nLastly, updates `getIntegrationsInfoFromPolicy()` to
also pull the base\r\n`package` details in addition to the
policy_template details, as this is\r\nwhat ensure base packages show as
`Installed: enabled` if they have an\r\nintegration policy assigned (vs
just showing as `Installed` like when\r\nthere isn't an integration
policy).\r\n\r\nNote: This PR also adds the `getPackages()` method to
the\r\n`PackageClient` as it didn't currently exist, and was only
available via\r\nthe fleet API via the `/api/fleet/epm/packages`
route.\r\n\r\n\r\n### Before:\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png\"\r\n/>\r\n</p>\r\n\r\n\r\n\r\n###
After\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png\"\r\n/>\r\n</p>\r\n\r\n\r\n---------\r\n\r\nCo-authored-by:
Georgii Gorbachev
<[email protected]>","sha":"b833b108215c858177535fd3feee406cc628bca8","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Fleet","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection
Rules","v8.7.0","v8.8.0","v8.6.3","Feature:Related
Integrations"],"number":152055,"url":"https://github.com/elastic/kibana/pull/152055","mergeCommit":{"message":"[Security
Solution] Fixes Related Integrations showing as not installed or enabled
when they actually are (#152055)\n\n## Summary\r\n\r\nResolves:
https://github.com/elastic/kibana/issues/142081\r\nhttps://github.com/elastic/kibana/issues/149970\r\nhttps://github.com/elastic/kibana/issues/150968\r\n\r\nBy
adding an initial query for installed integrations and augments
the\r\nexisting `InstalledIntegrationArray` constructed
using\r\n`PackagePolicy`'s. Also removes `version` from the `packageKey`
when\r\ncalculating installed integrations as there can be mis-matches
between\r\ndifferent policy versions and the integration itself, and I
believe the\r\nintended behavior here is to not have multiple
`relatedIntegrations`\r\nreturned for different versions. We may want to
expand the response here\r\nto include all the different policy versions
that exist (and perhaps #\r\nof agents assigned the
policy).\r\n\r\nLastly, updates `getIntegrationsInfoFromPolicy()` to
also pull the base\r\n`package` details in addition to the
policy_template details, as this is\r\nwhat ensure base packages show as
`Installed: enabled` if they have an\r\nintegration policy assigned (vs
just showing as `Installed` like when\r\nthere isn't an integration
policy).\r\n\r\nNote: This PR also adds the `getPackages()` method to
the\r\n`PackageClient` as it didn't currently exist, and was only
available via\r\nthe fleet API via the `/api/fleet/epm/packages`
route.\r\n\r\n\r\n### Before:\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png\"\r\n/>\r\n</p>\r\n\r\n\r\n\r\n###
After\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png\"\r\n/>\r\n</p>\r\n\r\n\r\n---------\r\n\r\nCo-authored-by:
Georgii Gorbachev
<[email protected]>","sha":"b833b108215c858177535fd3feee406cc628bca8"}},"sourceBranch":"main","suggestedTargetBranches":["8.7","8.6"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/152055","number":152055,"mergeCommit":{"message":"[Security
Solution] Fixes Related Integrations showing as not installed or enabled
when they actually are (#152055)\n\n## Summary\r\n\r\nResolves:
https://github.com/elastic/kibana/issues/142081\r\nhttps://github.com/elastic/kibana/issues/149970\r\nhttps://github.com/elastic/kibana/issues/150968\r\n\r\nBy
adding an initial query for installed integrations and augments
the\r\nexisting `InstalledIntegrationArray` constructed
using\r\n`PackagePolicy`'s. Also removes `version` from the `packageKey`
when\r\ncalculating installed integrations as there can be mis-matches
between\r\ndifferent policy versions and the integration itself, and I
believe the\r\nintended behavior here is to not have multiple
`relatedIntegrations`\r\nreturned for different versions. We may want to
expand the response here\r\nto include all the different policy versions
that exist (and perhaps #\r\nof agents assigned the
policy).\r\n\r\nLastly, updates `getIntegrationsInfoFromPolicy()` to
also pull the base\r\n`package` details in addition to the
policy_template details, as this is\r\nwhat ensure base packages show as
`Installed: enabled` if they have an\r\nintegration policy assigned (vs
just showing as `Installed` like when\r\nthere isn't an integration
policy).\r\n\r\nNote: This PR also adds the `getPackages()` method to
the\r\n`PackageClient` as it didn't currently exist, and was only
available via\r\nthe fleet API via the `/api/fleet/epm/packages`
route.\r\n\r\n\r\n### Before:\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png\"\r\n/>\r\n</p>\r\n\r\n\r\n\r\n###
After\r\n<p align=\"center\">\r\n<img
width=\"500\"\r\nsrc=\"https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png\"\r\n/>\r\n</p>\r\n\r\n\r\n---------\r\n\r\nCo-authored-by:
Georgii Gorbachev
<[email protected]>","sha":"b833b108215c858177535fd3feee406cc628bca8"}},{"branch":"8.6","label":"v8.6.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Garrett Spong <[email protected]>
@banderror banderror reopened this Mar 1, 2023
@banderror
Copy link
Contributor Author

@terrancedejesus So we ended up adding support for parent packages (like aws, azure, gcp) specified as related integrations in prebuilt rules, to the app. 🙂

Now the logic is as follows. If a given top-level package is specified as a related integration, for example:

// instead of this:
related_integrations: [{
  package: 'azure',
  version: '^1.1.0',
  integration: 'activitylogs'
}]

// we have this in a rule:
related_integrations: [{
  package: 'azure',
  version: '^1.1.0'
}]

Then we should be able to correctly identify the status of this related integration:

  • We will show Not installed if the whole package is not installed at the moment (neither any of its integration policies exist, nor any assets are installed).
  • We will show Installed if the package itself is installed, but no integration policies exist for this package. This happens when you click "Install package assets" in Fleet, or when you install a package by creating policies, but later delete all of them.
  • We will show Installed: enabled if the package is installed + any of its child integrations have an existing policy.

That said, I'm not sure if from the UX perspective, it makes any sense to specify top-level packages (like Azure) instead of their concrete integrations because I guess it's the concrete integrations that determine what source events will be indexed into ES.

cc @approksiu

@banderror
Copy link
Contributor Author

@MadameSheema Could you please make sure this bug + #150968 + #149970 are verified against the next BC? These three should be fixed by #152055.

@banderror banderror added the fixed label Mar 1, 2023
@MadameSheema
Copy link
Member

@karanbirsingh-qasource @sukhwindersingh-qasource can you please help to validate this ticket on the current BC? Thanks!

@sukhwindersingh-qasource

Hi @MadameSheema

We have validated this issue on 8.7.0 BC4 build and observed that issue is not occurring, It is Fixed. ✔️

Please find the below Testing Details:

Build info

VERSION: 8.7.0
BUILD: 60949
COMMIT: de22cd9361a0dbf429f9648d3c7b7c45aa862e90

Screen-Shot
out Azure

azure
out gcp

Gcp

Hence, We are marking it as QA Validated!!

Thanks!!

@sukhwindersingh-qasource sukhwindersingh-qasource added the QA:Validated Issue has been validated by QA label Mar 9, 2023
bmorelli25 pushed a commit to bmorelli25/kibana that referenced this issue Mar 10, 2023
…ed or enabled when they actually are (elastic#152055)

## Summary

Resolves: elastic#142081
elastic#149970
elastic#150968

By adding an initial query for installed integrations and augments the
existing `InstalledIntegrationArray` constructed using
`PackagePolicy`'s. Also removes `version` from the `packageKey` when
calculating installed integrations as there can be mis-matches between
different policy versions and the integration itself, and I believe the
intended behavior here is to not have multiple `relatedIntegrations`
returned for different versions. We may want to expand the response here
to include all the different policy versions that exist (and perhaps #
of agents assigned the policy).

Lastly, updates `getIntegrationsInfoFromPolicy()` to also pull the base
`package` details in addition to the policy_template details, as this is
what ensure base packages show as `Installed: enabled` if they have an
integration policy assigned (vs just showing as `Installed` like when
there isn't an integration policy).

Note: This PR also adds the `getPackages()` method to the
`PackageClient` as it didn't currently exist, and was only available via
the fleet API via the `/api/fleet/epm/packages` route.


### Before:
<p align="center">
<img width="500"
src="https://user-images.githubusercontent.com/2946766/221066781-be7aa1c6-1728-4200-98b2-d40946e48bbe.png"
/>
</p>



### After
<p align="center">
<img width="500"
src="https://user-images.githubusercontent.com/2946766/221323469-e24081f9-0741-41fd-8227-9e319c98b0d3.png"
/>
</p>


---------

Co-authored-by: Georgii Gorbachev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area Feature:Related Integrations Security Solution Detection Rules Related Integrations feature fixed impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. QA:Validated Issue has been validated by QA Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.7.0
Projects
None yet
6 participants