feat: F4.6g3 a computer's firewall window, measured against Java's with traffic from two networks

The firewall-pc scenario and FirewallWindowRun use Java's window as a person
does and send a ping, a TCP connection and a DNS question from the server's
network and from behind the router after each step. The core adds and
removes port rules (personalFirewall.ts) and writes both into the firewall's
log, which now carries each line's time; the room takes the window's
actions and sends its view and the log as lines; the editor shows Java's
window with its two tabs. Not adopted from Java: any integer as a port,
a port after a space refused without a word, a log one can type into.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 21:18:05 +00:00
co-authored by Claude Opus 5.5
parent 065b42430d
commit 2b85e7432c
25 changed files with 2092 additions and 19 deletions
+17
View File
@@ -175,6 +175,20 @@ const FROM_JAVA: Readonly<Record<string, string>> = {
'firewall.dropIcmp': 'jfirewalldialog_msg40',
'firewall.dropIcmpHint': 'jfirewalldialog_msg41',
'firewall.filterSyn': 'jfirewalldialog_msg42',
'personalFirewall.hint': 'firewall_msg2',
'personalFirewall.port': 'firewall_msg3',
'personalFirewall.allSenders': 'firewall_msg4',
'personalFirewall.sameNetwork': 'firewall_msg5',
'personalFirewall.add': 'firewall_msg6',
'personalFirewall.delete': 'firewall_msg7',
'personalFirewall.portColumn': 'firewall_msg8',
'personalFirewall.sender': 'firewall_msg9',
'personalFirewall.setup': 'firewall_msg10',
'personalFirewall.log': 'firewall_msg11',
'personalFirewall.localNetwork': 'firewall_msg12',
'personalFirewall.allowIcmp': 'firewall_msg13',
'personalFirewall.filterUdp': 'firewall_msg14',
'personalFirewall.portRuleRemoved': 'sw_firewall_msg7',
'sheet.connections': 'jvermittlungsrechnerkonfiguration_msg23',
'connections.local': 'jvermittlungsrechnerkonfiguration_msg22',
'connections.add': 'jvermittlungsrechnerkonfiguration_msg24',
@@ -319,6 +333,9 @@ const FROM_JAVA_JOINED: Readonly<Record<string, readonly [string, string, string
/** Java's words before a value, joined as its programs join them (SMTPMitarbeiter, SMTPClient, the server window's question). */
const FROM_JAVA_BEFORE: Readonly<Record<string, readonly [string, string, string?]>> = {
'personalFirewall.ruleMatched': ['sw_firewall_msg8', ' #{number} ({rule}) -> {action}'],
'personalFirewall.icmpDropped': ['firewallthread_msg1', ' {sender} -> {receiver} (code: {code}, type: {type})'],
'personalFirewall.portRuleAdded': ['sw_firewall_msg5', ' {port}/{protocol}'],
'mail.sendFailed': ['sw_smtpmitarbeiter_msg14', ' {address}'],
'mail.mailSent': ['sw_smtpclient_msg4', ' {recipients}'],
// "'" + name + "'", the question's two halves written against it.
+47 -3
View File
@@ -1,13 +1,17 @@
// A server's lines as Java's web server window wrote them
// (packages/sim/test/browserWindow.java.json, BrowserWindowRun): each kind
// the window got there, in Java's words.
// the window got there, in Java's words. And a computer's firewall's log and
// table as Java's firewall window wrote them
// (packages/core/test/firewallWindow.java.json, FirewallWindowRun).
import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
import type { ServerLogEntry, SimpleClientLogEntry } from '@mdg-filius/core';
import { serverLine, simpleClientLine } from '../src/desktop/serverLines.js';
import { DIRECTLY_CONNECTED_SOURCE_MARKER, firewallRule, type FirewallLogEntry, type ServerLogEntry, type SimpleClientLogEntry } from '@mdg-filius/core';
import type { FirewallViewRule } from '@mdg-filius/protocol';
import { firewallRow } from '../src/desktop/PersonalFirewallPanel.js';
import { firewallLine, serverLine, simpleClientLine } from '../src/desktop/serverLines.js';
import { translate } from '../src/i18n/i18n.js';
const java = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '../../sim/test/browserWindow.java.json'), 'utf8')) as { steps: { step: string; log?: string }[] };
@@ -78,3 +82,43 @@ describe("the echo windows' lines", () => {
]).toEqual(['Fehler beim Verbindungsaufbau', 'Fehler beim Verbindungsaufbau\nAktives Öffnen des Sockets fehlgeschlagen', 'Keine Verbindung hergestellt!', 'Verbindung nicht aufgebaut!']);
});
});
describe("a computer's firewall's lines", () => {
const firewallJava = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '../../core/test/firewallWindow.java.json'), 'utf8')) as { steps: { step: string; log: string }[] };
const javaLog = firewallJava.steps.find((step) => step.step === 'delete row 0')!.log.split('\n');
it("are Java's, line by line", () => {
const network = { ipAddress: '10.0.0.10', subnetMask: '255.255.255.0' };
const entries: FirewallLogEntry[] = [
{ kind: 'portRuleAdded', port: 55555, protocol: 'tcp' },
{ kind: 'ruleMatched', ruleNumber: 1, rule: firewallRule({ port: 55555, protocol: 'tcp', action: 'accept' }), firstInterface: network, accepted: true },
{ kind: 'ruleMatched', ruleNumber: 2, rule: firewallRule({ port: 53, protocol: 'udp', action: 'accept', sourceIPAddress: DIRECTLY_CONNECTED_SOURCE_MARKER }), firstInterface: network, accepted: true },
{ kind: 'icmpDropped', senderIPAddress: '10.0.0.2', receiverIPAddress: '10.0.0.10', type: 8, code: 0 },
{ kind: 'portRuleAdded', port: -1, protocol: 'all' },
{ kind: 'portRuleRemoved' },
];
const lines = entries.map((entry) => firewallLine(entry, t));
for (const line of lines) expect(javaLog, line).toContain(line);
expect(firewallLine({ kind: 'ruleMatched', ruleNumber: 3, rule: firewallRule({ port: 80 }), firstInterface: undefined, accepted: false }, t)).toBe(
'Firewall-Regel hat gegriffen: #3 (*/* -> */*; TCP:80 => DROP) -> verwerfen',
);
});
it("are the table's rows as Java's ruleToVector writes them, and name a rule the window cannot make", () => {
expect(
[
{ protocol: 'tcp', port: 55555, sender: 'all', text: '' },
{ protocol: 'udp', port: 53, sender: 'sameNetwork', text: '' },
{ protocol: 'all', port: -1, sender: 'all', text: '' },
{ protocol: 'tcp', port: 0, sender: 'all', text: '' },
{ protocol: 'icmp', port: -1, sender: null, text: '10.0.0.0/255.0.0.0 -> */*; ?:* => DROP' },
].map((rule) => firewallRow(rule as FirewallViewRule, t)),
).toEqual([
['TCP', '55555', 'Alle Absender'],
['UDP', '53', 'Nur lokales Rechnernetz'],
['*', '', 'Alle Absender'],
['TCP', '0', 'Alle Absender'],
['ICMP', '', '10.0.0.0/255.0.0.0 -> */*; ?:* => DROP'],
]);
});
});