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.
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""_build_record must thread country fields through to the upsert payload."""
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
|
|
from decnet.correlation.parser import LogEvent
|
|
from decnet.geoip.rir.fetch import RIR_SOURCES
|
|
from decnet.profiler.worker import _build_record
|
|
|
|
|
|
def _evt(ip: str) -> LogEvent:
|
|
return LogEvent(
|
|
timestamp=datetime(2026, 4, 23, tzinfo=timezone.utc),
|
|
attacker_ip=ip,
|
|
decky="decky-01",
|
|
service="ssh",
|
|
event_type="conn",
|
|
fields={},
|
|
raw="",
|
|
)
|
|
|
|
|
|
def test_build_record_includes_country_when_resolved(tmp_path: Path) -> None:
|
|
(tmp_path / f"{RIR_SOURCES[0][0]}.txt").write_text(
|
|
"arin|US|ipv4|8.8.8.0|256|20000101|allocated|abc\n"
|
|
)
|
|
record = _build_record("8.8.8.8", [_evt("8.8.8.8")], None, [], [])
|
|
assert record["country_code"] == "US"
|
|
assert record["country_source"] == "rir"
|
|
|
|
|
|
def test_build_record_country_none_for_private(tmp_path: Path) -> None:
|
|
(tmp_path / f"{RIR_SOURCES[0][0]}.txt").write_text(
|
|
"arin|US|ipv4|8.8.8.0|256|20000101|allocated|abc\n"
|
|
)
|
|
record = _build_record("10.0.0.1", [_evt("10.0.0.1")], None, [], [])
|
|
assert record["country_code"] is None
|
|
assert record["country_source"] is None
|