diff options
| author | Anders Heimer <anders.heimer@est.tech> | 2026-05-18 16:59:09 +0200 |
|---|---|---|
| committer | Paul Barker <paul@pbarker.dev> | 2026-06-08 21:44:04 +0100 |
| commit | 73f77a019a9195f732e5a1066993f922bd1551b8 (patch) | |
| tree | 871c2001eee322515e8fbf65ba4d34f40c490fc6 /bitbake/lib/bb/tests | |
| parent | a42a436300d336b7d196ce76a02fb472dbda9d94 (diff) | |
| download | poky-73f77a019a9195f732e5a1066993f922bd1551b8.tar.gz | |
bitbake: fetch2: validate striplevel parameter
The striplevel URL parameter is appended to tar_cmd, which is later run
through the shell. Validate it as a decimal count before using it in the
tar arguments.
(Bitbake rev: 3a8937cc4b6513f9ed54fee0b0347589a892c8d7)
Signed-off-by: Anders Heimer <anders.heimer@est.tech>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 934fe718bfe29c7ec921e6b598d81ec2ebe8f7c7)
[YC: Removed the striplevel="1\n" subtest case. The URL-decoding regex
in decodeurl uses `.*` without `re.DOTALL`, causing literal newlines in
parameters to be silently truncated during parsing.]
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Paul Barker <paul@pbarker.dev>
Diffstat (limited to 'bitbake/lib/bb/tests')
| -rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 5735cf8f45..37e4eb9f4c 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | # | 7 | # |
| 8 | 8 | ||
| 9 | import contextlib | 9 | import contextlib |
| 10 | import shutil | ||
| 10 | import unittest | 11 | import unittest |
| 11 | import hashlib | 12 | import hashlib |
| 12 | import tempfile | 13 | import tempfile |
| @@ -853,6 +854,16 @@ class FetcherLocalTest(FetcherTest): | |||
| 853 | 854 | ||
| 854 | self.assertIn("does not contain supported data.tar* file", str(context.exception)) | 855 | self.assertIn("does not contain supported data.tar* file", str(context.exception)) |
| 855 | 856 | ||
| 857 | def assertInvalidStriplevel(self, value): | ||
| 858 | with self.assertRaises(bb.fetch2.UnpackError) as context: | ||
| 859 | self.fetchUnpack(['file://archive.tar;subdir=bar;striplevel=%s' % value]) | ||
| 860 | self.assertIn("Invalid striplevel parameter", str(context.exception)) | ||
| 861 | |||
| 862 | def test_local_striplevel_rejects_invalid_values(self): | ||
| 863 | for value in ("abc", "", "-1", "1 2"): | ||
| 864 | with self.subTest(striplevel=repr(value)): | ||
| 865 | self.assertInvalidStriplevel(value) | ||
| 866 | |||
| 856 | def dummyGitTest(self, suffix): | 867 | def dummyGitTest(self, suffix): |
| 857 | # Create dummy local Git repo | 868 | # Create dummy local Git repo |
| 858 | src_dir = tempfile.mkdtemp(dir=self.tempdir, | 869 | src_dir = tempfile.mkdtemp(dir=self.tempdir, |
