Skip to content

Commit a2d0d3c

Browse files
Merge pull request #376 from jaredhendrickson13/next_patch
v1.6.1 Fixes
2 parents 8ae9f04 + 41ad327 commit a2d0d3c

6 files changed

Lines changed: 102 additions & 33 deletions

File tree

.github/workflows/build.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
freebsd_version:
21-
- FreeBSD-14.0-CURRENT
22-
20+
include:
21+
- freebsd_version: FreeBSD-14.0-CURRENT
22+
freebsd_id: freebsd14
23+
2324
steps:
2425
- uses: actions/checkout@v3
2526
- name: Setup FreeBSD build VM
@@ -32,7 +33,7 @@ jobs:
3233
- name: Build pfSense-pkg-API on FreeBSD
3334
run: |
3435
/usr/bin/ssh -o StrictHostKeyChecking=no ${{ matrix.freebsd_version }}.jaredhendrickson.com 'sudo pkill ntpd || true && sudo ntpdate pool.ntp.org || true'
35-
/usr/local/bin/python3 tools/make_package.py --host ${{ matrix.freebsd_version }}.jaredhendrickson.com --branch ${{ env.commit_id }} --tag ${{ env.build_version }}_${{ matrix.freebsd_version }}
36+
/usr/local/bin/python3 tools/make_package.py --host ${{ matrix.freebsd_version }}.jaredhendrickson.com --branch ${{ env.commit_id }} --tag ${{ env.build_version }}_${{ matrix.freebsd_id }}
3637
3738
- name: Teardown FreeBSD build VM
3839
if: "${{ always() }}"
@@ -42,8 +43,8 @@ jobs:
4243
4344
- uses: actions/upload-artifact@v3
4445
with:
45-
name: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_version }}.pkg
46-
path: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_version }}.pkg
46+
name: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg
47+
path: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg
4748

4849
e2e_tests:
4950
runs-on: self-hosted
@@ -53,19 +54,19 @@ jobs:
5354
matrix:
5455
include:
5556
- pfsense_version: pfSense-2.7.0-RELEASE
56-
freebsd_version: FreeBSD-14.0-CURRENT
57+
freebsd_id: freebsd14
5758
- pfsense_version: pfSense-23.01-RELEASE
58-
freebsd_version: FreeBSD-14.0-CURRENT
59+
freebsd_id: freebsd14
5960
- pfsense_version: pfSense-23.05-RELEASE
60-
freebsd_version: FreeBSD-14.0-CURRENT
61+
freebsd_id: freebsd14
6162

6263
steps:
6364
- uses: actions/checkout@v3
6465

6566
- uses: actions/download-artifact@v3
6667
with:
67-
name: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_version }}.pkg
68-
path: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_version }}.pkg
68+
name: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg
69+
path: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg
6970

7071
- name: Setup pfSense VM
7172
run: |
@@ -79,11 +80,11 @@ jobs:
7980
run: |
8081
pfsense-vshell --host ${{ matrix.pfsense_version }}.jaredhendrickson.com -u admin -p pfsense -c 'pfSsh.php playback enablesshd' -k
8182
pfsense-vshell --host ${{ matrix.pfsense_version }}.jaredhendrickson.com -u admin -p pfsense -c "mkdir /root/.ssh/ && echo $(cat ~/.ssh/id_rsa.pub) > /root/.ssh/authorized_keys" -k
82-
scp -o StrictHostKeyChecking=no pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_version }}.pkg/pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_version }}.pkg admin@${{ matrix.pfsense_version }}.jaredhendrickson.com:/tmp/
83+
scp -o StrictHostKeyChecking=no pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg/pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg admin@${{ matrix.pfsense_version }}.jaredhendrickson.com:/tmp/
8384
8485
- name: Install pfSense-pkg-API on pfSense
8586
run: |
86-
/usr/local/bin/pfsense-vshell --host ${{ matrix.pfsense_version }}.jaredhendrickson.com --no_verify -c "pkg -C /dev/null add /tmp/pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_version }}.pkg" -u admin -p pfsense
87+
/usr/local/bin/pfsense-vshell --host ${{ matrix.pfsense_version }}.jaredhendrickson.com --no_verify -c "pkg -C /dev/null add /tmp/pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg" -u admin -p pfsense
8788
/usr/local/bin/pfsense-vshell --host ${{ matrix.pfsense_version }}.jaredhendrickson.com --no_verify -c '/etc/rc.restart_webgui' -u admin -p pfsense || true
8889
sleep 10
8990

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
concurrency: build
9+
10+
jobs:
11+
build:
12+
runs-on: self-hosted
13+
14+
strategy:
15+
matrix:
16+
include:
17+
- freebsd_version: FreeBSD-14.0-CURRENT
18+
pfsense_version: 2.7
19+
- freebsd_version: FreeBSD-14.0-CURRENT
20+
pfsense_version: 23.05
21+
- freebsd_version: FreeBSD-14.0-CURRENT
22+
pfsense_version: 23.01
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Setup FreeBSD build VM
27+
run: |
28+
/usr/local/bin/VBoxManage controlvm ${{ matrix.freebsd_version }} poweroff || true
29+
/usr/local/bin/VBoxManage snapshot ${{ matrix.freebsd_version }} restore initial
30+
/usr/local/bin/VBoxManage startvm ${{ matrix.freebsd_version }} --type headless
31+
sleep 5
32+
33+
- name: Build pfSense-pkg-API on FreeBSD
34+
run: |
35+
/usr/bin/ssh -o StrictHostKeyChecking=no ${{ matrix.freebsd_version }}.jaredhendrickson.com 'sudo pkill ntpd || true && sudo ntpdate pool.ntp.org || true'
36+
/usr/local/bin/python3 tools/make_package.py --host ${{ matrix.freebsd_version }}.jaredhendrickson.com --branch ${{ github.sha }} --tag ${{ github.ref_name }} --filename pfSense-${{ matrix.pfsense_version }}-pkg-API.pkg
37+
38+
- name: Teardown FreeBSD build VM
39+
if: "${{ always() }}"
40+
run: |
41+
/usr/local/bin/VBoxManage controlvm ${{ matrix.freebsd_version }} poweroff || true
42+
/usr/local/bin/VBoxManage snapshot ${{matrix.freebsd_version}} restore initial
43+
44+
- name: Release
45+
uses: softprops/action-gh-release@v1
46+
with:
47+
files: pfSense-${{ matrix.pfsense_version }}-pkg-API.pkg

pfSense-pkg-API/files/etc/inc/api/models/APIFirewallAliasEntryCreate.inc

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,19 @@ class APIFirewallAliasEntryCreate extends APIModel {
111111
}
112112

113113
public function __validate_detail() {
114+
# Get a list of the new addresses and details requested
115+
$this->initial_data["address"] = $this->__value_to_array($this->initial_data["address"]);
114116
$this->initial_data["detail"] = $this->__value_to_array($this->initial_data["detail"]);
115-
$this->validated_data["detail"] = ($this->validated_data["detail"]) ? explode("||", $this->validated_data["detail"]) : [];
116-
$this->validated_data["detail"] = $this->__value_to_array($this->validated_data["detail"]);
117-
$address = ($this->validated_data["address"]) ? explode(" ", $this->validated_data["address"]) : [];
118-
119-
# If we have less detail values than address values, add some defaults
120-
while(true) {
121-
# Check if we have the correct number of detail values
122-
if (count($this->initial_data["detail"]) < count($address)) {
117+
$this->validated_data["detail"] = $this->__value_to_array(explode("||", $this->validated_data["detail"]));
118+
119+
# Ensure the number of addresses is greater than or equal to the number details
120+
if (count($this->initial_data["address"]) >= count($this->initial_data["detail"])) {
121+
# Add automatic generated details if there are more addresses than details
122+
while (count($this->initial_data["address"]) > count($this->initial_data["detail"])) {
123123
$this->initial_data["detail"][] = "Entry added " . date('r');
124-
} else {
125-
break;
126124
}
127-
}
128125

129-
# Ensure the number of detail values is less than or equal to the number of address values
130-
if (count($this->initial_data["detail"]) <= count($address)) {
131-
# Loop through each alias detail and ensure it is a string
126+
# Loop through each ali:as detail and ensure it is a string
132127
foreach ($this->initial_data["detail"] as $detail) {
133128
if (is_string($detail)) {
134129
$this->validated_data["detail"][] = $detail;
@@ -168,7 +163,6 @@ class APIFirewallAliasEntryCreate extends APIModel {
168163
return [];
169164
} else {
170165
return [$value];
171-
172166
}
173167
} else {
174168
return $value;

pfSense-pkg-API/files/etc/inc/api/models/APISystemAPIVersionRead.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class APISystemAPIVersionRead extends APIModel {
3535

3636
public static function get_api_version() {
3737
# Pull the raw pkg info for the API package into an array for each line
38-
$pkg_info = explode(PHP_EOL, shell_exec("pkg info pfSense-pkg-API"));
38+
$pkg_info = explode(PHP_EOL, shell_exec("pkg-static info pfSense-pkg-API"));
3939

4040
# Loop through each line and check the version
4141
foreach ($pkg_info as $pkg_line) {

tests/test_api_v1_firewall_alias.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,17 @@ class APIE2ETestFirewallAlias(e2e_test_framework.APIE2ETest):
146146
"type": "port",
147147
"address": ["!@#!@#!@#"]
148148
}
149+
},
150+
{
151+
"name": "Check alias entry detail maximum constraint",
152+
"status": 400,
153+
"return": 4106,
154+
"req_data": {
155+
"name": "TEST",
156+
"type": "port",
157+
"address": [80],
158+
"detail": ["HTTP", "One-too-many!"]
159+
}
149160
}
150161
]
151162
put_tests = [

tools/make_package.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,23 @@ def build_on_remote_host(self):
125125
v=self.port_version,
126126
r="_" + self.port_revision if self.port_revision != "0" else ""
127127
)
128-
self.run_scp_cmd(src, ".")
128+
self.run_scp_cmd(src, f"{self.args.filename}")
129129

130130
def __start_argparse__(self):
131131
# Custom tag type for argparse
132132
def tag(value_string):
133-
if "." in value_string and "_" in value_string:
134-
return value_string
133+
if "." not in value_string:
134+
raise ValueError(f"{value_string} is not a semantic version tag")
135135

136-
raise argparse.ArgumentTypeError(f"{value_string} is not a semantic version tag")
136+
# Remove the leading 'v' if present
137+
if value_string.startswith("v"):
138+
value_string = value_string[1:]
139+
140+
# Convert the patch section to be prefixed with _ if it is prefixed with .
141+
if len(value_string.split(".")) == 3:
142+
value_string = value_string[::-1].replace(".", "_", 1)[::-1]
143+
144+
return value_string
137145

138146
parser = argparse.ArgumentParser(
139147
description="Build the pfSense API on FreeBSD"
@@ -166,6 +174,14 @@ def tag(value_string):
166174
required=True,
167175
help="The version tag to use when building."
168176
)
177+
parser.add_argument(
178+
'--filename', '-f',
179+
dest="filename",
180+
type=str,
181+
default=".",
182+
required=False,
183+
help="The filename to use for the package file."
184+
)
169185
self.args = parser.parse_args()
170186

171187
try:

0 commit comments

Comments
 (0)