Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Options to select index patterns #77192

Merged
merged 108 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
f630f48
init commit
stephmilovic Aug 6, 2020
a1986df
lots of cleanup
stephmilovic Aug 6, 2020
d51828d
starting on tests... problems
stephmilovic Aug 6, 2020
005e127
Merge branch 'master' into sourcerer
stephmilovic Aug 10, 2020
d4c9421
Ready for review
stephmilovic Aug 10, 2020
78a546a
remove sample data
stephmilovic Aug 10, 2020
5b1b109
remove comment and fix type
stephmilovic Aug 12, 2020
4fb260f
Merge branch 'master' into sourcerer
stephmilovic Aug 12, 2020
a5cac92
pr changes
stephmilovic Aug 12, 2020
f9d18c1
fix type
stephmilovic Aug 12, 2020
204f12c
scratchy
stephmilovic Aug 13, 2020
b1faec2
sourcerer in timeline
stephmilovic Aug 18, 2020
805b5b0
sourcerer in timeline
stephmilovic Aug 18, 2020
eece90e
merge
stephmilovic Aug 20, 2020
daa5c02
wip
stephmilovic Aug 21, 2020
e7f1655
Merge branch 'master' into sourcerer-offshoot
stephmilovic Aug 21, 2020
e9dac14
Merge branch 'master' into sourcerer-in-timeline
stephmilovic Aug 21, 2020
8312030
merge in timeline work
stephmilovic Aug 21, 2020
2cf5297
moving to redux
stephmilovic Aug 21, 2020
a9bac9a
working on types
stephmilovic Aug 21, 2020
9555121
Merge branch 'master' into sourcerer-offshoot
stephmilovic Aug 24, 2020
5ed042a
fixed
stephmilovic Aug 24, 2020
b1d2275
more adjustments, tests fixed
stephmilovic Aug 24, 2020
9a902f8
Merge branch 'master' into sourcerer-offshoot
stephmilovic Aug 25, 2020
7e294cb
FF off
stephmilovic Aug 25, 2020
b3a2d3d
pr ready
stephmilovic Aug 25, 2020
b689637
renaming
stephmilovic Aug 26, 2020
3440a5c
url state working, hoc not working
stephmilovic Aug 26, 2020
88ff613
url state working for timeline and default scope
stephmilovic Aug 26, 2020
d754299
script to build fields for beat doc
XavierM Aug 31, 2020
fa909f2
Merge branch 'sourcerer-offshoot' of github.com:stephmilovic/kibana i…
XavierM Aug 31, 2020
8d0eab5
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Aug 31, 2020
dcafb63
refactor sourcerer
XavierM Sep 10, 2020
3713ea2
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 10, 2020
23302a0
refactor host to useSourcerer
XavierM Sep 10, 2020
6040a80
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 10, 2020
ea0d731
refactor network to useSourcerer
XavierM Sep 10, 2020
4e85306
refactor overview to useSourcerer
XavierM Sep 10, 2020
0ed9ee1
refactor detections to useSourcerer
XavierM Sep 11, 2020
32efc40
wip for timelines to remove all useSource
XavierM Sep 15, 2020
934ba91
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 15, 2020
04fd00d
wip indexes timeline
XavierM Sep 15, 2020
deb5127
do component tests
stephmilovic Sep 14, 2020
8c219ca
start container tests
stephmilovic Sep 15, 2020
6ca8d08
start container tests
stephmilovic Sep 15, 2020
3518510
update selection widget of index patterns + remove last useWithSource
XavierM Sep 16, 2020
48b6dc4
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 16, 2020
9988ba6
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 16, 2020
03a1c92
add indexeNames in network kpi
XavierM Sep 16, 2020
d17e6e7
fix type errors
stephmilovic Sep 16, 2020
ee13c38
resolve merge
stephmilovic Sep 16, 2020
87e0c20
fix type
stephmilovic Sep 16, 2020
f2aee2c
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 16, 2020
248d82c
missing merge master
XavierM Sep 16, 2020
7a7969c
get existing index from config file
XavierM Sep 16, 2020
b369a11
fixing broken tests
stephmilovic Sep 16, 2020
d663f42
fixing and merging
stephmilovic Sep 16, 2020
10b8869
add saving button to avoid to many queries to be aborted
XavierM Sep 17, 2020
730833c
reducer timeline tests broke
stephmilovic Sep 17, 2020
9523896
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
stephmilovic Sep 17, 2020
0a319d8
need to rewind
stephmilovic Sep 17, 2020
a21d439
much better
stephmilovic Sep 17, 2020
41feec2
fixed
stephmilovic Sep 17, 2020
d985e8b
timeline saving index names + clean up url state to only manage default
XavierM Sep 17, 2020
f4e351b
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 17, 2020
6eba2e6
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 17, 2020
2d3a388
more test fixing
stephmilovic Sep 17, 2020
a270c62
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
stephmilovic Sep 17, 2020
c7383a7
more test changes
stephmilovic Sep 17, 2020
04b27b9
remove all the useWithSource + deprecated the graphql until we delete…
XavierM Sep 18, 2020
970add9
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 18, 2020
c218359
default timeline to all index when creation + filter index patterns t…
XavierM Sep 18, 2020
4f2a3b6
fix types
XavierM Sep 18, 2020
d221c24
test for stateful timeline render
stephmilovic Sep 18, 2020
3e2d0b9
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
stephmilovic Sep 18, 2020
eea000b
we should not have change that
XavierM Sep 18, 2020
1610035
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 18, 2020
c55baa1
no chnages + snapshot
XavierM Sep 18, 2020
0e348e2
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 18, 2020
e5d73df
fix test + bugs from review
XavierM Sep 21, 2020
85bda62
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 21, 2020
c33db66
fix uncommon processes indexNames
XavierM Sep 21, 2020
2b1122a
review III
XavierM Sep 21, 2020
03a7e18
change design for main page of the sourcerer from design
XavierM Sep 21, 2020
a812f7f
bug fixes when opening old timeline + implementation of new design
XavierM Sep 22, 2020
e7fc42a
fix circular deps
patrykkopycinski Sep 22, 2020
c5e75cb
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
patrykkopycinski Sep 22, 2020
573cddc
remove unused attributes for event details
XavierM Sep 22, 2020
31c442f
design cleanup
XavierM Sep 22, 2020
1867c45
Merge branch 'master' into sourcerer-offshoot
stephmilovic Sep 22, 2020
7a66d7c
fix api integration test with the new search strategy
XavierM Sep 23, 2020
460ee5b
add reset + manage accordion state
XavierM Sep 23, 2020
9e6a6fd
fix bugs + types issues
XavierM Sep 23, 2020
a9ba61d
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 23, 2020
8e84682
cleanup
patrykkopycinski Sep 23, 2020
087d6b5
update docs
patrykkopycinski Sep 23, 2020
5b4e7d1
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
patrykkopycinski Sep 23, 2020
886f5fb
review -> remove tooltip when popover is open
XavierM Sep 23, 2020
cb739a2
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 23, 2020
9b01f73
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 23, 2020
e608404
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
stephmilovic Sep 23, 2020
09b3ca7
cypress fixing
stephmilovic Sep 23, 2020
39b6beb
fix for ml_condition_links and url_state cypress tests
stephmilovic Sep 23, 2020
627f825
add cy wait for race condition in pagination tests
stephmilovic Sep 23, 2020
fccef71
merge master
stephmilovic Sep 23, 2020
670e7d4
missing plumbing kpi host
XavierM Sep 23, 2020
71c19e0
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 23, 2020
f329c94
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ export class IndexPatternsService {
return this.savedObjectsCache.map((obj) => obj?.attributes?.title);
};

getIdsWithTitle = async (
refresh: boolean = false
): Promise<Array<{ id: string; title: string }>> => {
if (!this.savedObjectsCache || refresh) {
await this.refreshSavedObjectsCache();
}
if (!this.savedObjectsCache) {
return [];
}
return this.savedObjectsCache.map((obj) => ({
id: obj?.id,
title: obj?.attributes?.title,
}));
};

getFieldsForTimePattern = (options: GetFieldsOptions = {}) => {
return this.apiClient.getFieldsForTimePattern(options);
};
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/security_solution/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const APP_ICON = 'securityAnalyticsApp';
export const APP_ICON_SOLUTION = 'logoSecurity';
export const APP_PATH = `/app/security`;
export const ADD_DATA_PATH = `/app/home#/tutorial_directory/security`;
export const ADD_INDEX_PATH = `/app/management/kibana/indexPatterns/create`;
export const DEFAULT_BYTES_FORMAT = 'format:bytes:defaultPattern';
export const DEFAULT_DATE_FORMAT = 'dateFormat';
export const DEFAULT_DATE_FORMAT_TZ = 'dateFormat:tz';
Expand Down Expand Up @@ -58,6 +57,8 @@ export const APP_TIMELINES_PATH = `${APP_PATH}/timelines`;
export const APP_CASES_PATH = `${APP_PATH}/cases`;
export const APP_MANAGEMENT_PATH = `${APP_PATH}/administration`;

export const DETECTIONS_SUB_PLUGIN_ID = `${APP_ID}:${SecurityPageName.detections}`;

/** The comma-delimited list of Elasticsearch indices from which the SIEM app collects events */
export const DEFAULT_INDEX_PATTERN = [
'apm-*-transaction*',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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 {
IEsSearchRequest,
IEsSearchResponse,
IFieldSubType,
} from '../../../../../../src/plugins/data/common';
import { Maybe } from '../common';

export type BeatFieldsFactoryQueryType = 'beatFields';

interface FieldInfo {
category: string;
description?: string;
example?: string | number;
format?: string;
name: string;
type?: string;
}

export interface IndexField {
/** Where the field belong */
category: string;
/** Example of field's value */
example?: Maybe<string | number>;
/** whether the field's belong to an alias index */
indexes: Array<Maybe<string>>;
/** The name of the field */
name: string;
/** The type of the field's values as recognized by Kibana */
type: string;
/** Whether the field's values can be efficiently searched for */
searchable: boolean;
/** Whether the field's values can be aggregated */
aggregatable: boolean;
/** Description of the field */
description?: Maybe<string>;
format?: Maybe<string>;
/** the elastic type as mapped in the index */
esTypes?: string[];
subType?: IFieldSubType;
readFromDocValues: boolean;
}

export type BeatFields = Record<string, FieldInfo>;

export interface IndexFieldsStrategyRequest extends IEsSearchRequest {
indices: string[];
onlyCheckIfIndicesExist: boolean;
}

export interface IndexFieldsStrategyResponse extends IEsSearchResponse {
indexFields: IndexField[];
indicesExists: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export const SavedTimelineRuntimeType = runtimeTypes.partial({
excludedRowRendererIds: unionWithNullType(runtimeTypes.array(RowRendererIdRuntimeType)),
favorite: unionWithNullType(runtimeTypes.array(SavedFavoriteRuntimeType)),
filters: unionWithNullType(runtimeTypes.array(SavedFilterRuntimeType)),
indexNames: unionWithNullType(runtimeTypes.array(runtimeTypes.string)),
kqlMode: unionWithNullType(runtimeTypes.string),
kqlQuery: unionWithNullType(SavedFilterQueryQueryRuntimeType),
title: unionWithNullType(runtimeTypes.string),
Expand Down Expand Up @@ -398,3 +399,5 @@ export const importTimelineResultSchema = runtimeTypes.exact(
);

export type ImportTimelineResultSchema = runtimeTypes.TypeOf<typeof importTimelineResultSchema>;

export type TimelineEventsType = 'all' | 'raw' | 'alert' | 'signal' | 'custom';
1 change: 1 addition & 0 deletions x-pack/plugins/security_solution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "Elastic-License",
"scripts": {
"extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js && node ../../../scripts/eslint ./public/pages/detection_engine/mitre/mitre_tactics_techniques.ts --fix",
"build-beat-doc": "node scripts/beat_docs/build.js && node ../../../scripts/eslint ./server/utils/beat_schema/fields.ts --fix",
"build-graphql-types": "node scripts/generate_types_from_graphql.js",
"cypress:open": "cypress open --config-file ./cypress/cypress.json",
"cypress:open-as-ci": "node ../../../scripts/functional_tests --config ../../test/security_solution_cypress/visual_config.ts",
Expand Down
18 changes: 7 additions & 11 deletions x-pack/plugins/security_solution/public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import { ApolloClientContext } from '../common/utils/apollo_context';
import { ManageGlobalTimeline } from '../timelines/components/manage_timeline';
import { StartServices } from '../types';
import { PageRouter } from './routes';
import { ManageSource } from '../common/containers/sourcerer';

interface StartAppComponent extends AppFrontendLibs {
children: React.ReactNode;
history: History;
Expand All @@ -56,15 +54,13 @@ const StartAppComponent: FC<StartAppComponent> = ({ children, apolloClient, hist
<ReduxStoreProvider store={store}>
<ApolloProvider client={apolloClient}>
<ApolloClientContext.Provider value={apolloClient}>
<ManageSource>
<ThemeProvider theme={theme}>
<MlCapabilitiesProvider>
<ManageUserInfo>
<PageRouter history={history}>{children}</PageRouter>
</ManageUserInfo>
</MlCapabilitiesProvider>
</ThemeProvider>
</ManageSource>
<ThemeProvider theme={theme}>
<MlCapabilitiesProvider>
<ManageUserInfo>
<PageRouter history={history}>{children}</PageRouter>
</ManageUserInfo>
</MlCapabilitiesProvider>
</ThemeProvider>
<ErrorToastDispatcher />
<GlobalToaster />
</ApolloClientContext.Provider>
Expand Down
30 changes: 16 additions & 14 deletions x-pack/plugins/security_solution/public/app/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useMemo } from 'react';
import React, { useRef } from 'react';
import styled from 'styled-components';

import { TimelineId } from '../../../common/types/timeline';
Expand All @@ -14,11 +14,12 @@ import { HeaderGlobal } from '../../common/components/header_global';
import { HelpMenu } from '../../common/components/help_menu';
import { AutoSaveWarningMsg } from '../../timelines/components/timeline/auto_save_warning';
import { UseUrlState } from '../../common/components/url_state';
import { useWithSource } from '../../common/containers/source';
import { useShowTimeline } from '../../common/utils/timeline/use_show_timeline';
import { navTabs } from './home_navigations';
import { useSignalIndex } from '../../detections/containers/detection_engine/alerts/use_signal_index';
import { useUserInfo } from '../../detections/components/user_info';
import { useInitSourcerer, useSourcererScope } from '../../common/containers/sourcerer';
import { useKibana } from '../../common/lib/kibana';
import { DETECTIONS_SUB_PLUGIN_ID } from '../../../common/constants';
import { SourcererScopeName } from '../../common/store/sourcerer/model';

const SecuritySolutionAppWrapper = styled.div`
display: flex;
Expand All @@ -42,20 +43,21 @@ interface HomePageProps {
}

const HomePageComponent: React.FC<HomePageProps> = ({ children }) => {
const { signalIndexExists, signalIndexName } = useSignalIndex();
const { application } = useKibana().services;
const subPluginId = useRef<string>('');

const indexToAdd = useMemo<string[] | null>(() => {
if (signalIndexExists && signalIndexName != null) {
return [signalIndexName];
}
return null;
}, [signalIndexExists, signalIndexName]);
application.currentAppId$.subscribe((appId) => {
subPluginId.current = appId ?? '';
});

useInitSourcerer(
subPluginId.current === DETECTIONS_SUB_PLUGIN_ID
? SourcererScopeName.detections
: SourcererScopeName.default
);
const [showTimeline] = useShowTimeline();
const { browserFields, indexPattern, indicesExist } = useWithSource('default', indexToAdd);

// side effect: this will attempt to create the signals index if it doesn't exist
useUserInfo();
const { browserFields, indexPattern, indicesExist } = useSourcererScope();

return (
<SecuritySolutionAppWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import React from 'react';
import { HeaderPage, HeaderPageProps } from '../../../common/components/header_page';
import * as i18n from './translations';

const CaseHeaderPageComponent: React.FC<HeaderPageProps> = (props) => <HeaderPage {...props} />;
const CaseHeaderPageComponent: React.FC<HeaderPageProps> = (props) => (
<HeaderPage hideSourcerer={true} {...props} />
);

CaseHeaderPageComponent.defaultProps = {
badgeOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export const CaseComponent = React.memo<CaseProps>(
<HeaderPage
backOptions={backOptions}
data-test-subj="case-view-title"
hideSourcerer={true}
titleNode={
<EditableTitle
disabled={!userCanCrud}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { alertsDefaultModel } from './default_headers';
import { useManageTimeline } from '../../../timelines/components/manage_timeline';
import * as i18n from './translations';
import { useKibana } from '../../lib/kibana';
import { SourcererScopeName } from '../../store/sourcerer/model';

export interface OwnProps {
end: string;
Expand Down Expand Up @@ -89,6 +90,7 @@ const AlertsTableComponent: React.FC<Props> = ({
defaultModel={alertsDefaultModel}
end={endDate}
id={timelineId}
scopeId={SourcererScopeName.default}
start={startDate}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const AlertsViewComponent: React.FC<AlertsComponentsProps> = ({
deleteQuery,
endDate,
filterQuery,
indexNames,
pageFilters,
setQuery,
startDate,
Expand Down Expand Up @@ -62,6 +63,7 @@ const AlertsViewComponent: React.FC<AlertsComponentsProps> = ({
endDate={endDate}
filterQuery={filterQuery}
id={ID}
indexNames={indexNames}
setQuery={setQuery}
startDate={startDate}
{...alertsHistogramConfigs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CommonQueryProps = HostsComponentsQueryProps | NetworkComponentQueryProps;
export interface AlertsComponentsProps
extends Pick<
CommonQueryProps,
'deleteQuery' | 'endDate' | 'filterQuery' | 'skip' | 'setQuery' | 'startDate'
'deleteQuery' | 'endDate' | 'filterQuery' | 'indexNames' | 'skip' | 'setQuery' | 'startDate'
> {
timelineId: TimelineIdLiteral;
pageFilters: Filter[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

import { mount, shallow } from 'enzyme';
import React from 'react';
import { MockedProvider } from 'react-apollo/test-utils';

import { mockBrowserFields, mocksSource } from '../../containers/source/mock';
import { mockBrowserFields } from '../../containers/source/mock';
import { TestProviders } from '../../mock';

import { DragDropContextWrapper } from './drag_drop_context_wrapper';
Expand All @@ -20,11 +19,9 @@ describe('DragDropContextWrapper', () => {

const wrapper = shallow(
<TestProviders>
<MockedProvider mocks={{}} addTypename={false}>
<DragDropContextWrapper browserFields={mockBrowserFields}>
{message}
</DragDropContextWrapper>
</MockedProvider>
<DragDropContextWrapper browserFields={mockBrowserFields}>
{message}
</DragDropContextWrapper>
</TestProviders>
);
expect(wrapper.find('DragDropContextWrapper')).toMatchSnapshot();
Expand All @@ -35,11 +32,9 @@ describe('DragDropContextWrapper', () => {

const wrapper = mount(
<TestProviders>
<MockedProvider mocks={mocksSource} addTypename={false}>
<DragDropContextWrapper browserFields={mockBrowserFields}>
{message}
</DragDropContextWrapper>
</MockedProvider>
<DragDropContextWrapper browserFields={mockBrowserFields}>
{message}
</DragDropContextWrapper>
</TestProviders>
);

Expand Down
Loading