Skip to content

Commit 6fb3d3e

Browse files
committed
add system-config setting to dis-allow traffic-forwarding
1 parent da8fc5e commit 6fb3d3e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/firewall_test/plugins/system/abstract.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ class FirewallSystem(ABC):
1616
ROUTE_STATIC_RULES = False
1717

1818
# if the system allows traffic to bogon-networks to be sent to wan/default-route
19-
FIREWALL_DROP_WAN_BOGONS = True
19+
SYSTEM_DROP_WAN_BOGONS = True
20+
21+
# if the system allows traffic to be forwarded; todo: should be instance-specific
22+
SYSTEM_DROP_FORWARD = False
2023

2124
# the firewall supports bsd-pf-style quick/lazy matching
2225
FIREWALL_ACTION_LAZY = False

src/firewall_test/plugins/system/system_linux_netfilter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ class SystemLinuxNetfilter(FirewallSystem):
99
ROUTE_STATIC = True
1010
ROUTE_STATIC_RULES = True
1111

12-
FIREWALL_DROP_WAN_BOGONS = True
12+
SYSTEM_DROP_WAN_BOGONS = True
13+
SYSTEM_DROP_FORWARD = False
14+
1315
FIREWALL_ACTION_LAZY = False
1416
FIREWALL_CT = True
1517
FIREWALL_PRIO_LOWER_BETTER = True

src/firewall_test/simulator/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def __init__(self, packet: PACKET_KINDS, simulator):
8989
log_error('System', 'Dropping traffic to WAN targeting bogons', final=True)
9090
return
9191

92+
if self.flow_type == FlowForward and self._s.system.SYSTEM_DROP_FORWARD:
93+
# DROP PACKET IF TRAFFIC-FORWARDING IS NOT ALLOWED
94+
log_error('System', 'Dropping forward traffic', final=True)
95+
return
96+
9297
### PROCESSING MAIN FIREWALL-FILTERS ###
9398

9499
result, rule = self._s.fw.process_main(packet=packet, flow=self.flow_type)

0 commit comments

Comments
 (0)