Skip to content

Commit

Permalink
[Security Solution][Endpoint] Fix server start to ensure it does not …
Browse files Browse the repository at this point in the history
…prevent Kibana from starting if optional plugin dependencies are not available (#88291)

* Ensure that services that depend on fleet are only initialized if fleet dependency is available
* rename "Ingest manager" to "Fleet" in UI strings/code comments
  • Loading branch information
paul-tavares authored Jan 14, 2021
1 parent 245d521 commit 9f57844
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/public/app/home/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const Setup: React.FunctionComponent<{
}> = ({ fleet, notifications }) => {
React.useEffect(() => {
const defaultText = i18n.translate('xpack.securitySolution.endpoint.ingestToastMessage', {
defaultMessage: 'Ingest Manager failed during its setup.',
defaultMessage: 'Fleet failed during its setup.',
});

const title = i18n.translate('xpack.securitySolution.endpoint.ingestToastTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const NoPermissions = memo(() => {
<EuiText color="subdued">
<FormattedMessage
id="xpack.securitySolution.endpointManagement.noPermissionsSubText"
defaultMessage="It looks like Ingest Manager is disabled. Ingest Manager must be enabled to use this feature. If you do not have permissions to enable Ingest Manager, contact your Kibana administrator."
defaultMessage="It looks like Fleet is disabled. Fleet must be enabled to use this feature. If you do not have permissions to enable Fleet, contact your Kibana administrator."
/>
</EuiText>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const getManifest = async (logger: Logger, manifestManager: ManifestManager): Pr
};

/**
* Callback to handle creation of PackagePolicies in Ingest Manager
* Callback to handle creation of PackagePolicies in Fleet
*/
export const getPackagePolicyCreateCallback = (
logger: Logger,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/server/endpoint/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const createMockPackageService = (): jest.Mocked<PackageService> => {
};

/**
* Creates a mock IndexPatternService for use in tests that need to interact with the Ingest Manager's
* Creates a mock IndexPatternService for use in tests that need to interact with the Fleet's
* ESIndexPatternService.
*
* @param indexPattern a string index pattern to return when called by a test
Expand Down
50 changes: 24 additions & 26 deletions x-pack/plugins/security_solution/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { ListPluginSetup } from '../../lists/server';
import { EncryptedSavedObjectsPluginSetup as EncryptedSavedObjectsSetup } from '../../encrypted_saved_objects/server';
import { SpacesPluginSetup as SpacesSetup } from '../../spaces/server';
import { ILicense, LicensingPluginStart } from '../../licensing/server';
import { FleetStartContract, ExternalCallback } from '../../fleet/server';
import { FleetStartContract } from '../../fleet/server';
import { TaskManagerSetupContract, TaskManagerStartContract } from '../../task_manager/server';
import { initServer } from './init_server';
import { compose } from './lib/compose/kibana';
Expand Down Expand Up @@ -323,27 +323,41 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S

public start(core: CoreStart, plugins: StartPlugins) {
const savedObjectsClient = new SavedObjectsClient(core.savedObjects.createInternalRepository());

const registerIngestCallback = plugins.fleet?.registerExternalCallback;
let manifestManager: ManifestManager | undefined;
let registerIngestCallback: ((...args: ExternalCallback) => void) | undefined;

const exceptionListsStartEnabled = () => {
return this.lists && plugins.taskManager && plugins.fleet;
};
this.licensing$ = plugins.licensing.license$;

if (exceptionListsStartEnabled()) {
const exceptionListClient = this.lists!.getExceptionListClient(savedObjectsClient, 'kibana');
if (this.lists && plugins.taskManager && plugins.fleet) {
// Exceptions, Artifacts and Manifests start
const exceptionListClient = this.lists.getExceptionListClient(savedObjectsClient, 'kibana');
const artifactClient = new ArtifactClient(savedObjectsClient);

registerIngestCallback = plugins.fleet!.registerExternalCallback;
manifestManager = new ManifestManager({
savedObjectsClient,
artifactClient,
exceptionListClient,
packagePolicyService: plugins.fleet!.packagePolicyService,
packagePolicyService: plugins.fleet.packagePolicyService,
logger: this.logger,
cache: this.exceptionsCache,
});

if (this.manifestTask) {
this.manifestTask.start({
taskManager: plugins.taskManager,
});
} else {
this.logger.debug('User artifacts task not available.');
}

// License related start
licenseService.start(this.licensing$);
this.policyWatcher = new PolicyWatcher(
plugins.fleet!.packagePolicyService,
core.savedObjects,
this.logger
);
this.policyWatcher.start(licenseService);
}

this.endpointAppContextService.start({
Expand All @@ -362,23 +376,7 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
licenseService,
});

if (exceptionListsStartEnabled() && this.manifestTask) {
this.manifestTask.start({
taskManager: plugins.taskManager!,
});
} else {
this.logger.debug('User artifacts task not available.');
}

this.telemetryEventsSender.start(core, plugins.telemetry, plugins.taskManager);
this.licensing$ = plugins.licensing.license$;
licenseService.start(this.licensing$);
this.policyWatcher = new PolicyWatcher(
plugins.fleet!.packagePolicyService,
core.savedObjects,
this.logger
);
this.policyWatcher.start(licenseService);
return {};
}

Expand Down

0 comments on commit 9f57844

Please sign in to comment.