Skip to content

Commit

Permalink
[Security Solution][Resolver] Add no process events found messaging t…
Browse files Browse the repository at this point in the history
…o resolver (#91561)
  • Loading branch information
michaelolo24 authored Feb 17, 2021
1 parent 5774e97 commit 50bead6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ describe('Resolver: data loading and resolution states', () => {
});
});

it('should display a resolver graph with 0 nodes', async () => {
it('should display a message informing the user why no nodes are present', async () => {
await expect(
simulator.map(() => ({
resolverGraphLoading: simulator.testSubject('resolver:graph:loading').length,
resolverGraphError: simulator.testSubject('resolver:graph:error').length,
resolverTree: simulator.testSubject('resolver:graph').length,
resolverEmptyMessage: simulator.testSubject('resolver:no-process-events').length,
resolverGraphNodes: simulator.testSubject('resolver:node').length,
}))
).toYieldEqualTo({
resolverGraphLoading: 0,
resolverGraphError: 0,
resolverTree: 1,
resolverEmptyMessage: 1,
resolverGraphNodes: 0,
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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 { i18n } from '@kbn/i18n';
import styled from 'styled-components';
import { EuiCodeBlock, EuiFlexGroup, EuiTitle, EuiSpacer, EuiText } from '@elastic/eui';

const StyledEuiCodeBlock = styled(EuiCodeBlock)`
align-self: flex-start;
display: inline-block;
`;

const StyledEuiFlexGroup = styled(EuiFlexGroup)`
max-width: 600px;
margin: 60px auto 0;
`;

export const ResolverNoProcessEvents = () => (
<StyledEuiFlexGroup data-test-subj="resolver:no-process-events" direction="column">
<EuiTitle>
<h4>
{i18n.translate('xpack.securitySolution.resolver.noProcessEvents.title', {
defaultMessage: 'No Process Events Found',
})}
</h4>
</EuiTitle>
<EuiSpacer size="m" />
<EuiText size="s">
{i18n.translate('xpack.securitySolution.resolver.noProcessEvents.timeRange', {
defaultMessage: `
The Analyze Event tool creates graphs based on process events.
If the analyzed event does not have an associated process in the current time range,
or stored in Elasticsearch within any time range, a graph will not be created.
You can check for associated processes by expanding your time range.
`,
})}
</EuiText>
<EuiSpacer size="m" />
<EuiText size="s">
{i18n.translate('xpack.securitySolution.resolver.noProcessEvents.eventCategory', {
defaultMessage: `You may also add the below to your timeline query to check for process events.
If none are listed, a graph cannot be created from events found in that query.`,
})}
</EuiText>
<EuiSpacer size="m" />
<StyledEuiCodeBlock language="html" paddingSize="s" isCopyable>
{"event.category: 'process'"}
</StyledEuiCodeBlock>
</StyledEuiFlexGroup>
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/* eslint-disable react/display-name */

import React, { useContext, useCallback } from 'react';
import React, { useContext, useCallback, useMemo } from 'react';
import { useSelector } from 'react-redux';
import { EuiLoadingSpinner } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
Expand All @@ -26,6 +26,7 @@ import { ResolverProps, ResolverState } from '../types';
import { PanelRouter } from './panels';
import { useColors } from './use_colors';
import { useSyncSelectedNode } from './use_sync_selected_node';
import { ResolverNoProcessEvents } from './resolver_no_process_events';

/**
* The highest level connected Resolver component. Needs a `Provider` in its ancestry to work.
Expand Down Expand Up @@ -96,6 +97,10 @@ export const ResolverWithoutProviders = React.memo(
const activeDescendantId = useSelector(selectors.ariaActiveDescendant);
const colorMap = useColors();

const noProcessEventsFound = useMemo(() => processNodePositions.size < 1, [
processNodePositions,
]);

return (
<StyledMapContainer className={className} backgroundColor={colorMap.resolverBackground}>
{isLoading ? (
Expand All @@ -112,6 +117,8 @@ export const ResolverWithoutProviders = React.memo(
/>
</div>
</div>
) : noProcessEventsFound ? (
<ResolverNoProcessEvents />
) : (
<>
<GraphContainer
Expand Down

0 comments on commit 50bead6

Please sign in to comment.