diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts b/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts index 6b6bc018c8e5c..0fc09348a2b1e 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts @@ -200,7 +200,7 @@ export type AlertsIndexNamespace = z.infer; export const AlertsIndexNamespace = z.string(); export type MaxSignals = z.infer; -export const MaxSignals = z.number().int().min(1); +export const MaxSignals = z.number().int().min(1).max(1000); export type ThreatSubtechnique = z.infer; export const ThreatSubtechnique = z.object({ diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_request_schema.test.ts b/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_request_schema.test.ts index 0b89cbdc72889..a166f1ec0411d 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_request_schema.test.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_request_schema.test.ts @@ -483,6 +483,19 @@ describe('rules schema', () => { ); }); + test('max_signals cannot be greater than 1000', () => { + const payload: RuleCreateProps = { + ...getCreateRulesSchemaMock(), + max_signals: 1001, + }; + + const result = RuleCreateProps.safeParse(payload); + expectParseError(result); + expect(stringifyZodError(result.error)).toEqual( + 'max_signals: Number must be less than or equal to 1000' + ); + }); + test('max_signals can be 1', () => { const payload: RuleCreateProps = { ...getCreateRulesSchemaMock(), diff --git a/x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.ts b/x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.ts index 7a810fa9247d2..5a5601b3ffd09 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.ts @@ -129,7 +129,11 @@ export const appErrorToErrorStack = (error: AppError): Error => { : ''; const stringifiedError = getStringifiedStack(error); const adaptedError = new Error( - `${String(error.body.message).trim() !== '' ? error.body.message : error.message} ${statusCode}` + postprocessErrorString( + `${ + String(error.body.message).trim() !== '' ? error.body.message : error.message + } ${statusCode}` + ) ); // Note although all the Typescript typings say that error.name is a string and exists, we still can encounter an undefined so we // do an extra guard here and default to empty string if it is undefined @@ -239,3 +243,8 @@ export const isEmptyObjectWhenStringified = (item: unknown): boolean => { return false; } }; + +function postprocessErrorString(str: string): string { + // Remove the `[request body]` prefix added by Zod for request validation errors + return str.replace(/\[request body\]:/g, ''); +}