Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into rules-types-versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenIdo committed Dec 7, 2023
2 parents 92a0e64 + ef5305d commit 9cc8af6
Show file tree
Hide file tree
Showing 39 changed files with 659 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export class AnalyticsService {
type: 'keyword',
_meta: { description: 'The Cluster version', optional: true },
},
cluster_build_flavor: {
type: 'keyword',
_meta: { description: 'The Cluster build flavor', optional: true },
},
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface InjectedMetadataClusterInfo {
cluster_uuid?: string;
cluster_name?: string;
cluster_version?: string;
cluster_build_flavor?: string;
}

/** @internal */
Expand Down
6 changes: 0 additions & 6 deletions x-pack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ xpack.observability.unsafe.alertDetails.metrics.enabled: true
**[For Infrastructure rule types]** In Kibana configuration, will allow the user to navigate to the new Alert Details page, instead of the Alert Flyout when clicking on `View alert details` in the Alert table

```yaml
xpack.observability.unsafe.alertDetails.logs.enabled: true
```

**[For Logs threshold rule type]** In Kibana configuration, will allow the user to navigate to the new Alert Details page, instead of the Alert Flyout when clicking on `View alert details` in the Alert table

```yaml
xpack.observability.unsafe.alertDetails.uptime.enabled: true
```
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/cloud_security_posture/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export type GcpCredentialsTypeFieldMap = {

export type AzureCredentialsType =
| 'arm_template'
| 'manual' // TODO: remove for stack version 8.13
| 'service_principal_with_client_secret'
| 'service_principal_with_client_certificate'
| 'service_principal_with_client_username_and_password'
| 'managed_identity'
| 'manual';
| 'managed_identity';

export type AzureCredentialsTypeFieldMap = {
[key in AzureCredentialsType]: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,6 @@ const TemporaryManualSetup = ({ integrationLink }: { integrationLink: string })
const AZURE_MINIMUM_PACKAGE_VERSION = '1.6.0';
const AZURE_MANUAL_FIELDS_PACKAGE_VERSION = '1.7.0';

export const getDefaultAzureManualCredentialType = (packageInfo: PackageInfo) => {
const packageSemanticVersion = semverValid(packageInfo.version);
const cleanPackageVersion = semverCoerce(packageSemanticVersion) || '';

const isPackageVersionValidForManualFields = !semverLt(
cleanPackageVersion,
AZURE_MANUAL_FIELDS_PACKAGE_VERSION
);

return isPackageVersionValidForManualFields ? 'managed_identity' : 'manual';
};

const AzureInputVarFields = ({
fields,
onChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ export const getAzureCredentialsFormManualOptions = (): Array<{
value: AzureCredentialsType;
text: string;
}> => {
return Object.entries(getAzureCredentialsFormOptions())
.map(([key, value]) => ({
value: key as AzureCredentialsType,
text: value.label,
}))
.filter(({ value }) => value !== 'arm_template');
return (
Object.entries(getAzureCredentialsFormOptions())
.map(([key, value]) => ({
value: key as AzureCredentialsType,
text: value.label,
}))
// TODO: remove 'manual' for stack version 8.13
.filter(({ value }) => value !== 'arm_template' && value !== 'manual')
);
};

export const getInputVarsFields = (input: NewPackagePolicyInput, fields: AzureCredentialsFields) =>
Expand Down Expand Up @@ -75,6 +78,12 @@ export const getAzureCredentialsFormOptions = (): AzureOptions => ({
info: [],
fields: {},
},
// TODO: remove for stack version 8.13
manual: {
label: 'Manual',
info: [],
fields: {},
},
service_principal_with_client_secret: {
label: i18n.translate('xpack.csp.azureIntegration.servicePrincipalWithClientSecretLabel', {
defaultMessage: 'Service principal with Client Secret',
Expand Down Expand Up @@ -131,18 +140,4 @@ export const getAzureCredentialsFormOptions = (): AzureOptions => ({
},
},
},
manual: {
label: i18n.translate('xpack.csp.azureIntegration.credentialType.manualLabel', {
defaultMessage: 'Manual',
}),
info: (
<EuiText color="subdued" size="s">
<FormattedMessage
id="xpack.csp.azureIntegration.credentialType.manualInfo"
defaultMessage="Ensure the agent is deployed on a resource that supports managed identities (e.g., Azure Virtual Machines). No explicit credentials need to be provided; Azure handles the authentication."
/>
</EuiText>
),
fields: {},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

import { useEffect, useRef } from 'react';
import { NewPackagePolicy, PackageInfo } from '@kbn/fleet-plugin/common';
import {
AZURE_ARM_TEMPLATE_CREDENTIAL_TYPE,
getDefaultAzureManualCredentialType,
} from './azure_credentials_form';
import { AZURE_ARM_TEMPLATE_CREDENTIAL_TYPE } from './azure_credentials_form';
import { cspIntegrationDocsNavigation } from '../../../common/navigation/constants';
import {
getArmTemplateUrlFromCspmPackage,
Expand Down Expand Up @@ -151,7 +148,7 @@ export const useAzureCredentialsForm = ({
setupFormat,
});

const defaultAzureManualCredentialType = getDefaultAzureManualCredentialType(packageInfo);
const defaultAzureManualCredentialType = 'managed_identity';

const onSetupFormatChange = (newSetupFormat: SetupFormat) => {
if (newSetupFormat === AZURE_ARM_TEMPLATE_CREDENTIAL_TYPE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ describe('<CspPolicyTemplateForm />', () => {
).toBeInTheDocument();
});

// TODO: remove for stack version 8.13
it(`doesnt render ${CLOUDBEAT_AZURE} Manual fields when version is not at least version 1.7.0`, () => {
let policy = getMockPolicyAzure();
policy = getPosturePolicy(policy, CLOUDBEAT_AZURE, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { i18n } from '@kbn/i18n';
import { AZURE_ARM_TEMPLATE_CREDENTIAL_TYPE } from './azure_credentials_form/azure_credentials_form';
import { CspRadioGroupProps, RadioGroup } from './csp_boxed_radio_group';
import { assert } from '../../../common/utils/helpers';
import type { PostureInput, CloudSecurityPolicyTemplate } from '../../../common/types';
import type { CloudSecurityPolicyTemplate, PostureInput } from '../../../common/types';
import {
CLOUDBEAT_AWS,
CLOUDBEAT_VANILLA,
Expand All @@ -41,14 +41,14 @@ import {
SUPPORTED_POLICY_TEMPLATES,
} from '../../../common/constants';
import {
getPosturePolicy,
getMaxPackageName,
getPostureInputHiddenVars,
getPosturePolicy,
getVulnMgmtCloudFormationDefaultValue,
POSTURE_NAMESPACE,
type NewPackagePolicyPostureInput,
isPostureInput,
getMaxPackageName,
isBelowMinVersion,
type NewPackagePolicyPostureInput,
POSTURE_NAMESPACE,
} from './utils';
import {
PolicyTemplateInfo,
Expand All @@ -58,6 +58,8 @@ import {
} from './policy_template_selectors';
import { usePackagePolicyList } from '../../common/api/use_package_policy_list';
import { gcpField, getInputVarsFields } from './gcp_credential_form';
import { SetupTechnologySelector } from './setup_technology_selector/setup_technology_selector';
import { useSetupTechnology } from './setup_technology_selector/use_setup_technology';

const DEFAULT_INPUT_TYPE = {
kspm: CLOUDBEAT_VANILLA,
Expand Down Expand Up @@ -520,14 +522,29 @@ const IntegrationSettings = ({ onChange, fields }: IntegrationInfoFieldsProps) =
);

export const CspPolicyTemplateForm = memo<PackagePolicyReplaceDefineStepExtensionComponentProps>(
({ newPolicy, onChange, validationResults, isEditPage, packageInfo }) => {
({
agentPolicy,
newPolicy,
onChange,
validationResults,
isEditPage,
packageInfo,
handleSetupTechnologyChange,
agentlessPolicy,
}) => {
const integrationParam = useParams<{ integration: CloudSecurityPolicyTemplate }>().integration;
const integration = SUPPORTED_POLICY_TEMPLATES.includes(integrationParam)
? integrationParam
: undefined;
// Handling validation state
const [isValid, setIsValid] = useState(true);
const input = getSelectedOption(newPolicy.inputs, integration);
const { isAgentlessAvailable, setupTechnology, setSetupTechnology } = useSetupTechnology({
input,
agentPolicy,
agentlessPolicy,
handleSetupTechnologyChange,
});

const updatePolicy = useCallback(
(updatedPolicy: NewPackagePolicy) => {
Expand Down Expand Up @@ -722,6 +739,13 @@ export const CspPolicyTemplateForm = memo<PackagePolicyReplaceDefineStepExtensio
onChange={(field, value) => updatePolicy({ ...newPolicy, [field]: value })}
/>

{isAgentlessAvailable && (
<SetupTechnologySelector
setupTechnology={setupTechnology}
onSetupTechnologyChange={setSetupTechnology}
/>
)}

{/* Defines the vars of the enabled input of the active policy template */}
<PolicyTemplateVarsForm
input={input}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';

import { SetupTechnology } from '@kbn/fleet-plugin/public';
import { FormattedMessage } from '@kbn/i18n-react';
import {
EuiAccordion,
EuiFormRow,
EuiLink,
EuiSpacer,
EuiSuperSelect,
EuiText,
useGeneratedHtmlId,
} from '@elastic/eui';

export const SetupTechnologySelector = ({
setupTechnology,
onSetupTechnologyChange,
}: {
setupTechnology: SetupTechnology;
onSetupTechnologyChange: (value: SetupTechnology) => void;
}) => {
const options = [
{
value: SetupTechnology.AGENTLESS,
inputDisplay: (
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.agentlessInputDisplay"
defaultMessage="Agentless"
/>
),
dropdownDisplay: (
<>
<strong>
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.agentlessDrowpownDisplay"
defaultMessage="Agentless"
/>
</strong>
<EuiText size="s" color="subdued">
<p>
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.agentlessDrowpownDescription"
defaultMessage="Set up the integration without an agent"
/>
</p>
</EuiText>
</>
),
},
{
value: SetupTechnology.AGENT_BASED,
inputDisplay: (
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.agentbasedInputDisplay"
defaultMessage="Agent-based"
/>
),
dropdownDisplay: (
<>
<strong>
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.agentbasedDrowpownDisplay"
defaultMessage="Agent-based"
/>
</strong>
<EuiText size="s" color="subdued">
<p>
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.agentbasedDrowpownDescription"
defaultMessage="Set up the integration with an agent"
/>
</p>
</EuiText>
</>
),
},
];

return (
<>
<EuiSpacer size="l" />
<EuiAccordion
id={useGeneratedHtmlId({ prefix: 'setup-type' })}
buttonContent={
<EuiLink>
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.advancedOptionsLabel"
defaultMessage="Advanced options"
/>
</EuiLink>
}
>
<EuiSpacer size="l" />
<EuiFormRow
fullWidth
label={
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.setupTechnologyLabel"
defaultMessage="Setup technology"
/>
}
>
<EuiSuperSelect
options={options}
valueOfSelected={setupTechnology}
placeholder={
<FormattedMessage
id="xpack.csp.fleetIntegration.setupTechnology.setupTechnologyPlaceholder"
defaultMessage="Select the setup technology"
/>
}
onChange={onSetupTechnologyChange}
itemLayoutAlign="top"
hasDividers
fullWidth
/>
</EuiFormRow>
</EuiAccordion>
</>
);
};
Loading

0 comments on commit 9cc8af6

Please sign in to comment.