Skip to content

Commit

Permalink
Merge branch 'master' into retry-rebalance-and-split-ci-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 18, 2021
2 parents 782dd4a + f7fdda5 commit 2b2eea8
Show file tree
Hide file tree
Showing 36 changed files with 1,559 additions and 1,791 deletions.
29 changes: 11 additions & 18 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,6 @@
#CC# /x-pack/legacy/plugins/canvas/ @elastic/kibana-presentation
#CC# /x-pack/plugins/dashboard_mode @elastic/kibana-presentation

# Core UI
# Exclude tutorials folder for now because they are not owned by Kibana app and most will move out soon
/src/plugins/home/public @elastic/kibana-core-ui
/src/plugins/home/server/*.ts @elastic/kibana-core-ui
/src/plugins/home/server/services/ @elastic/kibana-core-ui
/src/plugins/kibana_overview/ @elastic/kibana-core-ui
/x-pack/plugins/global_search_bar/ @elastic/kibana-core-ui
#CC# /src/plugins/newsfeed @elastic/kibana-core-ui
#CC# /src/plugins/home/public @elastic/kibana-core-ui
#CC# /src/plugins/home/server/services/ @elastic/kibana-core-ui
#CC# /src/plugins/home/ @elastic/kibana-core-ui
#CC# /x-pack/plugins/global_search_providers/ @elastic/kibana-core-ui

# Observability UIs
/x-pack/plugins/infra/ @elastic/logs-metrics-ui
Expand Down Expand Up @@ -138,10 +126,6 @@
/x-pack/test/functional/apps/maps/ @elastic/kibana-gis
/x-pack/test/functional/es_archives/maps/ @elastic/kibana-gis
/x-pack/test/visual_regression/tests/maps/index.js @elastic/kibana-gis
/x-pack/plugins/stack_alerts/server/alert_types/geo_containment @elastic/kibana-gis
/x-pack/plugins/stack_alerts/public/alert_types/geo_containment @elastic/kibana-gis
/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold @elastic/kibana-gis
/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold @elastic/kibana-gis
#CC# /src/plugins/maps_legacy/ @elastic/kibana-gis
#CC# /src/plugins/maps_oss/ @elastic/kibana-gis
#CC# /x-pack/plugins/file_upload @elastic/kibana-gis
Expand Down Expand Up @@ -200,6 +184,11 @@
/src/plugins/status_page/ @elastic/kibana-core
/src/plugins/saved_objects_management/ @elastic/kibana-core
/src/dev/run_check_published_api_changes.ts @elastic/kibana-core
/src/plugins/home/public @elastic/kibana-core
/src/plugins/home/server/*.ts @elastic/kibana-core
/src/plugins/home/server/services/ @elastic/kibana-core
/src/plugins/kibana_overview/ @elastic/kibana-core
/x-pack/plugins/global_search_bar/ @elastic/kibana-core
#CC# /src/core/server/csp/ @elastic/kibana-core
#CC# /src/legacy/server/config/ @elastic/kibana-core
#CC# /src/legacy/server/http/ @elastic/kibana-core
Expand All @@ -210,6 +199,11 @@
#CC# /x-pack/plugins/cloud/ @elastic/kibana-core
#CC# /x-pack/plugins/features/ @elastic/kibana-core
#CC# /x-pack/plugins/global_search/ @elastic/kibana-core
#CC# /src/plugins/newsfeed @elastic/kibana-core
#CC# /src/plugins/home/public @elastic/kibana-core
#CC# /src/plugins/home/server/services/ @elastic/kibana-core
#CC# /src/plugins/home/ @elastic/kibana-core
#CC# /x-pack/plugins/global_search_providers/ @elastic/kibana-core

# Kibana Telemetry
/packages/kbn-analytics/ @elastic/kibana-core
Expand All @@ -236,7 +230,6 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
# Security
/src/core/server/csp/ @elastic/kibana-security @elastic/kibana-core
/src/plugins/security_oss/ @elastic/kibana-security
/src/plugins/spaces_oss/ @elastic/kibana-security
/test/security_functional/ @elastic/kibana-security
/x-pack/plugins/spaces/ @elastic/kibana-security
/x-pack/plugins/encrypted_saved_objects/ @elastic/kibana-security
Expand All @@ -263,7 +256,7 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/ @elastic/kibana-alerting-services
/docs/user/alerting/ @elastic/kibana-alerting-services
/docs/management/alerting/ @elastic/kibana-alerting-services
#CC# /x-pack/plugins/stack_alerts/ @elastic/kibana-alerting-services
#CC# /x-pack/plugins/stack_alerts @elastic/kibana-alerting-services

# Enterprise Search
# Shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class SearchSessionService implements ISessionService {
filter,
namespaces: ['*'],
});
this.logger.warn(`getAllMappedSavedObjects | Got ${res.saved_objects.length} items`);
this.logger.debug(`getAllMappedSavedObjects | Got ${res.saved_objects.length} items`);
return res.saved_objects;
}

Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/event_log/server/es/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('createEsContext', () => {
logger,
clusterClientPromise: Promise.resolve(clusterClient),
indexNameRoot: 'test0',
kibanaVersion: '1.2.3',
});

expect(context.initialized).toBeFalsy();
Expand All @@ -38,6 +39,7 @@ describe('createEsContext', () => {
logger,
clusterClientPromise: Promise.resolve(clusterClient),
indexNameRoot: 'test-index',
kibanaVersion: '1.2.3',
});

const esNames = context.esNames;
Expand All @@ -57,6 +59,7 @@ describe('createEsContext', () => {
logger,
clusterClientPromise: Promise.resolve(clusterClient),
indexNameRoot: 'test1',
kibanaVersion: '1.2.3',
});
clusterClient.callAsInternalUser.mockResolvedValue(false);

Expand All @@ -74,6 +77,7 @@ describe('createEsContext', () => {
logger,
clusterClientPromise: Promise.resolve(clusterClient),
indexNameRoot: 'test2',
kibanaVersion: '1.2.3',
});
clusterClient.callAsInternalUser.mockResolvedValue(true);
context.initialize();
Expand All @@ -98,6 +102,7 @@ describe('createEsContext', () => {
logger,
clusterClientPromise: Promise.resolve(clusterClient),
indexNameRoot: 'test2',
kibanaVersion: '1.2.3',
});
context.initialize();
const success = await context.waitTillReady();
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/event_log/server/es/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface EsContextCtorParams {
logger: Logger;
clusterClientPromise: Promise<EsClusterClient>;
indexNameRoot: string;
kibanaVersion: string;
}

class EsContextImpl implements EsContext {
Expand All @@ -47,7 +48,7 @@ class EsContextImpl implements EsContext {

constructor(params: EsContextCtorParams) {
this.logger = params.logger;
this.esNames = getEsNames(params.indexNameRoot);
this.esNames = getEsNames(params.indexNameRoot, params.kibanaVersion);
this.readySignal = createReadySignal();
this.initialized = false;
this.esAdapter = new ClusterClientAdapter({
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/event_log/server/es/documents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ describe('getIlmPolicy()', () => {
});

describe('getIndexTemplate()', () => {
const esNames = getEsNames('XYZ');
const kibanaVersion = '1.2.3';
const esNames = getEsNames('XYZ', kibanaVersion);

test('returns the correct details of the index template', () => {
const indexTemplate = getIndexTemplate(esNames);
Expand Down
16 changes: 9 additions & 7 deletions x-pack/plugins/event_log/server/es/names.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ jest.mock('../lib/../../../../package.json', () => ({
describe('getEsNames()', () => {
test('works as expected', () => {
const base = 'XYZ';
const version = '1.2.3';
const esNames = getEsNames(base);
const kibanaVersion = '1.2.3';
const esNames = getEsNames(base, kibanaVersion);
expect(esNames.base).toEqual(base);
expect(esNames.alias).toEqual(`${base}-event-log-${version}`);
expect(esNames.alias).toEqual(`${base}-event-log-${kibanaVersion}`);
expect(esNames.ilmPolicy).toEqual(`${base}-event-log-policy`);
expect(esNames.indexPattern).toEqual(`${base}-event-log-*`);
expect(esNames.indexPatternWithVersion).toEqual(`${base}-event-log-${version}-*`);
expect(esNames.initialIndex).toEqual(`${base}-event-log-${version}-000001`);
expect(esNames.indexTemplate).toEqual(`${base}-event-log-${version}-template`);
expect(esNames.indexPatternWithVersion).toEqual(`${base}-event-log-${kibanaVersion}-*`);
expect(esNames.initialIndex).toEqual(`${base}-event-log-${kibanaVersion}-000001`);
expect(esNames.indexTemplate).toEqual(`${base}-event-log-${kibanaVersion}-template`);
});

test('ilm policy name does not contain dot prefix', () => {
const base = '.XYZ';
const esNames = getEsNames(base);
const kibanaVersion = '1.2.3';

const esNames = getEsNames(base, kibanaVersion);
expect(esNames.ilmPolicy).toEqual('XYZ-event-log-policy');
});
});
6 changes: 2 additions & 4 deletions x-pack/plugins/event_log/server/es/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import xPackage from '../../../../package.json';

const EVENT_LOG_NAME_SUFFIX = `-event-log`;
const EVENT_LOG_VERSION_SUFFIX = `-${xPackage.version}`;

export interface EsNames {
base: string;
Expand All @@ -19,7 +16,8 @@ export interface EsNames {
indexTemplate: string;
}

export function getEsNames(baseName: string): EsNames {
export function getEsNames(baseName: string, kibanaVersion: string): EsNames {
const EVENT_LOG_VERSION_SUFFIX = `-${kibanaVersion.toLocaleLowerCase()}`;
const eventLogName = `${baseName}${EVENT_LOG_NAME_SUFFIX}`;
const eventLogNameWithVersion = `${eventLogName}${EVENT_LOG_VERSION_SUFFIX}`;
const eventLogPolicyName = `${
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/event_log/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ export class Plugin implements CorePlugin<IEventLogService, IEventLogClientServi
private globalConfig$: Observable<SharedGlobalConfig>;
private eventLogClientService?: EventLogClientService;
private savedObjectProviderRegistry: SavedObjectProviderRegistry;
private kibanaVersion: PluginInitializerContext['env']['packageInfo']['version'];

constructor(private readonly context: PluginInitializerContext) {
this.systemLogger = this.context.logger.get();
this.config$ = this.context.config.create<IEventLogConfig>();
this.globalConfig$ = this.context.config.legacy.globalConfig$;
this.savedObjectProviderRegistry = new SavedObjectProviderRegistry();
this.kibanaVersion = this.context.env.packageInfo.version;
}

async setup(core: CoreSetup): Promise<IEventLogService> {
Expand All @@ -78,6 +80,7 @@ export class Plugin implements CorePlugin<IEventLogService, IEventLogClientServi
clusterClientPromise: core
.getStartServices()
.then(([{ elasticsearch }]) => elasticsearch.legacy.client),
kibanaVersion: this.kibanaVersion,
});

this.eventLogService = new EventLogService({
Expand Down
22 changes: 22 additions & 0 deletions x-pack/plugins/event_log/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"server/**/*",
"scripts/**/*",
"generated/*",
// have to declare *.json explicitly due to https://github.com/microsoft/TypeScript/issues/25636
"generated/*.json",
"common/*"
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../spaces/tsconfig.json" }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,16 @@ describe('removeOrphanedSourcesAndLayers', () => {
removeOrphanedSourcesAndLayers(mockMbMap, [], spatialFilterLayer);
expect(mockMbMap.getStyle()).toEqual(styleWithSpatialFilters);
});

test('should not remove mapbox gl draw layers and sources', async () => {
const fooLayer = makeMultiSourceMockLayer('foo');
const layerList = [fooLayer];

const currentStyle = getMockStyle(layerList);
currentStyle.layers.push({ id: 'gl-draw-points' });
const mockMbMap = new MockMbMap(currentStyle);

removeOrphanedSourcesAndLayers(mockMbMap, layerList, spatialFilterLayer);
expect(mockMbMap.getStyle()).toEqual(currentStyle);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export function removeOrphanedSourcesAndLayers(mbMap, layerList, spatialFilterLa
return;
}

// ignore gl-draw layers
if (mbLayer.id.startsWith('gl-draw')) {
return;
}

const layer = layerList.find((layer) => {
return layer.ownsMbLayerId(mbLayer.id);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { SetStateAction, useEffect, useState } from 'react';
import { fetchQueryAlerts } from './api';
import { AlertSearchResponse } from './types';

type Func = () => void;
type Func = () => Promise<void>;

export interface ReturnQueryAlerts<Hit, Aggs> {
loading: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createSignalIndex, getSignalIndex } from './api';
import * as i18n from './translations';
import { isSecurityAppError } from '../../../../common/utils/api';

type Func = () => void;
type Func = () => Promise<void>;

export interface ReturnSignalIndex {
loading: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export const fetchRules = async ({
...showElasticRuleFilter,
].join(' AND ');

const tags = [
...(filterOptions.tags?.map((t) => `alert.attributes.tags: "${t.replace(/"/g, '\\"')}"`) ?? []),
].join(' AND ');
const tags = filterOptions.tags
.map((t) => `alert.attributes.tags: "${t.replace(/"/g, '\\"')}"`)
.join(' AND ');

const filterString =
filtersWithoutTags !== '' && tags !== ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ export interface FilterOptions {
filter: string;
sortField: RulesSortingFields;
sortOrder: SortOrder;
showCustomRules?: boolean;
showElasticRules?: boolean;
tags?: string[];
showCustomRules: boolean;
showElasticRules: boolean;
tags: string[];
}

export interface FetchRulesResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
getPrePackagedTimelineStatus,
} from '../../../pages/detection_engine/rules/helpers';

type Func = () => void;
type Func = () => Promise<void>;
export type CreatePreBuiltRules = () => Promise<boolean>;

interface ReturnPrePackagedTimelines {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ export const useRulesStatuses = (rules: Rules): ReturnRulesStatuses => {
setLoading(false);
}
};
if (rules != null && rules.length > 0) {

if (rules.length > 0) {
fetchData(rules.map((r) => r.id));
}

return () => {
isSubscribed = false;
abortCtrl.abort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ describe('useRules', () => {
filter: '',
sortField: 'created_at',
sortOrder: 'desc',
tags: [],
showCustomRules: false,
showElasticRules: false,
},
})
);
Expand All @@ -48,6 +51,9 @@ describe('useRules', () => {
filter: '',
sortField: 'created_at',
sortOrder: 'desc',
tags: [],
showCustomRules: false,
showElasticRules: false,
},
})
);
Expand Down Expand Up @@ -153,6 +159,9 @@ describe('useRules', () => {
filter: '',
sortField: 'created_at',
sortOrder: 'desc',
tags: [],
showCustomRules: false,
showElasticRules: false,
},
})
);
Expand Down Expand Up @@ -182,6 +191,9 @@ describe('useRules', () => {
filter: '',
sortField: 'created_at',
sortOrder: 'desc',
tags: [],
showCustomRules: false,
showElasticRules: false,
},
},
}
Expand All @@ -198,6 +210,9 @@ describe('useRules', () => {
filter: 'hello world',
sortField: 'created_at',
sortOrder: 'desc',
tags: [],
showCustomRules: false,
showElasticRules: false,
},
});
await waitForNextUpdate();
Expand Down
Loading

0 comments on commit 2b2eea8

Please sign in to comment.