[Alerting] Export rules and connectors (#98802)

* Adding importableAndExportable but hidden saved object types to saved object feature privilege

* Adding helper function for transforming rule for export. Added audit logging

* Adding helper function for transforming rule for export. Added audit logging

* Adding unit test for transforming rules for export

* Exporting connectors

* Removing auditing during export

* Adding import/export to docs

* PR fixes

* Using action type validation onExport

* Fixing logic for connectors with optional secrets

* Fixing logic for connectors with optional secrets

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
ymao1 2021-05-05 11:33:01 -04:00 committed by GitHub
parent 0d7a5826a4
commit 4ab86c77d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 495 additions and 7 deletions

View file

@ -27,6 +27,20 @@ describe('Features Plugin', () => {
namespaceType: 'single' as 'single',
},
]);
typeRegistry.getImportableAndExportableTypes.mockReturnValue([
{
name: 'hidden-importableAndExportable',
hidden: true,
mappings: { properties: {} },
namespaceType: 'single' as 'single',
},
{
name: 'not-hidden-importableAndExportable',
hidden: false,
mappings: { properties: {} },
namespaceType: 'single' as 'single',
},
]);
coreStart.savedObjects.getTypeRegistry.mockReturnValue(typeRegistry);
});
@ -87,7 +101,9 @@ describe('Features Plugin', () => {
`);
});
it('registers kibana features with not hidden saved objects types', async () => {
it('registers kibana features with visible saved objects types and hidden saved object types that are importable and exportable', async () => {
typeRegistry.isHidden.mockReturnValueOnce(true);
typeRegistry.isHidden.mockReturnValueOnce(false);
const plugin = new FeaturesPlugin(initContext);
await plugin.setup(coreSetup, {});
const { getKibanaFeatures } = plugin.start(coreStart);
@ -98,6 +114,8 @@ describe('Features Plugin', () => {
expect(soTypes.includes('foo')).toBe(true);
expect(soTypes.includes('bar')).toBe(false);
expect(soTypes.includes('hidden-importableAndExportable')).toBe(true);
expect(soTypes.includes('not-hidden-importableAndExportable')).toBe(false);
});
it('returns registered elasticsearch features', async () => {

View file

@ -128,7 +128,15 @@ export class FeaturesPlugin
private registerOssFeatures(savedObjects: SavedObjectsServiceStart) {
const registry = savedObjects.getTypeRegistry();
const savedObjectTypes = registry.getVisibleTypes().map((t) => t.name);
const savedObjectVisibleTypes = registry.getVisibleTypes().map((t) => t.name);
const savedObjectImportableAndExportableHiddenTypes = registry
.getImportableAndExportableTypes()
.filter((t) => registry.isHidden(t.name))
.map((t) => t.name);
const savedObjectTypes = Array.from(
new Set([...savedObjectVisibleTypes, ...savedObjectImportableAndExportableHiddenTypes])
);
this.logger.debug(
`Registering OSS features with SO types: ${savedObjectTypes.join(', ')}. "includeTimelion": ${