Skip to content

Commit

Permalink
Merge branch '7.x' into 7.x-revert-chromium-edge-support
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Apr 14, 2020
2 parents c70faed + e6c5ce6 commit 6d7db22
Show file tree
Hide file tree
Showing 49 changed files with 471 additions and 330 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*/

import _ from 'lodash';
import { EMS_TMS, LAYER_TYPE } from '../constants';
import { SOURCE_TYPES, LAYER_TYPE } from '../constants';

function isEmsTileSource(layerDescriptor) {
const sourceType = _.get(layerDescriptor, 'sourceDescriptor.type');
return sourceType === EMS_TMS;
return sourceType === SOURCE_TYPES.EMS_TMS;
}

function isTileLayer(layerDescriptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
*/

import _ from 'lodash';
import { ES_GEO_GRID, ES_PEW_PEW, ES_SEARCH } from '../constants';
import { SOURCE_TYPES } from '../constants';

function isEsSource(layerDescriptor) {
const sourceType = _.get(layerDescriptor, 'sourceDescriptor.type');
return [ES_GEO_GRID, ES_PEW_PEW, ES_SEARCH].includes(sourceType);
return [SOURCE_TYPES.ES_GEO_GRID, SOURCE_TYPES.ES_PEW_PEW, SOURCE_TYPES.ES_SEARCH].includes(
sourceType
);
}

// Migration to move applyGlobalQuery from layer to sources.
Expand Down
8 changes: 6 additions & 2 deletions x-pack/legacy/plugins/maps/common/migrations/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
// Can not use public Layer classes to extract references since this logic must run in both client and server.

import _ from 'lodash';
import { ES_GEO_GRID, ES_SEARCH, ES_PEW_PEW } from '../constants';
import { SOURCE_TYPES } from '../constants';

function doesSourceUseIndexPattern(layerDescriptor) {
const sourceType = _.get(layerDescriptor, 'sourceDescriptor.type');
return sourceType === ES_GEO_GRID || sourceType === ES_SEARCH || sourceType === ES_PEW_PEW;
return (
sourceType === SOURCE_TYPES.ES_GEO_GRID ||
sourceType === SOURCE_TYPES.ES_SEARCH ||
sourceType === SOURCE_TYPES.ES_PEW_PEW
);
}

export function extractReferences({ attributes, references = [] }) {
Expand Down
14 changes: 7 additions & 7 deletions x-pack/legacy/plugins/maps/common/migrations/references.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
*/

import { extractReferences, injectReferences } from './references';
import { ES_GEO_GRID, ES_SEARCH, ES_PEW_PEW } from '../constants';
import { SOURCE_TYPES } from '../constants';

const layerListJSON = {
esSearchSource: {
withIndexPatternId: `[{\"sourceDescriptor\":{\"type\":\"${ES_SEARCH}\",\"indexPatternId\":\"c698b940-e149-11e8-a35a-370a8516603a\"}}]`,
withIndexPatternRef: `[{\"sourceDescriptor\":{\"type\":\"${ES_SEARCH}\",\"indexPatternRefName\":\"layer_0_source_index_pattern\"}}]`,
withIndexPatternId: `[{\"sourceDescriptor\":{\"type\":\"${SOURCE_TYPES.ES_SEARCH}\",\"indexPatternId\":\"c698b940-e149-11e8-a35a-370a8516603a\"}}]`,
withIndexPatternRef: `[{\"sourceDescriptor\":{\"type\":\"${SOURCE_TYPES.ES_SEARCH}\",\"indexPatternRefName\":\"layer_0_source_index_pattern\"}}]`,
},
esGeoGridSource: {
withIndexPatternId: `[{\"sourceDescriptor\":{\"type\":\"${ES_GEO_GRID}\",\"indexPatternId\":\"c698b940-e149-11e8-a35a-370a8516603a\"}}]`,
withIndexPatternRef: `[{\"sourceDescriptor\":{\"type\":\"${ES_GEO_GRID}\",\"indexPatternRefName\":\"layer_0_source_index_pattern\"}}]`,
withIndexPatternId: `[{\"sourceDescriptor\":{\"type\":\"${SOURCE_TYPES.ES_GEO_GRID}\",\"indexPatternId\":\"c698b940-e149-11e8-a35a-370a8516603a\"}}]`,
withIndexPatternRef: `[{\"sourceDescriptor\":{\"type\":\"${SOURCE_TYPES.ES_GEO_GRID}\",\"indexPatternRefName\":\"layer_0_source_index_pattern\"}}]`,
},
join: {
withIndexPatternId:
Expand All @@ -23,8 +23,8 @@ const layerListJSON = {
'[{"joins":[{"right":{"indexPatternRefName":"layer_0_join_0_index_pattern"}}]}]',
},
pewPewSource: {
withIndexPatternId: `[{\"sourceDescriptor\":{\"type\":\"${ES_PEW_PEW}\",\"indexPatternId\":\"c698b940-e149-11e8-a35a-370a8516603a\"}}]`,
withIndexPatternRef: `[{\"sourceDescriptor\":{\"type\":\"${ES_PEW_PEW}\",\"indexPatternRefName\":\"layer_0_source_index_pattern\"}}]`,
withIndexPatternId: `[{\"sourceDescriptor\":{\"type\":\"${SOURCE_TYPES.ES_PEW_PEW}\",\"indexPatternId\":\"c698b940-e149-11e8-a35a-370a8516603a\"}}]`,
withIndexPatternRef: `[{\"sourceDescriptor\":{\"type\":\"${SOURCE_TYPES.ES_PEW_PEW}\",\"indexPatternRefName\":\"layer_0_source_index_pattern\"}}]`,
},
};

Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/maps/common/migrations/scaling_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*/

import _ from 'lodash';
import { ES_SEARCH, SCALING_TYPES } from '../constants';
import { SOURCE_TYPES, SCALING_TYPES } from '../constants';
import { LayerDescriptor, ESSearchSourceDescriptor } from '../descriptor_types';
import { MapSavedObjectAttributes } from '../../../../../plugins/maps/common/map_saved_object_type';

function isEsDocumentSource(layerDescriptor: LayerDescriptor) {
const sourceType = _.get(layerDescriptor, 'sourceDescriptor.type');
return sourceType === ES_SEARCH;
return sourceType === SOURCE_TYPES.ES_SEARCH;
}

export function migrateUseTopHitsToScalingType({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*/

import _ from 'lodash';
import { ES_SEARCH, SORT_ORDER } from '../constants';
import { SOURCE_TYPES, SORT_ORDER } from '../constants';

function isEsDocumentSource(layerDescriptor) {
const sourceType = _.get(layerDescriptor, 'sourceDescriptor.type');
return sourceType === ES_SEARCH;
return sourceType === SOURCE_TYPES.ES_SEARCH;
}

export function topHitsTimeToSort({ attributes }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import DrawRectangle from 'mapbox-gl-draw-rectangle-mode';
import { DrawCircle } from './draw_circle';
import {
createDistanceFilterWithMeta,
createSpatialFilterWithBoundingBox,
createSpatialFilterWithGeometry,
getBoundingBoxGeometry,
roundCoordinates,
Expand Down Expand Up @@ -84,23 +83,17 @@ export class DrawControl extends React.Component {
roundCoordinates(geometry.coordinates);

try {
const options = {
const filter = createSpatialFilterWithGeometry({
geometry:
this.props.drawState.drawType === DRAW_TYPE.BOUNDS
? getBoundingBoxGeometry(geometry)
: geometry,
indexPatternId: this.props.drawState.indexPatternId,
geoFieldName: this.props.drawState.geoFieldName,
geoFieldType: this.props.drawState.geoFieldType,
geometryLabel: this.props.drawState.geometryLabel,
relation: this.props.drawState.relation,
};
const filter =
this.props.drawState.drawType === DRAW_TYPE.BOUNDS
? createSpatialFilterWithBoundingBox({
...options,
geometry: getBoundingBoxGeometry(geometry),
})
: createSpatialFilterWithGeometry({
...options,
geometry,
});
});
this.props.addFilters([filter]);
} catch (error) {
// TODO notify user why filter was not created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'src/core/server';
import { IFieldType, IIndexPattern } from 'src/plugins/data/public';
import {
EMS_FILE,
SOURCE_TYPES,
ES_GEO_FIELD_TYPE,
MAP_SAVED_OBJECT_TYPE,
TELEMETRY_TYPE,
Expand Down Expand Up @@ -100,7 +100,7 @@ export function buildMapsTelemetry({
const emsLayersCount = layerLists.map(lList =>
_(lList)
.countBy((layer: LayerDescriptor) => {
const isEmsFile = _.get(layer, 'sourceDescriptor.type') === EMS_FILE;
const isEmsFile = _.get(layer, 'sourceDescriptor.type') === SOURCE_TYPES.EMS_FILE;
return isEmsFile && _.get(layer, 'sourceDescriptor.id');
})
.pick((val, key) => key !== 'false')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
LayerMappingDetails,
} from './types';
import * as i18n from './translations';
import { SOURCE_TYPES } from '../../../../../../plugins/maps/common/constants';
const euiVisColorPalette = euiPaletteColorBlind();

// Update field mappings to modify what fields will be returned to map tooltip
Expand Down Expand Up @@ -101,7 +102,7 @@ export const lmc: LayerMappingCollection = {
export const getLayerList = (indexPatternIds: IndexPatternMapping[]) => {
return [
{
sourceDescriptor: { type: 'EMS_TMS', isAutoSelect: true },
sourceDescriptor: { type: SOURCE_TYPES.EMS_TMS, isAutoSelect: true },
id: uuid.v4(),
label: null,
minZoom: 0,
Expand Down Expand Up @@ -260,7 +261,7 @@ export const getLineLayer = (
layerDetails: LayerMapping
) => ({
sourceDescriptor: {
type: 'ES_PEW_PEW',
type: SOURCE_TYPES.ES_PEW_PEW,
applyGlobalQuery: true,
id: uuid.v4(),
indexPatternId,
Expand Down
9 changes: 4 additions & 5 deletions x-pack/plugins/actions/server/lib/action_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export class ActionExecutor {
} = this.actionExecutorContext!;

const services = getServices(request);
const namespace = spaces && spaces.getSpaceId(request);
const spaceId = spaces && spaces.getSpaceId(request);
const namespace = spaceId && spaceId !== 'default' ? { namespace: spaceId } : {};

// Ensure user can read the action before processing
const {
Expand All @@ -91,9 +92,7 @@ export class ActionExecutor {
} = await encryptedSavedObjectsPlugin.getDecryptedAsInternalUser<RawAction>(
'action',
actionId,
{
namespace: namespace === 'default' ? undefined : namespace,
}
namespace
);
const actionType = actionTypeRegistry.get(actionTypeId);

Expand All @@ -112,7 +111,7 @@ export class ActionExecutor {
const actionLabel = `${actionTypeId}:${actionId}: ${name}`;
const event: IEvent = {
event: { action: EVENT_LOG_ACTIONS.execute },
kibana: { namespace, saved_objects: [{ type: 'action', id: actionId }] },
kibana: { saved_objects: [{ type: 'action', id: actionId, ...namespace }] },
};

eventLogger.startTiming(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ test('calls actionsPlugin.execute per selected action', async () => {
"alerting": Object {
"instance_id": "2",
},
"namespace": "default",
"saved_objects": Array [
Object {
"id": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@ export function createExecutionHandler({
apiKey,
});

const namespace = spaceId === 'default' ? {} : { namespace: spaceId };

const event: IEvent = {
event: { action: EVENT_LOG_ACTIONS.executeAction },
kibana: {
alerting: {
instance_id: alertInstanceId,
},
namespace: spaceId,
saved_objects: [
{ type: 'alert', id: alertId },
{ type: 'action', id: action.id },
{ type: 'alert', id: alertId, ...namespace },
{ type: 'action', id: action.id, ...namespace },
],
},
};
Expand Down
15 changes: 8 additions & 7 deletions x-pack/plugins/alerting/server/task_runner/task_runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ describe('Task Runner', () => {
"action": "execute",
},
"kibana": Object {
"namespace": undefined,
"saved_objects": Array [
Object {
"id": "1",
"namespace": undefined,
"type": "alert",
},
],
Expand Down Expand Up @@ -229,10 +229,10 @@ describe('Task Runner', () => {
"action": "execute",
},
"kibana": Object {
"namespace": undefined,
"saved_objects": Array [
Object {
"id": "1",
"namespace": undefined,
"type": "alert",
},
],
Expand All @@ -249,10 +249,10 @@ describe('Task Runner', () => {
"alerting": Object {
"instance_id": "1",
},
"namespace": undefined,
"saved_objects": Array [
Object {
"id": "1",
"namespace": undefined,
"type": "alert",
},
],
Expand All @@ -269,14 +269,15 @@ describe('Task Runner', () => {
"alerting": Object {
"instance_id": "1",
},
"namespace": undefined,
"saved_objects": Array [
Object {
"id": "1",
"namespace": undefined,
"type": "alert",
},
Object {
"id": "1",
"namespace": undefined,
"type": "action",
},
],
Expand Down Expand Up @@ -344,10 +345,10 @@ describe('Task Runner', () => {
"action": "execute",
},
"kibana": Object {
"namespace": undefined,
"saved_objects": Array [
Object {
"id": "1",
"namespace": undefined,
"type": "alert",
},
],
Expand All @@ -364,10 +365,10 @@ describe('Task Runner', () => {
"alerting": Object {
"instance_id": "2",
},
"namespace": undefined,
"saved_objects": Array [
Object {
"id": "1",
"namespace": undefined,
"type": "alert",
},
],
Expand Down Expand Up @@ -560,10 +561,10 @@ describe('Task Runner', () => {
"action": "execute",
},
"kibana": Object {
"namespace": undefined,
"saved_objects": Array [
Object {
"id": "1",
"namespace": undefined,
"type": "alert",
},
],
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/alerting/server/task_runner/task_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class TaskRunner {
const alertLabel = `${this.alertType.id}:${alertId}: '${name}'`;
const event: IEvent = {
event: { action: EVENT_LOG_ACTIONS.execute },
kibana: { namespace, saved_objects: [{ type: 'alert', id: alertId }] },
kibana: { saved_objects: [{ type: 'alert', id: alertId, namespace }] },
};
eventLogger.startTiming(event);

Expand Down Expand Up @@ -378,11 +378,10 @@ function generateNewAndResolvedInstanceEvents(params: GenerateNewAndResolvedInst
action,
},
kibana: {
namespace: params.namespace,
alerting: {
instance_id: id,
},
saved_objects: [{ type: 'alert', id: params.alertId }],
saved_objects: [{ type: 'alert', id: params.alertId, namespace: params.namespace }],
},
message,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const generatePolicy = (): PolicyConfig => {
mac: {
events: {
process: true,
file: true,
network: true,
},
malware: {
mode: ProtectionModes.detect,
Expand All @@ -67,6 +69,8 @@ export const generatePolicy = (): PolicyConfig => {
linux: {
events: {
process: true,
file: true,
network: true,
},
logging: {
stdout: 'debug',
Expand Down
Loading

0 comments on commit 6d7db22

Please sign in to comment.