[8.x] Create the "Asset Inventory" Kibana Plugin (#202291) (#202827)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Create the "Asset Inventory" Kibana Plugin
(#202291)](https://github.com/elastic/kibana/pull/202291)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alberto
Blázquez","email":"albertoblaz@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-12-03T10:29:53Z","message":"Create
the \"Asset Inventory\" Kibana Plugin (#202291)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/201704.\r\n\r\nCreate an empty
\"Asset Inventory\" plugin with the minimal boilerplate\r\nrequired to
set it up, install it and run it on Kibana with a
blank\r\nslate.\r\n\r\nI generated the files using the `node
scripts/generate_plugin <NAME>`\r\nscript as per [this
documentation\r\npage](https://docs.elastic.dev/kibana-dev-docs/getting-started/hello-world-app#2-option-2---use-the-automatic-plugin-generator).\r\n\r\n###
Screenshots\r\n\r\n\r\n<details><summary>Main page (Sample
page)</summary>\r\n<img width=\"2498\" alt=\"Screenshot 2024-11-29 at 14
20
57\"\r\nsrc=\"https://github.com/user-attachments/assets/9d8a3751-519b-4661-bc90-cbb1e836b111\">\r\n</details>
\r\n\r\n### Implementation details\r\n\r\n- [x] Generated a new Kibana
plugin with minimal boilerplate and zero\r\ndependencies\r\n- [x] Use
[Cloud
Security\r\nPosture](https://github.com/elastic/kibana/tree/main/x-pack/plugins/cloud_security_posture)\r\nplugin
as configuration reference\r\n- [x] Render \"Inventory\" title on the
main page\r\n- [x] Ensure the plugin is properly integrated into
Kibana's build and\r\ncan be loaded without errors\r\n- [x] Place the
plugin under the `x-pack/plugins` directory\r\n- [x] Include Readme
file\r\n- [x] Introduce placeholders for initialization of pipelines
and\r\ntransforms following [Cloud
Security\r\nPosture](https://github.com/elastic/kibana/blob/main/x-pack/plugins/cloud_security_posture/server/plugin.ts)\r\nplugin
initialize function.\r\n\r\n### PR Checklist\r\n\r\n- [ ] No docs for
now\r\n~~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials~~\r\n- [x] The
PR description includes the appropriate Release Notes section,\r\nand
the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Risks\r\n\r\nNo risks at all since this is totally green-field and will
be hidden by\r\na feature
toggle.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Paulo Silva
<paulo.henrique@elastic.co>","sha":"e5b1773971656ad9529935832675b5f9c1849594","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud
Security","backport:prev-minor","backport:version","v8.18.0"],"number":202291,"url":"https://github.com/elastic/kibana/pull/202291","mergeCommit":{"message":"Create
the \"Asset Inventory\" Kibana Plugin (#202291)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/201704.\r\n\r\nCreate an empty
\"Asset Inventory\" plugin with the minimal boilerplate\r\nrequired to
set it up, install it and run it on Kibana with a
blank\r\nslate.\r\n\r\nI generated the files using the `node
scripts/generate_plugin <NAME>`\r\nscript as per [this
documentation\r\npage](https://docs.elastic.dev/kibana-dev-docs/getting-started/hello-world-app#2-option-2---use-the-automatic-plugin-generator).\r\n\r\n###
Screenshots\r\n\r\n\r\n<details><summary>Main page (Sample
page)</summary>\r\n<img width=\"2498\" alt=\"Screenshot 2024-11-29 at 14
20
57\"\r\nsrc=\"https://github.com/user-attachments/assets/9d8a3751-519b-4661-bc90-cbb1e836b111\">\r\n</details>
\r\n\r\n### Implementation details\r\n\r\n- [x] Generated a new Kibana
plugin with minimal boilerplate and zero\r\ndependencies\r\n- [x] Use
[Cloud
Security\r\nPosture](https://github.com/elastic/kibana/tree/main/x-pack/plugins/cloud_security_posture)\r\nplugin
as configuration reference\r\n- [x] Render \"Inventory\" title on the
main page\r\n- [x] Ensure the plugin is properly integrated into
Kibana's build and\r\ncan be loaded without errors\r\n- [x] Place the
plugin under the `x-pack/plugins` directory\r\n- [x] Include Readme
file\r\n- [x] Introduce placeholders for initialization of pipelines
and\r\ntransforms following [Cloud
Security\r\nPosture](https://github.com/elastic/kibana/blob/main/x-pack/plugins/cloud_security_posture/server/plugin.ts)\r\nplugin
initialize function.\r\n\r\n### PR Checklist\r\n\r\n- [ ] No docs for
now\r\n~~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials~~\r\n- [x] The
PR description includes the appropriate Release Notes section,\r\nand
the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Risks\r\n\r\nNo risks at all since this is totally green-field and will
be hidden by\r\na feature
toggle.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Paulo Silva
<paulo.henrique@elastic.co>","sha":"e5b1773971656ad9529935832675b5f9c1849594"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202291","number":202291,"mergeCommit":{"message":"Create
the \"Asset Inventory\" Kibana Plugin (#202291)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/201704.\r\n\r\nCreate an empty
\"Asset Inventory\" plugin with the minimal boilerplate\r\nrequired to
set it up, install it and run it on Kibana with a
blank\r\nslate.\r\n\r\nI generated the files using the `node
scripts/generate_plugin <NAME>`\r\nscript as per [this
documentation\r\npage](https://docs.elastic.dev/kibana-dev-docs/getting-started/hello-world-app#2-option-2---use-the-automatic-plugin-generator).\r\n\r\n###
Screenshots\r\n\r\n\r\n<details><summary>Main page (Sample
page)</summary>\r\n<img width=\"2498\" alt=\"Screenshot 2024-11-29 at 14
20
57\"\r\nsrc=\"https://github.com/user-attachments/assets/9d8a3751-519b-4661-bc90-cbb1e836b111\">\r\n</details>
\r\n\r\n### Implementation details\r\n\r\n- [x] Generated a new Kibana
plugin with minimal boilerplate and zero\r\ndependencies\r\n- [x] Use
[Cloud
Security\r\nPosture](https://github.com/elastic/kibana/tree/main/x-pack/plugins/cloud_security_posture)\r\nplugin
as configuration reference\r\n- [x] Render \"Inventory\" title on the
main page\r\n- [x] Ensure the plugin is properly integrated into
Kibana's build and\r\ncan be loaded without errors\r\n- [x] Place the
plugin under the `x-pack/plugins` directory\r\n- [x] Include Readme
file\r\n- [x] Introduce placeholders for initialization of pipelines
and\r\ntransforms following [Cloud
Security\r\nPosture](https://github.com/elastic/kibana/blob/main/x-pack/plugins/cloud_security_posture/server/plugin.ts)\r\nplugin
initialize function.\r\n\r\n### PR Checklist\r\n\r\n- [ ] No docs for
now\r\n~~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials~~\r\n- [x] The
PR description includes the appropriate Release Notes section,\r\nand
the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Risks\r\n\r\nNo risks at all since this is totally green-field and will
be hidden by\r\na feature
toggle.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Paulo Silva
<paulo.henrique@elastic.co>","sha":"e5b1773971656ad9529935832675b5f9c1849594"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Alberto Blázquez 2024-12-04 01:37:49 +01:00 committed by GitHub
parent c68c515dde
commit 692b9b1e5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 462 additions and 0 deletions

1
.github/CODEOWNERS vendored
View file

@ -51,6 +51,7 @@ packages/kbn-apm-types @elastic/obs-ux-infra_services-team
packages/kbn-apm-utils @elastic/obs-ux-infra_services-team
test/plugin_functional/plugins/app_link_test @elastic/kibana-core
x-pack/test/usage_collection/plugins/application_usage_test @elastic/kibana-core
x-pack/plugins/asset_inventory @elastic/kibana-cloud-security-posture
x-pack/test/security_api_integration/plugins/audit_log @elastic/kibana-security
packages/kbn-avc-banner @elastic/security-defend-workflows
packages/kbn-axe-config @elastic/kibana-qa

View file

@ -470,6 +470,10 @@ The plugin exposes the static DefaultEditorController class to consume.
|WARNING: Missing README.
|{kib-repo}blob/{branch}/x-pack/plugins/asset_inventory/README.md[assetInventory]
|Centralized asset inventory experience within the Elastic Security solution. A central place for users to view and manage all their assets from different environments.
|{kib-repo}blob/{branch}/x-pack/plugins/banners/README.md[banners]
|Allow to add a header banner that will be displayed on every page of the Kibana application

View file

@ -190,6 +190,7 @@
"@kbn/apm-utils": "link:packages/kbn-apm-utils",
"@kbn/app-link-test-plugin": "link:test/plugin_functional/plugins/app_link_test",
"@kbn/application-usage-test-plugin": "link:x-pack/test/usage_collection/plugins/application_usage_test",
"@kbn/asset-inventory-plugin": "link:x-pack/plugins/asset_inventory",
"@kbn/audit-log-plugin": "link:x-pack/test/security_api_integration/plugins/audit_log",
"@kbn/avc-banner": "link:packages/kbn-avc-banner",
"@kbn/banners-plugin": "link:x-pack/plugins/banners",

View file

@ -5,6 +5,7 @@ pageLoadAssetSize:
aiops: 17680
alerting: 106936
apm: 64385
assetInventory: 18478
banners: 17946
bfetch: 22837
canvas: 29355

View file

@ -96,6 +96,8 @@
"@kbn/app-link-test-plugin/*": ["test/plugin_functional/plugins/app_link_test/*"],
"@kbn/application-usage-test-plugin": ["x-pack/test/usage_collection/plugins/application_usage_test"],
"@kbn/application-usage-test-plugin/*": ["x-pack/test/usage_collection/plugins/application_usage_test/*"],
"@kbn/asset-inventory-plugin": ["x-pack/plugins/asset_inventory"],
"@kbn/asset-inventory-plugin/*": ["x-pack/plugins/asset_inventory/*"],
"@kbn/audit-log-plugin": ["x-pack/test/security_api_integration/plugins/audit_log"],
"@kbn/audit-log-plugin/*": ["x-pack/test/security_api_integration/plugins/audit_log/*"],
"@kbn/avc-banner": ["packages/kbn-avc-banner"],

View file

@ -0,0 +1,13 @@
# Asset Inventory Kibana Plugin
Centralized asset inventory experience within the Elastic Security solution. A central place for users to view and manage all their assets from different environments.
---
## Development
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment.
## Testing
For general guidelines, read [Kibana Testing Guide](https://www.elastic.co/guide/en/kibana/current/development-tests.html) for more details

View file

@ -0,0 +1,8 @@
/*
* 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.
*/
export const PLUGIN_ID = 'assetInventory';
export const PLUGIN_NAME = 'assetInventory';

View file

@ -0,0 +1,17 @@
{
"type": "plugin",
"id": "@kbn/asset-inventory-plugin",
"owner": ["@elastic/kibana-cloud-security-posture"],
"group": "security",
"visibility": "private",
"description": "Centralized asset inventory experience within the Elastic Security solution. A central place for users to view and manage all their assets from different environments",
"plugin": {
"id": "assetInventory",
"browser": true,
"server": true,
"configPath": ["xpack", "assetInventory"],
"requiredPlugins": [],
"requiredBundles": [],
"optionalPlugins": []
}
}

View file

@ -0,0 +1,7 @@
{
"author": "Elastic",
"name": "@kbn/asset-inventory-plugin",
"version": "1.0.0",
"private": true,
"license": "Elastic License 2.0"
}

View file

@ -0,0 +1,24 @@
/*
* 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 React from 'react';
import ReactDOM from 'react-dom';
import type { AppMountParameters, CoreStart } from '@kbn/core/public';
import type { AppPluginStartDependencies } from './types';
import { AssetInventoryApp } from './components/app';
export const renderApp = (
{ notifications, http }: CoreStart,
{}: AppPluginStartDependencies,
{ appBasePath, element }: AppMountParameters
) => {
ReactDOM.render(
<AssetInventoryApp basename={appBasePath} notifications={notifications} http={http} />,
element
);
return () => ReactDOM.unmountComponentAtNode(element);
};

View file

@ -0,0 +1,38 @@
/*
* 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 React from 'react';
import { FormattedMessage, I18nProvider } from '@kbn/i18n-react';
import { BrowserRouter as Router } from '@kbn/shared-ux-router';
import { EuiPageTemplate, EuiTitle } from '@elastic/eui';
import type { CoreStart } from '@kbn/core/public';
interface AssetInventoryAppDeps {
basename: string;
notifications: CoreStart['notifications'];
http: CoreStart['http'];
}
export const AssetInventoryApp = ({ basename }: AssetInventoryAppDeps) => {
return (
<Router basename={basename}>
<I18nProvider>
<>
<EuiPageTemplate restrictWidth="1000px">
<EuiPageTemplate.Header>
<EuiTitle size="l">
<h1>
<FormattedMessage id="assetInventory.helloWorldText" defaultMessage="Inventory" />
</h1>
</EuiTitle>
</EuiPageTemplate.Header>
<EuiPageTemplate.Section />
</EuiPageTemplate>
</>
</I18nProvider>
</Router>
);
};

View file

@ -0,0 +1,14 @@
/*
* 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 { AssetInventoryPlugin } from './plugin';
// This exports static code and TypeScript types,
// as well as, Kibana Platform `plugin()` initializer.
export function plugin() {
return new AssetInventoryPlugin();
}
export type { AssetInventoryPluginSetup, AssetInventoryPluginStart } from './types';

View file

@ -0,0 +1,35 @@
/*
* 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 { AppMountParameters, CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
import type {
AssetInventoryPluginSetup,
AssetInventoryPluginStart,
AppPluginStartDependencies,
} from './types';
export class AssetInventoryPlugin
implements Plugin<AssetInventoryPluginSetup, AssetInventoryPluginStart>
{
public setup(core: CoreSetup): AssetInventoryPluginSetup {
return {};
}
public start(
coreStart: CoreStart,
depsStart: AppPluginStartDependencies
): AssetInventoryPluginStart {
return {
getAssetInventoryPage: async (params: AppMountParameters) => {
// Load application bundle
const { renderApp } = await import('./application');
// Render the application
return renderApp(coreStart, depsStart as AppPluginStartDependencies, params);
},
};
}
public stop() {}
}

View file

@ -0,0 +1,15 @@
/*
* 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.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AssetInventoryPluginSetup {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AssetInventoryPluginStart {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AppPluginStartDependencies {}

View file

@ -0,0 +1,142 @@
/*
* 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 { transformError } from '@kbn/securitysolution-es-utils';
import { TransformPutTransformRequest } from '@elastic/elasticsearch/lib/api/types';
import type { ElasticsearchClient, Logger } from '@kbn/core/server';
import { errors } from '@elastic/elasticsearch';
// TODO: Move transforms to integration package
export const initializeTransforms = async (
esClient: ElasticsearchClient,
logger: Logger
): Promise<void> => {
// Deletes old assets from previous versions as part of upgrade process
await deletePreviousTransformsVersions(esClient, logger);
// TODO initialize transforms here
// await initializeTransform(esClient, <TRANSFORM_HERE>, logger);
};
export const initializeTransform = async (
esClient: ElasticsearchClient,
transform: TransformPutTransformRequest,
logger: Logger
) => {
const success = await createTransformIfNotExists(esClient, transform, logger);
if (success) {
await startTransformIfNotStarted(esClient, transform.transform_id, logger);
}
};
/**
* Checks if a transform exists, And if not creates it
*
* @param transform - the transform to create. If a transform with the same transform_id already exists, nothing is created or updated.
*
* @return true if the transform exits or created, false otherwise.
*/
export const createTransformIfNotExists = async (
esClient: ElasticsearchClient,
transform: TransformPutTransformRequest,
logger: Logger
) => {
try {
await esClient.transform.getTransform({
transform_id: transform.transform_id,
});
return true;
} catch (existErr) {
const existError = transformError(existErr);
if (existError.statusCode === 404) {
try {
await esClient.transform.putTransform(transform);
return true;
} catch (createErr) {
const createError = transformError(createErr);
logger.error(
`Failed to create transform ${transform.transform_id}: ${createError.message}`
);
}
} else {
logger.error(
`Failed to check if transform ${transform.transform_id} exists: ${existError.message}`
);
}
}
return false;
};
export const startTransformIfNotStarted = async (
esClient: ElasticsearchClient,
transformId: string,
logger: Logger
) => {
try {
const transformStats = await esClient.transform.getTransformStats({
transform_id: transformId,
});
if (transformStats.count <= 0) {
logger.error(`Failed starting transform ${transformId}: couldn't find transform`);
return;
}
const fetchedTransformStats = transformStats.transforms[0];
// trying to restart the transform in case it comes to a full stop or failure
if (fetchedTransformStats.state === 'stopped' || fetchedTransformStats.state === 'failed') {
try {
return await esClient.transform.startTransform({ transform_id: transformId });
} catch (startErr) {
const startError = transformError(startErr);
logger.error(
`Failed to start transform ${transformId}. Transform State: Transform State: ${fetchedTransformStats.state}. Error: ${startError.message}`
);
}
}
if (fetchedTransformStats.state === 'stopping' || fetchedTransformStats.state === 'aborting') {
logger.error(
`Not starting transform ${transformId} since it's state is: ${fetchedTransformStats.state}`
);
}
} catch (statsErr) {
const statsError = transformError(statsErr);
logger.error(`Failed to check if transform ${transformId} is started: ${statsError.message}`);
}
};
const deletePreviousTransformsVersions = async (esClient: ElasticsearchClient, logger: Logger) => {
// TODO Concat all deprecated transforms versions
const deprecatedTransforms: string[] = [];
for (const transform of deprecatedTransforms) {
const response = await deleteTransformSafe(esClient, logger, transform);
if (response) return;
}
};
const deleteTransformSafe = async (
esClient: ElasticsearchClient,
logger: Logger,
name: string
): Promise<boolean> => {
try {
await esClient.transform.deleteTransform({ transform_id: name, force: true });
logger.info(`Deleted transform successfully [Name: ${name}]`);
return true;
} catch (e) {
if (e instanceof errors.ResponseError && e.statusCode === 404) {
logger.trace(`Transform not exists [Name: ${name}]`);
return false;
} else {
logger.error(`Failed to delete transform [Name: ${name}]`);
logger.error(e);
return false;
}
}
};

View file

@ -0,0 +1,17 @@
/*
* 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 { PluginInitializerContext } from '@kbn/core/server';
// This exports static code and TypeScript types,
// as well as, Kibana Platform `plugin()` initializer.
export async function plugin(initializerContext: PluginInitializerContext) {
const { AssetInventoryPlugin } = await import('./plugin');
return new AssetInventoryPlugin(initializerContext);
}
export type { AssetInventoryPluginSetup, AssetInventoryPluginStart } from './types';

View file

@ -0,0 +1,63 @@
/*
* 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 {
PluginInitializerContext,
CoreSetup,
CoreStart,
Plugin,
Logger,
} from '@kbn/core/server';
import type { AssetInventoryPluginSetup, AssetInventoryPluginStart } from './types';
import { defineRoutes } from './routes';
// TODO Uncomment this line when initialize() is enabled
// import { initializeTransforms } from './create_transforms/create_transforms';
export class AssetInventoryPlugin
implements Plugin<AssetInventoryPluginSetup, AssetInventoryPluginStart>
{
private readonly logger: Logger;
// TODO Uncomment this line when initialize() is enabled
// private isInitialized: boolean = false;
constructor(initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get();
}
public setup(core: CoreSetup) {
this.logger.debug('assetInventory: Setup');
const router = core.http.createRouter();
// Register server side APIs
defineRoutes(router);
return {};
}
public start(core: CoreStart) {
this.logger.debug('assetInventory: Started');
// TODO Invoke initialize() when it's due
// this.initialize(core).catch(() => {});
return {};
}
public stop() {}
/**
* Initialization is idempotent and required for (re)creating indices and transforms.
*/
// TODO Uncomment these lines when initialize() is enabled
// async initialize(core: CoreStart): Promise<void> {
// this.logger.debug('initialize');
// const esClient = core.elasticsearch.client.asInternalUser;
// await initializeTransforms(esClient, this.logger);
// this.isInitialized = true;
// }
}

View file

@ -0,0 +1,23 @@
/*
* 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 { IRouter } from '@kbn/core/server';
export function defineRoutes(router: IRouter) {
router.get(
{
path: '/api/asset_inventory/example',
validate: false,
},
async (context, request, response) => {
return response.ok({
body: {
time: new Date().toISOString(),
},
});
}
);
}

View file

@ -0,0 +1,10 @@
/*
* 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.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AssetInventoryPluginSetup {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AssetInventoryPluginStart {}

View file

@ -0,0 +1,23 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types"
},
"include": [
"common/**/*.ts",
"common/**/*.json",
"public/**/*.ts",
"public/**/*.tsx",
"public/**/*.json",
"server/**/*.ts",
"server/**/*.json",
"../../../typings/**/*"
],
"exclude": ["target/**/*"],
"kbn_references": [
"@kbn/core",
"@kbn/i18n-react",
"@kbn/shared-ux-router",
"@kbn/securitysolution-es-utils"
]
}

View file

@ -3990,6 +3990,10 @@
version "0.0.0"
uid ""
"@kbn/asset-inventory-plugin@link:x-pack/plugins/asset_inventory":
version "0.0.0"
uid ""
"@kbn/audit-log-plugin@link:x-pack/test/security_api_integration/plugins/audit_log":
version "0.0.0"
uid ""