Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Sep 16, 2020
1 parent 1722514 commit 9149cff
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { HostsKpiHostsStrategyResponse } from './hosts';
import { HostsKpiUniqueIpsStrategyResponse } from './unique_ips';

export enum HostsKpiQueries {
authentications = 'hostsKpiAuthentications',
hosts = 'hostsKpiHosts',
uniqueIps = 'hostsKpiUniqueIps',
kpiAuthentications = 'hostsKpiAuthentications',
kpiHosts = 'hostsKpiHosts',
kpiUniqueIps = 'hostsKpiUniqueIps',
}

export type HostsKpiStrategyResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ export type StrategyResponseType<T extends FactoryQueryTypes> = T extends HostsQ
? HostFirstLastSeenStrategyResponse
: T extends HostsQueries.uncommonProcesses
? HostUncommonProcessesStrategyResponse
: T extends HostsKpiQueries.authentications
: T extends HostsKpiQueries.kpiAuthentications
? HostsKpiAuthenticationsStrategyResponse
: T extends HostsKpiQueries.hosts
: T extends HostsKpiQueries.kpiHosts
? HostsKpiHostsStrategyResponse
: T extends HostsKpiQueries.uniqueIps
: T extends HostsKpiQueries.kpiUniqueIps
? HostsKpiUniqueIpsStrategyResponse
: T extends NetworkQueries.details
? NetworkDetailsStrategyResponse
Expand Down Expand Up @@ -162,11 +162,11 @@ export type StrategyRequestType<T extends FactoryQueryTypes> = T extends HostsQu
? HostFirstLastSeenRequestOptions
: T extends HostsQueries.uncommonProcesses
? HostUncommonProcessesRequestOptions
: T extends HostsKpiQueries.authentications
: T extends HostsKpiQueries.kpiAuthentications
? HostsKpiAuthenticationsRequestOptions
: T extends HostsKpiQueries.hosts
: T extends HostsKpiQueries.kpiHosts
? HostsKpiHostsRequestOptions
: T extends HostsKpiQueries.uniqueIps
: T extends HostsKpiQueries.kpiUniqueIps
? HostsKpiUniqueIpsRequestOptions
: T extends NetworkQueries.details
? NetworkDetailsRequestOptions
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const useHostsKpiAuthentications = ({
HostsKpiAuthenticationsRequestOptions
>({
defaultIndex,
factoryQueryType: HostsKpiQueries.authentications,
factoryQueryType: HostsKpiQueries.kpiAuthentications,
filterQuery: createFilter(filterQuery),
id: ID,
timerange: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useHostsKpiHosts = ({
const [loading, setLoading] = useState(false);
const [hostsKpiHostsRequest, setHostsKpiHostsRequest] = useState<HostsKpiHostsRequestOptions>({
defaultIndex,
factoryQueryType: HostsKpiQueries.hosts,
factoryQueryType: HostsKpiQueries.kpiHosts,
filterQuery: createFilter(filterQuery),
id: ID,
timerange: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const useHostsKpiUniqueIps = ({
HostsKpiUniqueIpsRequestOptions
>({
defaultIndex,
factoryQueryType: HostsKpiQueries.uniqueIps,
factoryQueryType: HostsKpiQueries.kpiUniqueIps,
filterQuery: createFilter(filterQuery),
id: ID,
timerange: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const hostsFactory: Record<
[HostsQueries.firstLastSeen]: firstLastSeenHost,
[HostsQueries.uncommonProcesses]: uncommonProcesses,
[HostsQueries.authentications]: authentications,
[HostsKpiQueries.authentications]: hostsKpiAuthentications,
[HostsKpiQueries.hosts]: hostsKpiHosts,
[HostsKpiQueries.uniqueIps]: hostsKpiUniqueIps,
[HostsKpiQueries.kpiAuthentications]: hostsKpiAuthentications,
[HostsKpiQueries.kpiHosts]: hostsKpiHosts,
[HostsKpiQueries.kpiUniqueIps]: hostsKpiUniqueIps,
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { SecuritySolutionFactory } from '../../../types';
import { buildHostsKpiAuthenticationsQuery } from './query.hosts_kpi_authentications.dsl';
import { formatAuthenticationsHistogramData } from './helpers';

export const hostsKpiAuthentications: SecuritySolutionFactory<HostsKpiQueries.authentications> = {
export const hostsKpiAuthentications: SecuritySolutionFactory<HostsKpiQueries.kpiAuthentications> = {
buildDsl: (options: HostsKpiAuthenticationsRequestOptions) =>
buildHostsKpiAuthenticationsQuery(options),
parse: async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ export const buildHostsKpiAuthenticationsQuery = ({
},
];

const dslQuery = [
{
index: defaultIndex,
allowNoIndices: true,
ignoreUnavailable: true,
},
{
const dslQuery = {
index: defaultIndex,
allowNoIndices: true,
ignoreUnavailable: true,
body: {
aggs: {
authentication_success: {
filter: {
Expand Down Expand Up @@ -97,6 +95,7 @@ export const buildHostsKpiAuthenticationsQuery = ({
size: 0,
track_total_hits: false,
},
];
};

return dslQuery;
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { SecuritySolutionFactory } from '../../../types';
import { buildHostsKpiHostsQuery } from './query.hosts_kpi_hosts.dsl';
import { formatGeneralHistogramData } from '../common';

export const hostsKpiHosts: SecuritySolutionFactory<HostsKpiQueries.hosts> = {
export const hostsKpiHosts: SecuritySolutionFactory<HostsKpiQueries.kpiHosts> = {
buildDsl: (options: HostsKpiHostsRequestOptions) => buildHostsKpiHostsQuery(options),
parse: async (
options: HostsKpiHostsRequestOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ export const buildHostsKpiHostsQuery = ({
},
];

const dslQuery = [
{
index: defaultIndex,
allowNoIndices: true,
ignoreUnavailable: true,
},
{
const dslQuery = {
index: defaultIndex,
allowNoIndices: true,
ignoreUnavailable: true,
body: {
aggs: {
authentication_success: {
filter: {
Expand Down Expand Up @@ -97,6 +95,7 @@ export const buildHostsKpiHostsQuery = ({
size: 0,
track_total_hits: false,
},
];
};

return dslQuery;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import {
FactoryQueryTypes,
HostsKpiQueries,
} from '../../../../../../common/search_strategy/security_solution';

import { SecuritySolutionFactory } from '../../types';
import { hostsKpiAuthentications } from './authentications';
import { hostsKpiHosts } from './hosts';
import { hostsKpiUniqueIps } from './unique_ips';

export const hostsKpiFactory: Record<
HostsKpiQueries,
SecuritySolutionFactory<FactoryQueryTypes>
> = {
[HostsKpiQueries.authentications]: hostsKpiAuthentications,
[HostsKpiQueries.hosts]: hostsKpiHosts,
[HostsKpiQueries.uniqueIps]: hostsKpiUniqueIps,
};
export * from './authentications';
export * from './common';
export * from './hosts';
export * from './unique_ips';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { SecuritySolutionFactory } from '../../../types';
import { buildHostsKpiUniqueIpsQuery } from './query.hosts_kpi_unique_ips.dsl';
import { formatGeneralHistogramData } from '../common';

export const hostsKpiUniqueIps: SecuritySolutionFactory<HostsKpiQueries.uniqueIps> = {
export const hostsKpiUniqueIps: SecuritySolutionFactory<HostsKpiQueries.kpiUniqueIps> = {
buildDsl: (options: HostsKpiUniqueIpsRequestOptions) => buildHostsKpiUniqueIpsQuery(options),
parse: async (
options: HostsKpiUniqueIpsRequestOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ export const buildHostsKpiUniqueIpsQuery = ({
},
];

const dslQuery = [
{
index: defaultIndex,
allowNoIndices: true,
ignoreUnavailable: true,
},
{
const dslQuery = {
index: defaultIndex,
allowNoIndices: true,
ignoreUnavailable: true,
body: {
aggregations: {
unique_source_ips: {
cardinality: {
Expand Down Expand Up @@ -78,7 +76,7 @@ export const buildHostsKpiUniqueIpsQuery = ({
size: 0,
track_total_hits: false,
},
];
};

return dslQuery;
};

0 comments on commit 9149cff

Please sign in to comment.