[SecuritySolution] Fix TypeScript errors (#167147)

Co-authored-by: Tomasz Ciecierski <ciecierskitomek@gmail.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Jan Monschke 2023-09-27 08:25:45 +02:00 committed by GitHub
parent f5705f3668
commit 26873aff87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 45 additions and 37 deletions

View file

@ -6,6 +6,7 @@
*/
export { UpsellingService } from './upselling_service';
export type {
MessageUpsellings,
PageUpsellings,
SectionUpsellings,
UpsellingSectionId,

View file

@ -5,6 +5,8 @@
* 2.0.
*/
// TODO: This import can be removed, once https://github.com/elastic/eui/pull/7221 made its way into Kibana main
import type { DefaultEuiMarkdownProcessingPlugins } from '@elastic/eui/src/components/markdown_editor/plugins/markdown_default_plugins/processing_plugins';
import {
getDefaultEuiMarkdownParsingPlugins,
getDefaultEuiMarkdownProcessingPlugins,
@ -14,15 +16,11 @@ import * as timelineMarkdownPlugin from './timeline';
import * as osqueryMarkdownPlugin from './osquery';
import * as insightMarkdownPlugin from './insight';
export const {
uiPlugins: nonStatefulUiPlugins,
parsingPlugins,
processingPlugins,
} = {
uiPlugins: getDefaultEuiMarkdownUiPlugins(),
parsingPlugins: getDefaultEuiMarkdownParsingPlugins(),
processingPlugins: getDefaultEuiMarkdownProcessingPlugins(),
};
export const nonStatefulUiPlugins = getDefaultEuiMarkdownUiPlugins();
export const parsingPlugins = getDefaultEuiMarkdownParsingPlugins();
// TODO: This explicit type can be removed, once https://github.com/elastic/eui/pull/7221 made its way into Kibana main
export const processingPlugins: DefaultEuiMarkdownProcessingPlugins =
getDefaultEuiMarkdownProcessingPlugins();
export const platinumOnlyPluginTokens = [insightMarkdownPlugin.insightPrefix];

View file

@ -11,6 +11,7 @@ import { PREFIX } from '../../shared/test_ids';
export const ANALYZER_GRAPH_TEST_ID = `${PREFIX}AnalyzerGraph` as const;
export const SESSION_VIEW_TEST_ID = `${PREFIX}SessionView` as const;
export const SESSION_VIEW_ERROR_TEST_ID = `${PREFIX}SessionViewError` as const;
/* Insights tab */

View file

@ -63,7 +63,7 @@ describe(
});
// roles `t1_analyst` and `t2_analyst` are very similar with exception of one page
(['t1_analyst', `t2_analyst`] as ROLE[]).forEach((roleName) => {
[ROLE.t1_analyst, ROLE.t2_analyst].forEach((roleName) => {
describe(`for role: ${roleName}`, () => {
const deniedPages = allPages.filter((page) => page.id !== 'endpointList');
@ -350,7 +350,7 @@ describe(
});
});
(['platform_engineer', 'endpoint_policy_manager'] as ROLE[]).forEach((roleName) => {
[ROLE.platform_engineer, ROLE.endpoint_policy_manager].forEach((roleName) => {
describe(`for role: ${roleName}`, () => {
const artifactPagesFullAccess = [
pageById.trustedApps,

View file

@ -55,7 +55,7 @@ describe(
});
// roles `t1_analyst` and `t2_analyst` are the same as far as endpoint access
(['t1_analyst', `t2_analyst`] as ROLE[]).forEach((roleName) => {
[ROLE.t1_analyst, ROLE.t2_analyst].forEach((roleName) => {
describe(`for role: ${roleName}`, () => {
const deniedPages = allPages.filter((page) => page.id !== 'endpointList');
@ -237,9 +237,11 @@ describe(
});
// Endpoint Operations Manager, Endpoint Policy Manager and Platform Engineer currently have the same level of access
(
['platform_engineer', `endpoint_operations_analyst`, 'endpoint_policy_manager'] as ROLE[]
).forEach((roleName) => {
[
ROLE.platform_engineer,
ROLE.endpoint_operations_analyst,
ROLE.endpoint_policy_manager,
].forEach((roleName) => {
describe(`for role: ${roleName}`, () => {
const artifactPagesFullAccess = [
pageById.trustedApps,

View file

@ -94,7 +94,6 @@ const sendApiLoginRequest = (
const basicProvider = loginState.body.selector.providers.find(
(provider) => provider.type === 'basic'
);
return request({
url: loginUrl,
method: 'POST',

View file

@ -7,9 +7,11 @@
import { coreMock } from '@kbn/core/public/mocks';
import { securitySolutionMock } from '@kbn/security-solution-plugin/public/mocks';
import { licensingMock } from '@kbn/licensing-plugin/public/mocks';
import type { Services } from '../services';
export const mockServices: Services = {
...coreMock.createStart(),
securitySolution: securitySolutionMock.createStart(),
licensing: licensingMock.createStart(),
};

View file

@ -5,10 +5,10 @@
* 2.0.
*/
import type { AppFeatureKey } from '@kbn/security-solution-plugin/common';
import type { AppFeatureKeyType } from '@kbn/security-solution-features';
import { PLI_APP_FEATURES } from '../../../common/pli/pli_config';
export const getProductTypeByPLI = (requiredPLI: AppFeatureKey): string | null => {
export const getProductTypeByPLI = (requiredPLI: AppFeatureKeyType): string | null => {
if (PLI_APP_FEATURES.security.essentials.includes(requiredPLI)) {
return 'Security Essentials';
}

View file

@ -8,11 +8,11 @@
import { EuiEmptyPrompt, EuiIcon } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import React from 'react';
import type { AppFeatureKey } from '@kbn/security-solution-plugin/common';
import type { AppFeatureKeyType } from '@kbn/security-solution-features';
import { getProductTypeByPLI } from '../hooks/use_product_type_by_pli';
const OsqueryResponseActionsUpsellingSection: React.FC<{ requiredPLI: AppFeatureKey }> = React.memo(
({ requiredPLI }) => {
const OsqueryResponseActionsUpsellingSection: React.FC<{ requiredPLI: AppFeatureKeyType }> =
React.memo(({ requiredPLI }) => {
const productTypeRequired = getProductTypeByPLI(requiredPLI);
return (
@ -38,8 +38,7 @@ const OsqueryResponseActionsUpsellingSection: React.FC<{ requiredPLI: AppFeature
}
/>
);
}
);
});
OsqueryResponseActionsUpsellingSection.displayName = 'OsqueryResponseActionsUpsellingSection';

View file

@ -8,11 +8,11 @@
import React from 'react';
import { EuiEmptyPrompt, EuiIcon } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { AppFeatureKey } from '@kbn/security-solution-plugin/common';
import type { AppFeatureKeyType } from '@kbn/security-solution-features';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import { getProductTypeByPLI } from '../hooks/use_product_type_by_pli';
const ThreatIntelligencePaywall: React.FC<{ requiredPLI: AppFeatureKey }> = React.memo(
const ThreatIntelligencePaywall: React.FC<{ requiredPLI: AppFeatureKeyType }> = React.memo(
function PaywallComponent({ requiredPLI }) {
const productTypeRequired = getProductTypeByPLI(requiredPLI);

View file

@ -47,9 +47,11 @@ describe('Inspect Explore pages', { tags: ['@ess', '@serverless', '@brokenInServ
login();
visit(url, {
onLoad: () => {
waitForWelcomePanelToBeLoaded();
selectDataView(DATA_VIEW);
visitOptions: {
onLoad: () => {
waitForWelcomePanelToBeLoaded();
selectDataView(DATA_VIEW);
},
},
});

View file

@ -9,7 +9,7 @@ import { expandFirstAlert, waitForAlerts } from '../../../tasks/alerts';
import { createRule } from '../../../tasks/api_calls/rules';
import { cleanKibana } from '../../../tasks/common';
import { login } from '../../../tasks/login';
import { visit } from '../../../tasks/navigation';
import { visit, visitWithTimeRange } from '../../../tasks/navigation';
import { getNewRule } from '../../../objects/rule';

View file

@ -34,9 +34,11 @@ describe('Row renderers', { tags: ['@ess', '@serverless'] }, () => {
deleteTimelines();
login();
visitWithTimeRange(hostsUrl('allHosts'), {
onLoad: () => {
waitForWelcomePanelToBeLoaded();
waitForAllHostsToBeLoaded();
visitOptions: {
onLoad: () => {
waitForWelcomePanelToBeLoaded();
waitForAllHostsToBeLoaded();
},
},
});
openTimelineUsingToggle();

View file

@ -142,13 +142,14 @@ const loginWithUsernameAndPassword = (username: string, password: string) => {
const basicProvider = loginState.body.selector.providers.find(
(provider) => provider.type === 'basic'
);
return cy.request({
url: `${baseUrl}/internal/security/login`,
method: 'POST',
headers,
body: {
providerType: basicProvider.type,
providerName: basicProvider.name,
providerType: basicProvider?.type,
providerName: basicProvider?.name,
currentURL: '/',
params: { username, password },
},

View file

@ -8,6 +8,7 @@
import { request } from '@kbn/security-solution-plugin/public/management/cypress/tasks/common';
import { LoginState } from '@kbn/security-plugin/common/login_state';
import type { ServerlessRoleName } from '../../../../../shared/lib';
import { ServerlessRoleName as RoleName } from '../../../../../shared/lib/security/types';
import { STANDARD_HTTP_HEADERS } from '../../../../../shared/lib/security/default_http_headers';
/**
@ -36,8 +37,8 @@ const sendApiLoginRequest = (
method: 'POST',
headers,
body: {
providerType: basicProvider.type,
providerName: basicProvider.name,
providerType: basicProvider?.type,
providerName: basicProvider?.name,
currentURL: '/',
params: { username, password },
},
@ -64,7 +65,7 @@ interface CyLoginTask {
* @param user Defaults to `soc_manager`
*/
export const login: CyLoginTask = (
user: ServerlessRoleName | 'elastic' = 'soc_manager'
user: ServerlessRoleName | 'elastic' = RoleName.SOC_MANAGER
): ReturnType<typeof sendApiLoginRequest> => {
let username = Cypress.env('KIBANA_USERNAME');
let password = Cypress.env('KIBANA_PASSWORD');