Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SecuritySolution] Fix TypeScript errors #167147

Merged
merged 8 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
export { UpsellingService } from './upselling_service';
export type {
MessageUpsellings,
PageUpsellings,
SectionUpsellings,
UpsellingSectionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linking elastic/eui#7221 here to keep track of it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janmonschke , now that the linked PR is merged. Do you want to go ahead and remove the import in this PR only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@logeekal Oh, did they already update EUI in Kibana?

Copy link
Contributor

@patrykkopycinski patrykkopycinski Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, #166868

import {
getDefaultEuiMarkdownParsingPlugins,
getDefaultEuiMarkdownProcessingPlugins,
Expand All @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linking elastic/eui#7221 here to keep track of it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

export const processingPlugins: DefaultEuiMarkdownProcessingPlugins =
getDefaultEuiMarkdownProcessingPlugins();

export const platinumOnlyPluginTokens = [insightMarkdownPlugin.insightPrefix];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ const sendApiLoginRequest = (
const basicProvider = loginState.body.selector.providers.find(
(provider) => provider.type === 'basic'
);

return request({
url: loginUrl,
method: 'POST',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -38,8 +38,7 @@ const OsqueryResponseActionsUpsellingSection: React.FC<{ requiredPLI: AppFeature
}
/>
);
}
);
});

OsqueryResponseActionsUpsellingSection.displayName = 'OsqueryResponseActionsUpsellingSection';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ describe('Row renderers', { tags: ['@ess', '@serverless'] }, () => {
deleteTimelines();
login();
visitWithTimeRange(hostsUrl('allHosts'), {
onLoad: () => {
waitForWelcomePanelToBeLoaded();
waitForAllHostsToBeLoaded();
visitOptions: {
onLoad: () => {
waitForWelcomePanelToBeLoaded();
waitForAllHostsToBeLoaded();
},
},
});
openTimelineUsingToggle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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 },
},
Expand All @@ -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');
Expand Down