85 lines
4.8 KiB
Python
85 lines
4.8 KiB
Python
#!/usr/bin/env python3
|
||
"""Static SYS.API security, branding and rollout contract."""
|
||
from pathlib import Path
|
||
root=Path(__file__).resolve().parents[2]
|
||
read=lambda p:(root/p).read_text(encoding="utf-8")
|
||
api=read("addons/SysApi/SysApiHost.cs")
|
||
auth=read("addons/SysApi/SysApiConnector.cs")
|
||
secret=read("addons/SysApi/PortalSecretStore.cs")
|
||
js=read("addons/SysApi/www/app.js")
|
||
web=read("addons/SysApi/www/index.html")
|
||
project=read("addons/SysApi/sys.api.csproj")
|
||
for needle in ("sys.api", "www/ogl-mascot.webp", "OpenSim.Server.Handlers.csproj"):
|
||
assert needle in project,needle
|
||
for needle in ('UserLevel < 200', 'Access Denied – Keine Berechtigung',
|
||
'Authenticate(account.PrincipalID', 'GetUserAccount(UUID.Zero',
|
||
'CryptographicOperations.FixedTimeEquals', 'HttpOnly; SameSite=Strict',
|
||
'X-OGL-CSRF', 'IsTrustedProxy', 'Content-Security-Policy',
|
||
'127.0.0.1:', '/api/v1/portal/ping', '/api/v1/portal/capabilities',
|
||
'/api/admin/overview'):
|
||
assert needle in api,needle
|
||
for needle in ('GetBoolean("Enabled", false)', 'IUserAccountService',
|
||
'IAuthenticationService', 'PortalSecretStore.OpenOrCreate'):
|
||
assert needle in auth,needle
|
||
assert "Optional module initialization failed" in auth and "catch (Exception e)" in auth
|
||
for needle in ('FileMode.CreateNew', 'RandomNumberGenerator.GetBytes(64)',
|
||
'UnixFileMode.UserRead | UnixFileMode.UserWrite'):
|
||
assert needle in secret,needle
|
||
assert "innerHTML" not in js
|
||
money = read("addons/SysApi/SysApiNvMoney.cs")
|
||
money_js = read("addons/SysApi/www/money.js")
|
||
for marker in ("/api/admin/money/payouts", "/api/v1/portal/money/payouts",
|
||
"/api/v1/portal/money/rate", "ValidPortalCredential",
|
||
'if (!IsTrustedProxy(req)', "paymentSettlementEnabled = false"):
|
||
assert marker in api + money, "SYS.API money security invariant absent: " + marker
|
||
for marker in ("AdministrativeAdjustment(", "GetTransaction(", "NexLedgerConflictException",
|
||
"FixedTimeEquals", "portal-manual", "admin-manual", "NvPerEuro = 100"):
|
||
assert marker in money, marker
|
||
assert "innerHTML" not in money_js
|
||
assert "OGL_SYSAPI_MONEY_PORTAL_TOKEN" in auth
|
||
assert 'MoneyPortalEnabled", false' in auth
|
||
assert 'MoneyAdminEnabled", false' in auth
|
||
assert 'www/money.js' in project
|
||
assert 'id="nv-money-form"' in web
|
||
|
||
assert "ogl-mascot.webp" in web
|
||
# Never replace production's complete SYS.API with a foundation-only build:
|
||
# doing so removes the centrally published citizen rules and blocks all logins.
|
||
for source in (
|
||
"addons/SysApi/SysApiAccessPolicyStore.cs",
|
||
"addons/SysApi/SysApiResidentGateway.cs",
|
||
"addons/SysApi/SysApiResidentGroups.cs",
|
||
"addons/SysApi/SysApiResidentMessages.cs",
|
||
"addons/SysApi/SysApiResidentInventory.cs",
|
||
"addons/SysApi/SysApiAdminData.cs",
|
||
"addons/SysApi/SysApiUpdatePublisher.cs",
|
||
"OpenSim/Framework/OglLiveAccessPolicy.cs",
|
||
):
|
||
assert (root / source).is_file(), source + " missing from canonical build"
|
||
for marker in ("/api/v1/policies/active", "/api/v1/citizen-rules/current",
|
||
"ISysApiAccessPolicyStore", "SysApiUpdatePublisher",
|
||
'path == "/api/admin/alerts"'):
|
||
assert marker in api, marker
|
||
assert "NexVerseTosFromSysApi" in read("OpenSim/Services/LLLoginService/LLLoginService.cs")
|
||
assert "TryCitizenRules" in read("OpenSim/Services/LLLoginService/LLLoginService.cs")
|
||
assert '<Compile Include="OglLiveAccessPolicy.cs" />' in read("OpenSim/Framework/OpenSim.Framework.csproj")
|
||
assert '<form id="signin" method="post" action="/api/session/login"' in web
|
||
assert 'id="alert-form"' in web
|
||
assert '<form id="signin" method="post" action="/api/session/login"' in web, "Insecure GET fallback would leak passwords into browser history and proxy logs"
|
||
assert "<noscript>" in web, "Missing JavaScript-disabled login warning"
|
||
assert (root/"addons/SysApi/www/ogl-mascot.webp").stat().st_size > 60000
|
||
for p in ("bin/Robust.HG.ini","bin/Robust.HG.ini.example","bin/Robust.ini.example",
|
||
"bin/Robust.HG.OGLAsset.ini.example"):
|
||
contents=read(p)
|
||
assert 'SysApiConnector = "SysApi@' in contents, p
|
||
assert "[SysApi]" in contents and "Enabled = false" in contents.split("[SysApi]")[1],p
|
||
assert "os_webinterface" in read("OpenSim.sln")
|
||
assert "sys.api" in read("OpenSim.sln")
|
||
assert "sys.api" in read("runprebuild.sh") and "sys.api.dll" in read("compile.sh")
|
||
assert "NexVerseWorldApiConnector" in read("bin/Robust.HG.ini"),"Legacy World API removed"
|
||
assert "ssl_certificate" in read("tools/ops/sys-api-nginx-8850.conf.example")
|
||
installer=read("tools/ops/sys-api-tls-install.sh")
|
||
for marker in ("certbot certonly", "certbot.timer", "nginx -t", "renewal-hooks/deploy", "/.well-known/acme-challenge/"):
|
||
assert marker in installer, marker
|
||
print("SYS.API independent DLL, UserLevel 200, persistent token, TLS proxy, legacy API and OGL mascot: PASS")
|