forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Detection Engine] add deprecation warning for non…
…-migrated signals (elastic#204247) ## Summary - addresses partly elastic/security-team#10878 - shows deprecation warning if siem index was not migrated ### How to test #### How to create legacy siem index? run script that used for FTR tests ```bash node scripts/es_archiver --kibana-url=http://elastic:changeme@localhost:5601 --es-url=http://elastic:changeme@localhost:9200 load x-pack/test/functional/es_archives/signals/legacy_signals_index node scripts/es_archiver --kibana-url=http://elastic:changeme@localhost:5601 --es-url=http://elastic:changeme@localhost:9200 load x-pack/test/functional/es_archives/signals/legacy_signals_index_non_default_space ``` These would create legacy siem indices. But be aware, it might break Kibana .alerts indices creation. But sufficient for testing Visit also detection rules page, to ensure alerts index created. Otherwise, https://www.elastic.co/guide/en/security/current/signals-migration-api.html#migration-1 API might not show these indices outdated #### How to test deprecated feature? 1. Observe warning feature deprecation on Kibana Upgrade page, if you set up legacy siem signals <details> <summary> Kibana Upgrade feature deprecation flyout </summary> <img width="2540" alt="Screenshot 2024-12-17 at 16 59 04" src="https://github.com/user-attachments/assets/c6aa420f-af69-4545-8400-6a6513f613a9" /> </details> #### Test outdated indices created in 7.x 1. Create cloud env of 7.x version 2. Create rule, generate alerts for .siem-signals 3. Create cloud env of 8.18 from existing 7.x snapshot (from previous steps) 4. Connect local Kibana to 8.18 from mirror branch of this one(elastic#204621) 5. Add to Kibana dev config following options to enable Upgrade assistant(UA) showing outdated indices ```yml xpack.upgrade_assistant.featureSet: mlSnapshots: true migrateDataStreams: true migrateSystemIndices: true reindexCorrectiveActions: true ``` 6. Go to Detection rules page, ensure rule is running and new .alerts index has been created (visiting rules table page should be enough) 7. Open UA, ensure Kibana deprecations show signals are not migrated 8. Open UA, check Elasticsearch deprecations 9. Find outdated siem-signals index 10. Migrate it 11. Check Kibana deprecations still signals are not migrated 12. Migrate signals using https://www.elastic.co/guide/en/security/current/signals-migration-api.html API 13. Ensure Kibana deprecations does not show that space as not migrated Demo video of migration .siem-signal from another-3 Kibana space https://github.com/user-attachments/assets/d2729482-d2c8-4a23-a780-ad19d4f52c73
- Loading branch information
1 parent
1485c6f
commit 4e021b0
Showing
10 changed files
with
381 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
x-pack/solutions/security/plugins/security_solution/server/deprecations/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import type { CoreSetup, Logger } from '@kbn/core/server'; | ||
import type { ConfigType } from '../config'; | ||
|
||
import { getSignalsMigrationDeprecationsInfo } from './signals_migration'; | ||
|
||
export const registerDeprecations = ({ | ||
core, | ||
config, | ||
logger, | ||
}: { | ||
core: CoreSetup; | ||
config: ConfigType; | ||
logger: Logger; | ||
}) => { | ||
core.deprecations.registerDeprecations({ | ||
getDeprecations: async (ctx) => { | ||
return [...(await getSignalsMigrationDeprecationsInfo(ctx, config, logger, core.docLinks))]; | ||
}, | ||
}); | ||
}; |
85 changes: 85 additions & 0 deletions
85
x-pack/solutions/security/plugins/security_solution/server/deprecations/signals_migration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { | ||
DeprecationsDetails, | ||
GetDeprecationsContext, | ||
Logger, | ||
DocLinksServiceSetup, | ||
} from '@kbn/core/server'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { DETECTION_ENGINE_SIGNALS_MIGRATION_STATUS_URL } from '../../common/constants'; | ||
import type { ConfigType } from '../config'; | ||
|
||
import { getNonMigratedSignalsInfo } from '../lib/detection_engine/migrations/get_non_migrated_signals_info'; | ||
|
||
const constructMigrationApiCall = (space: string, range: string) => | ||
`GET <kibana host>:<port>${ | ||
space === 'default' ? '' : `/s/${space}` | ||
}${DETECTION_ENGINE_SIGNALS_MIGRATION_STATUS_URL}?from=${range}`; | ||
|
||
export const getSignalsMigrationDeprecationsInfo = async ( | ||
ctx: GetDeprecationsContext, | ||
config: ConfigType, | ||
logger: Logger, | ||
docLinks: DocLinksServiceSetup | ||
): Promise<DeprecationsDetails[]> => { | ||
const esClient = ctx.esClient.asInternalUser; | ||
const { isMigrationRequired, spaces } = await getNonMigratedSignalsInfo({ | ||
esClient, | ||
signalsIndex: config.signalsIndex, | ||
logger, | ||
}); | ||
// Deprecation API requires time range to be part of request (https://www.elastic.co/guide/en/security/current/signals-migration-api.html#migration-1) | ||
// Return the earliest date, so it would capture the oldest possible signals | ||
const fromRange = new Date(0).toISOString(); | ||
|
||
if (isMigrationRequired) { | ||
return [ | ||
{ | ||
deprecationType: 'feature', | ||
title: i18n.translate('xpack.securitySolution.deprecations.signalsMigrationTitle', { | ||
defaultMessage: 'Found not migrated detection alerts', | ||
}), | ||
level: 'warning', | ||
message: i18n.translate('xpack.securitySolution.deprecations.signalsMigrationMessage', { | ||
defaultMessage: `After upgrading Kibana, the latest Elastic Security features will be available for any newly generated detection alerts. However, in order to enable new features for existing detection alerts, migration may be necessary.`, | ||
}), | ||
documentationUrl: docLinks.links.securitySolution.signalsMigrationApi, | ||
correctiveActions: { | ||
manualSteps: [ | ||
i18n.translate( | ||
'xpack.securitySolution.deprecations.migrateIndexIlmPolicy.signalsMigrationManualStepOne', | ||
{ | ||
defaultMessage: `Visit "Learn more" link for instructions how to migrate detection alerts. Migrate indices for each space.`, | ||
} | ||
), | ||
i18n.translate( | ||
'xpack.securitySolution.deprecations.migrateIndexIlmPolicy.signalsMigrationManualStepTwo', | ||
{ | ||
defaultMessage: 'Spaces with at least one non-migrated signals index: {spaces}.', | ||
values: { | ||
spaces: spaces.join(', '), | ||
}, | ||
} | ||
), | ||
i18n.translate( | ||
'xpack.securitySolution.deprecations.migrateIndexIlmPolicy.signalsMigrationManualStepFour', | ||
{ | ||
defaultMessage: 'Example of migration API calls:', | ||
} | ||
), | ||
...spaces.map((space) => constructMigrationApiCall(space, fromRange)), | ||
], | ||
}, | ||
}, | ||
]; | ||
} | ||
|
||
return []; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,11 @@ export const createMigrationIndex = async ({ | |
}, | ||
}, | ||
}, | ||
mappings: { | ||
_meta: { | ||
version, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
x-pack/test/functional/es_archives/signals/legacy_signals_index_non_default_space/data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "1", | ||
"index": ".siem-signals-another-space-legacy", | ||
"source": { | ||
"@timestamp": "2020-10-10T00:00:00.000Z", | ||
"signal": {} | ||
}, | ||
"type": "_doc" | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../test/functional/es_archives/signals/legacy_signals_index_non_default_space/mappings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"type": "index", | ||
"value": { | ||
"aliases": { | ||
".siem-signals-another-space": { | ||
"is_write_index": false | ||
} | ||
}, | ||
"index": ".siem-signals-another-space-legacy", | ||
"mappings": { | ||
"_meta": { | ||
"version": 1 | ||
}, | ||
"properties": { | ||
"@timestamp": { | ||
"type": "date" | ||
}, | ||
"signal": { "type": "object" } | ||
} | ||
}, | ||
"settings": { | ||
"index": { | ||
"lifecycle": { | ||
"indexing_complete": true | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.