[Kimchi-devel] [PATCH 3/3] Fix Network create name checking in backend (slashes and quotes)

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Mar 24 16:46:45 UTC 2015


This patch adds the JSON checking for Network name, when user tries to
create a new network using the API directly.
Slashes are not allowed by default, but quotes should also be avoided
due to an error raised in /sbin/dnsmasq.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/kimchi/API.json | 1 +
 src/kimchi/i18n.py  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 9d54665..fa18e84 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -319,6 +319,7 @@
                     "description": "The name of the new network",
                     "type": "string",
                     "minLength": 1,
+                    "pattern": "^[^/\"]*$",
                     "required": true,
                     "error": "KCHNET0011E"
                 },
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 0a2a59d..34137f1 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -224,7 +224,7 @@ messages = {
     "KCHNET0008E": _("Unable to create network %(name)s. Details: %(err)s"),
     "KCHNET0009E": _("Unable to find a free IP address for network '%(name)s'"),
     "KCHNET0010E": _("The interface %(iface)s already exists."),
-    "KCHNET0011E": _("Network name must be a string"),
+    "KCHNET0011E": _("Network name must be a string without slashes (/) or quotes (\")"),
     "KCHNET0012E": _("Supported network types are isolated, NAT and bridge"),
     "KCHNET0013E": _("Network subnet must be a string with IP address and prefix or netmask"),
     "KCHNET0014E": _("Network interface must be a string"),
-- 
2.1.0




More information about the Kimchi-devel mailing list