diff --git a/packages/kbn-securitysolution-io-ts-alerting-types/src/threat_mapping/index.test.ts b/packages/kbn-securitysolution-io-ts-alerting-types/src/threat_mapping/index.test.ts index 6e2e671dbb029..3ebc7331aef71 100644 --- a/packages/kbn-securitysolution-io-ts-alerting-types/src/threat_mapping/index.test.ts +++ b/packages/kbn-securitysolution-io-ts-alerting-types/src/threat_mapping/index.test.ts @@ -37,7 +37,7 @@ describe('threat_mapping', () => { }); test('it should fail validation with an extra entry item', () => { - const payload: ThreatMappingEntries & Array<{ extra: string }> = [ + const payload: Array = [ { field: 'field.one', type: 'mapping', @@ -111,7 +111,7 @@ describe('threat_mapping', () => { }); test('it should fail validate with an extra key', () => { - const payload: ThreatMapping & Array<{ extra: string }> = [ + const payload: Array = [ { entries: [ { @@ -133,7 +133,7 @@ describe('threat_mapping', () => { }); test('it should fail validate with an extra inner entry', () => { - const payload: ThreatMapping & Array<{ entries: Array<{ extra: string }> }> = [ + const payload: Array }> = [ { entries: [ { diff --git a/packages/kbn-securitysolution-utils/src/add_remove_id_to_item/index.ts b/packages/kbn-securitysolution-utils/src/add_remove_id_to_item/index.ts index 37a58438e62f2..7dff865312829 100644 --- a/packages/kbn-securitysolution-utils/src/add_remove_id_to_item/index.ts +++ b/packages/kbn-securitysolution-utils/src/add_remove_id_to_item/index.ts @@ -19,7 +19,7 @@ import { v4 as uuidv4 } from 'uuid'; */ type NotArray = T extends unknown[] ? never : T; export const addIdToItem = (item: NotArray): T => { - const maybeId: typeof item & { id?: string } = item; + const maybeId = item as typeof item & { id?: string }; if (maybeId.id != null) { return item; } else { @@ -41,7 +41,7 @@ export const removeIdFromItem = ( }, Exclude > => { - const maybeId: typeof item & { id?: string } = item; + const maybeId = item as typeof item & { id?: string }; if (maybeId.id != null) { const { id, ...noId } = maybeId; return noId; diff --git a/x-pack/plugins/lists/server/routes/utils/build_siem_response.ts b/x-pack/plugins/lists/server/routes/utils/build_siem_response.ts index d61a02a869d28..f4baa8779201f 100644 --- a/x-pack/plugins/lists/server/routes/utils/build_siem_response.ts +++ b/x-pack/plugins/lists/server/routes/utils/build_siem_response.ts @@ -5,7 +5,12 @@ * 2.0. */ -import { CustomHttpResponseOptions, KibanaResponseFactory } from '@kbn/core/server'; +import { + CustomHttpResponseOptions, + HttpResponsePayload, + KibanaResponseFactory, + ResponseError, +} from '@kbn/core/server'; /** * Copied from x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts @@ -49,7 +54,12 @@ export class SiemResponseFactory { constructor(private response: KibanaResponseFactory) {} // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - error({ statusCode, body, headers, bypassErrorFormat }: CustomHttpResponseOptions) { + error({ + statusCode, + body, + headers, + bypassErrorFormat, + }: CustomHttpResponseOptions) { // KibanaResponse is not exported so we cannot use a return type here and that is why the linter is turned off above const contentType: CustomHttpResponseOptions['headers'] = { 'content-type': 'application/json', @@ -60,7 +70,7 @@ export class SiemResponseFactory { }; const formattedBody = bypassErrorFormat - ? body + ? Object.assign<{}, unknown>({}, body) // eslint-disable-line prefer-object-spread : { message: body ?? statusToErrorMessage(statusCode) }; return this.response.custom({ diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts index a200afdd34199..5b0e859052500 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts @@ -12,6 +12,8 @@ import type { RouteValidationFunction, KibanaResponseFactory, CustomHttpResponseOptions, + HttpResponsePayload, + ResponseError, } from '@kbn/core/server'; import { CustomHttpRequestError } from '../../../utils/custom_http_request_error'; @@ -160,7 +162,11 @@ const statusToErrorMessage = (statusCode: number) => { export class SiemResponseFactory { constructor(private response: KibanaResponseFactory) {} - error({ statusCode, body, headers }: CustomHttpResponseOptions) { + error({ + statusCode, + body, + headers, + }: CustomHttpResponseOptions) { const contentType: CustomHttpResponseOptions['headers'] = { 'content-type': 'application/json', }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/utils.ts index d624d9033f299..18634fb7162b7 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/utils.ts @@ -13,9 +13,11 @@ import { BulkActionEditTypeEnum } from '../../../../../../common/api/detection_e * @param editAction {@link BulkActionEditType} * @returns {boolean} */ -export const isIndexPatternsBulkEditAction = (editAction: BulkActionEditType) => - [ +export const isIndexPatternsBulkEditAction = (editAction: BulkActionEditType) => { + const indexPatternsActions: BulkActionEditType[] = [ BulkActionEditTypeEnum.add_index_patterns, BulkActionEditTypeEnum.delete_index_patterns, BulkActionEditTypeEnum.set_index_patterns, - ].includes(editAction); + ]; + return indexPatternsActions.includes(editAction); +}; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/validations.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/validations.ts index 4a1aef9ed28d7..74fc6f91d37c4 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/validations.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/validations.ts @@ -10,7 +10,10 @@ import { invariant } from '../../../../../../common/utils/invariant'; import { isMlRule } from '../../../../../../common/machine_learning/helpers'; import { isEsqlRule } from '../../../../../../common/detection_engine/utils'; import { BulkActionsDryRunErrCode } from '../../../../../../common/constants'; -import type { BulkActionEditPayload } from '../../../../../../common/api/detection_engine/rule_management'; +import type { + BulkActionEditPayload, + BulkActionEditType, +} from '../../../../../../common/api/detection_engine/rule_management'; import { BulkActionEditTypeEnum } from '../../../../../../common/api/detection_engine/rule_management'; import type { RuleAlertType } from '../../../rule_schema'; import { isIndexPatternsBulkEditAction } from './utils'; @@ -99,11 +102,11 @@ export const validateBulkEditRule = async ({ * add_rule_actions, set_rule_actions can be applied to prebuilt/immutable rules */ const istEditApplicableToImmutableRule = (edit: BulkActionEditPayload[]): boolean => { - return edit.every(({ type }) => - [BulkActionEditTypeEnum.set_rule_actions, BulkActionEditTypeEnum.add_rule_actions].includes( - type - ) - ); + const applicableActions: BulkActionEditType[] = [ + BulkActionEditTypeEnum.set_rule_actions, + BulkActionEditTypeEnum.add_rule_actions, + ]; + return edit.every(({ type }) => applicableActions.includes(type)); }; /**