Skip to content

Commit

Permalink
[Cloud Posture] Remove k8s instructions for cspm policies (#146843)
Browse files Browse the repository at this point in the history
## Summary

When installing CSPM the kubernetes deployment is not relevant and
shouldn't be visible.
This PR is fixing that

<img width="837" alt="Screen Shot 2022-12-04 at 15 41 00"
src="https://user-images.githubusercontent.com/61654899/205493957-7d8e95c3-8e20-4e34-9c3d-556e201e62f9.png">

## How to test it
In order to install CSPM integration you use cloud_security_posture
1.1.0 which is recently available
elastic/integrations#4752
  • Loading branch information
kfirpeled authored Dec 5, 2022
1 parent 23389a1 commit f72e50f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/constants/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const FLEET_APM_PACKAGE = 'apm';
export const FLEET_SYNTHETICS_PACKAGE = 'synthetics';
export const FLEET_KUBERNETES_PACKAGE = 'kubernetes';
export const FLEET_CLOUD_SECURITY_POSTURE_PACKAGE = 'cloud_security_posture';
export const FLEET_CLOUD_SECURITY_POSTURE_KSPM_POLICY_TEMPLATE = 'kspm';

export const PACKAGE_TEMPLATE_SUFFIX = '@package';
export const USER_SETTINGS_TEMPLATE_SUFFIX = '@custom';
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
FLEET_ELASTIC_AGENT_PACKAGE,
FLEET_KUBERNETES_PACKAGE,
FLEET_CLOUD_SECURITY_POSTURE_PACKAGE,
FLEET_CLOUD_SECURITY_POSTURE_KSPM_POLICY_TEMPLATE,
FLEET_ENDPOINT_PACKAGE,
// Saved object type
AGENT_POLICY_SAVED_OBJECT_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ import { i18n } from '@kbn/i18n';

import type { PackagePolicy, AgentPolicy } from '../../types';
import { sendGetOneAgentPolicy, useStartServices } from '../../hooks';
import { FLEET_KUBERNETES_PACKAGE, FLEET_CLOUD_SECURITY_POSTURE_PACKAGE } from '../../../common';
import {
FLEET_KUBERNETES_PACKAGE,
FLEET_CLOUD_SECURITY_POSTURE_PACKAGE,
FLEET_CLOUD_SECURITY_POSTURE_KSPM_POLICY_TEMPLATE,
} from '../../../common';

import type { K8sMode } from './types';

// Packages that requires custom elastic-agent manifest
const K8S_PACKAGES = new Set([FLEET_KUBERNETES_PACKAGE, FLEET_CLOUD_SECURITY_POSTURE_PACKAGE]);
const K8S_PACKAGES = new Set([FLEET_KUBERNETES_PACKAGE]);

export function useAgentPolicyWithPackagePolicies(policyId?: string) {
const [agentPolicyWithPackagePolicies, setAgentPolicy] = useState<AgentPolicy | null>(null);
Expand Down Expand Up @@ -66,4 +70,14 @@ export function useIsK8sPolicy(agentPolicy?: AgentPolicy) {
return { isK8s };
}

const isK8sPackage = (pkg: PackagePolicy) => K8S_PACKAGES.has(pkg.package?.name as string);
const isK8sPackage = (pkg: PackagePolicy) => {
const name = pkg.package?.name as string;
if (name === FLEET_CLOUD_SECURITY_POSTURE_PACKAGE) {
return pkg.inputs.some(
(input) =>
input.enabled && input.policy_template === FLEET_CLOUD_SECURITY_POSTURE_KSPM_POLICY_TEMPLATE
);
}

return K8S_PACKAGES.has(name);
};

0 comments on commit f72e50f

Please sign in to comment.