diff --git a/CHANGELOG.md b/CHANGELOG.md index a7b38f4..6985f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,14 @@ what has already shipped, and for nothing else. See `RELEASING.md`. ## [Unreleased] +### Security + +- **opentelemetry-api 1.45.2** in `uv.lock`, from 1.45.1. The older release parses a `traceparent` + header in quadratic time, a denial of service (CVE-2026-126360, GHSA-mf5v-w3w3-f6cg, medium, + published 2026-11-13); 1.45.2, on PyPI since 2026-10-29, is the release the advisory names as fixed. + It arrives through fastapi, so `uv lock --upgrade-package opentelemetry-api` moved that one entry and + nothing else. Dependabot raised the alert on 2026-11-14 but opened no pull request. + ### Changed - **The sqlite3 findings say what Debian decided, and Trivy's two new ones are recorded.** On @@ -45,6 +53,29 @@ what has already shipped, and for nothing else. See `RELEASING.md`. ### Fixed +- **The weekly mutation run gets past its stats phase again.** It had been red since 2026-10-24, four + Saturdays, on `assert [13226] == []` in `tests/test_sql_is_not_formatted.py`. mutmut runs the suite + from `mutants/`, where database.py holds every mutant beside the code, and one of them drops the + statement from `db.execute(sql, params)` and leaves the parameters, a tuple built with `*` and `+`, + where the check expects the statement; a few dozen more repeat the listings' ORDER BY, which another + test of the file counts. The three checks now read the database.py in the repository, the same path + without `mutants/`, so they hold or fail under mutmut exactly as they do in the ordinary run. The new + test has mutmut build its copy of the real database.py and reproduced the failure before the fix. + +- **The README's badges render, and none states the version by hand.** The README is also the long + description on PyPI. The PyPI badge had been pasted into its own URL and showed as a broken image; it + is one badge again. The static `calver-2026.8.2` badge named a release two months old; it now says + the project uses CalVer, and the version is left to the PyPI badges, which ask PyPI. + `tests/test_readme_badges.py` holds both. + +- **Changelog headings.** 2026.40 had two `### Changed` sections, now one; 2026.48 was dated + 2026-10-23 with a hyphen, and is now dated 2026-10-24, the day of its tag, with the em dash the other + releases use. + +- **The two CodeQL exceptions name the lines CodeQL reports.** Their `where` said `api/main.py:69` and + `ui_harness.js:45`; the open alerts are at lines 145 and 73, the same warning and the same setter, + moved by the code around them. Only the text changed: the gate matches an exception by rule and path. + - **Security Posture reads every page of alerts.** The code scanning API returns at most a hundred alerts per call, and the gate read one page of each list. Found in cookieradar on 2026-11-13 (cookieradar #70): a pull request with 123 open alerts and main with 142, three exceptions whose @@ -72,7 +103,7 @@ what has already shipped, and for nothing else. See `RELEASING.md`. attempts, 30 s apart) until it succeeds or names the version it could not install: the same script, and the same `tests/test_install_from_pypi.py`, in all six Radar. -## [2026.48] - 2026-10-23 +## [2026.48] — 2026-10-24 ### Security @@ -1241,20 +1272,6 @@ what has already shipped, and for nothing else. See `RELEASING.md`. done it. 2026 is a settling year; from 2027 the count moves when the code moves. - -### Fixed - -- **An NVD API key, paced requests, and a scan that admits a source was - silent.** Without a key NVD allows five requests per rolling thirty seconds, - and the scanner sent them as fast as it could: the throttling that followed - came back as empty results, which the report presented as "no CVEs" — the - strongest possible claim, produced by not having asked. A key is read from the - environment when present, requests are paced to what the tier actually allows, - and a source that did not answer is reported as a source that did not answer - rather than as an absence of findings. - -### Changed - - **The Docker image builds from this repository instead of from a published release.** The Dockerfile could only install `patchradar==${PATCHRADAR_VERSION}` from PyPI, with a default of `2026.8.33` — an August release, while the package @@ -1267,6 +1284,17 @@ what has already shipped, and for nothing else. See `RELEASING.md`. database where the volume actually is, which is the failure that once emptied the watchlist on every container recreation. +### Fixed + +- **An NVD API key, paced requests, and a scan that admits a source was + silent.** Without a key NVD allows five requests per rolling thirty seconds, + and the scanner sent them as fast as it could: the throttling that followed + came back as empty results, which the report presented as "no CVEs" — the + strongest possible claim, produced by not having asked. A key is read from the + environment when present, requests are paced to what the tier actually allows, + and a source that did not answer is reported as a source that did not answer + rather than as an absence of findings. + ## [2026.9.6] — 2026-09-24 ### Fixed diff --git a/README.md b/README.md index 09a09ce..ae3912b 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ PatchRadar checks the CVE feeds for the software on your watchlist, most urgent Scans run when you start one — `patchradar scan`, or **Scan** in the web UI. There is no scheduler and no notification inside PatchRadar: to scan on a schedule, run `patchradar scan` from cron or the Windows Task Scheduler. ![Python](https://img.shields.io/badge/python-3.11+-blue?style=flat-square) -![CalVer](https://img.shields.io/badge/calver-2026.8.2-green?style=flat-square) +![CalVer](https://img.shields.io/badge/versioning-CalVer-green?style=flat-square) ![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square) -![PyPI](https://img.shields.io/pypi/v/patchradar?style=flat-square![PyPI](https://img.shields.io/pypi/v/patchradar?style=flat-square)label=pypi) +![PyPI](https://img.shields.io/pypi/v/patchradar?style=flat-square&label=pypi) [![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://app.codspeed.io/maksimtech/patchradar?utm_source=badge) --- diff --git a/SECURITY-EXCEPTIONS.toml b/SECURITY-EXCEPTIONS.toml index 9cc4521..a5260f2 100644 --- a/SECURITY-EXCEPTIONS.toml +++ b/SECURITY-EXCEPTIONS.toml @@ -126,7 +126,7 @@ review_by = "2026-12-31" id = "py/clear-text-logging-sensitive-data" source = "CodeQL" path = "src/patchradar/api/main.py" -where = "api/main.py:69, the warning logged when no API key is configured" +where = "api/main.py:145, the warning logged when no API key is configured" why = """ The expression logs API_KEY_ENV, which is the *name* of the environment variable \ ("PATCHRADAR_API_KEY"), never its value — and it is only reached when \ @@ -139,7 +139,7 @@ review_by = "2026-12-31" id = "js/incomplete-multi-character-sanitization" source = "CodeQL" path = "tests/js/ui_harness.js" -where = "ui_harness.js:45, the innerHTML setter of the fake DOM" +where = "ui_harness.js:73, the innerHTML setter of the fake DOM" why = """ It is not a sanitizer. The harness models a browser for the UI tests, and its \ innerHTML setter strips tags to record what the page assigned; no untrusted input \ diff --git a/tests/test_readme_badges.py b/tests/test_readme_badges.py new file mode 100644 index 0000000..36ad157 --- /dev/null +++ b/tests/test_readme_badges.py @@ -0,0 +1,45 @@ +"""The README's badges are well formed, and none of them states the version by hand. + +The README is also the long description on PyPI, so what is broken here is broken +there too. On 2026-11-16 one badge held another inside its URL, the PyPI one pasted +into itself, and rendered as a broken image; another, a static `calver-2026.8.2`, +named a release that had been out of date for two months. A version belongs in a +badge that asks PyPI for it, which cannot fall behind. +""" + +from __future__ import annotations + +import re +from pathlib import Path + +README = Path(__file__).resolve().parents[1] / "README.md" + +# `![alt](url)`, the URL up to the first closing parenthesis or space. +IMAGE = re.compile(r"!\[[^\]]*\]\(([^)\s]*)") + +# A CalVer number of this project's shape: 2026.48, 2026.8.2. +VERSION = re.compile(r"\b20\d\d\.\d+(?:\.\d+)?\b") + + +def _image_urls() -> list[str]: + return IMAGE.findall(README.read_text(encoding="utf-8")) + + +def test_no_image_link_holds_another(): + assert [url for url in _image_urls() if "![" in url] == [] + + +def test_no_static_badge_states_a_version(): + static = [url for url in _image_urls() if "img.shields.io/badge/" in url] + assert static, "the README has no static badge left to check" + assert [url for url in static if VERSION.search(url)] == [] + + +def test_the_patterns_recognise_what_was_broken(): + pasted = ( + "![PyPI](https://img.shields.io/pypi/v/patchradar?style=flat-square" + "![PyPI](https://img.shields.io/pypi/v/patchradar?style=flat-square)label=pypi)" + ) + assert "![" in IMAGE.findall(pasted)[0] + assert VERSION.search("https://img.shields.io/badge/calver-2026.8.2-green?style=flat-square") + assert not VERSION.search("https://img.shields.io/badge/python-3.11+-blue?style=flat-square") diff --git a/tests/test_sql_is_not_formatted.py b/tests/test_sql_is_not_formatted.py index 4e6c2b7..7aae730 100644 --- a/tests/test_sql_is_not_formatted.py +++ b/tests/test_sql_is_not_formatted.py @@ -21,13 +21,31 @@ import patchradar.db.database as database from patchradar.priority import sql_order -SOURCE = pathlib.Path(database.__file__).read_text(encoding="utf-8") DML = re.compile(r"^\s*(SELECT|INSERT|UPDATE|DELETE)\b", re.I) -def _formatted_statements() -> list[int]: +def _repository_file(path: pathlib.Path) -> pathlib.Path: + """The file in the repository that `path` stands for. + + mutmut copies the repository into `mutants/` and imports the package from + there, so `database.__file__` is its copy, with every mutant beside the code; + the file the checks are about is the same path without that component. The + claims are about what is written, which a mutant does not change: under mutmut + they hold or fail exactly as they do in the ordinary run. + """ + parts = path.parts + if "mutants" not in parts: + return path + cut = len(parts) - 1 - parts[::-1].index("mutants") + return pathlib.Path(*parts[:cut], *parts[cut + 1 :]) + + +SOURCE = _repository_file(pathlib.Path(database.__file__)).read_text(encoding="utf-8") + + +def _formatted_statements(source: str) -> list[int]: lines = [] - for node in ast.walk(ast.parse(SOURCE)): + for node in ast.walk(ast.parse(source)): if not (isinstance(node, ast.Call) and getattr(node.func, "attr", "") in {"execute", "executemany"}): continue if not node.args: @@ -43,7 +61,33 @@ def _formatted_statements() -> list[int]: def test_no_select_insert_update_or_delete_is_a_formatted_string(): - assert _formatted_statements() == [] + assert _formatted_statements(SOURCE) == [] + + +def test_under_mutmut_the_checks_read_the_repository_not_its_copy(tmp_path): + """mutmut runs the suite from `mutants/`, a copy of the repository in which + database.py holds, beside every function, each of its mutated variants. One + of them drops the statement from `db.execute(sql, params)` and leaves the + parameters first, a tuple built with `*` and `+`, which is a formatted + statement to the check above; another few dozen repeat the listings' ORDER + BY. Read there, the checks fail on code nobody wrote, and the weekly mutation + run stopped in its stats phase on 2026-10-24 and every Saturday since. + + The copy is made by mutmut itself, from the real database.py, in a tree laid + out as mutmut lays out its own. + """ + from mutmut.mutation.file_mutation import mutate_file_contents + + source = _repository_file(pathlib.Path(database.__file__)).read_text(encoding="utf-8") + original = tmp_path / "src" / "patchradar" / "db" / "database.py" + copy = tmp_path / "mutants" / "src" / "patchradar" / "db" / "database.py" + for path in (original, copy): + path.parent.mkdir(parents=True) + original.write_text(source, encoding="utf-8") + copy.write_text(mutate_file_contents(str(original), source).code, encoding="utf-8") + + assert _formatted_statements(copy.read_text(encoding="utf-8")) != [] + assert _formatted_statements(_repository_file(copy).read_text(encoding="utf-8")) == [] def test_the_listings_are_ordered_by_what_priority_ranks_by(): diff --git a/uv.lock b/uv.lock index 54dd335..7db62e2 100644 --- a/uv.lock +++ b/uv.lock @@ -730,14 +730,14 @@ wheels = [ [[package]] name = "opentelemetry-api" -version = "1.45.1" +version = "1.45.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/2e/02/6e0ae9cc61bd3169d401077b507b3ebc344745171e1051ab430be012dcd9/opentelemetry_api-1.45.1.tar.gz", hash = "sha256:aa38ed19bcc084ba42782a73255b3582283eced7ad6dddbd6695189e69adfb75", size = 72804, upload-time = "2026-10-06T17:32:58.133Z" } +sdist = { url = "https://files.pythonhosted.org/packages/19/14/cf3a6b6448849656e1e5f4e2101f3988dc6789724050096aba1bc5ccf592/opentelemetry_api-1.45.2.tar.gz", hash = "sha256:d7b0008e21e5fd61cbe7a7f34ca3b6905a78ab677d9bc395e299359c75cda6b4", size = 73277, upload-time = "2026-10-29T17:29:37.888Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/1e/41/f7dcf80b81ee8e71c1a2b59f14208bc723edbd89ed027a73b175abf6348e/opentelemetry_api-1.45.1-py3-none-any.whl", hash = "sha256:b31553efa588ae44bc306f863c785c5333a9ecc091248c6ee68b4b6c87fdedfb", size = 60256, upload-time = "2026-10-06T17:32:33.506Z" }, + { url = "https://files.pythonhosted.org/packages/a9/2d/610db864d7513158cebb8f36cc88e67e73bd6c7aa1905ef18d89e1281c81/opentelemetry_api-1.45.2-py3-none-any.whl", hash = "sha256:2cbd737377e710ee740d261c94e93fa0f08e6d037c18f17513cc0a2d94479a34", size = 60335, upload-time = "2026-10-29T17:29:06.955Z" }, ] [[package]]