Skip to content

Commit

Permalink
[Cloud Posture] Adding CSP 3P support callout for Wiz integration (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSh authored Oct 14, 2024
1 parent 5067f15 commit ebe16fa
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,7 @@ x-pack/plugins/osquery @elastic/security-defend-workflows
/x-pack/plugins/fleet/public/components/cloud_security_posture @elastic/fleet @elastic/kibana-cloud-security-posture
/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/components/cloud_security_posture @elastic/fleet @elastic/kibana-cloud-security-posture
/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/hooks/setup_technology.* @elastic/fleet @elastic/kibana-cloud-security-posture
/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/cloud_posture_third_party_support_callout.* @elastic/fleet @elastic/kibana-cloud-security-posture
/x-pack/plugins/security_solution/public/cloud_security_posture @elastic/kibana-cloud-security-posture
/x-pack/test/security_solution_cypress/cypress/e2e/explore/hosts/vulnerabilities_contextual_flyout.cy.ts @elastic/kibana-cloud-security-posture

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 { render, screen } from '@testing-library/react';

import useLocalStorage from 'react-use/lib/useLocalStorage';

import type { PackageInfo } from '../../../../../../../../common';

import { CloudPostureThirdPartySupportCallout } from './cloud_posture_third_party_support_callout';

jest.mock('react-use/lib/useLocalStorage');

describe('CloudPostureThirdPartySupportCallout', () => {
const mockPackageInfo = { name: 'wiz' } as PackageInfo;

beforeEach(() => {
(useLocalStorage as jest.Mock).mockClear();
});

it('renders callout when package is wiz and callout is not dismissed', () => {
(useLocalStorage as jest.Mock).mockReturnValue([false, jest.fn()]);

render(<CloudPostureThirdPartySupportCallout packageInfo={mockPackageInfo} />);

expect(screen.getByText(/New! Starting from version 1.9/)).toBeInTheDocument();
});

it('does not render callout when package is not wiz', () => {
const nonWizPackageInfo = { name: 'other' } as PackageInfo;
render(<CloudPostureThirdPartySupportCallout packageInfo={nonWizPackageInfo} />);

expect(screen.queryByText(/New! Starting from version 1.9/)).not.toBeInTheDocument();
});

it('does not render callout when it has been dismissed', () => {
(useLocalStorage as jest.Mock).mockReturnValue([true, jest.fn()]);

render(<CloudPostureThirdPartySupportCallout packageInfo={mockPackageInfo} />);

expect(screen.queryByText(/New! Starting from version 1.9/)).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 useLocalStorage from 'react-use/lib/useLocalStorage';
import { EuiCallOut, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import type { PackageInfo } from '../../../../../../../../common';

const LS_CLOUD_POSTURE_3P_SUPPORT_WIZ_INTEGRATIONS_CALLOUT_KEY =
'fleet:cloudSecurityPosture:thirdPartySupport:wizIntegrationsCallout';

export const CloudPostureThirdPartySupportCallout = ({
packageInfo,
}: {
packageInfo: PackageInfo;
}) => {
const [userHasDismissedWizCallout, setUserHasDismissedWizCallout] = useLocalStorage(
LS_CLOUD_POSTURE_3P_SUPPORT_WIZ_INTEGRATIONS_CALLOUT_KEY
);

if (packageInfo.name !== 'wiz' || userHasDismissedWizCallout) return null;

return (
<>
<EuiCallOut
onDismiss={() => setUserHasDismissedWizCallout(true)}
iconType="cheer"
title={i18n.translate('xpack.fleet.epm.wizIntegration.newFeaturesCallout', {
defaultMessage:
'New! Starting from version 1.9, ingest vulnerability and misconfiguration findings from Wiz into Elastic. Leverage out-of-the-box contextual investigation and threat-hunting workflows.',
})}
/>
<EuiSpacer size="s" />
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import { SideBarColumn } from '../../../components/side_bar_column';

import type { FleetStartServices } from '../../../../../../../plugin';

import { CloudPostureThirdPartySupportCallout } from '../components/cloud_posture_third_party_support_callout';

import { Screenshots } from './screenshots';
import { Readme } from './readme';
import { Details } from './details';
Expand Down Expand Up @@ -319,6 +321,7 @@ export const OverviewPage: React.FC<Props> = memo(
<EuiSpacer size="s" />
</>
)}
<CloudPostureThirdPartySupportCallout packageInfo={packageInfo} />
{isPrerelease && (
<PrereleaseCallout
packageName={packageInfo.name}
Expand Down

0 comments on commit ebe16fa

Please sign in to comment.