LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Firewall: rule input parser for the rule sheet, with C and JS tests on shared cases
Federico Pereira91078a82c8c3
diff --git a/sdk/fwrule.js b/sdk/fwrule.jsnew file mode 100644index 0000000..cb7907d--- /dev/null+++ b/sdk/fwrule.js@@ -0,0 +1,224 @@+// fwrule.js — checks and normalizes what the user types for a firewall rule (Settings → Privacy →+// per-app network, and the Monitor's "Allow / Block this domain"), with the same rules as the C+// store (server/src/fw/rules.c: fw_parse_dest, fw_format_dest, norm_domain; docs/FIREWALL.md).+// lord.fw.addRule validates again in C: this module only lets the sheet say what is wrong before+// saving, and shows the rules in the order the engine weighs them. Pure functions, no imports, so+// node can test them (server/tests/fwrule_input_test.mjs, against the C parser with the shared cases+// in server/tests/fw_dest_cases.txt).+//+// parseDest('*.Example.com.') → { ok: true, kind: 'wildcard', dst: '*.example.com' }+// parseDest('10.0.0.1/8') → { ok: false, error: 'hostBits' }+// parsePort('8000-8080') → { ok: true, port: '8000-8080' }+// checkRule({ dst, port, proto, action }) → { ok, rule } | { ok: false, field, error }+// specificity(rule) / sortByPrecedence(rules): the engine has no priority numbers; the most+// specific destination wins, then the smaller port range, a concrete protocol, deny, the newest.++// ---- domains -------------------------------------------------------------------------------------++// Lowercase, no trailing dot, labels of 1–63 from [a-z0-9-_], up to 253 in total; the last label+// can't be only digits (a mistyped IP). International names go in punycode (xn--…).+export function normDomain(s) {+ if (typeof s !== 'string') return null;+ let d = s;+ if (d.endsWith('.')) d = d.slice(0, -1);+ if (!d || d.length > 253) return null;+ d = d.replace(/[A-Z]/g, (c) => c.toLowerCase());+ const labels = d.split('.');+ for (const l of labels) if (!/^[a-z0-9_-]{1,63}$/.test(l)) return null;+ if (/^[0-9]+$/.test(labels[labels.length - 1])) return null;+ return d;+}++// ---- addresses (inet_pton / inet_ntop as glibc does them) -----------------------------------------++function parseV4(s) {+ const p = s.split('.');+ if (p.length !== 4) return null;+ const out = [];+ for (const x of p) {+ if (!/^[0-9]{1,3}$/.test(x) || (x.length > 1 && x[0] === '0')) return null;+ const v = Number(x);+ if (v > 255) return null;+ out.push(v);+ }+ return out;+}++function parseV6(s) {+ if (!/^[0-9a-fA-F:.]+$/.test(s)) return null;+ let tail4 = null;+ let str = s;+ const lastColon = str.lastIndexOf(':');+ if (str.includes('.')) { // a trailing dotted IPv4+ tail4 = parseV4(str.slice(lastColon + 1));+ if (!tail4) return null;+ str = str.slice(0, lastColon + 1) + 'x'; // placeholder for two words+ }+ const dbl = str.indexOf('::');+ if (dbl !== str.lastIndexOf('::') && dbl >= 0) return null;+ const parseGroups = (part) => (part === '' ? [] : part.split(':'));+ let head, tail;+ if (dbl >= 0) { head = parseGroups(str.slice(0, dbl)); tail = parseGroups(str.slice(dbl + 2)); }+ else { head = parseGroups(str); tail = null; }+ const words = (list) => {+ const w = [];+ for (const g of list) {+ if (g === 'x') { if (!tail4) return null; w.push((tail4[0] << 8) | tail4[1], (tail4[2] << 8) | tail4[3]); continue; }+ if (!/^[0-9a-fA-F]{1,4}$/.test(g)) return null;+ w.push(parseInt(g, 16));+ }+ return w;+ };+ const hw = words(head);+ if (!hw) return null;+ // the IPv4 placeholder may only be the last group+ if (head.includes('x') && (tail !== null || head[head.length - 1] !== 'x')) return null;+ let all;+ if (tail === null) {+ if (hw.length !== 8) return null;+ all = hw;+ } else {+ const tw = words(tail);+ if (!tw) return null;+ if (tail.includes('x') && tail[tail.length - 1] !== 'x') return null;+ if (hw.length + tw.length > 7) return null; // "::" stands for at least one word+ all = [...hw, ...new Array(8 - hw.length - tw.length).fill(0), ...tw];+ }+ const b = [];+ for (const w of all) b.push(w >> 8, w & 255);+ return b;+}++// inet_ntop(AF_INET6): the longest run (≥ 2) of zero words becomes "::" (the first on a tie);+// ::ffff:a.b.c.d and ::a.b.c.d (but not :: or ::1) keep the dotted IPv4, as glibc prints them.+function formatV6(b) {+ const w = [];+ for (let i = 0; i < 16; i += 2) w.push((b[i] << 8) | b[i + 1]);+ let best = -1, bestLen = 0;+ for (let i = 0; i < 8;) {+ if (w[i] !== 0) { i++; continue; }+ let j = i;+ while (j < 8 && w[j] === 0) j++;+ if (j - i > bestLen) { best = i; bestLen = j - i; }+ i = j;+ }+ if (bestLen < 2) best = -1;+ let out = '';+ for (let i = 0; i < 8; i++) {+ if (best >= 0 && i >= best && i < best + bestLen) {+ if (i === best) out += ':';+ continue;+ }+ if (i) out += ':';+ if (i === 6 && best === 0 && (bestLen === 6 || (bestLen === 5 && w[5] === 0xffff))) {+ out += `${b[12]}.${b[13]}.${b[14]}.${b[15]}`;+ return out;+ }+ out += w[i].toString(16);+ }+ if (best >= 0 && best + bestLen === 8) out += ':';+ return out;+}++const bitAt = (a, i) => (a[i >> 3] >> (7 - (i & 7))) & 1;+const hostBitsZero = (a, prefix) => { for (let i = prefix; i < a.length * 8; i++) if (bitAt(a, i)) return false; return true; };++function parseCidr(s) {+ const slash = s.indexOf('/');+ const ip = slash >= 0 ? s.slice(0, slash) : s;+ if (!ip || ip.length >= 64) return { ok: false, error: 'address' };+ let fam, a;+ if (ip.includes(':')) { a = parseV6(ip); fam = 6; } else { a = parseV4(ip); fam = 4; }+ if (!a) return { ok: false, error: 'address' };+ const bits = fam === 4 ? 32 : 128;+ let pfx = bits;+ if (slash >= 0) {+ const p = s.slice(slash + 1);+ if (!/^[0-9]{1,5}$/.test(p) || (p.length > 1 && p[0] === '0') || Number(p) > bits) return { ok: false, error: 'prefix' };+ pfx = Number(p);+ }+ if (fam === 6 && pfx >= 96 && a.slice(0, 10).every((x) => x === 0) && a[10] === 0xff && a[11] === 0xff) {+ a = a.slice(12); // ::ffff:a.b.c.d/n is its IPv4+ fam = 4;+ pfx -= 96;+ }+ if (!hostBitsZero(a, pfx)) return { ok: false, error: 'hostBits' };+ const text = fam === 4 ? a.join('.') : formatV6(a);+ const full = pfx === (fam === 4 ? 32 : 128);+ return { ok: true, kind: full ? 'address' : 'network', fam, prefix: pfx, dst: full ? text : `${text}/${pfx}` };+}++// ---- destinations --------------------------------------------------------------------------------++// kind: 'domain' | 'wildcard' | 'address' | 'network' | 'lan' | 'internet' | 'any'.+// error: 'empty' | 'domain' | 'wildcard' | 'address' | 'prefix' | 'hostBits'.+export function parseDest(input) {+ if (typeof input !== 'string') return { ok: false, error: 'empty' };+ const s = input.trim();+ if (!s) return { ok: false, error: 'empty' };+ if (s === 'any' || s === 'lan' || s === 'internet') return { ok: true, kind: s, dst: s };+ if (s.includes(':') || s.includes('/')) return parseCidr(s);+ if (s[0] === '*') {+ const d = s[1] === '.' ? normDomain(s.slice(2)) : null;+ return d ? { ok: true, kind: 'wildcard', dst: `*.${d}`, domain: d } : { ok: false, error: 'wildcard' };+ }+ const c = parseCidr(s);+ if (c.ok) return c;+ const d = normDomain(s);+ if (d) return { ok: true, kind: 'domain', dst: d, domain: d };+ return { ok: false, error: /^[0-9.]+$/.test(s) ? 'address' : 'domain' };+}++// "" (any port), "443" or "8000-8080"; 1–65535, lo ≤ hi, no leading zeros.+export function parsePort(input) {+ const s = typeof input === 'string' ? input.trim() : input == null ? '' : String(input);+ if (!s) return { ok: true, port: '' };+ const m = /^([1-9][0-9]{0,4})(?:\s*-\s*([1-9][0-9]{0,4}))?$/.exec(s);+ if (!m) return { ok: false, error: 'port' };+ const lo = Number(m[1]), hi = m[2] ? Number(m[2]) : lo;+ if (hi > 65535 || lo > hi) return { ok: false, error: 'port' };+ return { ok: true, port: lo === hi ? String(lo) : `${lo}-${hi}`, lo, hi };+}++// The whole rule as the sheet has it. proto: '' | 'tcp' | 'udp'; action: 'allow' | 'deny'.+// A bare "any" (every destination, port and protocol) is the app's default, set apart in the UI.+export function checkRule({ dst, port, proto = '', action, dir = 'out' } = {}) {+ const d = parseDest(dst);+ if (!d.ok) return { ok: false, field: 'dst', error: d.error };+ const p = parsePort(port);+ if (!p.ok) return { ok: false, field: 'port', error: p.error };+ if (proto !== '' && proto !== 'tcp' && proto !== 'udp') return { ok: false, field: 'proto', error: 'proto' };+ if (action !== 'allow' && action !== 'deny') return { ok: false, field: 'action', error: 'action' };+ if (dir !== 'out' && dir !== 'in') return { ok: false, field: 'dir', error: 'dir' };+ if (d.kind === 'any' && !p.port && !proto && dir === 'out') return { ok: false, field: 'dst', error: 'isDefault' };+ return { ok: true, kind: d.kind, rule: { dst: d.dst, port: p.port, proto, action, dir } };+}++// The app's default ("allow everything" / "block everything except the rules") is the rule+// {out, any, any port, any protocol}, the Monitor's switch.+export const isDefaultRule = (r) => r && r.dir === 'out' && r.dst === 'any' && !r.port && !r.proto;++// ---- precedence (fw_decide's order, see rules.c "consider") ---------------------------------------++const SC_ANY = 0, SC_NET = 500, SC_CIDR = 1000, SC_WILD = 2000, SC_EXACT = 3000;++export function specificity(rule) {+ const d = parseDest(rule.dst);+ if (!d.ok) return -1;+ switch (d.kind) {+ case 'domain': return SC_EXACT;+ case 'wildcard': return SC_WILD + d.domain.split('.').length;+ case 'address': case 'network': return SC_CIDR + d.prefix;+ case 'lan': case 'internet': return SC_NET;+ default: return SC_ANY;+ }+}++const portWidth = (r) => { const p = parsePort(r.port || ''); return p.ok && p.port ? p.hi - p.lo : 65535; };++// Strongest first: what the engine would pick when several rules match the same connection.+export function comparePrecedence(a, b) {+ return specificity(b) - specificity(a) || portWidth(a) - portWidth(b) || (b.proto ? 1 : 0) - (a.proto ? 1 : 0) ||+ (b.action === 'deny' ? 1 : 0) - (a.action === 'deny' ? 1 : 0) || (b.id || 0) - (a.id || 0);+}+export const sortByPrecedence = (rules) => [...rules].sort(comparePrecedence);diff --git a/sdk/index.js b/sdk/index.jsindex 4c880c5..2bc76d5 100644--- a/sdk/index.js+++ b/sdk/index.js@@ -43,6 +43,7 @@ export { Markdown, markdownHeadings, parseMarkdown, parseInline, toggleTask } frexport { dock, useDockEntries, dockActivate, dockMenu, registerDockMenu, launcherIdOf, dockPrefs, DOCK_DEFAULTS, quitApp } from './dock.js';export { sound, useSound, useSoundPeak, soundState, defaultSink, defaultSource, microphones } from './sound.js';export { monitor, useMonitor, monitorSamples, monitorProcesses, monitorConnections, monitorDevices, MONITOR_HISTORY, firewall, firewallState } from './monitor.js';+export * as fwRule from './fwrule.js'; // checks what the user types for a firewall ruleexport { packages, packageList, refreshPackages, packageFile, loadWasm } from './packages.js';import { refreshPackages } from './packages.js';export {diff --git a/server/Makefile b/server/Makefileindex 217f45a..5ae95f4 100644--- a/server/Makefile+++ b/server/Makefile@@ -233,6 +233,13 @@ build/fw-rules-test: tests/fw_rules_test.c src/fw/rules.c src/fw/fwmap.c src/sec@mkdir -p build$(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/fw_rules_test.c src/fw/rules.c src/fw/fwmap.c src/sec/json.c./$@ || { rm -f $@; exit 1; }+# the destinations a user types in the rule sheet (tests/fw_dest_cases.txt), through the store's+# parser; tests/fwrule_input_test.mjs checks the same file against sdk/fwrule.js (run_suites.sh)+test: build/fwdest-test+build/fwdest-test: tests/fwdest_test.c tests/fw_dest_cases.txt src/fw/rules.c src/fw/fwmap.c src/sec/json.c $(wildcard src/fw/*.h) src/sec/json.h+ @mkdir -p build+ $(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/fwdest_test.c src/fw/rules.c src/fw/fwmap.c src/sec/json.c+ ./$@ || { rm -f $@; exit 1; }build/dnsmap-test: tests/dnsmap_test.c src/fw/dnsmap.c src/fw/rules.c src/fw/fwmap.c src/sec/json.c $(wildcard src/fw/*.h) src/sec/json.h@mkdir -p build$(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/dnsmap_test.c src/fw/dnsmap.c src/fw/rules.c src/fw/fwmap.c src/sec/json.cdiff --git a/server/tests/fw_dest_cases.txt b/server/tests/fw_dest_cases.txtnew file mode 100644index 0000000..5c05516--- /dev/null+++ b/server/tests/fw_dest_cases.txt@@ -0,0 +1,67 @@+# fw_dest_cases.txt — destinations a user may type for a firewall rule, and what the store keeps.+# One case per line: input, a tab, then the canonical destination or "!" if it must be refused.+# Both parsers read this file: the C one (fw_parse_dest + fw_format_dest, build/fwdest-test) and+# the JS one the Settings sheet uses (sdk/fwrule.js, tests/fwrule_input_test.mjs), so they can't+# drift apart.+example.com example.com+Example.COM example.com+example.com. example.com+www.example.com www.example.com+a_b.example.com a_b.example.com+xn--bcher-kva.example xn--bcher-kva.example+localhost localhost+*.example.com *.example.com+*.Example.com. *.example.com+*.cdn.example.com *.cdn.example.com+*.com *.com+*example.com !+**.example.com !+*. !+*.*.example.com !+example..com !+.example.com !+- -+exa mple.com !+exämple.com !+example.123 !+1.2.3 !+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com !+any any+lan lan+internet internet+192.0.2.7 192.0.2.7+192.0.2.7/32 192.0.2.7+10.0.0.0/8 10.0.0.0/8+10.0.0.1/8 !+0.0.0.0/0 0.0.0.0/0+192.168.1.0/24 192.168.1.0/24+192.168.1.0/33 !+192.168.1.0/ !+192.168.1.0/08 !+192.168.1.0/-1 !+256.1.1.1 !+01.2.3.4 !+1.2.3.4.5 !+2001:db8::1 2001:db8::1+2001:DB8::1 2001:db8::1+2001:db8::/32 2001:db8::/32+2001:db8::1/32 !+2001:0db8:0000:0000:0000:0000:0000:0001 2001:db8::1+::1 ::1+:: ::+::/0 ::/0+fe80::/10 fe80::/10+1:0:0:2:0:0:0:3 1:0:0:2::3+1:0:0:0:2:0:0:3 1::2:0:0:3+::ffff:192.0.2.7 192.0.2.7+::ffff:10.0.0.0/104 10.0.0.0/8+::ffff:c000:207 192.0.2.7+1::2::3 !+::: !+:1 !+1: !+12345::1 !+1:2:3:4:5:6:7:8:9 !+1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0+2001:db8::/129 !+2001:db8::g !diff --git a/server/tests/fwdest_test.c b/server/tests/fwdest_test.cnew file mode 100644index 0000000..ed53abb--- /dev/null+++ b/server/tests/fwdest_test.c@@ -0,0 +1,35 @@+/* fwdest_test.c — the destinations of server/tests/fw_dest_cases.txt through the store's parser+ * (fw_parse_dest, then fw_format_dest): each one must be refused ("!") or come back as the canonical+ * text. The same file is checked against the Settings sheet's parser (sdk/fwrule.js) by+ * tests/fwrule_input_test.mjs, so what the sheet accepts is what lord.fw.addRule stores.+ *+ * build/fwdest-test [cases file] (default: tests/fw_dest_cases.txt, run from server/) */+#include "../src/fw/rules.h"++#include <stdio.h>+#include <string.h>++int main(int argc, char **argv) {+ const char *path = argc > 1 ? argv[1] : "tests/fw_dest_cases.txt";+ FILE *f = fopen(path, "r");+ if (!f) { perror(path); return 1; }+ char line[600];+ int n = 0, bad = 0;+ while (fgets(line, sizeof line, f)) {+ line[strcspn(line, "\r\n")] = 0;+ if (!line[0] || line[0] == '#') continue;+ char *tab = strchr(line, '\t');+ if (!tab) { fprintf(stderr, "malformed line: %s\n", line); bad++; continue; }+ *tab = 0;+ const char *in = line, *want = tab + 1;+ FwRule r;+ memset(&r, 0, sizeof r);+ char got[FW_NAME_MAX + 8] = "!";+ if (!fw_parse_dest(in, &r) && fw_format_dest(&r, got, sizeof got)) snprintf(got, sizeof got, "(format failed)");+ n++;+ if (strcmp(got, want)) { fprintf(stderr, "✗ %-40s want %-24s got %s\n", in, want, got); bad++; }+ }+ fclose(f);+ printf("fwdest-test: %d cases, %d failed\n", n, bad);+ return bad != 0 || n == 0;+}diff --git a/server/tests/fwrule_input_test.mjs b/server/tests/fwrule_input_test.mjsnew file mode 100644index 0000000..95caf5b--- /dev/null+++ b/server/tests/fwrule_input_test.mjs@@ -0,0 +1,86 @@+// fwrule_input_test.mjs — the Settings / Monitor rule sheet's parser (sdk/fwrule.js).+//+// node tests/fwrule_input_test.mjs (from server/; run_suites.sh runs it when node exists)+//+// 1. Every destination in tests/fw_dest_cases.txt gives what the C store gives (build/fwdest-test+// checks the same file against fw_parse_dest + fw_format_dest).+// 2. Ports, protocols, actions, the app default, and the precedence order (rules.c "consider").+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const here = path.dirname(fileURLToPath(import.meta.url));+const { parseDest, parsePort, checkRule, sortByPrecedence, specificity, isDefaultRule } = await import(path.join(here, '../../sdk/fwrule.js'));++let n = 0, bad = 0;+const eq = (name, got, want) => {+ n++;+ const g = JSON.stringify(got), w = JSON.stringify(want);+ if (g !== w) { bad++; console.log(`✗ ${name}: want ${w}, got ${g}`); }+};++// 1. the shared destination cases+for (const line of fs.readFileSync(path.join(here, 'fw_dest_cases.txt'), 'utf8').split('\n')) {+ if (!line || line[0] === '#') continue;+ const [input, want] = line.split('\t');+ const d = parseDest(input);+ eq(`dest ${input}`, d.ok ? d.dst : '!', want);+}++// kinds and errors the sheet explains+eq('kind exact', parseDest('example.com').kind, 'domain');+eq('kind wildcard', parseDest('*.example.com').kind, 'wildcard');+eq('kind address', parseDest('192.0.2.7').kind, 'address');+eq('kind network', parseDest('10.0.0.0/8').kind, 'network');+eq('kind v6 network', parseDest('2001:db8::/32').kind, 'network');+eq('err empty', parseDest(' ').error, 'empty');+eq('err wildcard', parseDest('*example.com').error, 'wildcard');+eq('err hostBits', parseDest('10.0.0.1/8').error, 'hostBits');+eq('err prefix', parseDest('10.0.0.0/33').error, 'prefix');+eq('err address', parseDest('256.1.1.1').error, 'address');+eq('err domain', parseDest('exa mple.com').error, 'domain');+eq('trimmed', parseDest(' Example.com ').dst, 'example.com');++// 2. ports+eq('port empty', parsePort(''), { ok: true, port: '' });+eq('port one', parsePort('443').port, '443');+eq('port range', parsePort('8000-8080').port, '8000-8080');+eq('port range spaces', parsePort('8000 - 8080').port, '8000-8080');+eq('port same', parsePort('53-53').port, '53');+for (const p of ['0', '65536', '080', '9-1', 'abc', '1-', '-1', '1-2-3', '+80']) eq(`port bad ${p}`, parsePort(p).ok, false);++// whole rules+eq('rule ok', checkRule({ dst: '*.Example.com', port: '', proto: '', action: 'deny' }),+ { ok: true, kind: 'wildcard', rule: { dst: '*.example.com', port: '', proto: '', action: 'deny', dir: 'out' } });+eq('rule bad dst', checkRule({ dst: 'x..y', action: 'allow' }).field, 'dst');+eq('rule bad port', checkRule({ dst: 'example.com', port: '70000', action: 'allow' }).field, 'port');+eq('rule bad proto', checkRule({ dst: 'example.com', proto: 'icmp', action: 'allow' }).field, 'proto');+eq('rule bad action', checkRule({ dst: 'example.com', action: 'maybe' }).field, 'action');+eq('rule default refused', checkRule({ dst: 'any', action: 'deny' }).error, 'isDefault');+eq('rule any with port', checkRule({ dst: 'any', port: '25', proto: 'tcp', action: 'deny' }).ok, true);+eq('isDefault', isDefaultRule({ dir: 'out', dst: 'any', port: '', proto: '' }), true);+eq('isDefault port', isDefaultRule({ dir: 'out', dst: 'any', port: '443', proto: '' }), false);++// precedence: exact > wildcard (more labels first) > network (longer prefix) > lan/internet > any;+// then the smaller port range, a concrete protocol, deny before allow, the newest (higher id)+eq('spec order', [specificity({ dst: 'a.example.com' }) > specificity({ dst: '*.a.example.com' }),+ specificity({ dst: '*.a.example.com' }) > specificity({ dst: '*.example.com' }),+ specificity({ dst: '*.com' }) > specificity({ dst: '192.0.2.7' }),+ specificity({ dst: '192.0.2.7' }) > specificity({ dst: '192.0.2.0/24' }),+ specificity({ dst: '0.0.0.0/0' }) > specificity({ dst: 'internet' }),+ specificity({ dst: 'lan' }) > specificity({ dst: 'any' })], [true, true, true, true, true, true]);+const rules = [+ { id: 1, dst: 'any', port: '', proto: '', action: 'deny' },+ { id: 2, dst: '*.example.com', port: '', proto: '', action: 'allow' },+ { id: 3, dst: '*.example.com', port: '443', proto: '', action: 'allow' },+ { id: 4, dst: 'api.example.com', port: '', proto: '', action: 'allow' },+ { id: 5, dst: '10.0.0.0/8', port: '', proto: '', action: 'deny' },+ { id: 6, dst: '10.1.0.0/16', port: '', proto: '', action: 'allow' },+ { id: 7, dst: '*.example.com', port: '443', proto: 'tcp', action: 'allow' },+ { id: 8, dst: '*.example.com', port: '443', proto: 'tcp', action: 'deny' },+ { id: 9, dst: '*.example.com', port: '443', proto: 'tcp', action: 'deny' },+];+eq('sorted', sortByPrecedence(rules).map((r) => r.id), [4, 9, 8, 7, 3, 2, 6, 5, 1]);++console.log(`fwrule-input-test: ${n} checks, ${bad} failed`);+process.exit(bad ? 1 : 0);diff --git a/server/tests/run_suites.sh b/server/tests/run_suites.shindex f02e608..348f25e 100644--- a/server/tests/run_suites.sh+++ b/server/tests/run_suites.sh@@ -147,6 +147,9 @@ EOFrun "ipp-test" build/ipp-testrun "tp-test" build/tp-testrun "fan-test" build/fan-test+ # the firewall rule sheet's parser (sdk/fwrule.js) against the same cases as build/fwdest-test+ if have node; then run "fwrule-input-test (sdk/fwrule.js)" node tests/fwrule_input_test.mjs+ else skip "fwrule-input-test" "node"; fi}full() {