Skip to content

Commit

Permalink
Fix incorrect detection rules sort order (#130105)
Browse files Browse the repository at this point in the history
  • Loading branch information
xcrzx committed Apr 28, 2022
1 parent 2ac7484 commit 85c1870
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { KueryNode } from '@kbn/es-query';
import { get, isEmpty } from 'lodash';
import mappings from '../../saved_objects/mappings.json';
import { alertMappings } from '../../saved_objects/mappings';

const astFunctionType = ['is', 'range', 'nested'];

Expand Down Expand Up @@ -92,7 +92,7 @@ export const iterateFilterKureyNode = ({
} else if (ast.type === 'literal' && ast.value && typeof ast.value === 'string') {
const key = ast.value.replace('.attributes', '');
const mappingKey = 'properties.' + key.split('.').join('.properties.');
const field = get(mappings, mappingKey);
const field = get(alertMappings, mappingKey);
if (field != null && field.type === 'nested') {
localNestedKeys = ast.value;
}
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/alerting/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import type {
SavedObject,
SavedObjectsExportTransformContext,
SavedObjectsServiceSetup,
SavedObjectsTypeMappingDefinition,
} from '@kbn/core/server';
import { EncryptedSavedObjectsPluginSetup } from '@kbn/encrypted-saved-objects-plugin/server';
import mappings from './mappings.json';
import { alertMappings } from './mappings';
import { getMigrations } from './migrations';
import { transformRulesForExport } from './transform_rule_for_export';
import { RawRule } from '../types';
Expand Down Expand Up @@ -60,7 +59,7 @@ export function setupSavedObjects(
namespaceType: 'multiple-isolated',
convertToMultiNamespaceTypeVersion: '8.0.0',
migrations: getMigrations(encryptedSavedObjects, isPreconfigured),
mappings: mappings.alert as SavedObjectsTypeMappingDefinition,
mappings: alertMappings,
management: {
displayName: 'rule',
importableAndExportable: true,
Expand Down
185 changes: 0 additions & 185 deletions x-pack/plugins/alerting/server/saved_objects/mappings.json

This file was deleted.

Loading

0 comments on commit 85c1870

Please sign in to comment.