@takodotid/circuit 0.33.1 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +11 -0
- package/dist/presets/index.js +12 -9
- package/dist/types/presets/index.d.ts +1 -1
- package/dist/types/schema/system.d.ts +2 -0
- package/package.json +1 -1
- package/src/adapters/devices/fortios/render.ts +4 -0
- package/src/adapters/devices/junos/index.ts +1 -0
- package/src/adapters/devices/raisecom-ros/index.ts +2 -0
- package/src/adapters/devices/routeros/TRAPS.md +2 -0
- package/src/adapters/devices/routeros/index.ts +1 -0
- package/src/adapters/devices/vrp/index.ts +2 -0
- package/src/presets/index.ts +17 -11
- package/src/schema/system.ts +2 -0
package/dist/cli/index.js
CHANGED
|
@@ -2450,6 +2450,9 @@ function routed(entry, device, name, settings, access) {
|
|
|
2450
2450
|
entry.set("allowaccess", access);
|
|
2451
2451
|
return;
|
|
2452
2452
|
}
|
|
2453
|
+
const answering = device.management?.interfaces;
|
|
2454
|
+
if (answering && !answering.includes(name))
|
|
2455
|
+
access = "ping";
|
|
2453
2456
|
const addresses = addressesOf2(settings);
|
|
2454
2457
|
const ipv4 = addresses.filter((address) => familyOf2(host2(address)) === "ipv4");
|
|
2455
2458
|
const ipv6 = addresses.filter((address) => familyOf2(host2(address)) === "ipv6");
|
|
@@ -4890,6 +4893,8 @@ function unsupported2(device) {
|
|
|
4890
4893
|
}
|
|
4891
4894
|
if (management.console)
|
|
4892
4895
|
found.push("management.console, the console uses the device's users");
|
|
4896
|
+
if (management.interfaces)
|
|
4897
|
+
found.push("management.interfaces, which only FortiOS builds for now");
|
|
4893
4898
|
if (management.native?.interfaces?.length)
|
|
4894
4899
|
found.push("management.native.interfaces, NETCONF runs over IP only");
|
|
4895
4900
|
if (management.ssh?.auth_timeout || management.ssh?.auth_retries)
|
|
@@ -5613,6 +5618,8 @@ async function read3(device, _network = [], options = {}) {
|
|
|
5613
5618
|
}
|
|
5614
5619
|
function unsupported3(device) {
|
|
5615
5620
|
const found = [];
|
|
5621
|
+
if (device.management?.interfaces)
|
|
5622
|
+
found.push("management.interfaces, which only FortiOS builds for now");
|
|
5616
5623
|
for (const [name, iface] of Object.entries(device.interfaces ?? {})) {
|
|
5617
5624
|
if (iface.type === "bridge")
|
|
5618
5625
|
found.push(`interfaces.${name}, a bridge, which only FortiOS builds for now`);
|
|
@@ -7624,6 +7631,8 @@ function unsupported4(device) {
|
|
|
7624
7631
|
const management = device.management;
|
|
7625
7632
|
if (management?.console)
|
|
7626
7633
|
found.push("management.console, the console uses the device's users");
|
|
7634
|
+
if (management?.interfaces)
|
|
7635
|
+
found.push("management.interfaces, which only FortiOS builds for now");
|
|
7627
7636
|
if (management?.privilege_password)
|
|
7628
7637
|
found.push("management.privilege_password, the platform has no privileged mode");
|
|
7629
7638
|
if (management?.snmp?.port)
|
|
@@ -8276,6 +8285,8 @@ function configurationOf(device, dump) {
|
|
|
8276
8285
|
}
|
|
8277
8286
|
function unsupported5(device) {
|
|
8278
8287
|
const found = [];
|
|
8288
|
+
if (device.management?.interfaces)
|
|
8289
|
+
found.push("management.interfaces, which only FortiOS builds for now");
|
|
8279
8290
|
for (const [name, iface] of Object.entries(device.interfaces ?? {})) {
|
|
8280
8291
|
if (iface.type === "bridge")
|
|
8281
8292
|
found.push(`interfaces.${name}, a bridge, which only FortiOS builds for now`);
|
package/dist/presets/index.js
CHANGED
|
@@ -33,10 +33,6 @@ var AMPLIFIERS = {
|
|
|
33
33
|
};
|
|
34
34
|
var ASKED = new Set([AMPLIFIERS.dns, AMPLIFIERS.ntp, AMPLIFIERS.snmp]);
|
|
35
35
|
function antiAmplification(destinations, options = {}) {
|
|
36
|
-
const below1024Except = (port) => [
|
|
37
|
-
{ min: 0, max: port - 1 },
|
|
38
|
-
{ min: port + 1, max: 1023 }
|
|
39
|
-
];
|
|
40
36
|
return destinations.flatMap((dst) => [
|
|
41
37
|
...(options.keep_fragments ?? []).filter((prefix) => contains2(dst, prefix)).map((prefix) => ({
|
|
42
38
|
description: `UDP fragments to ${prefix} kept`,
|
|
@@ -44,11 +40,18 @@ function antiAmplification(destinations, options = {}) {
|
|
|
44
40
|
action: "accept"
|
|
45
41
|
})),
|
|
46
42
|
{ description: `UDP fragments to ${dst}`, match: { protocol: "udp", dst, src_port: 0 }, action: "drop" },
|
|
47
|
-
...Object.entries(AMPLIFIERS).
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
...Object.entries(AMPLIFIERS).flatMap(([name, port]) => ASKED.has(port) ? [
|
|
44
|
+
{
|
|
45
|
+
description: `UDP to ${dst} from ${name}, between two servers`,
|
|
46
|
+
match: { protocol: "udp", dst, src_port: port, dst_port: port },
|
|
47
|
+
action: "accept"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
description: `UDP to ${dst} from ${name}, to a port below 1024`,
|
|
51
|
+
match: { protocol: "udp", dst, src_port: port, dst_port: { min: 0, max: 1023 } },
|
|
52
|
+
action: "drop"
|
|
53
|
+
}
|
|
54
|
+
] : [{ description: `UDP to ${dst} from ${name}`, match: { protocol: "udp", dst, src_port: port }, action: "drop" }])
|
|
52
55
|
]);
|
|
53
56
|
}
|
|
54
57
|
var BAD_TCP_FLAGS = [
|
|
@@ -37,7 +37,7 @@ export type AntiAmplificationOptions = {
|
|
|
37
37
|
* Hardware ACL rules dropping reflected UDP floods toward `destinations`, in the switch chip, without limiting anything else.
|
|
38
38
|
*
|
|
39
39
|
* - Replies from an amplifier no host asks across the internet are dropped.
|
|
40
|
-
* - Replies from DNS, NTP and SNMP are dropped only toward a port below 1024 that is not the service's own. A host that runs its own resolver, time server or monitoring keeps its answers.
|
|
40
|
+
* - Replies from DNS, NTP and SNMP are dropped only toward a port below 1024 that is not the service's own. A host that runs its own resolver, time server or monitoring keeps its answers. The service's own port passes first, so every drop takes the one range 0 to 1023: a switch chip has few port-range checkers, and on RouterOS a rule past them is invalid with every rule after it.
|
|
41
41
|
* - The fragments after the first carry no port, and a switch chip reads them as port 0. They are dropped, but toward `keep_fragments`.
|
|
42
42
|
*/
|
|
43
43
|
export declare function antiAmplification(destinations: readonly Prefix[], options?: AntiAmplificationOptions): AclRule<never>[];
|
|
@@ -84,6 +84,8 @@ export type SnmpUser = {
|
|
|
84
84
|
export type Management<I extends string, C extends string> = {
|
|
85
85
|
/** Sources allowed to every service that does not set its own. */
|
|
86
86
|
allow?: readonly Prefix[];
|
|
87
|
+
/** The ports and interfaces the services answer on; every other one answers ping alone. Every one with an address when absent. */
|
|
88
|
+
interfaces?: readonly I[];
|
|
87
89
|
/** Secure shell. */
|
|
88
90
|
ssh?: Service & {
|
|
89
91
|
/** Also offer legacy ciphers, MACs and key exchanges. Off when absent. */
|
package/package.json
CHANGED
|
@@ -495,6 +495,10 @@ function routed(entry: Block, device: Device, name: string, settings: RoutedSett
|
|
|
495
495
|
return;
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
+
// Services answer only where the config says, when it says; ping everywhere.
|
|
499
|
+
const answering = device.management?.interfaces;
|
|
500
|
+
if (answering && !answering.includes(name)) access = "ping";
|
|
501
|
+
|
|
498
502
|
const addresses = addressesOf(settings);
|
|
499
503
|
const ipv4 = addresses.filter((address) => familyOf(host(address)) === "ipv4");
|
|
500
504
|
const ipv6 = addresses.filter((address) => familyOf(host(address)) === "ipv6");
|
|
@@ -595,6 +595,7 @@ export function unsupported(device: Device): string[] {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
if (management.console) found.push("management.console, the console uses the device's users");
|
|
598
|
+
if (management.interfaces) found.push("management.interfaces, which only FortiOS builds for now");
|
|
598
599
|
if (management.native?.interfaces?.length) found.push("management.native.interfaces, NETCONF runs over IP only");
|
|
599
600
|
if (management.ssh?.auth_timeout || management.ssh?.auth_retries) found.push("management.ssh.auth_timeout and auth_retries");
|
|
600
601
|
|
|
@@ -420,6 +420,8 @@ export async function read(device: Device, _network: readonly Device[] = [], opt
|
|
|
420
420
|
export function unsupported(device: Device): string[] {
|
|
421
421
|
const found: string[] = [];
|
|
422
422
|
|
|
423
|
+
if (device.management?.interfaces) found.push("management.interfaces, which only FortiOS builds for now");
|
|
424
|
+
|
|
423
425
|
for (const [name, iface] of Object.entries(device.interfaces ?? {})) {
|
|
424
426
|
if (iface.type === "bridge") found.push(`interfaces.${name}, a bridge, which only FortiOS builds for now`);
|
|
425
427
|
if (iface.type === "vlan" && iface.mac) found.push(`interfaces.${name}.mac, which only RouterOS sets for now`);
|
|
@@ -44,3 +44,5 @@ Behaviour that looks like something else. Each one has been hit on a real device
|
|
|
44
44
|
- On the serial console, the prompt can come twice after a login. The console echoes a long command wrapped at 80 columns, and a `print` that fills the screen stops at `-- [Q quit|D dump|down]`, where `D` prints the rest.
|
|
45
45
|
- Every VLAN interface on the bridge has the bridge's MAC, and the bridge keeps a frame to that MAC on whatever VLAN it arrives. A gateway in front of a transparent firewall then never gets its replies: they come back on the inside VLAN and stop at the bridge. A MACVLAN on the VLAN interface gives the gateway a MAC of its own, and its replies cross the firewall back; proved with a FortiGate 3700D in transparent mode, the session offloaded to its NP6.
|
|
46
46
|
- A second VLAN interface with the same VLAN ID on the same interface is refused, `already have such vlan`, so a VLAN interface is known by its interface and VLAN ID, and a new name is a rename.
|
|
47
|
+
- A switch rule the chip cannot hold is flagged `I`, invalid, and every rule after it is invalid too, with no log line. On a CCR2216 (98DX8525, 7.23) it came at the sixth distinct `dst-port` range, with 66 rules in all, far below the 1,024 MikroTik lists: the amplifier drops toward every VLAN after it did nothing. Few distinct ranges, and check `print count-only where invalid` after an apply.
|
|
48
|
+
- A MACVLAN on a VLAN interface is not routed in the switch chip: its connected route never takes the `H` flag, even with `l3-hw-offloading=yes` on the VLAN under it.
|
|
@@ -192,6 +192,7 @@ export function unsupported(device: Device): string[] {
|
|
|
192
192
|
const management = device.management;
|
|
193
193
|
|
|
194
194
|
if (management?.console) found.push("management.console, the console uses the device's users");
|
|
195
|
+
if (management?.interfaces) found.push("management.interfaces, which only FortiOS builds for now");
|
|
195
196
|
if (management?.privilege_password) found.push("management.privilege_password, the platform has no privileged mode");
|
|
196
197
|
|
|
197
198
|
if (management?.snmp?.port) found.push("management.snmp.port");
|
|
@@ -639,6 +639,8 @@ function configurationOf(device: Device, dump: string): string {
|
|
|
639
639
|
export function unsupported(device: Device): string[] {
|
|
640
640
|
const found: string[] = [];
|
|
641
641
|
|
|
642
|
+
if (device.management?.interfaces) found.push("management.interfaces, which only FortiOS builds for now");
|
|
643
|
+
|
|
642
644
|
for (const [name, iface] of Object.entries(device.interfaces ?? {})) {
|
|
643
645
|
if (iface.type === "bridge") found.push(`interfaces.${name}, a bridge, which only FortiOS builds for now`);
|
|
644
646
|
if (iface.type === "vlan" && iface.mac) found.push(`interfaces.${name}.mac, which only RouterOS sets for now`);
|
package/src/presets/index.ts
CHANGED
|
@@ -54,15 +54,10 @@ export type AntiAmplificationOptions = {
|
|
|
54
54
|
* Hardware ACL rules dropping reflected UDP floods toward `destinations`, in the switch chip, without limiting anything else.
|
|
55
55
|
*
|
|
56
56
|
* - Replies from an amplifier no host asks across the internet are dropped.
|
|
57
|
-
* - Replies from DNS, NTP and SNMP are dropped only toward a port below 1024 that is not the service's own. A host that runs its own resolver, time server or monitoring keeps its answers.
|
|
57
|
+
* - Replies from DNS, NTP and SNMP are dropped only toward a port below 1024 that is not the service's own. A host that runs its own resolver, time server or monitoring keeps its answers. The service's own port passes first, so every drop takes the one range 0 to 1023: a switch chip has few port-range checkers, and on RouterOS a rule past them is invalid with every rule after it.
|
|
58
58
|
* - The fragments after the first carry no port, and a switch chip reads them as port 0. They are dropped, but toward `keep_fragments`.
|
|
59
59
|
*/
|
|
60
60
|
export function antiAmplification(destinations: readonly Prefix[], options: AntiAmplificationOptions = {}): AclRule<never>[] {
|
|
61
|
-
const below1024Except = (port: number) => [
|
|
62
|
-
{ min: 0, max: port - 1 },
|
|
63
|
-
{ min: port + 1, max: 1023 },
|
|
64
|
-
];
|
|
65
|
-
|
|
66
61
|
return destinations.flatMap((dst) => [
|
|
67
62
|
...(options.keep_fragments ?? [])
|
|
68
63
|
.filter((prefix) => contains(dst, prefix))
|
|
@@ -72,11 +67,22 @@ export function antiAmplification(destinations: readonly Prefix[], options: Anti
|
|
|
72
67
|
action: "accept",
|
|
73
68
|
})),
|
|
74
69
|
{ description: `UDP fragments to ${dst}`, match: { protocol: "udp", dst, src_port: 0 }, action: "drop" },
|
|
75
|
-
...Object.entries(AMPLIFIERS).
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
...Object.entries(AMPLIFIERS).flatMap(([name, port]): AclRule<never>[] =>
|
|
71
|
+
ASKED.has(port)
|
|
72
|
+
? [
|
|
73
|
+
{
|
|
74
|
+
description: `UDP to ${dst} from ${name}, between two servers`,
|
|
75
|
+
match: { protocol: "udp", dst, src_port: port, dst_port: port },
|
|
76
|
+
action: "accept",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
description: `UDP to ${dst} from ${name}, to a port below 1024`,
|
|
80
|
+
match: { protocol: "udp", dst, src_port: port, dst_port: { min: 0, max: 1023 } },
|
|
81
|
+
action: "drop",
|
|
82
|
+
},
|
|
83
|
+
]
|
|
84
|
+
: [{ description: `UDP to ${dst} from ${name}`, match: { protocol: "udp", dst, src_port: port }, action: "drop" }]
|
|
85
|
+
),
|
|
80
86
|
]);
|
|
81
87
|
}
|
|
82
88
|
|
package/src/schema/system.ts
CHANGED
|
@@ -89,6 +89,8 @@ export type SnmpUser = {
|
|
|
89
89
|
export type Management<I extends string, C extends string> = {
|
|
90
90
|
/** Sources allowed to every service that does not set its own. */
|
|
91
91
|
allow?: readonly Prefix[];
|
|
92
|
+
/** The ports and interfaces the services answer on; every other one answers ping alone. Every one with an address when absent. */
|
|
93
|
+
interfaces?: readonly I[];
|
|
92
94
|
/** Secure shell. */
|
|
93
95
|
ssh?: Service & {
|
|
94
96
|
/** Also offer legacy ciphers, MACs and key exchanges. Off when absent. */
|