Replaces LICENSE (GPLv3 -> AGPLv3) and prepends `SPDX-License-Identifier: AGPL-3.0-or-later` to every source file across decnet/, decnet_web/, tests/, scripts/, and tools/. Rationale: closes the GPLv3 ASP loophole so any party operating a modified DECNET as a network service must offer their modified source. Personal copyright (Samuel Paschuan) + inbound=outbound contributions make a future unilateral relicense infeasible. - LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt) - COPYRIGHT: project copyright notice - tools/add_spdx_headers.py: idempotent header injector (shebang- and PEP 263-aware) Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh). No behavior change; comments only.
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""RPKI validity enrichment — maps (IP, ASN) pairs to route origin validity.
|
|
|
|
Public surface:
|
|
|
|
* :func:`enrich_rpki` — takes an IP string and ASN int, returns
|
|
``(rpki_status, provider_name)`` or ``(None, None)``.
|
|
|
|
Validator selection goes through :func:`~decnet.rpki.factory.get_validator`
|
|
(env ``DECNET_RPKI_PROVIDER``, default ``ripestat``). Direct imports of
|
|
concrete validators are forbidden — mirrors the ``get_bus`` /
|
|
``get_repository`` rule.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from typing import Optional, Tuple
|
|
|
|
from decnet.rpki.factory import get_validator
|
|
|
|
|
|
def enrich_rpki(ip: str, asn: Optional[int]) -> Tuple[Optional[str], Optional[str]]:
|
|
"""Return ``(rpki_status, provider_name)`` or ``(None, None)``.
|
|
|
|
Never raises — any failure collapses to ``(None, None)`` so the
|
|
caller (profiler) can upsert the attacker row regardless.
|
|
|
|
Short-circuits to ``(None, None)`` when ``asn`` is None (no ASN
|
|
means no route origin to validate) or when
|
|
``DECNET_RPKI_ENABLED=false``.
|
|
"""
|
|
if os.environ.get("DECNET_RPKI_ENABLED", "true").lower() == "false":
|
|
return (None, None)
|
|
if asn is None:
|
|
return (None, None)
|
|
try:
|
|
validator = get_validator()
|
|
result = validator.validate(ip, asn)
|
|
return (result.status, validator.name)
|
|
except Exception:
|
|
return (None, None)
|
|
|
|
|
|
__all__ = ["enrich_rpki"]
|