Files
opengenesislinkserver/tools/ci/verify_sysapi_global_alert.py
T
OpenGenesis (EULA) e81076f33c feat(g1): global SYS.API alerts over signed NexBus to all simulator regions
Adds a CSRF-protected admin-only alert command with severity presets and 5-second rate limit; signs a NexBus event and fans out via native IDialogModule.SendGeneralAlert across all hosted regions, including EventSim when configured. Default remains opt-in. NexVerse CI, .NET10 full build, SYS.API HTTP/HMAC tests and security contracts passed. Cross-platform builds/ROBUST boot passed; release-artifact upload remains blocked by GitHub storage quota. No production deployment.
2026-11-22 21:53:26 +01:00

63 lines
3.0 KiB
Python

#!/usr/bin/env python3
"""SYS.API alert command + signed NexBus global fan-out integration contract."""
from pathlib import Path
root = Path(__file__).resolve().parents[2]
read = lambda relative: (root / relative).read_text(encoding="utf-8")
host = read("addons/SysApi/SysApiHost.cs")
connector = read("addons/SysApi/SysApiConnector.cs")
publisher = read("addons/SysApi/SysApiGlobalAlert.cs")
node = read("NexVerse/RegionModules/NodeAgent/NexVerseNodeAgentModule.cs")
page = read("addons/SysApi/www/index.html")
javascript = read("addons/SysApi/www/app.js")
tests = read("tools/ci/SysApiSmoke/Program.cs")
# Browser action is not an arbitrary remote command interpreter.
for term in ('path == "/api/admin/alerts"', 'req.HttpMethod != "POST"',
"TryAdmin(req, out AdminSession admin)", '"X-OGL-CSRF"',
"SysApiAlertCommand.TryParse", "_alertGate.WaitAsync",
"TimeSpan.FromSeconds(5)", "_alertPublisher.PublishAsync",
"await ReplyAsync(response, 202", "alertsAvailable"):
assert term in host, term
assert "RunCommand(" not in publisher
assert 'StartsWith("alert "' in publisher
assert 'value.Length is < 1 or > 500' in publisher
# Sys.API signs an event for the *existing* ROBUST NexBus on local loopback.
for term in ("NexBusProtocol.Sign", "NexBusProtocol.Serialize",
'"http://127.0.0.1:"', 'UseProxy = false', 'AllowAutoRedirect = false',
'"admin.alert.requested"', '"opengenesislink.sysapi"'):
assert term in publisher, term
for term in ('GetBoolean("AlertsEnabled", false)', 'GetBoolean("Enabled", false)',
'GetString("SharedKey", "")', 'GetString("Peers", "")'):
assert term in connector, term
# A shared NodeAgent handles the event once, then alerts every hosted scene.
for term in ('m_Bus.Subscribe("admin.alert.requested", HandleAdminAlert)',
"m_AdminAlertSubscription?.Dispose();", "m_Scenes.Values",
"scene.RequestModuleInterface<IDialogModule>()",
"dialog.SendGeneralAlert(message)", '"opengenesislink.sysapi"',
"TimeSpan.FromSeconds(30)"):
assert term in node, term
# UI deliberately uses textContent, confirmation and CSRF-enabled same-origin API.
for term in ('id="alert-form"', 'id="alert-level"', 'id="alert-message"',
'id="alert-preview"', 'id="alert-send"'):
assert term in page, term
for term in ('renderAlertPreview', 'window.confirm(', '"/api/admin/alerts"',
'textContent', 'JSON.stringify({command})'):
assert term in javascript, term
assert "innerHTML" not in javascript
for ini in ("bin/Robust.HG.ini", "bin/Robust.HG.ini.example",
"bin/Robust.ini.example"):
assert "AlertsEnabled = false" in read(ini), ini
for term in ('"anonymous alert blocked"', '"alert CSRF required"',
'"arbitrary console command forbidden"', '"multiline alert forbidden"',
'"global alert rate limit"', '"revoked admin cannot alert"'):
assert term in tests, term
print("PASS: global SYS.API alert command is protected, NexBus-signed and region-wide")