Files
opengenesislinkserver/tools/ci/verify_os_webinterface.py
T

70 lines
3.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Generation 1 simulator web interface static security/integration regression."""
from pathlib import Path
root = Path(__file__).resolve().parents[2]
def text(path):
return (root / path).read_text(encoding="utf-8-sig")
project = text("addons/OSWebInterface/os_webinterface.csproj")
module = text("addons/OSWebInterface/OSWebInterfaceModule.cs")
http = text("addons/OSWebInterface/AdminHttpServer.cs")
ops = text("addons/OSWebInterface/AdminOperations.cs")
updates = text("addons/OSWebInterface/UpdateStager.cs")
live = text("addons/OSWebInterface/LiveUpdateBridge.cs")
js = text("addons/OSWebInterface/www/app.js")
ini_paths = ("bin/OpenSim.ini", "bin/OpenSim.ini.example")
for ini in ini_paths:
c = text(ini).split("[OSWebInterface]", 1)
assert len(c) == 2 and "Enabled = false" in c[1] and "AllowLiveUpdates = false" in c[1] and 'PublicOrigin = ""' in c[1], ini
for part in (
"<AssemblyName>os_webinterface</AssemblyName>",
"EmbeddedResource Include=\"www/index.html\"",
"EmbeddedResource Include=\"www/app.js\"",
"EmbeddedResource Include=\"www/style.css\"",
):
assert part in project, part
for part in (
'Id = "OSWebInterface"', "ISharedRegionModule",
'GetBoolean("Enabled", false)',
"http://127.0.0.1:", "Directory.CreateDirectory",
"_server?.Dispose()",
):
assert part in module, part
for part in (
"GetUserAccount(UUID.Zero", "Authenticate(account.PrincipalID",
"account.UserLevel <= 0", "!account.LoginAllowed",
"Access Denied – Keine Berechtigung.",
"_liveUpdate.StatusAsync", "_liveUpdate.StartAsync",
"HttpOnly; SameSite=Strict", "X-OGL-CSRF", "SameOrigin(",
"Content-Security-Policy", "TrySession(request", "IsTrustedProxyRequest", "PublicOrigin",
'"/api/regions/restart"', '"/api/oar/import"', '"/api/oar/export"',
'"/api/oar/download"', '"/api/updates/check"', '"/api/updates/stage"',
):
assert part in http, part
for part in (
"RestartNow()", "ArchiveRegion(", "DearchiveRegion(",
"OnOarFileSaved", "OnOarFileLoaded", "GetActiveUdpListeners",
"GetActiveTcpListeners", "publicStatus =",
"MaxUploadBytes", "FileShare.ReadWrite", "CheckGitAsync(",
):
assert part in ops, part
for part in (
"PrivateFile", "File.SetUnixFileMode",
"BackupConfigs(", "configuration-backups", "Prune(",
"File.Move(tmp, filename)", "git", "latest",
):
assert part in updates, part
for marker in ("v1/status", "v1/updates", "127.0.0.1", "OGL", "Bearer", "_nodeId"):
assert marker in live, marker
assert "Process.Start(" not in live, "Web DLL must never run arbitrary commands."
assert "Process.Start(" not in updates, "Updater must never execute downloaded source."
assert "innerHTML" not in js, "Client must avoid arbitrary HTML insertion."
assert "textContent" in js
for p in ("OpenSim.sln", "runprebuild.sh", "compile.sh"):
assert "os_webinterface" in text(p) or "OSWebInterface" in text(p), p
assert "verify_os_webinterface.py" in text(".github/workflows/nexjast-ci.yml")
print("OS webinterface: opt-in module, auth, CSRF, OAR, logs, ports, staging and build integration OK")