From 1deab39453178fccd432fcdfde2a09f630e7611c Mon Sep 17 00:00:00 2001 From: Ashokaditya Date: Wed, 21 Apr 2021 10:09:43 +0200 Subject: [PATCH] update schema to enforce dropdown validation for PATH field refs elastic/security-team/issues/543 --- .../common/endpoint/schema/trusted_apps.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/security_solution/common/endpoint/schema/trusted_apps.ts b/x-pack/plugins/security_solution/common/endpoint/schema/trusted_apps.ts index 3c397257d3f79..03cbe53f60320 100644 --- a/x-pack/plugins/security_solution/common/endpoint/schema/trusted_apps.ts +++ b/x-pack/plugins/security_solution/common/endpoint/schema/trusted_apps.ts @@ -30,10 +30,16 @@ export const GetTrustedAppsRequestSchema = { }; const ConditionEntryTypeSchema = schema.literal('match'); -const ConditionEntryOperatorSchema = schema.oneOf([ - schema.literal(OperatorEntryField.included), - schema.literal(OperatorEntryField.wildcard_caseless), -]); +// when field === PATH -> operator in ('included', 'wildcard_caseless') else operator === 'included' +const ConditionEntryOperatorSchema = schema.conditional( + schema.siblingRef('field'), + ConditionEntryField.PATH, + schema.oneOf([ + schema.literal(OperatorEntryField.included), + schema.literal(OperatorEntryField.wildcard_caseless), + ]), + schema.literal(OperatorEntryField.included) +); /* * A generic Entry schema to be used for a specific entry schema depending on the OS