aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-02-02 17:44:01 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 13:29:21 +0000
commitcb6d290d0b93e0f6673d315075152fcef8a4b416 (patch)
tree04e850e32ac03f3b8532e03b8f8480acddf0da0b /bitbake
parent5634a251ce6b25beb948976433ba0a6443be4e09 (diff)
downloadopenembedded-core-contrib-cb6d290d0b93e0f6673d315075152fcef8a4b416.tar.gz
bitbake: toaster: API CustomImageRecipe check the recipe name supplied is valid
Check that the name for a new CustomImageRecipe doesn't already exist in the project or in the database of existing recipes (e.g. from the layer index). Also restrict the characters entered for the recipe naming convention. (Bitbake rev: f290d428460a07e73050ff613bc222cc8c04f5ec) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 65b38d0645..851e962c05 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2362,6 +2362,27 @@ if True:
# create custom recipe
try:
+
+ # Only allowed chars in name are a-z, 0-9 and -
+ if re.search(r'[^a-z|0-9|-]', request.POST["name"]):
+ return {"error": "invalid-name"}
+
+ # Are there any recipes with the name already?
+ for existing_recipe in Recipe.objects.filter(
+ name=request.POST["name"]):
+ try:
+ ci = CustomImageRecipe.objects.get(pk=existing_recipe.pk)
+ if ci.project == params["project"]:
+ return {"error": "already-exists" }
+ else:
+ # It is a CustomImageRecipe but not in our project
+ # this is fine so
+ continue
+ except:
+ # It isn't a CustomImageRecipe so is a recipe from
+ # another source.
+ return {"error": "already-exists" }
+
# create layer 'Custom layer' and verion if needed
layer = Layer.objects.get_or_create(
name="toaster-custom-images",