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

[CloudSecurity][Fleet] Add CloudFormation install method to CSPM #159994

Merged
merged 27 commits into from
Jun 26, 2023

Conversation

opauloh
Copy link
Contributor

@opauloh opauloh commented Jun 20, 2023

Summary

it closes #157761

This PR adds the CloudFormation install method to the CSPM Cloud Security integration. The following changes were made:

Cloud Security changes

  • Added option to select between CloudFormation or Manual setup format.
  • Converted EuiRadioGroup to Select for the Preferred manual method
  • Fixed a bug where the Confirmation Modal was dismissing after saving the integration.

Updates

  • Added aws.credentials.type : cloud_formation for better backwards compatibility
  • Fixed integration upgrade issues
  • Fixed integration editing issues
  • Moved CSPM AWS and KSPM EKS into their own separate files
  • Handling CloudFormation not supported use cases
  • Fixed broken links

Fleet changes

  • Added CloudFormation post-install modal
  • Added SUBMITTED_CLOUD_FORMATION to the integration install form to show the CloudFormation post-install modal for CloudFormation integrations.
  • Reorganized CloudFormation methods and added useCreateCloudFormationUrl hook.

Screenshots

image

image

image

image

@opauloh opauloh added release_note:feature Makes this part of the condensed release notes Team:Cloud Security Cloud Security team related v8.9.0 labels Jun 20, 2023
@opauloh opauloh requested review from a team as code owners June 20, 2023 11:35
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Jun 20, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@opauloh opauloh requested a review from JordanSh June 20, 2023 11:36
Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, added a few suggestions.

JordanSh
JordanSh previously approved these changes Jun 20, 2023
Copy link
Contributor

@JordanSh JordanSh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some suggestions mainly around simplifying readability

Comment on lines 449 to 457
const checkCurrentTemplate = newPolicy?.inputs?.find((i: any) => i.type === CLOUDBEAT_AWS)
?.config?.cloud_formation_template_url?.value;

if (setupFormat !== 'cloudFormation') {
if (checkCurrentTemplate !== null) {
updateCloudFormationPolicyTemplate(newPolicy, updatePolicy, null);
}
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can return undefined

const checkCurrentTemplate = newPolicy?.inputs?.find((i: any) => i.type === CLOUDBEAT_AWS)
      ?.config?.cloud_formation_template_url?.value;

so this:

if (checkCurrentTemplate !== null) {
        updateCloudFormationPolicyTemplate(newPolicy, updatePolicy, null);
      }

essentially checks for undefined !== null which will result in true, and updateCloudFormationPolicyTemplate will get called.

],
},
],
} as PackageInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to type the return, with as we might make mistakes that won't get noticed.

@opauloh opauloh added the ci:cloud-deploy Create or update a Cloud deployment label Jun 22, 2023
@JordanSh
Copy link
Contributor

@opauloh another issue is that we show CloudFormation option when the installed integration does not support it (1.3.0)

Screen.Recording.2023-06-22.at.21.14.16.mov

This one is important, happened to me and it's very confusing

@opauloh opauloh requested review from JordanSh and kfirpeled June 26, 2023 07:43
@kibana-ci
Copy link
Collaborator

kibana-ci commented Jun 26, 2023

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cloudSecurityPosture 201 204 +3
fleet 819 823 +4
total +7

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cloudSecurityPosture 218.9KB 229.0KB +10.0KB
fleet 974.1KB 977.5KB +3.3KB
total +13.4KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 130.9KB 132.0KB +1.1KB
Unknown metric groups

ESLint disabled line counts

id before after diff
cloudSecurityPosture 14 16 +2
enterpriseSearch 14 16 +2
securitySolution 416 420 +4
total +8

Total ESLint disabled count

id before after diff
cloudSecurityPosture 15 17 +2
enterpriseSearch 15 17 +2
securitySolution 497 501 +4
total +8

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@JordanSh JordanSh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments, i pulled the or and the overall flow seemed ok, i think its safe to merge so we can start testing it.

also, I don't think it's considered a blocker but I didn't have a fleet on my local env so I installed one locally. the installation was successful and I could follow it up by adding an agent to my integration (directly from fleet installation flyout). but when i clicked on add agent, I got the wrong form:

image

After that, closing and reopening the flyout did open the correct form with the cloudformation option. so it seems it's only a problem when coming from the fleet flyout, and we can push a separate fix for it.
cc: @kfirpeled @nick-alayil

import { SetupFormat, useAwsCredentialsForm } from './hooks';

interface AWSSetupInfoContentProps {
integrationLink: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename this? the current name suggest its a link to an integration

input: Extract<NewPackagePolicyPostureInput, { type: 'cloudbeat/cis_aws' }>;
updatePolicy(updatedPolicy: NewPackagePolicy): void;
packageInfo: PackageInfo;
onChange: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing type

@@ -15,7 +15,7 @@ describe('getPosturePolicy', () => {
['cloudbeat/cis_k8s', getMockPolicyK8s, null],
] as const) {
it(`updates package policy with hidden vars for ${name}`, () => {
const inputVars = getPostureInputHiddenVars(name);
const inputVars = getPostureInputHiddenVars(name, {} as any);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as PackageInfo is preferable

const template: string | undefined = newPolicy?.inputs?.find((i) => i.type === CLOUDBEAT_AWS)
?.config?.cloud_formation_template_url?.value;

return template || undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if template can either be string or undefined, || undefined is redundant

newPolicy: NewPackagePolicy;
input: Extract<NewPackagePolicyPostureInput, { type: 'cloudbeat/cis_aws' }>;
packageInfo: PackageInfo;
onChange: (opts: any) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing type

Copy link
Contributor

@kfirpeled kfirpeled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@opauloh opauloh added the backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) label Jun 26, 2023
@opauloh opauloh merged commit 5728bfa into elastic:main Jun 26, 2023
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 26, 2023
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.9

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 26, 2023
#159994) (#160559)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[CloudSecurity][Fleet] Add CloudFormation install method to CSPM
(#159994)](#159994)

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

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

<!--BACKPORT [{"author":{"name":"Paulo
Henrique","email":"paulo.henrique@elastic.co"},"sourceCommit":{"committedDate":"2023-06-26T18:19:05Z","message":"[CloudSecurity][Fleet]
Add CloudFormation install method to CSPM
(#159994)","sha":"5728bfa1a7514eeb425e0894dab85ba63f48e8fa","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Fleet","release_note:feature","Team:Cloud
Security","backport:prev-minor","ci:cloud-deploy","v8.9.0","v8.10.0"],"number":159994,"url":"https://github.com/elastic/kibana/pull/159994","mergeCommit":{"message":"[CloudSecurity][Fleet]
Add CloudFormation install method to CSPM
(#159994)","sha":"5728bfa1a7514eeb425e0894dab85ba63f48e8fa"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159994","number":159994,"mergeCommit":{"message":"[CloudSecurity][Fleet]
Add CloudFormation install method to CSPM
(#159994)","sha":"5728bfa1a7514eeb425e0894dab85ba63f48e8fa"}}]}]
BACKPORT-->

Co-authored-by: Paulo Henrique <paulo.henrique@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) ci:cloud-deploy Create or update a Cloud deployment release_note:feature Makes this part of the condensed release notes Team:Cloud Security Cloud Security team related Team:Fleet Team label for Observability Data Collection Fleet team v8.9.0 v8.10.0
Projects
None yet
8 participants