All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@windriver.com>
To: <yocto@yoctoproject.org>
Cc: paul.eggleton@linux.intel.com
Subject: [layerindex-web][PATCH 02/10] layerindex/tools/import_layer.py: Sanitize layer name.
Date: Mon, 26 Sep 2016 14:25:30 -0400	[thread overview]
Message-ID: <1474914338-26310-3-git-send-email-Liam.Howlett@WindRiver.com> (raw)
In-Reply-To: <1474914338-26310-1-git-send-email-Liam.Howlett@WindRiver.com>

Django will produce a cryptic error message if layers are added with
invalid names.  Sanitize the layer names when trying to add them.

Signed-off-by: Liam R. Howlett <Liam.Howlett@WindRiver.com>
---
 layerindex/tools/import_layer.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/layerindex/tools/import_layer.py b/layerindex/tools/import_layer.py
index 9b5da22..8d9e8cb 100755
--- a/layerindex/tools/import_layer.py
+++ b/layerindex/tools/import_layer.py
@@ -181,6 +181,8 @@ def get_github_layerinfo(layer_url, username = None, password = None):
 
 
 def main():
+    valid_layer_name = re.compile('[-\w]+$')
+
     parser = optparse.OptionParser(
         usage = """
     %prog [options] <url> [name]""")
@@ -222,6 +224,10 @@ def main():
             if layer_name.endswith('.git'):
                 layer_name = layer_name[:-4]
 
+    if not valid_layer_name.match(layer_name):
+            logger.error('Invlaid layer name "%s" -  Layer name can only include letters, numbers and dashes.', layer_name)
+            sys.exit(1)
+
     if options.github_auth:
         if not ':' in options.github_auth:
             logger.error('--github-auth value must be specified as username:password')
-- 
1.9.1



  parent reply	other threads:[~2016-09-26 18:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26 18:25 [layerindex-web][PATCH 00/10] Add Distribution, dependency and recommends detection, and import_project Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 01/10] import_layer: Add --actual-branch option Liam R. Howlett
2016-09-26 18:25 ` Liam R. Howlett [this message]
2016-10-03 22:47   ` [layerindex-web][PATCH 02/10] layerindex/tools/import_layer.py: Sanitize layer name Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 03/10] layerindex/tools/import_layer.py: Avoid failing if there is any layer to add Liam R. Howlett
2016-10-03 22:53   ` Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 04/10] layerindex/utils: Update runcmd to decode binary strings to strings Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 05/10] layerindex: Add distribution to web interface and model Liam R. Howlett
2016-10-03 22:59   ` Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 06/10] layerindex/tools/import_project: Add import_project Liam R. Howlett
2016-10-03 22:46   ` Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 07/10] layerindex: Detect dependencies from layer.conf files Liam R. Howlett
2016-10-03 22:54   ` Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 08/10] layerindex: Add collection and version to layerbranch Liam R. Howlett
2016-09-27 20:53   ` Mark Hatle
2016-10-03 22:54   ` Paul Eggleton
2016-10-04 13:51     ` Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 09/10] layerindexer: Add layer recommends support Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 10/10] recipeparse: remove unnecessary else statement Liam R. Howlett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474914338-26310-3-git-send-email-Liam.Howlett@WindRiver.com \
    --to=liam.howlett@windriver.com \
    --cc=paul.eggleton@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.