Dependency upgrades, and a fix for site notices
cover Dependency upgrades, and a fix for site notices
1: Fixes four advisories against soupsieve 2.9.2 (CVE-2026-126190,
-126191, -126192, -126193). Soupsieve 4 needs Python 3.11.5 or later, which the move to Ubuntu noble provides.
2: Upgrades the other dependencies with newer patch or minor releases.
Celery 5.7 also needs click-repl 0.4.1 and the new tzlocal.
3: Writing a test for the only use of Beautiful Soup turned up two
bugs in site notices: they showed a literal b'...', and a notice with an attribute on an allowed tag, such as <p class="x">, failed to render.
4: Adds tests that run the Celery tasks without a broker, to cover the
Celery upgrade.
The full test suite passes in the Docker image against MariaDB (83 passed, 1 skipped), and the series is running on a test instance loaded with a copy of the layers.openembedded.org database.
Tim Orling (4):
requirements.txt: upgrade soupsieve to 4.1 requirements.txt: upgrade patch and minor releases layerindex/utils.py: fix sanitise_html() for Python 3 and current bs4
tests: add tests for the Celery tasks
layerindex/utils.py | 6 +++--- requirements.txt | 29 +++++++++++++++-------------- tests/test_tasks.py | 39 +++++++++++++++++++++++++++++++++++++++ tests/test_utils.py | 13 +++++++++++++ 4 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 tests/test_tasks.py
base-commit: 08e58cdece30019a6f9e5d14af16ebe20afa6177
Signature · 1 line
2.56.0
PATCH 1/4 requirements.txt: upgrade soupsieve to 4.1
Fixes CVE-2026-126190, CVE-2026-126191, CVE-2026-126192 and CVE-2026-126193 in soupsieve 2.9.2; CVE-2026-126190 is only fixed in 4.0. Soupsieve 4 needs Python 3.11.5 or later, provided by Ubuntu noble.
AI-Generated: Claude Opus 5.5
--- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
requirements.txt +1 -1
@@ -33,7 +33,7 @@ python-dateutil==2.9.0.post0 pytz==2026.3.post1 six==1.17.0 smmap==5.0.3 -soupsieve==2.9.2 +soupsieve==4.1 sqlparse==0.6.0 typing_extensions==4.16.0 tzdata==2026.3
Signature · 1 line
2.56.0
PATCH 2/4 requirements.txt: upgrade patch and minor releases
In reply to Tim OrlingUpgrade amqp, asgiref, billiard, celery, click, click-repl, djangorestframework, kombu, mysqlclient, pytz, sqlparse, tzdata and wcwidth to their latest releases. Celery 5.7 needs click-repl 0.4.1 and adds a dependency on tzlocal, so pin that too.
AI-Generated: Claude Opus 5.5
--- requirements.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
requirements.txt +14 -13
@@ -1,13 +1,13 @@ -i https://pkgs.safetycli.com/repository/self-d8782/project/layerindex-web/pypi/simple/ -amqp==5.3.1 -asgiref==3.12.1 +amqp==5.4.2 +asgiref==3.13.0 beautifulsoup4==4.15.0 -billiard==4.2.4 -celery==5.6.3 -click==8.4.2 +billiard==4.3.2 +celery==5.7.0 +click==8.5.1 click-didyoumean==0.3.1 click-plugins==1.1.1.2 -click-repl==0.3.0 +click-repl==0.4.1 confusable-homoglyphs==3.3.1 diff-match-patch==20241021 Django>=5.2.18,<5.3
@@ -20,23 +20,24 @@ django-registration==5.2.1 django-reversion==6.3.0 django-reversion-compare==0.17.0 django-simple-captcha==0.7.0 -djangorestframework==3.18.2 +djangorestframework==3.18.3 gitdb==4.0.12 GitPython==3.2.1 -kombu==5.6.2 -mysqlclient==2.2.8 +kombu==5.7.0 +mysqlclient==2.3.1 packaging_legacy==23.0.post0 Pillow==13.0.0 prompt-toolkit==3.0.53 pyasyncore==1.0.5 python-dateutil==2.9.0.post0 -pytz==2026.3.post1 +pytz==2026.6 six==1.17.0 smmap==5.0.3 soupsieve==4.1 -sqlparse==0.6.0 +sqlparse==0.6.1 typing_extensions==4.16.0 -tzdata==2026.3 +tzdata==2026.6 +tzlocal==5.4.5 vine==5.1.0 -wcwidth==0.8.2 +wcwidth==0.9.4 PyYAML==6.0.3
Signature · 1 line
2.56.0
PATCH 3/4 layerindex/utils.py: fix sanitise_html() for Python 3 and current bs4
In reply to Tim OrlingSite notices showed a literal b'...', because sanitise_html() returned bytes, and a notice with an attribute on an allowed tag, such as <p class="x">, failed to render, because current Beautiful Soup needs a dict for tag.attrs. Return a str, clear attributes with a dict, and move off the deprecated findAll() and renderContents(). Add tests.
AI-Generated: Claude Opus 5.5
--- layerindex/utils.py | 6 +++--- tests/test_utils.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-)
layerindex/utils.py +3 -3
@@ -544,13 +544,13 @@ def run_command_interruptible(cmd): def sanitise_html(html): soup = BeautifulSoup(html, "html.parser") - for tag in soup.findAll(True): + for tag in soup.find_all(True): if tag.name not in ['strong', 'em', 'b', 'i', 'p', 'ul', 'ol', 'li', 'br', 'p']: tag.hidden = True elif tag.attrs: - tag.attrs = [] + tag.attrs = {} - return soup.renderContents() + return soup.decode_contents() def squashspaces(string): return re.sub(r"\s+", " ", string).strip()
tests/test_utils.py +13 -0
@@ -85,3 +85,16 @@ def test_in_nested_layer(repo_with_nested_layers, path, expected): assert utils.in_nested_layer(path, nested, repodir) is expected # Absolute paths give the same answer assert utils.in_nested_layer(os.path.join(repodir, path), nested, repodir) is expected + + [email protected]('html, expected', [ + # Allowed tags are kept, but lose their attributes + ('<p class="x" onclick="y">Hi <b>there</b></p>', '<p>Hi <b>there</b></p>'), + ('<ul><li>one</li></ul>', '<ul><li>one</li></ul>'), + # Other tags are dropped, but their text stays (escaped) + ('<a href="http://example.com">link</a>', 'link'), + ('<script>alert(1)</script>', 'alert(1)'), + ('<div><i>x</i> <y></div>', '<i>x</i> <y>'), +]) +def test_sanitise_html(html, expected): + assert utils.sanitise_html(html) == expected
Signature · 1 line
2.56.0
PATCH 4/4 tests: add tests for the Celery tasks
In reply to Tim OrlingRun send_email and run_update_command in-process, so that Celery upgrades are checked without a broker.
AI-Generated: Claude Opus 5.5
--- tests/test_tasks.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/test_tasks.py
tests/test_tasks.py new file +39 -0
@@ -0,0 +1,39 @@ +# layerindex-web - tests for the Celery tasks in layerindex/tasks.py +# +# The tasks run in-process with apply(), so no broker is needed. +# +# Licensed under the MIT license, see COPYING.MIT for details +# +# SPDX-License-Identifier: MIT + +from datetime import datetime + +import pytest + +from layerindex import tasks +from layerindex.models import Update + + +def test_send_email(mailoutbox): + result = tasks.send_email.apply(('Subject', 'Body', '[email protected]', ['[email protected]'])) + assert result.successful() + assert len(mailoutbox) == 1 + msg = mailoutbox[0] + assert (msg.subject, msg.body, msg.from_email, msg.to) == ('Subject', 'Body', '[email protected]', ['[email protected]']) + + [email protected]_db [email protected]('command, retcode, log', [ + ('echo update %update% on %branch%', 0, 'update {id} on master'), + ('echo failed; exit 3', 3, 'failed'), +]) +def test_run_update_command(settings, tmp_path, command, retcode, log): + settings.TASK_LOG_DIR = str(tmp_path / 'logs') + update = Update.objects.create(started=datetime.now(), task_id='test-task') + result = tasks.run_update_command.apply(('master', command), task_id='test-task') + assert result.get()['retcode'] == retcode + update.refresh_from_db() + assert update.retcode == retcode + assert update.log == log.format(id=update.id) + assert update.finished is not None + assert (tmp_path / 'logs' / 'task_test-task.log').exists()
Signature · 1 line
2.56.0