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

[Cloud Security] Allow force install package policy to agentless agent policy #173553

Merged
merged 4 commits into from
Dec 27, 2023

Conversation

maxcold
Copy link
Contributor

@maxcold maxcold commented Dec 18, 2023

Summary

Right now every Security project in serverless is created with an Agentless policy (gated be the feature flag based on or org id) and in this policy is_managed set to false. We in Cloud Security want to make the policy managed.

This change is to allow us to do that and still be able to install integrations on the policy. In a nutshell, the logic is to force install integration if the agent policy id is agentless. If we are not missing something, it should be safe, as when managed, the agentless agent policy won't be available in the list of Existing Hosts and the only way to pick it for installation in the UI is to implement the same logic we implemented in CSP integration in

Part of:

Screencast

screencast-github.aaakk.us.kg-2023.12.06-17_55_27.webm

Checklist

Delete any items that are not applicable to this PR.

@maxcold maxcold added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:Cloud Security Cloud Security team related v8.13.0 labels Dec 18, 2023
@maxcold
Copy link
Contributor Author

maxcold commented Dec 19, 2023

/ci

@maxcold maxcold force-pushed the csp-agentless-force-install-to-agentless-policy branch from 22f2e6f to 65930c8 Compare December 20, 2023 09:47
@maxcold maxcold requested a review from a team December 20, 2023 09:59
@maxcold maxcold marked this pull request as ready for review December 20, 2023 09:59
@maxcold maxcold requested a review from a team as a code owner December 20, 2023 09:59
@elasticmachine
Copy link
Contributor

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

@@ -298,12 +299,15 @@ export function useOnSubmit({
}
}

const agentPolicyIdToSave = createdPolicy?.id ?? packagePolicy.policy_id;
const forceInstall = force || agentPolicyIdToSave === AGENTLESS_POLICY_ID;
Copy link
Member

Choose a reason for hiding this comment

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

maybe worth checking we are in serverless too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

potentially there will be agentless on ESS, the work kicked off in parallel, but I agree that it makes sense to be on the safer side for now and check for serverless, or at least that it's not on-prem. will look into it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nchaulet updated the pr including the check for serverless env and agentless FF being enabled

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

Pinging @elastic/fleet (Team:Fleet)

@@ -373,9 +377,11 @@ export function useOnSubmit({
} else {
if (isVerificationError(error)) {
setFormState('VALID'); // don't show the add agent modal
const forceInstall = await confirmForceInstall(packagePolicy.package!);
const forceInstallUnverifiedIntegration = await confirmForceInstall(
packagePolicy.package!
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it be safer to add the packagePolicy.package to the if statement instead of using non null assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this line only the variable name changed, the rest is the same as it was. As we are not the code owner, I wouldn't touch what is not broken :)

@maxcold maxcold requested a review from nchaulet December 27, 2023 14:32
Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

Code LGTM 🚀

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
fleet 1.2MB 1.2MB +147.0B

History

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

@maxcold maxcold merged commit 460ef86 into main Dec 27, 2023
20 checks passed
@maxcold maxcold deleted the csp-agentless-force-install-to-agentless-policy branch December 27, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related Team:Fleet Team label for Observability Data Collection Fleet team v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants