-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Ece Özalp <[email protected]>
- Loading branch information
1 parent
100f04e
commit 59463dc
Showing
59 changed files
with
1,823 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ins/security_solution/common/search_strategy/security_solution/hosts/risky_hosts/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* 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 { Inspect, Maybe, RequestBasicOptions } from '../../..'; | ||
import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; | ||
|
||
export type HostsRiskyHostsRequestOptions = RequestBasicOptions; | ||
|
||
export interface HostsRiskyHostsStrategyResponse extends IEsSearchResponse { | ||
inspect?: Maybe<Inspect>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
x-pack/plugins/security_solution/cypress/integration/overview/risky_hosts_panel.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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 { | ||
OVERVIEW_RISKY_HOSTS_ENABLE_MODULE_BUTTON, | ||
OVERVIEW_RISKY_HOSTS_LINKS, | ||
OVERVIEW_RISKY_HOSTS_LINKS_ERROR_INNER_PANEL, | ||
OVERVIEW_RISKY_HOSTS_LINKS_WARNING_INNER_PANEL, | ||
OVERVIEW_RISKY_HOSTS_TOTAL_EVENT_COUNT, | ||
OVERVIEW_RISKY_HOSTS_VIEW_DASHBOARD_BUTTON, | ||
} from '../../screens/overview'; | ||
|
||
import { loginAndWaitForPage } from '../../tasks/login'; | ||
import { OVERVIEW_URL } from '../../urls/navigation'; | ||
import { cleanKibana } from '../../tasks/common'; | ||
import { esArchiverLoad, esArchiverUnload } from '../../tasks/es_archiver'; | ||
|
||
describe('Risky Hosts Link Panel', () => { | ||
before(() => { | ||
cleanKibana(); | ||
}); | ||
|
||
it('renders disabled panel view as expected', () => { | ||
loginAndWaitForPage(OVERVIEW_URL); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_LINKS} ${OVERVIEW_RISKY_HOSTS_LINKS_ERROR_INNER_PANEL}`).should( | ||
'exist' | ||
); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_VIEW_DASHBOARD_BUTTON}`).should('be.disabled'); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_TOTAL_EVENT_COUNT}`).should('have.text', 'Showing: 0 hosts'); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_ENABLE_MODULE_BUTTON}`).should('exist'); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_ENABLE_MODULE_BUTTON}`) | ||
.should('have.attr', 'href') | ||
.and('match', /host-risk-score.md/); | ||
}); | ||
|
||
describe('enabled module', () => { | ||
before(() => { | ||
esArchiverLoad('risky_hosts'); | ||
}); | ||
|
||
after(() => { | ||
esArchiverUnload('risky_hosts'); | ||
}); | ||
|
||
it('renders disabled dashboard module as expected when there are no hosts in the selected time period', () => { | ||
loginAndWaitForPage( | ||
`${OVERVIEW_URL}?sourcerer=(timerange:(from:%272021-07-08T04:00:00.000Z%27,kind:absolute,to:%272021-07-09T03:59:59.999Z%27))` | ||
); | ||
cy.get( | ||
`${OVERVIEW_RISKY_HOSTS_LINKS} ${OVERVIEW_RISKY_HOSTS_LINKS_WARNING_INNER_PANEL}` | ||
).should('exist'); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_VIEW_DASHBOARD_BUTTON}`).should('be.disabled'); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_TOTAL_EVENT_COUNT}`).should('have.text', 'Showing: 0 hosts'); | ||
}); | ||
|
||
it('renders dashboard module as expected when there are hosts in the selected time period', () => { | ||
loginAndWaitForPage(OVERVIEW_URL); | ||
cy.get( | ||
`${OVERVIEW_RISKY_HOSTS_LINKS} ${OVERVIEW_RISKY_HOSTS_LINKS_WARNING_INNER_PANEL}` | ||
).should('not.exist'); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_VIEW_DASHBOARD_BUTTON}`).should('be.disabled'); | ||
cy.get(`${OVERVIEW_RISKY_HOSTS_TOTAL_EVENT_COUNT}`).should('have.text', 'Showing: 1 host'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/security_solution/public/common/utils/exceptions/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const isIndexNotFoundError = (error: unknown): boolean => | ||
( | ||
error as { | ||
attributes?: { caused_by?: { type?: string } }; | ||
} | ||
).attributes?.caused_by?.type === 'index_not_found_exception'; |
40 changes: 40 additions & 0 deletions
40
...gins/security_solution/public/overview/components/link_panel/disabled_link_panel.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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 { TestProviders } from '../../../common/mock'; | ||
import { DisabledLinkPanel } from './disabled_link_panel'; | ||
import { ThreatIntelPanelView as TestView } from '../overview_cti_links/threat_intel_panel_view'; | ||
|
||
jest.mock('../../../common/lib/kibana'); | ||
|
||
describe('DisabledLinkPanel', () => { | ||
const defaultProps = { | ||
bodyCopy: 'body', | ||
buttonCopy: 'button', | ||
dataTestSubjPrefix: '_test_prefix_', | ||
docLink: '/doclink', | ||
LinkPanelViewComponent: TestView, | ||
listItems: [], | ||
titleCopy: 'title', | ||
}; | ||
|
||
it('renders expected children', () => { | ||
render( | ||
<TestProviders> | ||
<DisabledLinkPanel {...defaultProps} /> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.getByTestId('_test_prefix_-inner-panel-danger')).toBeInTheDocument(); | ||
expect(screen.getByTestId('_test_prefix_-enable-module-button')).toHaveTextContent( | ||
defaultProps.buttonCopy | ||
); | ||
expect(screen.getByRole('link')).toHaveAttribute('href', defaultProps.docLink); | ||
}); | ||
}); |
57 changes: 57 additions & 0 deletions
57
...k/plugins/security_solution/public/overview/components/link_panel/disabled_link_panel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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, { memo } from 'react'; | ||
import { EuiButton } from '@elastic/eui'; | ||
|
||
import { InnerLinkPanel } from './inner_link_panel'; | ||
import { LinkPanelListItem, LinkPanelViewProps } from './types'; | ||
|
||
interface DisabledLinkPanelProps { | ||
bodyCopy: string; | ||
buttonCopy: string; | ||
dataTestSubjPrefix: string; | ||
docLink: string; | ||
LinkPanelViewComponent: React.ComponentType<LinkPanelViewProps>; | ||
listItems: LinkPanelListItem[]; | ||
titleCopy: string; | ||
} | ||
|
||
const DisabledLinkPanelComponent: React.FC<DisabledLinkPanelProps> = ({ | ||
bodyCopy, | ||
buttonCopy, | ||
dataTestSubjPrefix, | ||
docLink, | ||
LinkPanelViewComponent, | ||
listItems, | ||
titleCopy, | ||
}) => ( | ||
<LinkPanelViewComponent | ||
listItems={listItems} | ||
splitPanel={ | ||
<InnerLinkPanel | ||
body={bodyCopy} | ||
button={ | ||
<EuiButton | ||
href={docLink} | ||
color="warning" | ||
target="_blank" | ||
data-test-subj={`${dataTestSubjPrefix}-enable-module-button`} | ||
> | ||
{buttonCopy} | ||
</EuiButton> | ||
} | ||
color="warning" | ||
dataTestSubj={`${dataTestSubjPrefix}-inner-panel-danger`} | ||
title={titleCopy} | ||
/> | ||
} | ||
/> | ||
); | ||
|
||
export const DisabledLinkPanel = memo(DisabledLinkPanelComponent); | ||
DisabledLinkPanel.displayName = 'DisabledLinkPanel'; |
17 changes: 17 additions & 0 deletions
17
x-pack/plugins/security_solution/public/overview/components/link_panel/helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* 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 { LinkPanelListItem } from '.'; | ||
|
||
export const isLinkPanelListItem = ( | ||
item: LinkPanelListItem | Partial<LinkPanelListItem> | ||
): item is LinkPanelListItem => | ||
typeof item.title === 'string' && typeof item.path === 'string' && typeof item.count === 'number'; | ||
|
||
export interface EventCounts { | ||
[key: string]: number; | ||
} |
11 changes: 11 additions & 0 deletions
11
x-pack/plugins/security_solution/public/overview/components/link_panel/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { InnerLinkPanel } from './inner_link_panel'; | ||
export { isLinkPanelListItem } from './helpers'; | ||
export { LinkPanel } from './link_panel'; | ||
export { LinkPanelListItem } from './types'; |
33 changes: 33 additions & 0 deletions
33
...plugins/security_solution/public/overview/components/link_panel/inner_link_panel.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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 { EuiButton } from '@elastic/eui'; | ||
import { TestProviders } from '../../../common/mock'; | ||
import { InnerLinkPanel } from './inner_link_panel'; | ||
|
||
describe('InnerLinkPanel', () => { | ||
const defaultProps = { | ||
body: 'test_body', | ||
button: <EuiButton />, | ||
dataTestSubj: 'custom_test_subj', | ||
title: 'test_title', | ||
}; | ||
|
||
it('renders expected children', () => { | ||
render( | ||
<TestProviders> | ||
<InnerLinkPanel color="warning" {...defaultProps} /> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.getByTestId('custom_test_subj')).toBeInTheDocument(); | ||
expect(screen.getByRole('button')).toBeInTheDocument(); | ||
expect(screen.getByTestId('inner-link-panel-title')).toHaveTextContent(defaultProps.title); | ||
}); | ||
}); |
Oops, something went wrong.