]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: validate virtual_ip parameter 46364/head
authorRedouane Kachach <rkachach@redhat.com>
Mon, 23 May 2022 10:14:07 +0000 (12:14 +0200)
committerRedouane Kachach <rkachach@redhat.com>
Mon, 23 May 2022 14:51:52 +0000 (16:51 +0200)
Fixes: https://tracker.ceph.com/issues/54581
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
src/pybind/mgr/nfs/cluster.py

index 4ddc750044eeb3b77cfc996997a55a346c4ddd51..b0c82aa606a5d21c1364d142d5585fac5b1dba7d 100644 (file)
@@ -1,3 +1,4 @@
+import ipaddress
 import logging
 import json
 import re
@@ -105,7 +106,13 @@ class NFSCluster:
             ingress: Optional[bool] = None,
             port: Optional[int] = None,
     ) -> Tuple[int, str, str]:
+
         try:
+            if virtual_ip:
+                # validate virtual_ip value: ip_address throws a ValueError
+                # exception in case it's not a valid ipv4 or ipv6 address
+                ip = virtual_ip.split('/')[0]
+                ipaddress.ip_address(ip)
             if virtual_ip and not ingress:
                 raise NFSInvalidOperation('virtual_ip can only be provided with ingress enabled')
             if not virtual_ip and ingress: