Skip to contentSkip to conversation

[2.18][PATCH v2 0/8] Patch review

bitbake Yoann Congal 1 participant 9 messages Jun 11

lore
Share & tools
lore
#0 lore raw

Please review this set of changes for 2.18/wrynose and have comments back by end of day Friday, June 12.

Passed a-full on autobuilder:
https://autobuilder.yoctoproject.org/valkyrie/?#/builders/29/builds/3975
* the meta-qcom warning is not related to this series and has been reported upstream:
https://github.com/qualcomm-linux/meta-qcom/issues/2436

v1->v2:
* Added security fix "fetch2/wget: limit auth on checkstatus redirects" and associated test.

The following changes since commit 294074e65f37822a0f31bb11eb968d311b54a66a:

toaster: use https for clones, remove cgit in links in defaults (2026-06-06 01:17:50 +0200)

are available in the Git repository at:

https://git.openembedded.org/bitbake-contrib stable/2.18-nut
https://git.openembedded.org/bitbake-contrib/log/?h=stable/2.18-nut

for you to fetch changes up to acfe02fa38b5da9e6a36c6cedcf91d4fcbefbfbd:

tests/fetch: cover checkstatus redirect auth handling (2026-06-11 11:50:29 +0200)

----------------------------------------------------------------

Anders Heimer (2):
fetch2/wget: limit auth on checkstatus redirects tests/fetch: cover checkstatus redirect auth handling

Anthony Squires (1):
fetch2: reraise IOError during download

João Marcos Costa (1):
layerindexlib: restapi.py: fix unbound variable

Marcio Henriques (1):
bitbake: fix issue with varflag exclusion

Thomas Perrot (2):
fetch2/crate: skip yanked versions when reading cargo index fetch2/crate: guard against empty version list

hongxu (1):
fetch2: allow empty value for params while formatting URI string.

 lib/bb/data.py               |  2 +-
 lib/bb/fetch2/__init__.py    |  8 +++--
 lib/bb/fetch2/crate.py       |  7 ++--
 lib/bb/fetch2/wget.py        | 27 ++++++++++++--
 lib/bb/tests/fetch.py        | 68 ++++++++++++++++++++++++++++++++++--
 lib/layerindexlib/restapi.py |  2 +-
 6 files changed, 102 insertions(+), 12 deletions(-)
#1 lore raw

[bitbake][wrynose][2.18][PATCH v2 6/8] fetch2: allow empty value for params while formatting URI string.

From: hongxu <[email protected]>

While using PREMIRRORS to gets source code, recipe sbom-cve-check-update-nvd-native do fetch failed:

$ bitbake sbom-cve-check-update-nvd-native  -cfetch -f
...
ERROR: sbom-cve-check-update-nvd-native-1.0-r0 do_fetch: Bitbake Fetcher Error: MalformedUrl('git:///path-to-premirror/git/github.com.fkie-cad.nvd-json-data-feeds.git;branch=main;protocol=file;destsuffix')
ERROR: Logfile of failure stored in: tmp/work/x86_64-linux/sbom-cve-check-update-nvd-native/1.0/temp/log.do_fetch.4135595
ERROR: Task (oe-core/meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-nvd-native.bb:do_fetch) failed with exit code '1'
...

In oe-core commit [1], destsuffix was configured to empty string through SRC_URI, but in bitbake commit [2], it removed `=' from destsuffix in which value is empty, and trigger MalformedUrl failure, see sbom-cve-check-update-nvd-native do_fetch log:

...log.do_fetch...
DEBUG: For url git://github.com/fkie-cad/nvd-json-data-feeds.git;branch=main;protocol=https;destsuffix= returning git:///path-to-premirror/git/github.com.fkie-cad.nvd-json-data-feeds.git;branch=main;protocol=file;destsuffix
...log.do_fetch...

This commit use function _query_str_join for query as usual (if a value is
None then it isn't a key-value pair, but a bare key.), and use function
_param_str_join for params to allow value is empty string and still key-value
pair, after applying this commit
...log.do_fetch...
DEBUG: For url git://github.com/fkie-cad/nvd-json-data-feeds.git;branch=main;protocol=https;destsuffix= returning git:///path-to-premirror/git/github.com.fkie-cad.nvd-json-data-feeds.git;branch=main;protocol=file;destsuffix=
...log.do_fetch...

$ bitbake-selftest -v bb.tests.fetch.URITest.test_uri
test_uri (bb.tests.fetch.URITest) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.001s

OK

[1] https://github.com/openembedded/openembedded-core/commit/131e024a6688074347e08879718221fbfb69033f
[2] https://github.com/openembedded/bitbake/commit/eac583bd4c46f3bb9661852cb6a1448f16147ff1

(cherry picked from commit b3867e6d35ef57239c7ba961a00fa45577600301)
---
 lib/bb/fetch2/__init__.py | 7 +++++--
 lib/bb/tests/fetch.py     | 6 +++---
 2 files changed, 8 insertions(+), 5 deletions(-)
lib/bb/fetch2/__init__.py +5 -2
index d913d7511..e0494b3cb 100644
@@ -304,7 +304,7 @@ class URI(object):
 
     def _query_str(self):
         return (
-            ''.join(['?', self._param_str_join(self.query, "&")])
+            ''.join(['?', self._query_str_join(self.query, "&")])
             if self.query else '')
 
     def _param_str_split(self, string, elmdelim, kvdelim="="):
@@ -313,9 +313,12 @@ class URI(object):
             ret[k] = v
         return ret
 
-    def _param_str_join(self, dict_, elmdelim, kvdelim="="):
+    def _query_str_join(self, dict_, elmdelim, kvdelim="="):
         return elmdelim.join([kvdelim.join([k, v]) if v else k for k, v in dict_.items()])
 
+    def _param_str_join(self, dict_, elmdelim, kvdelim="="):
+        return elmdelim.join([kvdelim.join([k, v]) for k, v in dict_.items()])
+
     @property
     def hostport(self):
         if not self.port:
lib/bb/tests/fetch.py +3 -3
index cc133c1f5..e661ff0d8 100644
@@ -292,8 +292,8 @@ class URITest(unittest.TestCase):
             'query': {},
             'relative': True
         },
-        "https://www.innodisk.com/Download_file?9BE0BF6657;downloadfilename=EGPL-T101.zip": {
-            'uri': 'https://www.innodisk.com/Download_file?9BE0BF6657;downloadfilename=EGPL-T101.zip',
+        "https://www.innodisk.com/Download_file?9BE0BF6657;downloadfilename=EGPL-T101.zip;someparam=": {
+            'uri': 'https://www.innodisk.com/Download_file?9BE0BF6657;downloadfilename=EGPL-T101.zip;someparam=',
             'scheme': 'https',
             'hostname': 'www.innodisk.com',
             'port': None,
@@ -303,7 +303,7 @@ class URITest(unittest.TestCase):
             'userinfo': '',
             'username': '',
             'password': '',
-            'params': {"downloadfilename" : "EGPL-T101.zip"},
+            'params': {"downloadfilename" : "EGPL-T101.zip", "someparam" : ""},
             'query': {"9BE0BF6657": None},
             'relative': False
         },
#2 lore raw

[bitbake][wrynose][2.18][PATCH v2 1/8] fetch2: reraise IOError during download

In reply to Yoann Congal

From: Anthony Squires <[email protected]>

Fixes [YOCTO #16268]

Adds a missing "raise" statement to download that ensures when there is an IOError/OSError that is is correctly reported and not silently discarded.

When an IOError is thrown in this case do_fetch silently passes which then leads to downstream failures in do_unpack when the file doesn't exist.

(cherry picked from commit 0460038e4705934e614b26ba5febc09293924cd4)
---
 lib/bb/fetch2/__init__.py | 1 +
 1 file changed, 1 insertion(+)
lib/bb/fetch2/__init__.py +1 -0
index 0e4f491ce..d913d7511 100644
@@ -1969,6 +1969,7 @@ class Fetch(object):
                 if e.errno in [errno.ESTALE]:
                     logger.error("Stale Error Observed %s." % u)
                     raise ChecksumError("Stale Error Detected")
+                raise
 
             except BBFetchException as e:
                 if isinstance(e, NoChecksumError):
#3 lore raw

[bitbake][wrynose][2.18][PATCH v2 7/8] fetch2/wget: limit auth on checkstatus redirects

In reply to Yoann Congal

From: Anders Heimer <[email protected]>

FixedHTTPRedirectHandler copies request headers when checkstatus() follows a redirect, including Authorization from SRC_URI or .netrc.

Keep same-origin redirects unchanged, but drop Authorization and Cookie for different-origin targets (scheme, host and effective port), following RFC 9110 redirect guidance for resource-specific headers. This only affects the Python checkstatus() path; normal wget downloads are unchanged.

(cherry picked from commit 1019d5a5c42c672ea673ae9d22363d626b57ccb9)
---
 lib/bb/fetch2/wget.py | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
lib/bb/fetch2/wget.py +25 -2
index 6ac4306c0..fc83b301a 100644
@@ -288,6 +288,18 @@ class Wget(FetchMethod):
             http_error_403 = http_error_405
 
 
+        def _url_origin(url):
+            parsed = urllib.parse.urlsplit(url)
+            scheme = parsed.scheme.lower()
+            host = parsed.hostname.lower() if parsed.hostname else ""
+            port = parsed.port
+            if port is None:
+                port = {"http": 80, "https": 443}.get(scheme)
+            return (scheme, host, port)
+
+        def _same_origin(url_a, url_b):
+            return _url_origin(url_a) == _url_origin(url_b)
+
         class FixedHTTPRedirectHandler(urllib.request.HTTPRedirectHandler):
             """
             urllib2.HTTPRedirectHandler before 3.13 has two flaws:
@@ -301,6 +313,9 @@ class Wget(FetchMethod):
 
             Until we depend on Python 3.13 onwards, copy the redirect_request
             method to fix these issues.
+
+            Additionally, strip sensitive headers (Authorization, Cookie) when
+            redirecting to a different origin to avoid credential leaks.
             """
             def redirect_request(self, req, fp, code, msg, headers, newurl):
                 m = req.get_method()
@@ -320,8 +335,16 @@ class Wget(FetchMethod):
                 newurl = newurl.replace(' ', '%20')
 
                 CONTENT_HEADERS = ("content-length", "content-type")
-                newheaders = {k: v for k, v in req.headers.items()
-                            if k.lower() not in CONTENT_HEADERS}
+                SENSITIVE_REDIRECT_HEADERS = ("authorization", "cookie")
+                same_origin = _same_origin(req.get_full_url(), newurl)
+                newheaders = {}
+                for k, v in req.headers.items():
+                    header = k.lower()
+                    if header in CONTENT_HEADERS:
+                        continue
+                    if not same_origin and header in SENSITIVE_REDIRECT_HEADERS:
+                        continue
+                    newheaders[k] = v
                 return urllib.request.Request(newurl,
                             method="HEAD" if m == "HEAD" else "GET",
                             headers=newheaders,
#4 lore raw

[bitbake][wrynose][2.18][PATCH v2 8/8] tests/fetch: cover checkstatus redirect auth handling

In reply to Yoann Congal

From: Anders Heimer <[email protected]>

Add local HTTP server tests for Wget.checkstatus() redirects. They check that Authorization is kept for same-origin redirects and dropped when the target has a different origin.

(cherry picked from commit c687d42b81b17e7a2399099cab0f1a6aafcf6520)
---
 lib/bb/tests/fetch.py | 62 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
lib/bb/tests/fetch.py +62 -0
index e661ff0d8..c071401e6 100644
@@ -7,6 +7,7 @@
 #
 
 import contextlib
+import http.server
 import shutil
 import unittest
 import unittest.mock
@@ -18,6 +19,7 @@ import os
 import signal
 import subprocess
 import tarfile
+import threading
 from bb.fetch2 import URI
 import bb
 import bb.utils
@@ -1643,6 +1645,41 @@ class FetchCheckStatusTest(FetcherTest):
                       "ftp://sourceware.org/pub/libffi/libffi-1.20.tar.gz",
                       ]
 
+    def _start_checkstatus_server(self):
+        class CheckStatusHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
+            def do_HEAD(self):
+                self.server.requests.append((self.path, dict(self.headers)))
+                if self.path == "/a" and self.server.redirect_url:
+                    self.send_response(302)
+                    self.send_header("Location", self.server.redirect_url)
+                    self.end_headers()
+                    return
+                self.send_response(200)
+                self.end_headers()
+
+            def log_message(self, format_str, *args):
+                pass
+
+        server = http.server.HTTPServer(("127.0.0.1", 0), CheckStatusHTTPRequestHandler)
+        server.redirect_url = None
+        server.requests = []
+        thread = threading.Thread(target=server.serve_forever, kwargs={"poll_interval": 0.05})
+        thread.daemon = True
+        thread.start()
+
+        def stop_server():
+            server.shutdown()
+            thread.join()
+            server.server_close()
+
+        self.addCleanup(stop_server)
+        return server
+
+    def _checkstatus(self, url):
+        fetch = bb.fetch2.Fetch([url], self.d)
+        ud = fetch.ud[url]
+        return ud.method.checkstatus(fetch, ud, self.d)
+
     @skipIfNoNetwork()
     def test_wget_checkstatus(self):
         fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d)
@@ -1670,6 +1707,31 @@ class FetchCheckStatusTest(FetcherTest):
 
         connection_cache.close_connections()
 
+    def test_wget_checkstatus_same_origin_redirect_keeps_auth(self):
+        server = self._start_checkstatus_server()
+        server.redirect_url = "http://127.0.0.1:%s/b" % server.server_port
+
+        url = "http://127.0.0.1:%s/a;user=user;pswd=pass" % server.server_port
+        self.assertTrue(self._checkstatus(url))
+
+        self.assertEqual(len(server.requests), 2)
+        redirected_headers = {k.lower(): v for k, v in server.requests[1][1].items()}
+        self.assertIn("authorization", redirected_headers)
+
+    def test_wget_checkstatus_different_origin_redirect_drops_auth(self):
+        origin = self._start_checkstatus_server()
+        target = self._start_checkstatus_server()
+        # Same host but different port is a different origin.
+        origin.redirect_url = "http://127.0.0.1:%s/b" % target.server_port
+
+        url = "http://127.0.0.1:%s/a;user=user;pswd=pass" % origin.server_port
+        self.assertTrue(self._checkstatus(url))
+
+        self.assertEqual(len(origin.requests), 1)
+        self.assertEqual(len(target.requests), 1)
+        redirected_headers = {k.lower(): v for k, v in target.requests[0][1].items()}
+        self.assertNotIn("authorization", redirected_headers)
+
 
 class GitMakeShallowTest(FetcherTest):
     def setUp(self):
#5 lore raw

[bitbake][wrynose][2.18][PATCH v2 4/8] fetch2/crate: skip yanked versions when reading cargo index

In reply to Yoann Congal

From: Thomas Perrot <[email protected]>

The cargo sparse index marks yanked crate versions with "yanked": true. Treat those the same way as non-existing versions so that version checking never promotes a yanked release as the latest one.

(cherry picked from commit 0d757e8dfff7c5d338a01437960d60312e9af490)
---
 lib/bb/fetch2/crate.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/fetch2/crate.py +2 -1
index b89817ab9..d84bae0bc 100644
@@ -178,7 +178,8 @@ class Crate(Wget):
         response = self._fetch_index(ud.versionsurl, ud, d)
         for line in response.splitlines():
             data = json.loads(line)
-            versions.append((0, data["vers"], ""))
+            if not data.get("yanked", False):
+                versions.append((0, data["vers"], ""))
 
         versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp))
         return (versions[-1][1], "")
#6 lore raw

[bitbake][wrynose][2.18][PATCH v2 5/8] fetch2/crate: guard against empty version list

In reply to Yoann Congal

From: Thomas Perrot <[email protected]>

Both latest_versionstring() and latest_versionstring_from_index() would raise IndexError on versions[-1] if the fetched index returns no usable versions.
Return ("", "") in that case, consistent with what callers expect when no upstream version can be determined.

(cherry picked from commit ffdc2a02693379d7ead0f7b940111340843d49a4)
---
 lib/bb/fetch2/crate.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/fetch2/crate.py +2 -2
index d84bae0bc..eb1fd5719 100644
@@ -164,7 +164,7 @@ class Crate(Wget):
         versions = [(0, i["num"], "") for i in json_data["versions"]]
         versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp))
 
-        return (versions[-1][1], "")
+        return (versions[-1][1], "") if versions else ("", "")
 
     def latest_versionstring_from_index(self, ud, d):
         """
@@ -182,4 +182,4 @@ class Crate(Wget):
                 versions.append((0, data["vers"], ""))
 
         versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp))
-        return (versions[-1][1], "")
+        return (versions[-1][1], "") if versions else ("", "")
#7 lore raw

[bitbake][wrynose][2.18][PATCH v2 3/8] layerindexlib: restapi.py: fix unbound variable

In reply to Yoann Congal

From: João Marcos Costa <[email protected]>

If the requested branch(es) is not found, a debugging message is displayed to list it, so the expected behavior is something like this:

$ bitbake-layers layerindex-fetch meta-firefox
NOTE: Starting bitbake server...
Loading https://layers.openembedded.org/layerindex/api/;branch=wrynose...
ERROR: Remote layer index ['https://layers.openembedded.org/layerindex/'] is empty for branches ['wrynose']

However, the variable currently used is unbound, and the error below comes up:

File "/src/bitbake/lib/layerindexlib/restapi.py", line 216, in load_index_web
logger.debug("No valid branches (%s) found at url %s." % (branch, url))
^^^^^^
UnboundLocalError: cannot access local variable 'branch' where it is not associated with a value

Replace 'branch' by 'branches' to fix this.

(cherry picked from commit df3295f016a74a1414b8af5adb9f2a3967c365b6)
---
 lib/layerindexlib/restapi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/layerindexlib/restapi.py +1 -1
index 81d99b02e..65405cb7e 100644
@@ -213,7 +213,7 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin):
         pindex['branches'] = _get_json_response(index.apilinks['branches'] + filter,
                                                     username=up.username, password=up.password)
         if not pindex['branches']:
-            logger.debug("No valid branches (%s) found at url %s." % (branch, url))
+            logger.debug("No valid branches (%s) found at url %s." % (branches, url))
             return index
         index.add_raw_element("branches", layerindexlib.Branch, pindex['branches'])
 
#8 lore raw

[bitbake][wrynose][2.18][PATCH v2 2/8] bitbake: fix issue with varflag exclusion

In reply to Yoann Congal

From: Marcio Henriques <[email protected]>

This patch fixes an issue when checking if a varflag can be safely excluded.

BB_SIGNATURE_EXCLUDE_FLAGS lists variable flags that can be safely excluded from checksum and dependency data for keys in the datastore.

When bitbake checks if a varflag must be excluded it checks if the varflag name is part of the string stored in BB_SIGNATURE_EXCLUDE_FLAGS.

As an example, if the varflag 'filename' is in BB_SIGNATURE_EXCLUDE_FLAGS, the varflag 'name' will also be excluded because the check will return 'True' when checking if the varflag is part of the string with the varflags to exclude.

To fix this issue the string from BB_SIGNATURE_EXCLUDE_FLAGS is converted to a list before checking if a varflag is part of it.

(cherry picked from commit 8ab71d0ce302521da6a7e18c887cd85d9a94e8ee)
---
 lib/bb/data.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/data.py +1 -1
index 5fdcdb04a..b12972c03 100644
@@ -378,7 +378,7 @@ def generate_dependencies(d, ignored_vars):
     mod_funcs = set(bb.codeparser.modulecode_deps.keys())
     keys = set(key for key in d if not key.startswith("__")) | mod_funcs
     shelldeps = set(key for key in d.getVar("__exportlist", False) if bb.utils.to_boolean(d.getVarFlag(key, "export")) and not bb.utils.to_boolean(d.getVarFlag(key, "unexport")))
-    varflagsexcl = d.getVar('BB_SIGNATURE_EXCLUDE_FLAGS')
+    varflagsexcl = (d.getVar('BB_SIGNATURE_EXCLUDE_FLAGS') or "").split()
 
     codeparserd = d.createCopy()
     for forced in (d.getVar('BB_HASH_CODEPARSER_VALS') or "").split():