@@ -624,6 +624,32 @@ const firewallRulesBehaviorsSchema = {
624624 errorMessage : 'The behaviors array must contain between 1 and 10 behavior items.' ,
625625} ;
626626
627+ const firewallFunctionsInstances = {
628+ type : 'object' ,
629+ properties : {
630+ name : {
631+ type : 'string' ,
632+ minLength : 1 ,
633+ maxLength : 100 ,
634+ errorMessage : 'The name must be a string between 1 and 100 characters long' ,
635+ } ,
636+ args : {
637+ type : 'object' ,
638+ default : { } ,
639+ errorMessage : "The 'args' field must be an object" ,
640+ } ,
641+ ref : {
642+ type : [ 'string' , 'number' ] ,
643+ errorMessage : "The 'ref' field must be a string or number referencing an existing Function name or ID" ,
644+ } ,
645+ } ,
646+ required : [ 'name' , 'ref' ] ,
647+ additionalProperties : false ,
648+ errorMessage : {
649+ additionalProperties : 'No additional properties are allowed in the firewallFunctionsInstance object' ,
650+ } ,
651+ } ;
652+
627653const azionConfigSchema = {
628654 $id : 'azionConfig' ,
629655 definitions : {
@@ -1361,9 +1387,19 @@ const azionConfigSchema = {
13611387 errorMessage : "The rule's 'match' field must be a string containing a valid regex pattern" ,
13621388 } ,
13631389 variable : {
1364- type : 'string' ,
1365- enum : FIREWALL_VARIABLES ,
1366- errorMessage : `The 'variable' field must be one of: ${ FIREWALL_VARIABLES . join ( ', ' ) } ` ,
1390+ anyOf : [
1391+ {
1392+ type : 'string' ,
1393+ pattern : '^\\$\\{(' + [ ...new Set ( FIREWALL_VARIABLES ) ] . join ( '|' ) + ')\\}$' ,
1394+ errorMessage : "The 'variable' field must be a valid variable wrapped in ${}" ,
1395+ } ,
1396+ {
1397+ type : 'string' ,
1398+ enum : [ ...FIREWALL_VARIABLES ] ,
1399+ errorMessage : "The 'variable' field must be a valid firewall variable" ,
1400+ } ,
1401+ ] ,
1402+ errorMessage : "The 'variable' field must be a valid variable (with or without ${})" ,
13671403 } ,
13681404 behaviors : firewallRulesBehaviorsSchema ,
13691405 criteria : {
@@ -1379,18 +1415,28 @@ const azionConfigSchema = {
13791415 errorMessage : `The 'conditional' field must be one of: ${ FIREWALL_RULE_CONDITIONAL . join ( ', ' ) } ` ,
13801416 } ,
13811417 variable : {
1382- type : 'string' ,
1383- enum : FIREWALL_VARIABLES ,
1384- errorMessage : `The 'variable' field must be one of: ${ FIREWALL_VARIABLES . join ( ', ' ) } ` ,
1418+ anyOf : [
1419+ {
1420+ type : 'string' ,
1421+ pattern : '^\\$\\{(' + [ ...new Set ( FIREWALL_VARIABLES ) ] . join ( '|' ) + ')\\}$' ,
1422+ errorMessage : "The 'variable' field must be a valid variable wrapped in ${}" ,
1423+ } ,
1424+ {
1425+ type : 'string' ,
1426+ enum : [ ...FIREWALL_VARIABLES ] ,
1427+ errorMessage : "The 'variable' field must be a valid firewall variable" ,
1428+ } ,
1429+ ] ,
1430+ errorMessage : "The 'variable' field must be a valid variable (with or without ${})" ,
13851431 } ,
13861432 operator : {
13871433 type : 'string' ,
13881434 enum : FIREWALL_RULE_OPERATORS ,
13891435 errorMessage : `The 'operator' field must be one of: ${ FIREWALL_RULE_OPERATORS . join ( ', ' ) } ` ,
13901436 } ,
13911437 argument : {
1392- type : 'string' ,
1393- errorMessage : 'The argument must be a string' ,
1438+ type : [ 'string' , 'number' ] ,
1439+ errorMessage : 'The argument must be a string or number ' ,
13941440 } ,
13951441 } ,
13961442 required : [ 'conditional' , 'variable' , 'operator' , 'argument' ] ,
@@ -1428,6 +1474,10 @@ const azionConfigSchema = {
14281474 } ,
14291475 } ,
14301476 } ,
1477+ functionsInstances : {
1478+ type : 'array' ,
1479+ items : firewallFunctionsInstances ,
1480+ } ,
14311481 } ,
14321482 required : [ 'name' ] ,
14331483 additionalProperties : false ,
@@ -2026,10 +2076,9 @@ const azionConfigSchema = {
20262076 } ,
20272077 } ,
20282078 additionalProperties : false ,
2029- required : [ 'build' , 'applications' , 'workloads' ] ,
20302079 errorMessage : {
20312080 additionalProperties :
2032- 'Config can only contain the following properties: build, functions, applications, workloads, purge, edgefirewall , networkList, waf, connectors, customPages' ,
2081+ 'Config can only contain the following properties: build, functions, applications, workloads, purge, firewall , networkList, waf, connectors, customPages' ,
20332082 type : 'Configuration must be an object' ,
20342083 } ,
20352084 } ,
0 commit comments