From 37cb3b8594e2750fb95c270ae29e1edc84aa4509 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Wed, 3 Sep 2025 18:19:43 -0600 Subject: [PATCH 1/2] fix(LengthValidator): don't validate maximum if no maximum is given This commit allows the maximum constraint to be entirely bypassed by setting the maximum property to 0 as some cases will not have a static maximum value. --- .../usr/local/pkg/RESTAPI/Validators/LengthValidator.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Validators/LengthValidator.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Validators/LengthValidator.inc index 2c536bdd8..3d0b30b4b 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Validators/LengthValidator.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Validators/LengthValidator.inc @@ -44,7 +44,7 @@ class LengthValidator extends RESTAPI\Core\Validator { ); } # Throw an error if the string contains more characters than the specified maximum - if (strlen($value) > $this->maximum) { + if ($this->maximum and strlen($value) > $this->maximum) { throw new ValidationError( message: "Field '$field_name' exceeds the maximum character length of $this->maximum.", response_id: 'LENGTH_VALIDATOR_MAXIMUM_CONSTRAINT', @@ -61,7 +61,7 @@ class LengthValidator extends RESTAPI\Core\Validator { ); } # Throw an error if the array contains more array entries than the specified maximum - if (count($value) > $this->maximum) { + if ($this->maximum and count($value) > $this->maximum) { throw new ValidationError( message: "Field '$field_name' exceeds the maximum array length of $this->maximum.", response_id: 'LENGTH_VALIDATOR_MAXIMUM_CONSTRAINT', From c2834dde567dd7d713eb871cd02cc9f035659970 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Wed, 3 Sep 2025 18:25:34 -0600 Subject: [PATCH 2/2] fix(FirewallAlias): do not use default many_maximum constraint for 'address' and 'detail' fields #745 The real maximum number of entries allowed in a specific table by pf varies by system. This commit ensures a static limit is not set for entries. --- .../files/usr/local/pkg/RESTAPI/Models/FirewallAlias.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/FirewallAlias.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/FirewallAlias.inc index 3319078a1..beae751f1 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/FirewallAlias.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/FirewallAlias.inc @@ -49,6 +49,7 @@ class FirewallAlias extends Model { default: [], allow_empty: true, many: true, + many_maximum: 0, // Do not enforce a maximum number of entries delimiter: ' ', help_text: "Sets the host, network or port entries for the alias. When `type` is set to `host`, each entry must be a valid IP address or FQDN. When `type` is set to `network`, each entry must be a valid @@ -59,6 +60,7 @@ class FirewallAlias extends Model { default: [], allow_empty: true, many: true, + many_maximum: 0, // Do not enforce a maximum number of entries delimiter: '||', help_text: "Sets descriptions for each alias `address`. Values must match the order of the `address` value it relates to. For example, the first value specified here is the description for the first