-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Changes from 2 commits
65930c8
4892776
8a57dcf
ac196ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ import { SelectedPolicyTab } from '../../components'; | |
import { useOnSaveNavigate } from '../../hooks'; | ||
import { prepareInputPackagePolicyDataset } from '../../services/prepare_input_pkg_policy_dataset'; | ||
import { getCloudFormationPropsFromPackagePolicy } from '../../../../../services'; | ||
import { AGENTLESS_POLICY_ID } from './setup_technology'; | ||
|
||
async function createAgentPolicy({ | ||
packagePolicy, | ||
|
@@ -298,12 +299,15 @@ export function useOnSubmit({ | |
} | ||
} | ||
|
||
const agentPolicyIdToSave = createdPolicy?.id ?? packagePolicy.policy_id; | ||
const forceInstall = force || agentPolicyIdToSave === AGENTLESS_POLICY_ID; | ||
|
||
setFormState('LOADING'); | ||
// passing pkgPolicy with policy_id here as setPackagePolicy doesn't propagate immediately | ||
const { error, data } = await savePackagePolicy({ | ||
...packagePolicy, | ||
policy_id: createdPolicy?.id ?? packagePolicy.policy_id, | ||
force, | ||
policy_id: agentPolicyIdToSave, | ||
force: forceInstall, | ||
}); | ||
|
||
const hasAzureArmTemplate = data?.item | ||
|
@@ -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! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't it be safer to add the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) |
||
); | ||
|
||
if (forceInstall) { | ||
if (forceInstallUnverifiedIntegration) { | ||
// skip creating the agent policy because it will have already been successfully created | ||
onSubmit({ overrideCreatedAgentPolicy: createdPolicy, force: true }); | ||
} | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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