Skip to content

Commit

Permalink
Merge branch 'main' into 184582-infra-running-processes-missing-from-…
Browse files Browse the repository at this point in the history
…processes-table
  • Loading branch information
jennypavlova authored Jan 31, 2025
2 parents ca96fec + 5c350b4 commit fe7e9fa
Show file tree
Hide file tree
Showing 72 changed files with 1,308 additions and 260 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,9 @@ packages/kbn-monaco/src/esql @elastic/kibana-esql
/.eslintignore @elastic/kibana-operations

# QA - Appex QA
/packages/kbn-es/src/serverless_resources/project_roles/es/roles.yml @elastic/appex-qa
/packages/kbn-es/src/serverless_resources/project_roles/oblt/roles.yml @elastic/appex-qa
/packages/kbn-es/src/serverless_resources/project_roles/security/roles.yml @elastic/appex-qa
/x-pack/platform/plugins/shared/maps/ui_tests @elastic/appex-qa # temporarily
/x-pack/platform/plugins/private/discover_enhanced/ui_tests/ @elastic/appex-qa # temporarily
/x-pack/test/functional/fixtures/package_registry_config.yml @elastic/appex-qa # No usages found
Expand Down
24 changes: 12 additions & 12 deletions config/serverless.security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ xpack.features.overrides:
privileges: [ "all" ]
- feature: "maps_v2"
privileges: [ "all" ]
- feature: "savedQueryManagement"
privileges: [ "all" ]
# Security's `Read` feature privilege should implicitly grant `Read` access to Discover, Dashboard, Maps, and
# Visualize features. Additionally, it should implicitly grant privilege to create short URLs in Discover,
### Dashboard, and Visualize apps.
Expand All @@ -57,34 +55,36 @@ xpack.features.overrides:
privileges: [ "read" ]
- feature: "maps_v2"
privileges: [ "read" ]
- feature: "savedQueryManagement"
privileges: [ "read" ]

### Security's feature privileges are fine-tuned to grant access to Discover, Dashboard, Maps, and Visualize apps.
siem:
privileges:
### Security's `All` feature privilege should implicitly grant `All` access to Discover, Dashboard, Maps, and
### Visualize features.
all.composedOf:
- feature: "discover"
- feature: "discover_v2"
privileges: [ "all" ]
- feature: "dashboard_v2"
privileges: [ "all" ]
- feature: "dashboard"
- feature: "visualize_v2"
privileges: [ "all" ]
- feature: "visualize"
- feature: "maps_v2"
privileges: [ "all" ]
- feature: "maps"
- feature: "savedQueryManagement"
privileges: [ "all" ]
# Security's `Read` feature privilege should implicitly grant `Read` access to Discover, Dashboard, Maps, and
# Visualize features. Additionally, it should implicitly grant privilege to create short URLs in Discover,
### Dashboard, and Visualize apps.
read.composedOf:
- feature: "discover"
- feature: "discover_v2"
privileges: [ "read" ]
- feature: "dashboard_v2"
privileges: [ "read" ]
- feature: "dashboard"
- feature: "visualize_v2"
privileges: [ "read" ]
- feature: "visualize"
- feature: "maps_v2"
privileges: [ "read" ]
- feature: "maps"
- feature: "savedQueryManagement"
privileges: [ "read" ]

## Cloud settings
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@
"expect": "^29.7.0",
"expose-loader": "^0.7.5",
"express": "^4.21.2",
"fetch-mock": "^7.3.9",
"fetch-mock": "^10.1.0",
"file-loader": "^4.2.0",
"find-cypress-specs": "^1.41.4",
"form-data": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const getIsAccessApiDeprecation = ({
export const buildApiAccessDeprecationDetails = ({
apiUsageStats,
deprecatedApiDetails,
docLinks,
}: BuildApiDeprecationDetailsParams): DomainDeprecationDetails<ApiDeprecationDetails> => {
const { apiId, apiTotalCalls, totalMarkedAsResolved } = apiUsageStats;
const { routeVersion, routePath, routeDeprecationOptions, routeMethod } = deprecatedApiDetails;
Expand All @@ -43,7 +44,7 @@ export const buildApiAccessDeprecationDetails = ({
apiId,
title: getApiDeprecationTitle(deprecatedApiDetails),
level: deprecationLevel,
message: getApiDeprecationMessage(deprecatedApiDetails, apiUsageStats),
message: getApiDeprecationMessage(deprecatedApiDetails, apiUsageStats, docLinks),
documentationUrl: routeDeprecationOptions?.documentationUrl,
correctiveActions: {
manualSteps: getApiDeprecationsManualSteps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { RouterDeprecatedApiDetails } from '@kbn/core-http-server';
import { CoreDeprecatedApiUsageStats } from '@kbn/core-usage-data-server';
import { i18n } from '@kbn/i18n';
import moment from 'moment';
import { DocLinksServiceSetup } from '@kbn/core-doc-links-server';
import type { DeprecationDetailsMessage } from '@kbn/core-deprecations-common';

export const getApiDeprecationTitle = (
details: Pick<RouterDeprecatedApiDetails, 'routePath' | 'routeMethod'>
Expand All @@ -31,8 +33,9 @@ export const getApiDeprecationMessage = (
RouterDeprecatedApiDetails,
'routePath' | 'routeMethod' | 'routeDeprecationOptions'
>,
apiUsageStats: CoreDeprecatedApiUsageStats
): string[] => {
apiUsageStats: CoreDeprecatedApiUsageStats,
docLinks: DocLinksServiceSetup
): Array<string | DeprecationDetailsMessage> => {
const { routePath, routeMethod, routeDeprecationOptions } = details;
const { apiLastCalledAt, apiTotalCalls, markedAsResolvedLastCalledAt, totalMarkedAsResolved } =
apiUsageStats;
Expand All @@ -41,7 +44,7 @@ export const getApiDeprecationMessage = (
const wasResolvedBefore = totalMarkedAsResolved > 0;
const routeWithMethod = `${routeMethod.toUpperCase()} ${routePath}`;

const messages = [
const messages: Array<string | DeprecationDetailsMessage> = [
i18n.translate('core.deprecations.apiAccessDeprecation.apiCallsDetailsMessage', {
defaultMessage:
'The API "{routeWithMethod}" has been called {apiTotalCalls} times. The last call was on {apiLastCalledAt}.',
Expand Down Expand Up @@ -72,6 +75,16 @@ export const getApiDeprecationMessage = (
'Internal APIs are meant to be used by Elastic services only. You should not use them. External access to these APIs will be restricted.',
})
);
messages.push({
type: 'markdown',
content: i18n.translate('core.deprecations.apiAccessDeprecation.enableDebugLogsMessage', {
defaultMessage:
'To include information in debug logs about calls to APIs that are internal to Elastic, edit your Kibana configuration as detailed in [the documentation]({enableDeprecationHttpDebugLogsLink}).',
values: {
enableDeprecationHttpDebugLogsLink: docLinks.links.logging.enableDeprecationHttpDebugLogs,
},
}),
});

if (routeDeprecationOptions?.message) {
// Surfaces additional deprecation messages passed into the route in UA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@ import {
createGetApiDeprecations,
} from './register_api_depercation_info';
import { buildApiDeprecationId } from './api_deprecation_id';
import { RouterDeprecatedApiDetails } from '@kbn/core-http-server';
import type {
RouterAccessDeprecatedApiDetails,
RouterDeprecatedApiDetails,
} from '@kbn/core-http-server';
import { httpServiceMock } from '@kbn/core-http-server-mocks';
import {
coreUsageDataServiceMock,
coreUsageStatsClientMock,
} from '@kbn/core-usage-data-server-mocks';
import { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
import _ from 'lodash';
import type { DocLinksServiceSetup } from '@kbn/core-doc-links-server';
import { CoreDeprecatedApiUsageStats } from '@kbn/core-usage-data-server';

describe('#registerApiDeprecationsInfo', () => {
const deprecationsFactory = mockDeprecationsFactory.create();
const deprecationsRegistry = mockDeprecationsRegistry.create();
const docLinks: DocLinksServiceSetup = docLinksServiceMock.createSetupContract();
let usageClientMock: ReturnType<typeof coreUsageStatsClientMock.create>;
let http: ReturnType<typeof httpServiceMock.createInternalSetupContract>;
let coreUsageData: ReturnType<typeof coreUsageDataServiceMock.createSetupContract>;
Expand All @@ -47,7 +53,7 @@ describe('#registerApiDeprecationsInfo', () => {

it('registers api deprecations', async () => {
deprecationsFactory.getRegistry.mockReturnValue(deprecationsRegistry);
registerApiDeprecationsInfo({ deprecationsFactory, coreUsageData, http });
registerApiDeprecationsInfo({ deprecationsFactory, coreUsageData, http, docLinks });

expect(deprecationsFactory.getRegistry).toBeCalledWith('core.api_deprecations');
expect(deprecationsRegistry.registerDeprecations).toBeCalledTimes(1);
Expand Down Expand Up @@ -77,6 +83,19 @@ describe('#registerApiDeprecationsInfo', () => {
overrides
);

const createInternalRouteDetails = (
overrides?: Partial<RouterAccessDeprecatedApiDetails>
): RouterAccessDeprecatedApiDetails =>
_.merge(
{
routeAccess: 'internal',
routeMethod: 'post',
routePath: '/internal/api/',
routeVersion: '1.0.0',
} as RouterAccessDeprecatedApiDetails,
overrides
);

const createApiUsageStat = (
apiId: string,
overrides?: DeepPartial<CoreDeprecatedApiUsageStats>
Expand All @@ -93,7 +112,7 @@ describe('#registerApiDeprecationsInfo', () => {
);

it('returns removed type deprecated route', async () => {
const getDeprecations = createGetApiDeprecations({ coreUsageData, http });
const getDeprecations = createGetApiDeprecations({ coreUsageData, http, docLinks });
const deprecatedRoute = createDeprecatedRouteDetails({
routePath: '/api/test_removed/',
routeDeprecationOptions: { reason: { type: 'remove' } },
Expand Down Expand Up @@ -129,6 +148,10 @@ describe('#registerApiDeprecationsInfo', () => {
"level": "critical",
"message": Array [
"The API \\"GET /api/test_removed/\\" has been called 13 times. The last call was on Sunday, September 1, 2024 6:06 AM -04:00.",
Object {
"content": "To include information about deprecated API calls in debug logs, edit your Kibana configuration as detailed in [the documentation](https://www.elastic.co/guide/en/kibana/test-branch/logging-settings.html#enable-http-debug-logs).",
"type": "markdown",
},
"This issue has been marked as resolved on Thursday, October 17, 2024 8:06 AM -04:00 but the API has been called 12 times since.",
],
"title": "The \\"GET /api/test_removed/\\" route is removed",
Expand All @@ -138,7 +161,7 @@ describe('#registerApiDeprecationsInfo', () => {
});

it('returns migrated type deprecated route', async () => {
const getDeprecations = createGetApiDeprecations({ coreUsageData, http });
const getDeprecations = createGetApiDeprecations({ coreUsageData, http, docLinks });
const deprecatedRoute = createDeprecatedRouteDetails({
routePath: '/api/test_migrated/',
routeDeprecationOptions: {
Expand Down Expand Up @@ -176,6 +199,10 @@ describe('#registerApiDeprecationsInfo', () => {
"level": "critical",
"message": Array [
"The API \\"GET /api/test_migrated/\\" has been called 13 times. The last call was on Sunday, September 1, 2024 6:06 AM -04:00.",
Object {
"content": "To include information about deprecated API calls in debug logs, edit your Kibana configuration as detailed in [the documentation](https://www.elastic.co/guide/en/kibana/test-branch/logging-settings.html#enable-http-debug-logs).",
"type": "markdown",
},
"This issue has been marked as resolved on Thursday, October 17, 2024 8:06 AM -04:00 but the API has been called 12 times since.",
],
"title": "The \\"GET /api/test_migrated/\\" route is migrated to a different API",
Expand All @@ -185,7 +212,7 @@ describe('#registerApiDeprecationsInfo', () => {
});

it('returns bumped type deprecated route', async () => {
const getDeprecations = createGetApiDeprecations({ coreUsageData, http });
const getDeprecations = createGetApiDeprecations({ coreUsageData, http, docLinks });
const deprecatedRoute = createDeprecatedRouteDetails({
routePath: '/api/test_bumped/',
routeDeprecationOptions: { reason: { type: 'bump', newApiVersion: '444' } },
Expand Down Expand Up @@ -221,6 +248,10 @@ describe('#registerApiDeprecationsInfo', () => {
"level": "critical",
"message": Array [
"The API \\"GET /api/test_bumped/\\" has been called 13 times. The last call was on Sunday, September 1, 2024 6:06 AM -04:00.",
Object {
"content": "To include information about deprecated API calls in debug logs, edit your Kibana configuration as detailed in [the documentation](https://www.elastic.co/guide/en/kibana/test-branch/logging-settings.html#enable-http-debug-logs).",
"type": "markdown",
},
"This issue has been marked as resolved on Thursday, October 17, 2024 8:06 AM -04:00 but the API has been called 12 times since.",
],
"title": "The \\"GET /api/test_bumped/\\" route has a newer version available",
Expand All @@ -230,7 +261,7 @@ describe('#registerApiDeprecationsInfo', () => {
});

it('returns deprecated type deprecated route', async () => {
const getDeprecations = createGetApiDeprecations({ coreUsageData, http });
const getDeprecations = createGetApiDeprecations({ coreUsageData, http, docLinks });
const deprecatedRoute = createDeprecatedRouteDetails({
routePath: '/api/test_deprecated/',
routeDeprecationOptions: { reason: { type: 'deprecate' }, message: 'additional message' },
Expand Down Expand Up @@ -265,6 +296,10 @@ describe('#registerApiDeprecationsInfo', () => {
"level": "critical",
"message": Array [
"The API \\"GET /api/test_deprecated/\\" has been called 13 times. The last call was on Sunday, September 1, 2024 6:06 AM -04:00.",
Object {
"content": "To include information about deprecated API calls in debug logs, edit your Kibana configuration as detailed in [the documentation](https://www.elastic.co/guide/en/kibana/test-branch/logging-settings.html#enable-http-debug-logs).",
"type": "markdown",
},
"This issue has been marked as resolved on Thursday, October 17, 2024 8:06 AM -04:00 but the API has been called 12 times since.",
"additional message",
],
Expand All @@ -275,7 +310,7 @@ describe('#registerApiDeprecationsInfo', () => {
});

it('does not return resolved deprecated route', async () => {
const getDeprecations = createGetApiDeprecations({ coreUsageData, http });
const getDeprecations = createGetApiDeprecations({ coreUsageData, http, docLinks });
const deprecatedRoute = createDeprecatedRouteDetails({ routePath: '/api/test_resolved/' });
http.getRegisteredDeprecatedApis.mockReturnValue([deprecatedRoute]);
usageClientMock.getDeprecatedApiUsageStats.mockResolvedValue([
Expand All @@ -290,7 +325,7 @@ describe('#registerApiDeprecationsInfo', () => {
});

it('returns never resolved deprecated route', async () => {
const getDeprecations = createGetApiDeprecations({ coreUsageData, http });
const getDeprecations = createGetApiDeprecations({ coreUsageData, http, docLinks });
const deprecatedRoute = createDeprecatedRouteDetails({
routePath: '/api/test_never_resolved/',
});
Expand Down Expand Up @@ -328,15 +363,68 @@ describe('#registerApiDeprecationsInfo', () => {
"level": "critical",
"message": Array [
"The API \\"GET /api/test_never_resolved/\\" has been called 13 times. The last call was on Sunday, September 1, 2024 6:06 AM -04:00.",
Object {
"content": "To include information about deprecated API calls in debug logs, edit your Kibana configuration as detailed in [the documentation](https://www.elastic.co/guide/en/kibana/test-branch/logging-settings.html#enable-http-debug-logs).",
"type": "markdown",
},
],
"title": "The \\"GET /api/test_never_resolved/\\" route is removed",
},
]
`);
});

it('returns internal route access deprecation', async () => {
const getDeprecations = createGetApiDeprecations({ coreUsageData, http, docLinks });
const deprecatedRoute = createInternalRouteDetails({});
http.getRegisteredDeprecatedApis.mockReturnValue([deprecatedRoute]);
usageClientMock.getDeprecatedApiUsageStats.mockResolvedValue([
createApiUsageStat(buildApiDeprecationId(deprecatedRoute), {
totalMarkedAsResolved: 0,
markedAsResolvedLastCalledAt: undefined,
}),
]);

const deprecations = await getDeprecations();
expect(deprecations).toMatchInlineSnapshot(`
Array [
Object {
"apiId": "1.0.0|post|/internal/api",
"correctiveActions": Object {
"manualSteps": Array [
"Identify the origin of these API calls.",
"Delete any requests you have that use this API. Check the learn more link for possible alternatives.",
"Once you have successfully stopped using this API, mark this issue as resolved. It will no longer appear in the Upgrade Assistant unless another call using this API is detected.",
],
"mark_as_resolved_api": Object {
"apiTotalCalls": 13,
"routeMethod": "post",
"routePath": "/internal/api/",
"routeVersion": "1.0.0",
"timestamp": 2024-10-17T12:06:41.224Z,
"totalMarkedAsResolved": 0,
},
},
"deprecationType": "api",
"documentationUrl": undefined,
"domainId": "core.http.access-deprecations",
"level": "warning",
"message": Array [
"The API \\"POST /internal/api/\\" has been called 13 times. The last call was on Sunday, September 1, 2024 6:06 AM -04:00.",
"Internal APIs are meant to be used by Elastic services only. You should not use them. External access to these APIs will be restricted.",
Object {
"content": "To include information in debug logs about calls to APIs that are internal to Elastic, edit your Kibana configuration as detailed in [the documentation](https://www.elastic.co/guide/en/kibana/test-branch/logging-settings.html#enable-http-debug-logs).",
"type": "markdown",
},
],
"title": "The \\"POST /internal/api/\\" API is internal to Elastic",
},
]
`);
});

it('does not return deprecated routes that have never been called', async () => {
const getDeprecations = createGetApiDeprecations({ coreUsageData, http });
const getDeprecations = createGetApiDeprecations({ coreUsageData, http, docLinks });
const deprecatedRoute = createDeprecatedRouteDetails({
routePath: '/api/test_never_resolved/',
});
Expand Down
Loading

0 comments on commit fe7e9fa

Please sign in to comment.