Skip to content

Commit

Permalink
Refactored plumbing of agg terms of Authentications
Browse files Browse the repository at this point in the history
  * Made it sort by desc of number of failures
  * Reduced type usages where possible to Ecs based types
  * Added newer fields to the Authentications based on feedback
  • Loading branch information
FrankHassanabad committed Jan 24, 2019
1 parent d784ca5 commit 1972f3f
Show file tree
Hide file tree
Showing 30 changed files with 668 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@ exports[`Authentication Table Component rendering it renders the default Authent
"node": Object {
"_id": "cPsuhGcB0WOhS6qyTKC0",
"failures": 10,
"host": Object {
"id": "123",
"ip": "192.168.0.1",
"name": "host-computer-1",
"lastFailure": Object {
"host": Object {
"id": "host-id-1",
"name": "host-2",
},
"source": Object {
"ip": "8.8.8.8",
},
"timestamp": "2019-01-23T22:35:32.222Z",
},
"latest": "2019-01-11T06:18:30.745Z",
"source": Object {
"ip": "127.0.0.1",
"lastSuccess": Object {
"host": Object {
"id": "host-id-1",
"name": "host-1",
},
"source": Object {
"ip": "127.0.0.1",
},
"timestamp": "2019-01-23T22:35:32.222Z",
},
"successes": 0,
"user": Object {
Expand All @@ -33,14 +44,25 @@ exports[`Authentication Table Component rendering it renders the default Authent
"node": Object {
"_id": "KwQDiWcB0WOhS6qyXmrW",
"failures": 10,
"host": Object {
"id": "234",
"ip": "192.168.0.1",
"name": "host-computer-2",
"lastFailure": Object {
"host": Object {
"id": "host-id-1",
"name": "host-2",
},
"source": Object {
"ip": "8.8.8.8",
},
"timestamp": "2019-01-23T22:35:32.222Z",
},
"latest": "2019-01-11T06:18:30.745Z",
"source": Object {
"ip": "127.0.0.1",
"lastSuccess": Object {
"host": Object {
"id": "host-id-1",
"name": "host-1",
},
"source": Object {
"ip": "127.0.0.1",
},
"timestamp": "2019-01-23T22:35:32.222Z",
},
"successes": 0,
"user": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import React from 'react';
import { connect } from 'react-redux';
import { pure } from 'recompose';

import { has } from 'lodash/fp';
import moment from 'moment';
import { AuthenticationsEdges } from '../../../../graphql/types';
import { authenticationsSelector, hostsActions, State } from '../../../../store';
import { DragEffects, DraggableWrapper } from '../../../drag_and_drop/draggable_wrapper';
import { defaultToEmpty, getEmptyValue } from '../../../empty_value';
import { defaultToEmpty, getEmptyValue, getOrEmpty } from '../../../empty_value';
import { ItemsPerRow, LoadMoreTable } from '../../../load_more_table';
import { Provider } from '../../../timeline/data_providers/provider';
import * as i18n from './translations';
Expand Down Expand Up @@ -74,7 +75,7 @@ const AuthenticationTableComponent = pure<AuthenticationTableProps>(
}) => (
<LoadMoreTable
columns={getAuthenticationColumns(startDate)}
loadingTitle={i18n.AUTHENTICATION_FAILURES}
loadingTitle={i18n.AUTHENTICATIONS}
loading={loading}
pageOfItems={data}
loadMore={() => loadMore(nextCursor)}
Expand All @@ -84,7 +85,7 @@ const AuthenticationTableComponent = pure<AuthenticationTableProps>(
updateLimitPagination={newlimit => updateLimitPagination({ limit: newlimit })}
title={
<h3>
{i18n.AUTHENTICATION_FAILURES} <EuiBadge color="hollow">{totalCount}</EuiBadge>
{i18n.AUTHENTICATIONS} <EuiBadge color="hollow">{totalCount}</EuiBadge>
</h3>
}
/>
Expand Down Expand Up @@ -146,30 +147,66 @@ const getAuthenticationColumns = (startDate: number) => [
hideForMobile: false,
render: ({ node }: AuthenticationsEdges) => <>{defaultToEmpty(node.failures)}</>,
},
{
name: i18n.LAST_FAILED_TIME,
truncateText: false,
hideForMobile: false,
render: ({ node }: AuthenticationsEdges) => {
return (
<>
{has('lastFailure.timestamp', node) ? (
<FormattedRelative value={new Date(node.lastFailure!.timestamp!)} />
) : (
getEmptyValue()
)}
</>
);
},
},
{
name: i18n.LAST_FAILED_SOURCE,
truncateText: false,
hideForMobile: false,
render: ({ node }: AuthenticationsEdges) => <>{getOrEmpty('lastFailure.source.ip', node)}</>,
},
{
name: i18n.LAST_FAILED_DESTINATION,
truncateText: false,
hideForMobile: false,
render: ({ node }: AuthenticationsEdges) => <>{getOrEmpty('lastFailure.host.name', node)}</>,
},
{
name: i18n.SUCCESSES,
truncateText: false,
hideForMobile: false,
render: ({ node }: AuthenticationsEdges) => <>{defaultToEmpty(node.successes)}</>,
},
{
name: i18n.FROM,
name: i18n.LAST_SUCCESSFUL_TIME,
truncateText: false,
hideForMobile: false,
render: ({ node }: AuthenticationsEdges) => <>{defaultToEmpty(node.source.ip)}</>,
render: ({ node }: AuthenticationsEdges) => {
return (
<>
{has('lastSuccess.timestamp', node) ? (
<FormattedRelative value={new Date(node.lastSuccess!.timestamp!)} />
) : (
getEmptyValue()
)}
</>
);
},
},
{
name: i18n.TO,
name: i18n.LAST_SUCCESSFUL_SOURCE,
truncateText: false,
hideForMobile: false,
render: ({ node }: AuthenticationsEdges) => <>{defaultToEmpty(node.host.name)}</>,
render: ({ node }: AuthenticationsEdges) => <>{getOrEmpty('lastSuccess.source.ip', node)}</>,
},
{
name: i18n.LATEST,
name: i18n.LAST_SUCCESSFUL_DESTINATION,
truncateText: false,
hideForMobile: false,
render: ({ node }: AuthenticationsEdges) => (
<>{node.latest ? <FormattedRelative value={new Date(node.latest)} /> : getEmptyValue()}</>
),
render: ({ node }: AuthenticationsEdges) => <>{getOrEmpty('lastSuccess.host.name', node)}</>,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,25 @@ export const mockData: { Authentications: AuthenticationsData } = {
failures: 10,
successes: 0,
user: { name: 'Evan Hassanabad' },
source: { ip: '127.0.0.1' },
latest: '2019-01-11T06:18:30.745Z',
host: {
id: '123',
name: 'host-computer-1',
ip: '192.168.0.1',
lastSuccess: {
timestamp: '2019-01-23T22:35:32.222Z',
source: {
ip: '127.0.0.1',
},
host: {
id: 'host-id-1',
name: 'host-1',
},
},
lastFailure: {
timestamp: '2019-01-23T22:35:32.222Z',
source: {
ip: '8.8.8.8',
},
host: {
id: 'host-id-1',
name: 'host-2',
},
},
},
cursor: {
Expand All @@ -34,12 +47,25 @@ export const mockData: { Authentications: AuthenticationsData } = {
failures: 10,
successes: 0,
user: { name: 'Braden Hassanabad' },
source: { ip: '127.0.0.1' },
latest: '2019-01-11T06:18:30.745Z',
host: {
id: '234',
name: 'host-computer-2',
ip: '192.168.0.1',
lastSuccess: {
timestamp: '2019-01-23T22:35:32.222Z',
source: {
ip: '127.0.0.1',
},
host: {
id: 'host-id-1',
name: 'host-1',
},
},
lastFailure: {
timestamp: '2019-01-23T22:35:32.222Z',
source: {
ip: '8.8.8.8',
},
host: {
id: 'host-id-1',
name: 'host-2',
},
},
},
cursor: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,43 @@

import { i18n } from '@kbn/i18n';

export const LATEST = i18n.translate('xpack.secops.authenticationsTable.latest', {
defaultMessage: 'Latest',
});
export const LAST_SUCCESSFUL_SOURCE = i18n.translate(
'xpack.secops.authenticationsTable.lastSuccessfulSource',
{
defaultMessage: 'Last Successful Source',
}
);

export const TO = i18n.translate('xpack.secops.authenticationsTable.to', {
defaultMessage: 'To',
});
export const LAST_SUCCESSFUL_DESTINATION = i18n.translate(
'xpack.secops.authenticationsTable.lastSuccessfulDestination',
{
defaultMessage: 'Last Successful Destination',
}
);

export const LAST_SUCCESSFUL_TIME = i18n.translate(
'xpack.secops.authenticationsTable.lastSuccessfulTime',
{
defaultMessage: 'Last Success',
}
);

export const LAST_FAILED_SOURCE = i18n.translate(
'xpack.secops.authenticationsTable.lastFailedSource',
{
defaultMessage: 'Last Failed Source',
}
);

export const LAST_FAILED_DESTINATION = i18n.translate(
'xpack.secops.authenticationsTable.lastFailedDestination',
{
defaultMessage: 'Last Failed Destination',
}
);

export const FROM = i18n.translate('xpack.secops.authenticationsTable.from', {
defaultMessage: 'From',
export const LAST_FAILED_TIME = i18n.translate('xpack.secops.authenticationsTable.lastFailedTime', {
defaultMessage: 'Last Failure',
});

export const SUCCESSES = i18n.translate('xpack.secops.authenticationsTable.successes', {
Expand All @@ -30,10 +57,10 @@ export const USER = i18n.translate('xpack.secops.authenticationsTable.user', {
defaultMessage: 'User',
});

export const AUTHENTICATION_FAILURES = i18n.translate(
export const AUTHENTICATIONS = i18n.translate(
'xpack.secops.authenticationsTable.authenticationFailures',
{
defaultMessage: 'Authentication Failures',
defaultMessage: 'Authentications',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,26 @@ export const authenticationsQuery = gql`
user {
name
}
source {
ip
lastSuccess {
timestamp
source {
ip
}
host {
id
name
}
}
host {
id
name
lastFailure {
timestamp
source {
ip
}
host {
id
name
}
}
latest
}
cursor {
value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const AuthenticationsComponentQuery = pure<AuthenticationsProps>(
variables: {
pagination: {
cursor: newCursor,
limit,
limit: limit + parseInt(newCursor, 10),
},
},
updateQuery: (prev, { fetchMoreResult }) => {
Expand Down
Loading

0 comments on commit 1972f3f

Please sign in to comment.