Revalidate Fortinet against the indexed document, not the blocked page
CI / Python 3.13 (push) Successful in 35s
CI / Python 3.12 (push) Successful in 41s
CI / Build and smoke-test image (push) Successful in 15s

This commit is contained in:
omar committed 2026-11-29 10:29:56 +03:00
1 parent 6aa4c744ea
commit 5cec513577
3 files changed
+45 -10

No files matched your search

+1 -1
View File
@@ -410,7 +410,7 @@ def _checks(group: Group, asset: Asset | None = None) -> set[Check]:
continue
if doc.source in _CLAIM_CHECK_SOURCES:
planned.add(Check(doc.source, ident))
elif doc.source in {'siemens', 'msrc', 'industrial'}:
elif doc.source in {'siemens', 'msrc', 'industrial', 'fortinet'}:
if doc.source in {'siemens', 'industrial'}:
planned.discard(Check(doc.source, ident))
planned.add(Check(doc.source, ident, doc.url))
+28 -9
View File
@@ -501,21 +501,40 @@ def _cacheable(headers: Mapping[str, str]) -> bool:
for name, value in headers.items() if name.lower() == "cache-control" for part in value.split(","))
def _target(kind: str, value: object) -> tuple[str, str | None]:
if kind == "id":
return _native(value), None
if kind == "url" and isinstance(value, tuple) and len(value) == 2:
native = _native(value[0])
link = _link(str(value[1]), _url_for(native))
if link is None or link[1] not in {"csaf", "cvrf"} or link[2] != native:
raise InvalidData("unexpected Fortinet document URL")
return native, link[0]
raise InvalidData("unsupported Fortinet lookup")
async def lookup_fortinet(
kind: str, value: object, *, http: _LiveHttp, deadline: float, continuation: str | None = None,
) -> ProviderPage:
"""Revalidate one official FG-IR advisory using the interactive route only."""
try:
if kind != "id" or continuation is not None:
if continuation is not None:
raise InvalidData("unsupported Fortinet lookup")
native = _native(value)
try:
page, page_headers = await http.bytes(_SOURCE, _url_for(native), deadline=deadline, limit=_DETAIL_LIMIT)
except HttpError as error:
if error.status == "not_found":
return ProviderPage(status=Status(source=_SOURCE, as_of=utc_now()))
raise
document_kind, url = await worker(_download_link, page, native)
native, known = _target(kind, value)
if known is None:
# Without an indexed document URL the landing page is the only handle,
# and the publisher's WAF denies it to some egress IPs.
try:
page, page_headers = await http.bytes(_SOURCE, _url_for(native), deadline=deadline,
limit=_DETAIL_LIMIT)
except HttpError as error:
if error.status == "not_found":
return ProviderPage(status=Status(source=_SOURCE, as_of=utc_now()))
raise
document_kind, url = await worker(_download_link, page, native)
else:
url, page_headers = known, {}
document_kind = "csaf" if _CSAF.fullmatch(urlsplit(url).path) else "cvrf"
content, document_headers = await http.bytes(_SOURCE, url, deadline=deadline, limit=_DETAIL_LIMIT)
if len(content) > _DETAIL_LIMIT:
raise InvalidData("Fortinet advisory exceeds byte limit")
+16
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
import json
from time import monotonic
from collections.abc import Mapping
from pathlib import Path
from urllib.parse import urlsplit
@@ -344,3 +345,18 @@ def test_spaced_range_operators_are_valid_product_labels() -> None:
assert _label("FortiMail >= 8.0.0 and <= 8.0.1", _PRODUCT_ID) == "FortiMail >= 8.0.0 and <= 8.0.1"
with pytest.raises(Exception):
_label("<b>FortiMail</b>", _PRODUCT_ID)
@pytest.mark.anyio
async def test_lookup_with_the_indexed_document_skips_the_page() -> None:
wire = LiveWire({artifact_url(): csaf()})
page = await lookup_fortinet("url", (NATIVE, artifact_url()), http=wire, deadline=monotonic() + 5)
assert page.status.status == "ok" and page.docs[0].native_id == NATIVE
# The blocked landing page is never requested.
assert [url for _source, url, _deadline in wire.requests] == [artifact_url()]
@pytest.mark.anyio
async def test_lookup_reports_a_document_url_for_another_identifier() -> None:
page = await lookup_fortinet("url", (NATIVE, artifact_url(OTHER)), http=LiveWire({}), deadline=monotonic() + 5)
assert page.status.status == "invalid_data" and not page.docs