f-75: ebtables: confinement de interface_ip, ARP et DHCP en FORWARD et OUTPUT, retrait des seules règles présentes #75

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-23 00:36:09 +02:00
commit f4790187c4
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
2 changed files with 89 additions and 0 deletions

View file

@ -41,3 +41,30 @@ func TestWithActionDoesNotAlterTheRule(t *testing.T) {
t.Errorf("la règle a été modifiée : %q devenu %q", before, strings.Join(rule, " "))
}
}
func TestGatewayRules(t *testing.T) {
want := []string{
"-t filter -A FORWARD --out-interface v-t33a-i -p arp --arp-op Request --arp-ip-dst 10.33.0.1 -j DROP",
"-t filter -A OUTPUT --out-interface v-t33a-i -p arp --arp-ip-src 10.33.0.1 -j DROP",
"-t filter -A FORWARD --out-interface v-t33a-i -p IPv4 --ip-protocol udp --ip-source-port 67:68 --ip-destination-port 67:68 --ip-source 10.33.0.1 -j DROP",
"-t filter -A OUTPUT --out-interface v-t33a-i -p IPv4 --ip-protocol udp --ip-source-port 67:68 --ip-destination-port 67:68 --ip-source 10.33.0.1 -j DROP",
}
rules := gatewayRules("v-t33a-i", "10.33.0.1")
if len(rules) != len(want) {
t.Fatalf("%d règles, %d attendues", len(rules), len(want))
}
for i, rule := range rules {
if got := strings.Join(withAction("-A", rule), " "); got != want[i] {
t.Errorf("règle %d : %q, %q attendu", i, got, want[i])
}
}
}
func TestGatewayRulesDoNotShareSlices(t *testing.T) {
rules := gatewayRules("v-x-i", "10.0.0.1")
before := strings.Join(rules[2], " ")
rules[3][len(rules[3])-1] = "ACCEPT"
if strings.Join(rules[2], " ") != before {
t.Errorf("les deux règles DHCP partagent leur tableau : %q", strings.Join(rules[2], " "))
}
}