P1: the packet filter holder reads a port's scope from its derived rule's comment
A derived accept rule's one comment says derived <modules> <protocol>/<port> scope <any|private-network|local-network>, its module list cut with a count past 128 bytes; allow without a source is refused for a port whose derived rules name no scope any, read from the comments, never from a rule's shape. Builds: design 47 H2 §813 (4); H-A-357, H-A-384 (1), H-A-349 DQ-11
This commit is contained in:
@@ -10,10 +10,18 @@ import {
|
||||
|
||||
interface Timer { ms: number; fire: () => void; cancelled: boolean }
|
||||
|
||||
// The loaded mesh table: the store's port from the private network only, 80 from anywhere and 8443 from both.
|
||||
// The loaded mesh table: the store's port from the private network only, 80 from anywhere and 8443 from both; each derived
|
||||
// accept rule carries the one comment the node-engine's render writes, `derived <modules> <protocol>/<port> scope <scope>`
|
||||
// (47 H2 §813 (4), H-A-357), its module list cut with a count past 128 bytes (H-A-384 (1)).
|
||||
const TABLE = 'table inet mesh {\n\tchain input {\n\t\ttype filter hook input priority filter; policy drop;\n' +
|
||||
'\t\tip saddr { 10.77.0.1, 10.77.0.2 } tcp dport 5432 accept\n\t\tip6 saddr { fd77::1 } tcp dport 5432 accept\n' +
|
||||
'\t\ttcp dport 80 accept\n\t\tip saddr { 10.77.0.1 } tcp dport { 8443, 9500-9600 } accept\n\t\ttcp dport 8443 accept\n\t}\n}\n';
|
||||
'\t\tip saddr { 10.77.0.1, 10.77.0.2 } tcp dport 5432 accept comment "derived postgres tcp/5432 scope private-network"\n' +
|
||||
'\t\tip6 saddr { fd77::1 } tcp dport 5432 accept comment "derived postgres tcp/5432 scope private-network"\n' +
|
||||
'\t\ttcp dport 80 accept comment "derived route-proxy tcp/80 scope any"\n' +
|
||||
'\t\tip saddr { 10.77.0.1 } tcp dport 8443 accept comment "derived a,b,+4 tcp/8443 scope private-network"\n' +
|
||||
'\t\ttcp dport 8443 accept comment "derived c tcp/8443 scope any"\n' +
|
||||
'\t\tip saddr { 192.168.1.0/24 } tcp dport 9500-9600 accept comment "derived nats tcp/9500-9600 scope local-network"\n' +
|
||||
'\t\ttcp dport 7000 accept comment "derived x,+2 tcp/7000 scope private-network"\n' +
|
||||
'\t\tip saddr { 10.77.0.1 } tcp dport 7100 accept\n\t}\n}\n';
|
||||
|
||||
// gate, when given, holds every delete until it opens, and every get waits a turn of the event loop: a slow store.
|
||||
function fake(at = "2026-11-21T20:00:00Z", node = "shanks", kept = new Map<string, Value>(), gate?: Promise<void>) {
|
||||
@@ -189,9 +197,12 @@ test("allowed asks converged again while none answered, and refuses when it does
|
||||
assert.equal(asks.asked, asked + 2, "an answer held is not asked again");
|
||||
});
|
||||
|
||||
test("privateOnly: a port accepted only with a source match, never from any source", () => {
|
||||
test("privateOnly: a port a derived rule's comment scopes to the private or the local network, none to any", () => {
|
||||
assert.equal(privateOnly(TABLE, "tcp", 5432), true);
|
||||
assert.equal(privateOnly(TABLE, "tcp", 9550), true, "a range of a set");
|
||||
assert.equal(privateOnly(TABLE, "tcp", 9550), true, "a range, local-network");
|
||||
// 47 H2 §813 (4): the scope is read from the rule's comment, never from its shape.
|
||||
assert.equal(privateOnly(TABLE, "tcp", 7000), true, "a comment cut with a count says private-network, whatever the shape");
|
||||
assert.equal(privateOnly(TABLE, "tcp", 7100), false, "a rule with a source match and no derived comment names no scope");
|
||||
assert.equal(privateOnly(TABLE, "tcp", 80), false);
|
||||
assert.equal(privateOnly(TABLE, "tcp", 8443), false, "accepted from anywhere too");
|
||||
assert.equal(privateOnly(TABLE, "udp", 5432), false);
|
||||
|
||||
Reference in New Issue
Block a user