From 9472bc8af446218492f883d912cbdaf957e0eee7 Mon Sep 17 00:00:00 2001
From: Tomas Cejka <cejkat@cesnet.cz>
Date: Fri, 21 Apr 2017 09:10:44 -0400
Subject: [PATCH] Forbid ICMP in combination with ports

---
 flowspec/forms.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/flowspec/forms.py b/flowspec/forms.py
index 1353c04a..5d940551 100644
--- a/flowspec/forms.py
+++ b/flowspec/forms.py
@@ -165,6 +165,9 @@ class RouteForm(forms.ModelForm):
                 existing_routes = existing_routes.filter(pk__in=route_pk_list)
             else:
                 existing_routes = existing_routes.filter(protocol=None)
+            if "icmp" in [str(i) for i in protocols] and (destinationports or sourceports or port):
+                raise forms.ValidationError(_('It is not allowed to specify ICMP protocol and source/destination ports at the same time.'))
+
         else:
             existing_routes = existing_routes.filter(protocol=None)
         if sourceports:
-- 
GitLab