Skip to content

Commit 1cfb08c

Browse files
Robert Austinkevinlogelasticmachinelegregonnamdifrankie
authored
[7.x] [Endpoint] Adding Endpoint to 7.x (#57867)
* Add Endpoint plugin and Resolver embeddable (#51994) * Add functional tests for plugins to x-pack (so we can do a functional test of the Resolver embeddable) * Add Endpoint plugin * Add Resolver embeddable * Test that Resolver embeddable can be rendered Conflicts: x-pack/.i18nrc.json x-pack/test/api_integration/apis/index.js * [Endpoint] Register endpoint app (#53527) * register app, create functional test * formatting * update tests * adjust test data for endpoint * add endpoint tests for testing spaces, app enabled, disabled, etc * linting * add read privileges to endpoint * rename variable since its used now * remove deprecated context * remove unused variable * fix type check * correct test suite message Co-Authored-By: Larry Gregory <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Larry Gregory <[email protected]> * [Endpoint] add react router to endpoint app (#53808) * add react router to endpoint app * linting * linting * linting * correct tests * change history from hash to browser, add new test util * remove default values in helper functions * fix type check, use FunctionComponent as oppsed to FC * use BrowserRouter component * use BrowserRouter component lin * add comments to test framework, change function name to include browserHistory Co-authored-by: Elastic Machine <[email protected]> * EMT-issue-65: add endpoint list api (#53861) add endpoint list api * EMT-65:always return accurate endpoint count (#54423) EMT-65:always return accurate endpoint count, independent of paging properties * Resolver component w/ sample data (#53619) Resolver is a map. It shows processes that ran on a computer. The processes are drawn as nodes and lines connect processes with their parents. Resolver is not yet implemented in Kibana. This PR adds a 'map' type UX. The user can click and drag to pan the map and zoom using trackpad pinching (or ctrl and mousewheel.) There is no code providing actual data. Sample data is included. The sample data is used to draw a map. The fundamental info needed is: process names the parent of a process With this info we can topologically lay out the processes. The sample data isn't yet in a realistic format. We'll be fixing that soon. Related issue: elastic/endpoint-app-team#30 * Resolver test plugin not using mount context. (#54933) Mount context was deprecated. Use core.getStartServices() instead. * Resolver nonlinear zoom (#54936) * [Endpoint] add Redux saga Middleware and app Store (#53906) * Added saga library * Initialize endpoint app redux store * Resolver is overflow: hidden to prevent obscured elements from showing up (#55076) * [Endpoint] Fix saga to start only after store is created and stopped on app unmount (#55245) - added `stop()`/`start()` methods to the Saga Middleware creator factory - adjust tests based on changes - changed application `renderApp` to stop sagas when react app is unmounted * Resolver zoom, pan, and center controls (#55221) * Resolver zoom, pan, and center controls * add tests, fix north panning * fix type issue * update west and east panning to behave like google maps * [Endpoint] FIX: Increase tests `sleep` default duration back to 100ms (#55492) Revert `sleep()` default duration, in the saga tests, back to 100ms in order to prevent intermittent failures during CI runs. Fixes #55464 Fixes #55465 * [Endpoint] EMT-65: make endpoint data types common, restructure (#54772) [Endpoint] EMT-65: make endpoint data types common, use schema changes * Basic Functionality Alert List (#55800) * sets up initial grid and data type * data feeds in from backend but doesnt update * sample data feeding in correctly * Fix combineReducers issue by importing Redux type from 'redux' package * Add usePageId hook that fires action when user navigates to page * Strict typing for middleware * addresses comments and uses better types * move types to common/types.ts * Move types to endpoint/types.ts, address PR comments blah 2 Co-authored-by: Pedro Jaramillo <[email protected]> * [Endpoint] Add Endpoint Details route (#55746) * Add Endpoint Details route * add Endpoint Details tests * sacrifices to the Type gods * update to latest endpoint schema Co-authored-by: Elastic Machine <[email protected]> * [Endpoint] EMT-67: add kql support for endpoint list (#56328) [Endpoint] EMT-67: add kql support for endpoint list * [Endpoint] ERT-82 ERT-83 ERT-84: Alert list API with pagination (#56538) * ERT-82 ERT-83 ERT-84 (partial): Add Alert List API with pagination * Better type safety for alert list API * Add Test to Verify Endpoint App Landing Page (#57129) Conflicts: x-pack/test/functional/page_objects/index.ts * fixes render bug in alert list (#57152) Co-authored-by: Elastic Machine <[email protected]> * Resolver: Animate camera, add sidebar (#55590) This PR adds a sidebar navigation. clicking the icons in the nav will focus the camera on the different nodes. There is an animation effect when the camera moves. Conflicts: yarn.lock * [Endpoint] Task/basic endpoint list (#55623) * Adds host management list to endpoint security plugin Co-authored-by: Elastic Machine <[email protected]> * [Endpoint] Policy List UI route and initial view (#56918) * Initial Policy List view * Add `endpoint/policy` route and displays Policy List * test cases (both unit and functional) Does not yet interact with API (Ingest). * Add ApplicationService app status management (#50223) This was already backported, but changes to endpoint app could not be backported, since endpoint app itself hadn't been backported. Now that the endpoint app is backported, reapply the endpoint specific changes from the original commit. * Implements `getStartServices` on server-side (#55156) This was already backported, but changes to endpoint app could not be backported, since endpoint app itself hadn't been backported. Now that the endpoint app is backported, reapply the endpoint specific changes from the original commit. * [ui/utils/query_string]: Remove unused methods & migrate apps to querystring lib (#56957) This was already backported, but changes to endpoint app could not be backported, since endpoint app itself hadn't been backported. Now that the endpoint app is backported, reapply the endpoint specific changes from the original commit. Co-authored-by: Kevin Logan <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Larry Gregory <[email protected]> Co-authored-by: nnamdifrankie <[email protected]> Co-authored-by: Davis Plumlee <[email protected]> Co-authored-by: Paul Tavares <[email protected]> Co-authored-by: Pedro Jaramillo <[email protected]> Co-authored-by: Dan Panzarella <[email protected]> Co-authored-by: Madison Caldwell <[email protected]> Co-authored-by: Charlie Pichette <[email protected]> Co-authored-by: Candace Park <[email protected]> Co-authored-by: Pierre Gayvallet <[email protected]> Co-authored-by: Alexey Antonov <[email protected]>
1 parent 48b2a33 commit 1cfb08c

File tree

146 files changed

+22497
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+22497
-16
lines changed

test/functional/page_objects/common_page.ts

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
3939
const defaultTryTimeout = config.get('timeouts.try');
4040
const defaultFindTimeout = config.get('timeouts.find');
4141

42+
interface NavigateProps {
43+
appConfig: {};
44+
ensureCurrentUrl: boolean;
45+
shouldLoginIfPrompted: boolean;
46+
shouldAcceptAlert: boolean;
47+
useActualUrl: boolean;
48+
}
49+
4250
class CommonPage {
4351
/**
4452
* Navigates the browser window to provided URL
@@ -115,6 +123,34 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
115123
return currentUrl;
116124
}
117125

126+
private async navigate(navigateProps: NavigateProps) {
127+
const {
128+
appConfig,
129+
ensureCurrentUrl,
130+
shouldLoginIfPrompted,
131+
shouldAcceptAlert,
132+
useActualUrl,
133+
} = navigateProps;
134+
const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);
135+
136+
await retry.try(async () => {
137+
if (useActualUrl) {
138+
log.debug(`navigateToActualUrl ${appUrl}`);
139+
await browser.get(appUrl);
140+
} else {
141+
await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
142+
}
143+
144+
const currentUrl = shouldLoginIfPrompted
145+
? await this.loginIfPrompted(appUrl)
146+
: await browser.getCurrentUrl();
147+
148+
if (ensureCurrentUrl && !currentUrl.includes(appUrl)) {
149+
throw new Error(`expected ${currentUrl}.includes(${appUrl})`);
150+
}
151+
});
152+
}
153+
118154
/**
119155
* Navigates browser using the pathname from the appConfig and subUrl as the hash
120156
* @param appName As defined in the apps config, e.g. 'home'
@@ -137,23 +173,44 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
137173
hash: useActualUrl ? subUrl : `/${appName}/${subUrl}`,
138174
};
139175

140-
const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);
141-
142-
await retry.try(async () => {
143-
if (useActualUrl) {
144-
log.debug(`navigateToActualUrl ${appUrl}`);
145-
await browser.get(appUrl);
146-
} else {
147-
await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
148-
}
176+
await this.navigate({
177+
appConfig,
178+
ensureCurrentUrl,
179+
shouldLoginIfPrompted,
180+
shouldAcceptAlert,
181+
useActualUrl,
182+
});
183+
}
149184

150-
const currentUrl = shouldLoginIfPrompted
151-
? await this.loginIfPrompted(appUrl)
152-
: await browser.getCurrentUrl();
185+
/**
186+
* Navigates browser using the pathname from the appConfig and subUrl as the extended path.
187+
* This was added to be able to test an application that uses browser history over hash history.
188+
* @param appName As defined in the apps config, e.g. 'home'
189+
* @param subUrl The route after the appUrl, e.g. 'tutorial_directory/sampleData'
190+
* @param args additional arguments
191+
*/
192+
public async navigateToUrlWithBrowserHistory(
193+
appName: string,
194+
subUrl?: string,
195+
{
196+
basePath = '',
197+
ensureCurrentUrl = true,
198+
shouldLoginIfPrompted = true,
199+
shouldAcceptAlert = true,
200+
useActualUrl = true,
201+
} = {}
202+
) {
203+
const appConfig = {
204+
// subUrl following the basePath, assumes no hashes. Ex: 'app/endpoint/management'
205+
pathname: `${basePath}${config.get(['apps', appName]).pathname}${subUrl}`,
206+
};
153207

154-
if (ensureCurrentUrl && !currentUrl.includes(appUrl)) {
155-
throw new Error(`expected ${currentUrl}.includes(${appUrl})`);
156-
}
208+
await this.navigate({
209+
appConfig,
210+
ensureCurrentUrl,
211+
shouldLoginIfPrompted,
212+
shouldAcceptAlert,
213+
useActualUrl,
157214
});
158215
}
159216

x-pack/.i18nrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"xpack.transform": "legacy/plugins/transform",
4040
"xpack.upgradeAssistant": "legacy/plugins/upgrade_assistant",
4141
"xpack.uptime": "legacy/plugins/uptime",
42-
"xpack.watcher": "plugins/watcher"
42+
"xpack.watcher": "plugins/watcher",
43+
"xpack.endpoint": "plugins/endpoint"
4344
},
4445
"translations": [
4546
"plugins/translations/translations/zh-CN.json",
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
/**
8+
* A deep readonly type that will make all children of a given object readonly recursively
9+
*/
10+
export type Immutable<T> = T extends undefined | null | boolean | string | number
11+
? T
12+
: T extends Array<infer U>
13+
? ImmutableArray<U>
14+
: T extends Map<infer K, infer V>
15+
? ImmutableMap<K, V>
16+
: T extends Set<infer M>
17+
? ImmutableSet<M>
18+
: ImmutableObject<T>;
19+
20+
export type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
21+
export type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
22+
export type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
23+
export type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
24+
25+
export class EndpointAppConstants {
26+
static ALERT_INDEX_NAME = 'my-index';
27+
static ENDPOINT_INDEX_NAME = 'endpoint-agent*';
28+
}
29+
30+
export interface AlertResultList {
31+
/**
32+
* The alerts restricted by page size.
33+
*/
34+
alerts: AlertData[];
35+
36+
/**
37+
* The total number of alerts on the page.
38+
*/
39+
total: number;
40+
41+
/**
42+
* The size of the requested page.
43+
*/
44+
request_page_size: number;
45+
46+
/**
47+
* The index of the requested page, starting at 0.
48+
*/
49+
request_page_index: number;
50+
51+
/**
52+
* The offset of the requested page, starting at 0.
53+
*/
54+
result_from_index: number;
55+
}
56+
57+
export interface EndpointResultList {
58+
/* the endpoints restricted by the page size */
59+
endpoints: EndpointMetadata[];
60+
/* the total number of unique endpoints in the index */
61+
total: number;
62+
/* the page size requested */
63+
request_page_size: number;
64+
/* the page index requested */
65+
request_page_index: number;
66+
}
67+
68+
export interface AlertData {
69+
'@timestamp': Date;
70+
agent: {
71+
id: string;
72+
version: string;
73+
};
74+
event: {
75+
action: string;
76+
};
77+
file_classification: {
78+
malware_classification: {
79+
score: number;
80+
};
81+
};
82+
host: {
83+
hostname: string;
84+
ip: string;
85+
os: {
86+
name: string;
87+
};
88+
};
89+
thread: {};
90+
}
91+
92+
export interface EndpointMetadata {
93+
event: {
94+
created: Date;
95+
};
96+
endpoint: {
97+
policy: {
98+
id: string;
99+
};
100+
};
101+
agent: {
102+
version: string;
103+
id: string;
104+
};
105+
host: {
106+
id: string;
107+
hostname: string;
108+
ip: string[];
109+
mac: string[];
110+
os: {
111+
name: string;
112+
full: string;
113+
version: string;
114+
};
115+
};
116+
}
117+
118+
/**
119+
* The PageId type is used for the payload when firing userNavigatedToPage actions
120+
*/
121+
export type PageId = 'alertsPage' | 'managementPage' | 'policyListPage';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "endpoint",
3+
"version": "1.0.0",
4+
"kibanaVersion": "kibana",
5+
"configPath": ["xpack", "endpoint"],
6+
"requiredPlugins": ["features", "embeddable"],
7+
"server": true,
8+
"ui": true
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"author": "Elastic",
3+
"name": "endpoint",
4+
"version": "0.0.0",
5+
"private": true,
6+
"license": "Elastic-License",
7+
"scripts": {},
8+
"dependencies": {
9+
"react-redux": "^7.1.0"
10+
},
11+
"devDependencies": {
12+
"@types/react-redux": "^7.1.0",
13+
"redux-devtools-extension": "^2.13.8"
14+
}
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import styled from 'styled-components';
8+
9+
export const TruncateText = styled.div`
10+
overflow: hidden;
11+
white-space: nowrap;
12+
text-overflow: ellipsis;
13+
`;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import * as React from 'react';
8+
import ReactDOM from 'react-dom';
9+
import { CoreStart, AppMountParameters } from 'kibana/public';
10+
import { I18nProvider, FormattedMessage } from '@kbn/i18n/react';
11+
import { Route, BrowserRouter, Switch } from 'react-router-dom';
12+
import { Provider } from 'react-redux';
13+
import { Store } from 'redux';
14+
import { appStoreFactory } from './store';
15+
import { AlertIndex } from './view/alerts';
16+
import { ManagementList } from './view/managing';
17+
import { PolicyList } from './view/policy';
18+
19+
/**
20+
* This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle.
21+
*/
22+
export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMountParameters) {
23+
coreStart.http.get('/api/endpoint/hello-world');
24+
25+
const store = appStoreFactory(coreStart);
26+
27+
ReactDOM.render(<AppRoot basename={appBasePath} store={store} />, element);
28+
29+
return () => {
30+
ReactDOM.unmountComponentAtNode(element);
31+
};
32+
}
33+
34+
interface RouterProps {
35+
basename: string;
36+
store: Store;
37+
}
38+
39+
const AppRoot: React.FunctionComponent<RouterProps> = React.memo(({ basename, store }) => (
40+
<Provider store={store}>
41+
<I18nProvider>
42+
<BrowserRouter basename={basename}>
43+
<Switch>
44+
<Route
45+
exact
46+
path="/"
47+
render={() => (
48+
<h1 data-test-subj="welcomeTitle">
49+
<FormattedMessage id="xpack.endpoint.welcomeTitle" defaultMessage="Hello World" />
50+
</h1>
51+
)}
52+
/>
53+
<Route path="/management" component={ManagementList} />
54+
<Route path="/alerts" component={AlertIndex} />
55+
<Route path="/policy" exact component={PolicyList} />
56+
<Route
57+
render={() => (
58+
<FormattedMessage id="xpack.endpoint.notFound" defaultMessage="Page Not Found" />
59+
)}
60+
/>
61+
</Switch>
62+
</BrowserRouter>
63+
</I18nProvider>
64+
</Provider>
65+
));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export * from './saga';

0 commit comments

Comments
 (0)