[Cloud Security] Misconfiguration preview & Refactor CSP Plugin to include new package PHASE 3#191317
Conversation
…m:animehart/kibana into misconfiguration-preview-refactor-phase-2
…orts to be more specific
…be directly from csp common package
…m:animehart/kibana into misconfiguration-preview-refactor-phase-2
…nt for types or interface to be directly from csp package now
…m:animehart/kibana into misconfiguration-preview-refactor-phase-2
…ad of just import
… latest rule versions import on CSP plugin etc
|
/ci |
…rsion to be directly from common package
…ules are from rules/latest in common package instead of rules.ts, furthermore deleted unused file that was created during Phase 2
|
/ci |
|
/ci |
|
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security) |
…checked on Phase 4 instead
| export const extractErrorMessage = (e: unknown, defaultMessage = 'Unknown Error'): string => { | ||
| if (e instanceof Error) return e.message; | ||
| if (typeof e === 'string') return e; | ||
|
|
||
| return defaultMessage; // TODO: i18n | ||
| }; |
There was a problem hiding this comment.
Let's fix this todo:
const defaultErrorMessage = i18n.translate('xpack.csp.common.utils.helpers.unknownError', {
defaultMessage: 'Unknown Error',
});
export const extractErrorMessage = (e: unknown, fallbackMessage ?: string): string => {
if (e instanceof Error) return e.message;
if (typeof e === 'string') return e;
return fallbackMessage ?? defaultErrorMessage;
};
opauloh
left a comment
There was a problem hiding this comment.
looks good overall, I only have some questions and nitpicks
|
|
||
| export const useGetCspBenchmarkRulesStatesApi = () => { | ||
| const { http } = useKibana().services; | ||
| const { http } = useKibana<CoreStart & CspClientPluginStartDeps>().services; |
There was a problem hiding this comment.
http is part of CoreStart so that's only what we need here:
const { http } = useKibana<CoreStart>().services;| options?: UseQueryOptions<CspSetupStatus, unknown, CspSetupStatus> | ||
| ) => { | ||
| const { http } = useKibana().services; | ||
| const { http } = useKibana<CoreStart & CspClientPluginStartDeps>().services; |
There was a problem hiding this comment.
| const { http } = useKibana<CoreStart & CspClientPluginStartDeps>().services; | |
| const { http } = useKibana<CoreStart>().services; |
| UpdatePackagePolicy, | ||
| } from '@kbn/fleet-plugin/common'; | ||
| import type { BenchmarkRuleSelectParams } from '@kbn/cloud-security-posture-common/schema/rules/latest'; | ||
| import type { BenchmarkRuleSelectParams as BenchmarkRuleSelectParamsV1 } from '@kbn/cloud-security-posture-common/schema/rules/v4'; |
There was a problem hiding this comment.
shouldn't be BenchmarkRuleSelectParamsV4?
| // export const extractErrorMessage = (e: unknown, defaultMessage = 'Unknown Error'): string => { | ||
| // if (e instanceof Error) return e.message; | ||
| // if (typeof e === 'string') return e; | ||
|
|
||
| return defaultMessage; // TODO: i18n | ||
| }; | ||
| // return defaultMessage; // TODO: i18n | ||
| // }; |
| import { i18n } from '@kbn/i18n'; | ||
| import { extractErrorMessage } from '../../../common/utils/helpers'; | ||
| import { extractErrorMessage } from './helpers'; | ||
|
|
There was a problem hiding this comment.
shouldn't this file be in kbn-cloud-security-posture instead? A toast notification It's mainly a frontend function, not meant to be shared with the server.
…isId to be directly from csp package
…m:animehart/kibana into misconfiguration-preview-refactor-phase-3
…m:animehart/kibana into misconfiguration-preview-refactor-phase-3
maxcold
left a comment
There was a problem hiding this comment.
lgtm, one small comment on the duplicated types file
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
| export type BenchmarksCisId = 'cis_k8s' | 'cis_azure' | 'cis_aws' | 'cis_eks' | 'cis_gcp'; |
There was a problem hiding this comment.
let's either put it under ./types.ts or another way around split types.ts into meaningful files, eg. types/status.ts and types/finding.ts
|
/ci |
|
/ci |
1 similar comment
|
/ci |
|
/ci |
1 similar comment
|
/ci |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: |
The previous #190105 was way too big and made it hard to review without missing any bugs or potential bugs, Thus we decided we are going to make series of smaller PR to make things more manageable
We will be splitting it into 4 PR
Phase 1: Creating empty packages for csp and csp-common
Phase 2: Move Types from CSP plugin to the Package + Deleting duplicates in the CSP plugin where possible
Phase 3: Move Functions, Utils or Helpers, Hooks to Package
Phase 4: Misconfiguration Preview feature (with Cypress test and other required test)
This is Phase 3 of the Process,
This also includes moving rule versions type
This PR is the continuation of this PR #190933
NOTE:
Merge phase 2 first before this