Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into fix/url-rewri…
Browse files Browse the repository at this point in the history
…tes-in-dist-styles
  • Loading branch information
spalger committed Feb 27, 2020
2 parents 3a75a11 + a25ba4e commit 3188314
Show file tree
Hide file tree
Showing 38 changed files with 1,282 additions and 6,005 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-project-assigner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Assign a PR to project based on label
steps:
- name: Assign to project
uses: elastic/github-actions/[email protected].2
uses: elastic/github-actions/[email protected].3
id: project_assigner
with:
issue-mappings: |
Expand All @@ -17,4 +17,4 @@ jobs:
{ "label": "Feature:Lens", "projectName": "Lens", "columnId": 6219362 },
{ "label": "Team:Canvas", "projectName": "canvas", "columnId": 6187580 }
]
ghToken: ${{ secrets.GITHUB_TOKEN }}
ghToken: ${{ secrets.PROJECT_ASSIGNER_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/project-assigner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
name: Assign issue or PR to project based on label
steps:
- name: Assign to project
uses: elastic/github-actions/[email protected].2
uses: elastic/github-actions/[email protected].3
id: project_assigner
with:
issue-mappings: '[{"label": "Team:AppArch", "projectName": "kibana-app-arch", "columnId": 6173895}, {"label": "Feature:Lens", "projectName": "Lens", "columnId": 6219363}, {"label": "Team:Canvas", "projectName": "canvas", "columnId": 6187593}]'
ghToken: ${{ secrets.GITHUB_TOKEN }}
ghToken: ${{ secrets.PROJECT_ASSIGNER_TOKEN }}


2 changes: 2 additions & 0 deletions src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
fromKueryExpression,
toElasticsearchQuery,
buildEsQuery,
buildQueryFromFilters,
getEsQueryConfig,
} from '../common';

Expand All @@ -67,6 +68,7 @@ export const esKuery = {
};

export const esQuery = {
buildQueryFromFilters,
getEsQueryConfig,
buildEsQuery,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { storiesOf } from '@storybook/react';
import cytoscape from 'cytoscape';
import React from 'react';
import { Cytoscape } from './Cytoscape';

const elements: cytoscape.ElementDefinition[] = [
{
data: {
id: 'opbeans-python',
label: 'opbeans-python',
agentName: 'python',
type: 'service'
}
},
{
data: {
id: 'opbeans-node',
label: 'opbeans-node',
agentName: 'nodejs',
type: 'service'
}
},
{
data: {
id: 'opbeans-ruby',
label: 'opbeans-ruby',
agentName: 'ruby',
type: 'service'
}
},
{ data: { source: 'opbeans-python', target: 'opbeans-node' } },
{
data: {
bidirectional: true,
source: 'opbeans-python',
target: 'opbeans-ruby'
}
}
];
const height = 300;
const serviceName = 'opbeans-python';

storiesOf('app/ServiceMap/Cytoscape', module).add(
'example',
() => {
return (
<Cytoscape
elements={elements}
height={height}
serviceName={serviceName}
/>
);
},
{
info: {
source: false
}
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const animationOptions: cytoscape.AnimationOptions = {
// @ts-ignore The cubic-bezier options here are not recognized by the cytoscape types
easing: theme.euiAnimSlightBounce
};

const lineColor = '#C5CCD7';
export const nodeHeight = parseInt(theme.avatarSizing.l.size, 10);

const layout = {
Expand Down Expand Up @@ -42,14 +42,14 @@ const style: cytoscape.Stylesheet[] = [
'background-image': (el: cytoscape.NodeSingular) =>
iconForNode(el) ?? defaultIcon,
'background-height': (el: cytoscape.NodeSingular) =>
isService(el) ? '80%' : '40%',
isService(el) ? '85%' : '40%',
'background-width': (el: cytoscape.NodeSingular) =>
isService(el) ? '80%' : '40%',
isService(el) ? '85%' : '40%',
'border-color': (el: cytoscape.NodeSingular) =>
el.hasClass('primary')
? theme.euiColorSecondary
el.hasClass('primary') || el.selected()
? theme.euiColorPrimary
: theme.euiColorMediumShade,
'border-width': 2,
'border-width': 1,
color: theme.textColors.default,
// theme.euiFontFamily doesn't work here for some reason, so we're just
// specifying a subset of the fonts for the label text.
Expand All @@ -76,9 +76,9 @@ const style: cytoscape.Stylesheet[] = [
selector: 'edge',
style: {
'curve-style': 'bezier',
'line-color': theme.euiColorMediumShade,
'line-color': lineColor,
'overlay-opacity': 0,
'target-arrow-color': theme.euiColorMediumShade,
'target-arrow-color': lineColor,
'target-arrow-shape': 'triangle',
// The DefinitelyTyped definitions don't specify this property since it's
// fairly new.
Expand All @@ -93,6 +93,7 @@ const style: cytoscape.Stylesheet[] = [
selector: 'edge[bidirectional]',
style: {
'source-arrow-shape': 'triangle',
'source-arrow-color': lineColor,
'target-arrow-shape': 'triangle',
// @ts-ignore
'source-distance-from-node': theme.paddingSizes.xs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ const icons: { [key: string]: string } = {
resource: globeIcon
};

const serviceIcons: { [key: string]: string } = {
dotnet: getAvatarIcon('.N', '#8562AD'),
go: getAvatarIcon('Go', '#00A9D6'),
java: getAvatarIcon('Jv', '#41717E'),
'js-base': getAvatarIcon('JS', '#F0DB4E', theme.euiTextColor),
nodejs: getAvatarIcon('No', '#689E62'),
python: getAvatarIcon('Py', '#376994'),
ruby: getAvatarIcon('Rb', '#CC362E')
const serviceAbbreviations: { [key: string]: string } = {
dotnet: '.N',
go: 'Go',
java: 'Jv',
'js-base': 'JS',
nodejs: 'No',
python: 'Py',
ruby: 'Rb'
};

export const defaultIcon = getAvatarIcon();
Expand All @@ -59,8 +59,14 @@ const isIE11 = !!window.MSInputMethodContext && !!document.documentMode;

export function iconForNode(node: cytoscape.NodeSingular) {
const type = node.data('type');

if (type === 'service') {
return serviceIcons[node.data('agentName') as string];
return getAvatarIcon(
serviceAbbreviations[node.data('agentName') as string],
node.selected() || node.hasClass('primary')
? theme.euiColorPrimary
: theme.euiColorDarkestShade
);
} else if (isIE11) {
return defaultIcon;
} else {
Expand Down
71 changes: 67 additions & 4 deletions x-pack/plugins/endpoint/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SearchResponse } from 'elasticsearch';

/**
* A deep readonly type that will make all children of a given object readonly recursively
*/
Expand All @@ -22,14 +24,28 @@ export type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
export type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
export type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };

export enum Direction {
asc = 'asc',
desc = 'desc',
}

export class EndpointAppConstants {
static BASE_API_URL = '/api/endpoint';
static ALERT_INDEX_NAME = 'my-index';
static ENDPOINT_INDEX_NAME = 'endpoint-agent*';
static EVENT_INDEX_NAME = 'endpoint-events-*';
static DEFAULT_TOTAL_HITS = 10000;
/**
* Legacy events are stored in indices with endgame-* prefix
*/
static LEGACY_EVENT_INDEX_NAME = 'endgame-*';

/**
* Alerts
**/
static ALERT_LIST_DEFAULT_PAGE_SIZE = 10;
static ALERT_LIST_DEFAULT_SORT = '@timestamp';
static ALERT_LIST_DEFAULT_ORDER = Direction.desc;
}

export interface AlertResultList {
Expand All @@ -51,12 +67,22 @@ export interface AlertResultList {
/**
* The index of the requested page, starting at 0.
*/
request_page_index: number;
request_page_index?: number;

/**
* The offset of the requested page, starting at 0.
*/
result_from_index: number;
result_from_index?: number;

/**
* A cursor-based URL for the next page.
*/
next: string | null;

/**
* A cursor-based URL for the previous page.
*/
prev: string | null;
}

export interface EndpointResultList {
Expand All @@ -70,13 +96,18 @@ export interface EndpointResultList {
request_page_index: number;
}

export interface AlertData {
'@timestamp': string;
/**
* Describes an Alert Event.
* Should be in line with ECS schema.
*/
export type AlertEvent = Immutable<{
'@timestamp': number;
agent: {
id: string;
version: string;
};
event: {
id: string;
action: string;
};
file_classification: {
Expand All @@ -91,9 +122,28 @@ export interface AlertData {
name: string;
};
};
process: {
pid: number;
};
thread: {};
}>;

/**
* Metadata associated with an alert event.
*/
interface AlertMetadata {
id: string;

// Alert Details Pagination
next: string | null;
prev: string | null;
}

/**
* Union of alert data and metadata.
*/
export type AlertData = AlertEvent & AlertMetadata;

export interface EndpointMetadata {
event: {
created: Date;
Expand Down Expand Up @@ -122,6 +172,19 @@ export interface EndpointMetadata {
};
}

/**
* Represents `total` response from Elasticsearch after ES 7.0.
*/
export interface ESTotal {
value: number;
relation: string;
}

/**
* `Hits` array in responses from ES search API.
*/
export type AlertHits = SearchResponse<AlertEvent>['hits']['hits'];

export interface LegacyEndpointEvent {
'@timestamp': Date;
endgame: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ export const mockAlertResultList: (options?: {
const alerts = [];
for (let index = 0; index < actualCountToReturn; index++) {
alerts.push({
'@timestamp': new Date(1542341895000).toString(),
'@timestamp': 1542341895000,
id: 'xDUYMHABAJk0XnHd8rrd',
agent: {
id: 'ced9c68e-b94a-4d66-bb4c-6106514f0a2f',
version: '3.0.0',
},
event: {
id: '2f1c0928-3876-4e11-acbb-9199257c7b1c',
action: 'open',
},
file_classification: {
malware_classification: {
score: 3,
},
},
process: {
pid: 107,
},
host: {
hostname: 'HD-c15-bc09190a',
ip: '10.179.244.14',
Expand All @@ -47,13 +52,17 @@ export const mockAlertResultList: (options?: {
},
},
thread: {},
prev: null,
next: null,
});
}
const mock: AlertResultList = {
alerts,
total,
request_page_size: requestPageSize,
request_page_index: requestPageIndex,
next: '/api/endpoint/alerts?after=1542341895000&after=2f1c0928-3876-4e11-acbb-9199257c7b1c',
prev: '/api/endpoint/alerts?before=1542341895000&before=2f1c0928-3876-4e11-acbb-9199257c7b1c',
result_from_index: 0,
};
return mock;
Expand Down
Loading

0 comments on commit 3188314

Please sign in to comment.