Files
opengenesislinkserver/tools/ci/verify_iar_progress.py
T

68 lines
4.8 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
"""Static regression guard for console progress and bounded import preflight."""
from pathlib import Path
root=Path(__file__).resolve().parents[2]
paths={
"contract": "OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs",
"console": "OpenSim/Framework/Console/LocalConsole.cs",
"asset_writer": "OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs",
"module": "OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs",
"reader": "OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs",
"writer": "OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs",
"assets": "OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs",
"inspector": "NexVerse/RegionModules/Archives/OglIarManagementModule.cs",
"manager": "NexVerse/RegionModules/Archives/OglIarOperationManager.cs",
}
src={k:(root / p).read_text() for k,p in paths.items()}
required={
"contract":["interface IInventoryArchiverProgress","interface IInventoryArchiveInspector","OnInventoryArchiveProgress"],
"console":["UpdateOglIarProgress","m_oglIarStatus","LockOutput();","m_lastOglIarStatusLength"],
"asset_writer":["Assets dem Archiv hinzugefügt","m_log.Debug"],
"module":["IInventoryArchiverProgress","DisplayConsoleArchiveProgress","TryInspect(loadPath","iar_total_entries","TriggerInventoryArchiveProgress","ArchiveInventory(id, firstName","DearchiveInventory(id, firstName",
'show iar progress', 'RefreshIarPrompt()', 'OGLIarLiveProgress', 'RemoveConsoleIarJob(id)', 'm_consoleJobs.TryGetValue(id', 'OGL-IAR'],
"reader":["ExpectedEntries","m_entriesProcessed","TriggerInventoryArchiveProgress(m_id, \"import\"","TriggerInventoryArchiveProgress(m_id, \"finalizing\""],
"writer":["TriggerInventoryArchiveProgress(m_id, \"inventory\"","TriggerInventoryArchiveProgress(m_id, \"assets\"","ReceivedAllAssets"],
"assets":["m_progressCallback","finally","++m_assetsProcessed",
"angeforderte Einträge waren nicht auffindbar"],
"inspector":["IInventoryArchiveInspector","OglIarInspector.Inspect(archivePath)","RegisterModuleInterface<IInventoryArchiveInspector>"],
"manager":["m_ProgressSource.OnInventoryArchiveProgress","HandleProgress","inspection.Entries","operation.ProgressPercent = 100","operation.ProgressPhase = \"completed\""],
}
for file, tokens in required.items():
for token in tokens:
assert token in src[file], f"{file}: missing {token}"
# Fail-closed validation must happen before the legacy IAR load starts.
module=src["module"]
assert module.index("inspector.TryInspect(loadPath") < module.index("DearchiveInventory(id, firstName, lastName, invPath, pass, loadPath, options)")
assert 'm_consoleProgressState.Remove(id)' in module
assert 'if (succeeded)' in module and '100% – Exportvorgang abgeschlossen' in module
assert 'if (liveUpdate)' in module and 'if (!report)' in module
assert 'm_pendingConsoleTasks.Contains(id)' in module
assert 'OGLIarLiveProgress = true' in (root / 'bin/OpenSim.ini.example').read_text()
# Native IAR preflight must not enforce the former 1 GiB compressed limit.
policy = (root / "NexVerse/RegionModules/Archives/OglIarManagement.cs").read_text()
assert "MaxCompressedBytes = 10L * 1024 * 1024 * 1024" in policy
assert "MaxExpandedBytes = 40L * 1024 * 1024 * 1024" in policy
assert "if (!IsAllowedCompressedSize(info.Length))" in policy
assert "MaxFileBytes = 64L * 1024 * 1024" in policy
assert "MaxEntries = 100000" in policy
# The IAR control XML must advertise the UTF-8 encoding actually stored by
# TarArchiveWriter.WriteFile(string), while legacy archives remain inspectable
# without permitting arbitrary encoding spoofing or XML external entities.
assert 'new(controlXml, new System.Text.UTF8Encoding(false))' in src["writer"]
assert 'Encoding.UTF8.GetString(controlXml.ToArray())' in src["writer"]
assert 'XmlTextWriter xtw = new XmlTextWriter(sw)' not in src["writer"]
assert 'const string legacyDeclaration = ' in policy
assert 'payload.AsSpan().StartsWith(legacyPrefix)' in policy
assert 'new UTF8Encoding(false, true).GetString(payload)' in policy
assert 'DtdProcessing = DtdProcessing.Prohibit' in policy
assert 'XmlResolver = null' in policy
# Terminal handoff must not disappear after the last asset-progress log.
assert 'GC.Collect();\n PerformAssetsRequestCallback(m_timeout);' not in src["assets"]
assert "Archivabschluss wird gestartet" in src["assets"]
assert "m_saveStream.Close();" in src["writer"] and "catch (Exception e)" in src["writer"]
assert "Rueckmeldung des Archivabschlusses fehlgeschlagen" in src["writer"]
assert "TAR/GZip abgeschlossen" in src["writer"]
assert "Integritaetspruefung" in src["manager"]
assert "iar_archive_validation_failed:" in src["manager"]
print("OpenGenesisLINK console IAR progress and bounded preflight wiring: OK")