summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-04-17 15:26:59 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-04-19 13:37:31 +0100
commit72d88f29da1ece634028420317233a45ff8e015b (patch)
tree78cbedae538c7895ca33c7f7ba734a05d5bedabf /bitbake/lib/bb/tests
parentf9b160571f795dc9d9d42ad7e85969ec54b86430 (diff)
downloadpoky-72d88f29da1ece634028420317233a45ff8e015b.tar.gz
bitbake: lib/bb/utils: add safeguard against recursively deleting things we shouldn't
Add some very basic safeguard against recursively deleting paths such as / and /home in the event of bugs or user mistakes. Addresses [YOCTO #7620]. (Bitbake rev: 56cddeb9e1e4d249f84ccd6ef65db245636e38ea) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/utils.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/utils.py b/bitbake/lib/bb/tests/utils.py
index 507de2de3c..6e09858e51 100644
--- a/bitbake/lib/bb/tests/utils.py
+++ b/bitbake/lib/bb/tests/utils.py
@@ -21,6 +21,7 @@
21 21
22import unittest 22import unittest
23import bb 23import bb
24import os
24 25
25class VerCmpString(unittest.TestCase): 26class VerCmpString(unittest.TestCase):
26 27
@@ -88,3 +89,19 @@ class VerCmpString(unittest.TestCase):
88 89
89 # Check that clearly invalid operator raises an exception 90 # Check that clearly invalid operator raises an exception
90 self.assertRaises(bb.utils.VersionStringException, bb.utils.vercmp_string_op, '0', '0', '$') 91 self.assertRaises(bb.utils.VersionStringException, bb.utils.vercmp_string_op, '0', '0', '$')
92
93
94class Path(unittest.TestCase):
95 def test_unsafe_delete_path(self):
96 checkitems = [('/', True),
97 ('//', True),
98 ('///', True),
99 (os.getcwd().count(os.sep) * ('..' + os.sep), True),
100 (os.environ.get('HOME', '/home/test'), True),
101 ('/home/someone', True),
102 ('/home/other/', True),
103 ('/home/other/subdir', False),
104 ('', False)]
105 for arg1, correctresult in checkitems:
106 result = bb.utils._check_unsafe_delete_path(arg1)
107 self.assertEqual(result, correctresult, '_check_unsafe_delete_path("%s") != %s' % (arg1, correctresult))