Follow two upstream catalogue shifts: release rows and bare branch bounds
This commit is contained in:
1 parent
86fee6cf7d
commit
aca8e5da1a
4 files changed
+28
-1
No files matched your search
@@ -296,7 +296,10 @@ def _archive(html: str) -> dict[str, _Month]:
|
||||
except ValueError:
|
||||
raise InvalidData("invalid Android archive bulletin link") from None
|
||||
stamp = _path_date(link.path)
|
||||
if (stamp is None or (link.scheme, link.netloc) not in {("", ""), ("https", _HOST)}
|
||||
if stamp is None:
|
||||
# Release pages such as android-11 have no month; the month rows do.
|
||||
continue
|
||||
if ((link.scheme, link.netloc) not in {("", ""), ("https", _HOST)}
|
||||
or link.query or link.fragment or stamp in entries or len(entries) >= _MAX_MONTHS):
|
||||
raise InvalidData("invalid or duplicate Android archive bulletin")
|
||||
month = _day(stamp)
|
||||
|
||||
@@ -167,6 +167,9 @@ def _modern_products(cna: dict[str, object]) -> list[Product]:
|
||||
# not extrapolate that statement to older end-of-life branches.
|
||||
if lower == "0":
|
||||
lower = f"{branch}.0"
|
||||
elif lower == branch:
|
||||
# A bare branch ("2.4") bounds the whole series from its start.
|
||||
lower = f"{branch}.0"
|
||||
if not isinstance(lower, str) or _branch(lower) != branch:
|
||||
raise InvalidData("Apache version interval crosses release branches")
|
||||
start, end = _numeric(lower), _numeric(upper)
|
||||
|
||||
@@ -254,3 +254,11 @@ async def test_historical_google_devices_do_not_narrow_aosp_branch_evidence() ->
|
||||
])
|
||||
def test_android_route_allowlist(host: str, path: str, live: bool, expected: bool) -> None:
|
||||
assert allowed(host, path, live=live) is expected
|
||||
|
||||
|
||||
def test_archive_skips_release_pages_that_carry_no_month() -> None:
|
||||
from vuln_mcp.sources.feed_android import _archive
|
||||
|
||||
html = archive(("android-11", "Android 11", "January 6, 2025", "2025-01-01"), JAN)
|
||||
entries = _archive(html.decode())
|
||||
assert list(entries) == ["2025-01-01"]
|
||||
@@ -236,3 +236,16 @@ async def test_apache_rejects_wrong_detail_identity(defect: str) -> None:
|
||||
def test_apache_allowlist(host: str, path: str, index: bool, live: bool) -> None:
|
||||
assert allowed(host, path, live=False) is index
|
||||
assert allowed(host, path, live=True) is live
|
||||
|
||||
|
||||
def test_modern_record_may_bound_a_whole_branch_from_its_start():
|
||||
from vuln_mcp.sources.feed_web import _advisory
|
||||
|
||||
raw = _modern()
|
||||
versions = raw["containers"]["cna"]["affected"][0]["versions"]
|
||||
versions[:] = [{"version": "2.4", "lessThanOrEqual": "2.4.54", "status": "affected", "versionType": "semver"}]
|
||||
doc = _advisory(raw)
|
||||
issue, = doc.issues
|
||||
ranged = [item for item in issue.products if item.get("range")]
|
||||
assert [(item["version"], item["range"], item["status"]) for item in ranged] == [
|
||||
("2.4.0", {"lessThanOrEqual": "2.4.54"}, "affected")]
|
||||
Reference in new issue
Block a user