
Backend was not validating storagepool names. It was possible to send a request to Kimchi API to create a pool with slashes in the name using CURL calls, for instance. The UI was doing the checking, but for better compatibility, this was moved to JSON validation phase. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/kimchi/API.json | 1 + src/kimchi/i18n.py | 2 +- ui/js/src/kimchi.storagepool_add_main.js | 5 ----- ui/pages/i18n.json.tmpl | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/kimchi/API.json b/src/kimchi/API.json index 2455745..9d54665 100644 --- a/src/kimchi/API.json +++ b/src/kimchi/API.json @@ -91,6 +91,7 @@ "description": "The name of the Storage Pool", "type": "string", "minLength": 1, + "pattern": "^[^/]*$", "required": true, "error": "KCHPOOL0016E" }, diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py index 7c11016..0a2a59d 100644 --- a/src/kimchi/i18n.py +++ b/src/kimchi/i18n.py @@ -166,7 +166,7 @@ messages = { "KCHPOOL0013E": _("Unable to create NFS Pool as export path %(path)s mount failed"), "KCHPOOL0014E": _("Unsupported storage pool type: %(type)s"), "KCHPOOL0015E": _("Error while retrieving storage pool XML to %(pool)s"), - "KCHPOOL0016E": _("Storage pool name must be a string"), + "KCHPOOL0016E": _("Storage pool name must be a string without slashes (/)"), "KCHPOOL0017E": _("Supported storage pool types are dir, netfs, logical, iscsi, isci and kimchi-iso"), "KCHPOOL0018E": _("Storage pool path must be a string"), "KCHPOOL0019E": _("Storage pool host must be a IP or hostname"), diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index 5ef84af..aaf2496 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -282,12 +282,7 @@ kimchi.inputsNotBlank = function() { }; kimchi.validateForm = function() { - var name = $('#poolId').val(); var poolType = $("#poolTypeInputId").val(); - if (name.indexOf("/")!=-1) { - kimchi.message.error.code('KCHPOOL6004E'); - return false; - } if (poolType === "dir") { return kimchi.validateDirForm(); } else if (poolType === "netfs") { diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl index 8e45b51..6ad9872 100644 --- a/ui/pages/i18n.json.tmpl +++ b/ui/pages/i18n.json.tmpl @@ -166,7 +166,6 @@ "KCHPOOL6001E": "$_("The storage pool name can not be blank.")", "KCHPOOL6002E": "$_("The storage pool path can not be blank.")", "KCHPOOL6003E": "$_("NFS server mount path can not be blank.")", - "KCHPOOL6004E": "$_("Invalid storage pool name. It should not contain '/'.")", "KCHPOOL6005E": "$_("Invalid NFS mount path.")", "KCHPOOL6006E": "$_("No logical device selected.")", "KCHPOOL6007E": "$_("The iSCSI target can not be blank.")", -- 2.1.0