Skip to content

Commit 9024718

Browse files
jaredhendrickson13Clément PAPPALARDOlemassykoi
authored
v2.11.1 Features & Fixes (#980)
* fix(DHCPServer): accept OUI-partial MAC entries in mac_allow/mac_deny (GUI parity) * fix(NetworkInterface): only validate descr filter-name rules on CHANGED values * feat(NetworkInterface): expose DHCPv6 client PD fields (dhcp6-ia-pd-len, dhcp6prefixonly) * docs: update default version in README install commands * docs: add notice that this project is reaching eol * feat: support pfSense CE 2.9.1 and Plus 26.07.1 * style: run prettier on changed files * test(NetworkInterface): fix broken NetworkInterface tests * test(NetworkInterface): fix broken interface descr length test * test(NetworkInterface): fix additional broken interface length tests * test(NetworkInterface): fix additional broken interface length tests * ci: update python version used in release workflow * ci: update python version used in quality workflow * ci: source oas schema from 2.9.0 in quality workflow * feat: support pfSense CE 2.9.2 and Plus 26.07.2 * ci: check oas schema with correct pf version * ci: correct freebsd version in oas checks --------- Co-authored-by: Clément PAPPALARDO <clement@NiPoGi.ipc.local> Co-authored-by: Clément PAPPALARDO <16377344+lemassykoi@users.noreply.github.com>
2 parents 82ff327 + 938a733 commit 9024718

12 files changed

Lines changed: 235 additions & 26 deletions

‎.github/workflows/build.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757
strategy:
5858
matrix:
5959
include:
60-
- PFSENSE_VERSION: pfSense-2.8.1-RELEASE
61-
FREEBSD_ID: freebsd15
60+
- PFSENSE_VERSION: pfSense-2.9.0-RELEASE
61+
FREEBSD_ID: freebsd16
6262
steps:
6363
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
6464
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
@@ -105,8 +105,8 @@ jobs:
105105
strategy:
106106
matrix:
107107
include:
108-
- PFSENSE_VERSION: pfSense-2.8.1-RELEASE
109-
FREEBSD_ID: freebsd15
108+
- PFSENSE_VERSION: pfSense-2.9.0-RELEASE
109+
FREEBSD_ID: freebsd16
110110
steps:
111111
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
112112
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
@@ -136,6 +136,10 @@ jobs:
136136
FREEBSD_ID: freebsd15
137137
- PFSENSE_VERSION: pfSense-2.9.0-RELEASE
138138
FREEBSD_ID: freebsd16
139+
- PFSENSE_VERSION: pfSense-2.9.1-RELEASE
140+
FREEBSD_ID: freebsd16
141+
- PFSENSE_VERSION: pfSense-2.9.2-RELEASE
142+
FREEBSD_ID: freebsd16
139143

140144
steps:
141145
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

‎.github/workflows/quality.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
needs: ["check_black"]
4545
strategy:
4646
matrix:
47-
PYTHON_VERSION: ["3.10", "3.11"]
47+
PYTHON_VERSION: ["3.14"]
4848
steps:
4949
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5050
- name: Set up Python ${{ matrix.PYTHON_VERSION }}

‎.github/workflows/release.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ concurrency: build
99
# Sets global environment variables for releases
1010
env:
1111
SWAGGER_UI_VERSION: "5.17.10"
12-
PYTHON_VERSION: "3.10"
12+
PYTHON_VERSION: "3.14"
1313
DEFAULT_PFSENSE_VERSION: "2.9.0"
1414

1515
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
@@ -30,6 +30,10 @@ jobs:
3030
PFSENSE_VERSION: "2.8.1"
3131
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
3232
PFSENSE_VERSION: "2.9.0"
33+
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
34+
PFSENSE_VERSION: "2.9.1"
35+
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
36+
PFSENSE_VERSION: "2.9.2"
3337
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
3438
PFSENSE_VERSION: "25.11.1"
3539
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
@@ -38,6 +42,10 @@ jobs:
3842
PFSENSE_VERSION: "26.03.1"
3943
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
4044
PFSENSE_VERSION: "26.07"
45+
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
46+
PFSENSE_VERSION: "26.07.1"
47+
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
48+
PFSENSE_VERSION: "26.07.2"
4149

4250
steps:
4351
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

‎README.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ The pfSense REST API package is an unofficial, open-source REST and GraphQL API
1111
firewalls. It is designed to be light-weight, fast, and easy to use. This guide will help you get started with the REST
1212
API package and provide you with the information you need to configure and use the package effectively.
1313

14+
> [!IMPORTANT]
15+
> This project will soon come to end. For more information on the path forward and migration to the official
16+
> pfSense API, please refer to the [announcement](https://github.com/pfrest/pfSense-pkg-RESTAPI/discussions/962).
17+
1418
## Key Features
1519

1620
- 200+ REST endpoints available for managing your firewall and associated services
@@ -36,13 +40,13 @@ commands are included below for quick reference.
3640
Install on pfSense CE:
3741

3842
```bash
39-
pkg-static add https://github.com/pfrest/pfSense-pkg-RESTAPI/releases/latest/download/pfSense-2.8.1-pkg-RESTAPI.pkg
43+
pkg-static add https://github.com/pfrest/pfSense-pkg-RESTAPI/releases/latest/download/pfSense-2.9.2-pkg-RESTAPI.pkg
4044
```
4145

4246
Install on pfSense Plus:
4347

4448
```bash
45-
pkg-static -C /dev/null add https://github.com/pfrest/pfSense-pkg-RESTAPI/releases/latest/download/pfSense-26.03.1-pkg-RESTAPI.pkg
49+
pkg-static -C /dev/null add https://github.com/pfrest/pfSense-pkg-RESTAPI/releases/latest/download/pfSense-26.07.2-pkg-RESTAPI.pkg
4650
```
4751

4852
> [!WARNING]

‎docs/INSTALL_AND_CONFIG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ run pfSense. It's recommended to follow Netgate's [minimum hardware requirements
1616

1717
- pfSense CE 2.8.1
1818
- pfSense CE 2.9.0
19+
- pfSense CE 2.9.1
20+
- pfSense CE 2.9.2
1921
- pfSense Plus 25.11.1
2022
- pfSense Plus 26.03
2123
- pfSense Plus 26.03.1
2224
- pfSense Plus 26.07
25+
- pfSense Plus 26.07.1
26+
- pfSense Plus 26.07.2
2327

2428
!!! Warning
2529
Installation of the package on unsupported versions of pfSense may result in unexpected behavior and/or system instability.

‎pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,17 @@ class DHCPServer extends Model {
128128
many: true,
129129
maximum_length: 17,
130130
verbose_name: 'MAC Allow',
131-
validators: [new MACAddressValidator()],
132-
help_text: 'MAC addresses this DHCP server is allowed to provide leases for.',
131+
validators: [new MACAddressValidator(allow_partial: true)],
132+
help_text: 'MAC addresses this DHCP server is allowed to provide leases for. OUI prefixes (partial MACs, e.g. `EC:71:DB`) are accepted to match all devices of a vendor (GUI parity).',
133133
);
134134
$this->mac_deny = new StringField(
135135
default: [],
136136
allow_empty: true,
137137
many: true,
138138
maximum_length: 17,
139139
verbose_name: 'MAC Deny',
140-
validators: [new MACAddressValidator()],
141-
help_text: 'MAC addresses this DHCP server is not allowed to provide leases for.',
140+
validators: [new MACAddressValidator(allow_partial: true)],
141+
help_text: 'MAC addresses this DHCP server is not allowed to provide leases for. OUI prefixes (partial MACs, e.g. `EC:71:DB`) are accepted to match all devices of a vendor (GUI parity).',
142142
);
143143
$this->domainsearchlist = new StringField(
144144
default: [],

‎pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServerAddressPool.inc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,18 @@ class DHCPServerAddressPool extends Model {
7474
allow_empty: true,
7575
many: true,
7676
maximum_length: 17,
77-
validators: [new MACAddressValidator()],
77+
validators: [new MACAddressValidator(allow_partial: true)],
7878
verbose_name: 'MAC Allow',
79-
help_text: 'MAC addresses this DHCP server is allowed to provide leases for.',
79+
help_text: 'MAC addresses this DHCP server is allowed to provide leases for. OUI prefixes (partial MACs, e.g. `EC:71:DB`) are accepted to match all devices of a vendor (GUI parity).',
8080
);
8181
$this->mac_deny = new StringField(
8282
default: [],
8383
allow_empty: true,
8484
many: true,
8585
maximum_length: 17,
86-
validators: [new MACAddressValidator()],
86+
validators: [new MACAddressValidator(allow_partial: true)],
8787
verbose_name: 'MAC Deny',
88-
help_text: 'MAC addresses this DHCP server is not allowed to provide leases for.',
88+
help_text: 'MAC addresses this DHCP server is not allowed to provide leases for. OUI prefixes (partial MACs, e.g. `EC:71:DB`) are accepted to match all devices of a vendor (GUI parity).',
8989
);
9090
$this->domainsearchlist = new StringField(
9191
default: [],

‎pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/NetworkInterface.inc‎

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class NetworkInterface extends Model {
6161
public ForeignModelField $gatewayv6;
6262
public BooleanField $ipv6usev4iface;
6363
public BooleanField $slaacusev4iface;
64+
public BooleanField $dhcp6prefixonly;
65+
public StringField $dhcp6_ia_pd_len;
6466
public StringField $prefix_6rd;
6567
public StringField $gateway_6rd;
6668
public IntegerField $prefix_6rd_v4plen;
@@ -94,10 +96,7 @@ class NetworkInterface extends Model {
9496
required: true,
9597
unique: true,
9698
maximum_length: 128,
97-
validators: [
98-
new FilterNameValidator(),
99-
new UniqueFromForeignModelValidator(model: 'FirewallAlias', field: 'name'),
100-
],
99+
validators: [new UniqueFromForeignModelValidator(model: 'FirewallAlias', field: 'name')],
101100
verbose_name: 'Description',
102101
help_text: 'The descriptive name for this interface.',
103102
);
@@ -367,6 +366,43 @@ class NetworkInterface extends Model {
367366
verbose_name: 'SLAAC Use IPv4 Interface',
368367
help_text: 'Enable or disable IPv6 using the IPv4 connectivity link (PPPoE).',
369368
);
369+
370+
$this->dhcp6prefixonly = new BooleanField(
371+
default: false,
372+
conditions: ['typev6' => 'dhcp6'],
373+
verbose_name: 'Request Only an IPv6 Prefix',
374+
help_text: 'Only request an IPv6 prefix, do not request an IPv6 address.',
375+
);
376+
$this->dhcp6_ia_pd_len = new StringField(
377+
required: false,
378+
default: 'none',
379+
allow_empty: false,
380+
conditions: ['typev6' => 'dhcp6'],
381+
choices: [
382+
'none',
383+
'0',
384+
'1',
385+
'2',
386+
'3',
387+
'4',
388+
'5',
389+
'6',
390+
'7',
391+
'8',
392+
'9',
393+
'10',
394+
'11',
395+
'12',
396+
'13',
397+
'14',
398+
'15',
399+
'16',
400+
],
401+
internal_name: 'dhcp6-ia-pd-len',
402+
maximum_length: 4,
403+
verbose_name: 'DHCPv6 Prefix Delegation size',
404+
help_text: 'The delegated prefix length provided by the DHCPv6 server. `none` disables delegation; numeric values are the IA-PD length (16 -> /48 ... 0 -> /64). Normally specified by the ISP.',
405+
);
370406
$this->prefix_6rd = new StringField(
371407
required: true,
372408
unique: true,
@@ -445,6 +481,16 @@ class NetworkInterface extends Model {
445481
* @returns string The validated $descr to set.
446482
* @throws ValidationError When the `$descr` value is invalid. */
447483
public function validate_descr(string $descr): string {
484+
# Only apply the filter-name validation when the descr CHANGES. pfSense
485+
# revalidates every field on PATCH, so validating an unchanged value
486+
# would lock entire interfaces whose pre-existing descr predates these
487+
# rules (e.g. 'LAN', which matches a reserved pf filter token) — the
488+
# GUI allows such interfaces to be edited without renaming.
489+
$initial = $this->initial_object;
490+
if ($initial !== null and $initial->descr->value === $descr) {
491+
return $descr;
492+
}
493+
448494
# Ensure OpenVPN interfaces are 22 characters or less
449495
if (str_starts_with($this->if->value, 'ovpn') and strlen($descr) > 22) {
450496
throw new ValidationError(
@@ -477,6 +523,11 @@ class NetworkInterface extends Model {
477523
);
478524
}
479525

526+
# Filter-name rules apply to NEW/CHANGED descr values only (moved
527+
# from the field-level validator so unchanged legacy values are
528+
# not re-validated on unrelated PATCHes).
529+
(new FilterNameValidator())->validate($descr, 'descr');
530+
480531
return $descr;
481532
}
482533

‎pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,4 +677,18 @@ class APIModelsDHCPServerTestCase extends TestCase {
677677
# Delete the test interface
678678
$interface->delete();
679679
}
680+
681+
/**
682+
* Ensures OUI-partial MAC entries (vendor prefixes, a supported pfSense GUI feature) are accepted in
683+
* mac_allow/mac_deny. Regression test: these fields are revalidated on every PATCH, so strict validation
684+
* locked entire scopes containing legacy partial entries behind HTTP 400 MAC_ADDRESS_VALIDATOR_FAILED.
685+
*/
686+
public function test_accept_oui_partial_mac_entries(): void {
687+
$this->assert_does_not_throw(function (): void {
688+
$dhcp_server = new DHCPServer(id: 'lan', async: false);
689+
$dhcp_server->mac_deny->value = ['EC:71:DB', '00:60:6E', 'B8:27:EB'];
690+
$dhcp_server->mac_allow->value = ['DC:A6:32'];
691+
$dhcp_server->update();
692+
});
693+
}
680694
}

‎pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsNetworkInterfaceTestCase.inc‎

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class APIModelsNetworkInterfaceTestCase extends TestCase {
5252
$test_model->if->value = 'ovpn1';
5353

5454
# Ensure the validation succeeds when value is an acceptable length
55-
$test_model->validate_descr('length is ok');
55+
$test_model->validate_descr('lengthisok');
5656
},
5757
);
5858
}
@@ -82,7 +82,7 @@ class APIModelsNetworkInterfaceTestCase extends TestCase {
8282
$test_model->if->value = 'ipsec1';
8383

8484
# Ensure the validation succeeds when value is an acceptable length
85-
$test_model->validate_descr('length is ok');
85+
$test_model->validate_descr('lengthisok');
8686
},
8787
);
8888
}
@@ -112,7 +112,7 @@ class APIModelsNetworkInterfaceTestCase extends TestCase {
112112
$test_model->if->value = 'gif1';
113113

114114
# Ensure the validation succeeds when value is an acceptable length
115-
$test_model->validate_descr('length is ok');
115+
$test_model->validate_descr('lengthisok');
116116
},
117117
);
118118
}
@@ -142,7 +142,7 @@ class APIModelsNetworkInterfaceTestCase extends TestCase {
142142
$test_model->if->value = 'gre1';
143143

144144
# Ensure the validation succeeds when value is an acceptable length
145-
$test_model->validate_descr('length is ok');
145+
$test_model->validate_descr('lengthisok');
146146
},
147147
);
148148
}
@@ -876,4 +876,79 @@ class APIModelsNetworkInterfaceTestCase extends TestCase {
876876
}
877877

878878
# TODO: Needs Tests to ensure other interface types are correctly configured on the backend
879+
880+
/**
881+
* Checks that a NEW descr value violating filter-name rules is rejected
882+
* (FilterNameValidator now runs in validate_descr for changed values).
883+
*/
884+
public function test_descr_new_value_rejects_reserved_name(): void {
885+
$this->assert_throws_response(
886+
response_id: 'FILTER_NAME_VALIDATOR_RESERVED_NAME_USED',
887+
code: 400,
888+
callable: function () {
889+
$test_model = new NetworkInterface();
890+
$test_model->if->value = 'igc0';
891+
$test_model->validate_descr('LAN');
892+
},
893+
);
894+
}
895+
896+
/**
897+
* Checks that validate_descr accepts reserved legacy values when the
898+
* descr is UNCHANGED from the initial object (regression: pfSense
899+
* revalidates every field on PATCH; validating an unchanged value
900+
* locked whole interfaces whose descr predates the rules).
901+
*/
902+
public function test_descr_unchanged_legacy_value_not_revalidated(): void {
903+
$this->assert_does_not_throw(
904+
callable: function () {
905+
$test_model = new NetworkInterface();
906+
$test_model->if->value = 'igc0';
907+
908+
# Simulate a loaded object whose initial descr is a legacy
909+
# reserved token (e.g. created before the validator existed)
910+
$test_model->initial_object = $test_model->copy();
911+
$test_model->initial_object->descr->value = 'LAN';
912+
$test_model->descr->value = 'LAN';
913+
914+
# Unchanged descr -> no filter-name validation
915+
$test_model->validate_descr('LAN');
916+
},
917+
);
918+
}
919+
920+
/**
921+
* Checks that dhcp6_ia_pd_len accepts the GUI choices ('none' and the
922+
* 16..0 IA-PD lengths) and rejects out-of-set values.
923+
*/
924+
public function test_dhcp6_ia_pd_len_choices(): void {
925+
$this->assert_does_not_throw(
926+
callable: function () {
927+
$test_model = new NetworkInterface();
928+
$test_model->typev6->value = 'dhcp6';
929+
$test_model->dhcp6_ia_pd_len->value = '0';
930+
$test_model->dhcp6_ia_pd_len->validate();
931+
},
932+
);
933+
934+
$this->assert_does_not_throw(
935+
callable: function () {
936+
$test_model = new NetworkInterface();
937+
$test_model->typev6->value = 'dhcp6';
938+
$test_model->dhcp6_ia_pd_len->value = 'none';
939+
$test_model->dhcp6_ia_pd_len->validate();
940+
},
941+
);
942+
943+
$this->assert_throws_response(
944+
response_id: 'FIELD_INVALID_CHOICE',
945+
code: 400,
946+
callable: function () {
947+
$test_model = new NetworkInterface();
948+
$test_model->typev6->value = 'dhcp6';
949+
$test_model->dhcp6_ia_pd_len->value = '999';
950+
$test_model->dhcp6_ia_pd_len->validate();
951+
},
952+
);
953+
}
879954
}

0 commit comments

Comments
 (0)