fix(mesh): LLSD model fee parsing and group-history Economy key (#276)

Decode typed OSDMap/OSDArray mesh upload request instances and OSD binary data; reject malformed scales and indices without unchecked casts. Add mesh fee integration regression; preserve the expected EventQueueGet 502 empty-poll semantics and document actual upload diagnostics and simulator autoport/proxy checks. Extend World API Economy machine key issuer with explicit groups:read for Firestorm group transaction history, with persistent scope tests. CI passed.
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-10-22 21:17:29 +02:00
1 parent 7396897d3d
commit 424e4ad330
9 files changed
+291 -27

No files matched your search

+4
View File
@@ -544,6 +544,10 @@ jobs:
chmod +x runprebuild.sh
./runprebuild.sh
- name: Regression-test LLSD mesh upload fee instances
shell: bash
run: dotnet run --configuration Release --project tools/ci/NexMeshUploadFeeRegression/NexMeshUploadFeeRegression.csproj
- name: Build Release
shell: bash
run: dotnet build --configuration Release OpenSim.sln
+2 -2
View File
@@ -607,7 +607,7 @@ Archivprüfungen bleiben auch für freigegebene Importe aktiv.</div>
<h2>2. Erforderliche Schlüssel auswählen</h2>
<p class="sectionlead">Bereits eingerichtete Schlüssel nicht unnötig neu erzeugen. Neue API-Schlüssel bleiben zusätzlich zu bestehenden registriert, bis sie ausdrücklich deaktiviert werden.</p>
<div class="changegrid">
<label class="change"><input type="checkbox" id="secretEconomy" style="width:auto" /> <strong>Economy / NV$</strong><p><code>economy:read</code> und <code>economy:transfer</code>. Nur auswählen, wenn noch kein gültiger Economy-Key existiert.</p></label>
<label class="change"><input type="checkbox" id="secretEconomy" style="width:auto" /> <strong>Economy / NV$ inkl. Gruppenhistorie</strong><p><code>economy:read</code>, <code>economy:transfer</code> und <code>groups:read</code>. Für neue Simulator-Schlüssel; bestehende Schlüssel für die Firestorm-Gruppenhistorie gezielt rotieren und erst nach dem Umstellen deaktivieren.</p></label>
<label class="change"><input type="checkbox" id="secretGroupLand" style="width:auto" /> <strong>NexGroups / Gridweite Landabfrage</strong><p><code>groups:read</code>. Eigener Simulator-Dienstschlüssel ausschließlich für die gruppeneigene Parzellensuche über die World API.</p></label>
<label class="change"><input type="checkbox" id="secretExperiences" checked style="width:auto" /> <strong>Experiences / Script</strong><p><code>experiences:script</code>. Eigener Schlüssel für die Simulator-LSL-Funktionen.</p></label>
<label class="change"><input type="checkbox" id="secretExperiencePermissions" style="width:auto" /> <strong>Experiences / Firestorm-Rechte</strong><p><code>experiences:viewer:permissions</code>. Separater Service-Schlüssel für Firestorm Allow/Block/Forget; nur für kontrolliert aktivierte Permission-CAPS.</p></label>
@@ -1825,7 +1825,7 @@ async function secretGenerate(onlyRegistration=false, onlyGroupLand=false) {
{wanted:wantGroupLand,name:'OGL Simulator Group Land',
scopes:['groups:read'],env:'NEXVERSE_GROUP_LAND_API_KEY'},
{wanted:wantEconomy,name:'OGL Simulator Economy',
scopes:['economy:read','economy:transfer'],env:'NEXVERSE_ECONOMY_API_KEY'},
scopes:['economy:read','economy:transfer','groups:read'],env:'NEXVERSE_ECONOMY_API_KEY'},
{wanted:wantExperiences,name:'OGL Simulator Experiences',
scopes:['experiences:script'],env:'NEXVERSE_EXPERIENCES_API_KEY'},
{wanted:wantPermissions,name:'OGL Simulator Experience Permissions',
@@ -209,7 +209,22 @@ namespace OpenSim.Region.ClientStack.Linden
for (int i = 0; i < numberMeshs; i++)
{
ameshCostParam curCost = new ameshCostParam();
byte[] data = (byte[])resources.mesh_list.Array[i];
if (resources.mesh_list.Array[i] is not OSD meshData)
{
error = "Invalid mesh list entry at index " + i;
return false;
}
if (meshData == null || meshData.Type != OSDType.Binary)
{
error = "Invalid mesh binary data at index " + i;
return false;
}
byte[] data = meshData.AsBinary();
if (data == null || data.Length == 0)
{
error = "Missing mesh binary data at index " + i;
return false;
}
if (!MeshCost(data, curCost, out curskeleton, out curAvatarPhys, out error))
{
@@ -235,21 +250,20 @@ namespace OpenSim.Region.ClientStack.Linden
// instances (prims) cost
int mesh;
int skipedSmall = 0;
for (int i = 0; i < numberInstances; i++)
{
Hashtable inst = (Hashtable)resources.instance_list.Array[i];
ArrayList ascale = (ArrayList)inst["scale"];
Vector3 scale;
double tmp;
tmp = (double)ascale[0];
scale.X = (float)tmp;
tmp = (double)ascale[1];
scale.Y = (float)tmp;
tmp = (double)ascale[2];
scale.Z = (float)tmp;
if (resources.instance_list.Array[i] is not OSD rawInstance)
{
error = "Invalid LLSD instance entry at index " + i;
return false;
}
if (!TryParseModelInstance(rawInstance, numberMeshs,
out Vector3 scale, out int mesh, out error))
{
error = "Invalid model instance " + i + ": " + error;
return false;
}
if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin)
{
@@ -263,15 +277,8 @@ namespace OpenSim.Region.ClientStack.Linden
return false;
}
if (haveMeshs && inst.ContainsKey("mesh"))
if (haveMeshs && mesh >= 0)
{
mesh = (int)inst["mesh"];
if (mesh >= numberMeshs)
{
error = "Incoerent model information.";
return false;
}
// streamming cost
@@ -339,6 +346,56 @@ namespace OpenSim.Region.ClientStack.Linden
return true;
}
/// <summary>
/// Decode a viewer's model instance from LLSD. The capability's
/// instance_list contains OSDMap/OSDArray values, not Hashtable
/// and ArrayList; invalid casts used to reject otherwise valid models.
/// </summary>
public static bool TryParseModelInstance(OSD instance, int meshCount,
out Vector3 scale, out int meshIndex, out string error)
{
scale = Vector3.Zero;
meshIndex = -1;
error = string.Empty;
if (instance is not OSDMap map ||
!map.TryGetValue("scale", out OSD rawScale) ||
rawScale is not OSDArray values || values.Count != 3)
{
error = "missing or invalid scale array";
return false;
}
double x = values[0].AsReal();
double y = values[1].AsReal();
double z = values[2].AsReal();
if (!double.IsFinite(x) || !double.IsFinite(y) || !double.IsFinite(z) ||
x <= 0 || y <= 0 || z <= 0 ||
x > float.MaxValue || y > float.MaxValue || z > float.MaxValue)
{
error = "scale components must be finite positive numbers";
return false;
}
scale = new Vector3((float)x, (float)y, (float)z);
if (map.TryGetValue("mesh", out OSD rawIndex))
{
if (rawIndex.Type != OSDType.Integer)
{
error = "mesh index is not an integer";
return false;
}
meshIndex = rawIndex.AsInteger();
if (meshIndex < 0 || meshIndex >= meshCount)
{
error = "mesh index out of bounds";
return false;
}
}
return true;
}
// single mesh asset cost
private bool MeshCost(byte[] data, ameshCostParam cost,out bool skeleton, out bool avatarPhys, out string error)
{
@@ -159,6 +159,23 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
/// <summary>
/// Test an attempt to put a message on the queue of a user that is not in the region.
/// </summary>
[Test]
public void TestEmptyQueueReturnsExpectedEventQueueProtocolStatus()
{
TestHelpers.InMethod();
UUID agentId = TestHelpers.ParseTail(0x1);
SceneHelpers.AddScenePresence(m_scene, agentId);
// EventQueueGet long polling intentionally returns 502 when a
// valid agent has no queued events (not a failed mesh upload).
Hashtable empty = m_eqgMod.NoEvents(UUID.Zero, agentId);
Assert.That((int)empty["int_response_code"],
Is.EqualTo((int)HttpStatusCode.BadGateway));
Hashtable missing = m_eqgMod.NoEvents(UUID.Zero, UUID.Random());
Assert.That((int)missing["int_response_code"],
Is.EqualTo((int)HttpStatusCode.NotFound));
}
[Test]
public void TestEnqueueMessageNoUser()
{
@@ -0,0 +1,70 @@
# Mesh-Upload in Firestorm: CE/502 und LLSD-Kostenschätzung
## Diagnose (2026-10-22)
Firestorm meldet beim Mesh-Upload wiederholt:
```
POST http://mainland.stadt-nexverse.de:9000/CE/<uuid> 502 Bad Gateway
```
`/CE/<uuid>` ist in OGL der **EventQueueGet**-Long-Poll-Endpunkt, nicht
der Mesh-Upload-Endpunkt. `EventQueueGetModule.NoEvents()` liefert
für eine vorhandene, aktuell leere Queue absichtlich `502 Bad Gateway`;
für eine unbekannte/geschlossene Queue dagegen `404`.
Daher ist **502 allein kein Beweis**, dass der Mesh-Upload oder der
Reverse-Proxy defekt ist. EventQueue-502 darf nicht ohne ein
Protokoll-/Viewer-Kompatibilitätstest zu 200 geändert werden.
Ein eigenständiger Fehler war jedoch in der **Mesh-Gebührenberechnung**
vorhanden: `MeshModelCost()` versuchte, LLSD-`instance_list`-Elemente
als `Hashtable` und `scale` als `ArrayList` zu lesen.
Die Viewer-Daten sind `OSDMap` und `OSDArray`; gültige Uploads
konnten dadurch einen `InvalidCastException` auslösen, anschließend
`state=error` und eine leere `uploader`-URL liefern. Der neue Parser
liest typisierte LLSD-Daten und lehnt ungültige Skalierungen und
Mesh-Indizes ausdrücklich ab. Binäre Mesh-Blöcke werden ebenfalls
typgeprüft.
## Nach Update überprüfen
1. ROBUST und **betroffenen Simulator** mit demselben neuen
GitHub-`main`-Stand bauen. Bestehende Deployment-Secrets behalten.
2. Den Simulator neu starten. Sicherstellen, dass Port
`mainland.stadt-nexverse.de:9000` extern wirklich beim **aktiven**
Simulator-HTTP-Listener ankommt. Bei `[NexVerseAutoPorts] Enabled=true`
kann der Prozess eine andere Portnummer aus 9000–9099 wählen.
Reverse-Proxy-Port/Portfreigaben entsprechend abgleichen. HTTP-Port
nicht mit dem UDP-Regionsport verwechseln.
3. In Firestorm dasselbe Mesh erneut hochladen; zuerst die
**Kostenberechnung**, dann den separaten **POST an die zurückgelieferte
`uploader`-URL** beurteilen. Nach erfolgreicher Gebührenanfrage muss
das LLSD-Feld `state=upload` und eine nichtleere `uploader`-URL
geliefert werden.
4. Serverlog unmittelbar zum Upload-Zeitpunkt betrachten:
```bash
grep -Ei 'MESH UPLOAD|NewAgentInventory|AssetUploader|BUNCH OF CAPS|EVENTQUEUE|Exception|HTTP' /opt/developer/bin/OpenSim.log | tail -n 120
```
Wenn `[MESH UPLOAD]: Fee validation rejected` erscheint, die konkrete
Fehlermeldung prüfen. `Insufficient funds` bzw.
`Insufficient permissions to upload` sind eigenständige Gründe.
Ein `/CE/`-502 ohne fehlgeschlagenen Upload-/Gebühren-HTTP-Aufruf kann
ein normales EventQueue-Long-Poll-Ende sein.
**Nicht durch CI abgedeckt:** Öffentliche Proxy-Erreichbarkeit,
Firewall-Regeln und der tatsächliche Mesh-Upload von Firestorm
gegen die produktive Region. Dafür sind Simulatorzugriff und ein echter
Viewer-Praxistest nötig.
## Economy-Key und Gruppenhistorie
Der World-API-Control-Center-Economy-Generator gibt für **neue**
Simulator-Economy-Schlüssel die Scopes
`economy:read`, `economy:transfer` und `groups:read` aus.
Damit kann die Firestorm-Gruppenhistorie nach lokaler
`GroupPowers.Accountable`-Prüfung geladen werden. Bereits erzeugte
Schlüssel werden nicht stillschweigend umgestellt. Für Rotation erst
den neuen Schlüssel generieren, Simulatoren umstellen und danach
den alten Schlüssel deaktivieren.
+5 -2
View File
@@ -88,8 +88,11 @@ Avatars und überträgt die Buchungszeilen anschließend in die nativen
`GroupAccountDetailsReply`- und `GroupAccountTransactionsReply`-Pakete.
**Konfiguration:** Der Simulator-Key unter `[NexEconomyViewer] ApiKey`
muss für diese neue Funktion zusätzlich zu `economy:read` auch
`groups:read` enthalten. Die World API akzeptiert für den
muss für diese Funktion zusätzlich zu `economy:read` auch
`groups:read` enthalten. **Der aktualisierte World-API-Schlüsselgenerator**
für Economy stellt neue Schlüssel mit `economy:read`,
`economy:transfer` und `groups:read` aus. Bestehende Economy-Schlüssel
bleiben unverändert und müssen bei Bedarf explizit rotiert werden. Die World API akzeptiert für den
Gruppenverlauf nur einen ausdrücklich doppelt berechtigten Maschinen-Key
oder einen tatsächlich berechtigten Bewohner-Token. Ohne die zusätzliche
Berechtigung bleibt der Kontostand funktionsfähig, der Verlauf kann jedoch
+23 -2
View File
@@ -103,6 +103,27 @@ internal static class Program
persistedLand.Scopes[0] == NexScopes.GroupsRead,
"Group land API key did not survive restart with least privilege");
// New simulator Economy keys may read NV$ group history only
// when groups:read is explicitly included. No admin scope.
NexApiKeyRegistration groupHistoryEconomy = reloaded.Create(
"OGL Simulator Economy",
new[] {
NexScopes.EconomyRead,
NexScopes.EconomyTransfer,
NexScopes.GroupsRead
});
PersistentNexApiKeyStore economyReloaded =
new PersistentNexApiKeyStore(path);
Require(economyReloaded.TryValidate(
groupHistoryEconomy.ApiKey,
out NexApiKeyRecord economyScopes) &&
economyScopes.Scopes.Length == 3 &&
economyScopes.Scopes.Contains(NexScopes.EconomyRead) &&
economyScopes.Scopes.Contains(NexScopes.EconomyTransfer) &&
economyScopes.Scopes.Contains(NexScopes.GroupsRead) &&
!economyScopes.Scopes.Contains(NexScopes.AdminAll),
"Group-history Economy key lacks correct persistent scopes");
bool rejectedAdmin = false;
try
{
@@ -231,7 +252,7 @@ internal static class Program
}
catch (InvalidOperationException) { rejectedDuplicate = true; }
Require(rejectedDuplicate, "Duplicate enabled service key accepted");
Require(experiencesReloaded.List().Count == 5,
Require(experiencesReloaded.List().Count == 6,
"Duplicate rejection modified the persistent key inventory");
// Deletion is an irreversible second step after explicit disable.
@@ -261,7 +282,7 @@ internal static class Program
"Last-used metadata lost when cloning records");
PersistentNexApiKeyStore afterCleanup =
new PersistentNexApiKeyStore(path);
Require(afterCleanup.List().Count == 5 &&
Require(afterCleanup.List().Count == 6 &&
afterCleanup.TryValidate(replacement.ApiKey, out _),
"Key cleanup or replacement did not survive restart");
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../../../OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.csproj" />
<Reference Include="OpenMetaverse"><HintPath>../../../bin/OpenMetaverse.dll</HintPath><Private>True</Private></Reference>
<Reference Include="OpenMetaverse.StructuredData"><HintPath>../../../bin/OpenMetaverse.StructuredData.dll</HintPath><Private>True</Private></Reference>
<Reference Include="OpenMetaverseTypes"><HintPath>../../../bin/OpenMetaverseTypes.dll</HintPath><Private>True</Private></Reference>
</ItemGroup>
</Project>
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: MPL-2.0
// Real LLSD instance structures as sent in mesh upload fee requests.
using System;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Region.ClientStack.Linden;
internal static class Program
{
private static void Assert(bool result, string reason)
{
if (!result) throw new InvalidOperationException("Mesh fee LLSD regression: " + reason);
}
private static OSDMap Instance(OSD scale, OSD mesh = null)
{
var map = new OSDMap { ["scale"] = scale };
if (mesh != null) map["mesh"] = mesh;
return map;
}
private static OSDArray Scale(double x, double y, double z)
{
return new OSDArray {
OSD.FromReal(x), OSD.FromReal(y), OSD.FromReal(z)
};
}
private static void Main()
{
// These are OSD maps/arrays after real LLSD decoding, NOT
// legacy Hashtable/ArrayList. Valid uploads used to throw.
var ok = Instance(Scale(1.5, 2.0, 0.5), OSD.FromInteger(0));
Assert(ModelCost.TryParseModelInstance(ok, 1, out Vector3 scale,
out int mesh, out string error),
"valid mesh instance rejected: " + error);
Assert(mesh == 0 && scale.X == 1.5f && scale.Y == 2f &&
scale.Z == 0.5f, "valid LLSD values were not preserved");
var other = Instance(Scale(1, 1, 1), OSD.FromInteger(2));
Assert(ModelCost.TryParseModelInstance(other, 3, out _,
out mesh, out _) && mesh == 2,
"multi-mesh index rejected");
var prim = Instance(Scale(1, 2, 3));
Assert(ModelCost.TryParseModelInstance(prim, 0, out _,
out mesh, out _) && mesh == -1,
"non-mesh instance rejected");
Assert(!ModelCost.TryParseModelInstance(other, 2, out _,
out _, out error) && error.Contains("bounds"),
"out-of-range mesh index accepted");
Assert(!ModelCost.TryParseModelInstance(
Instance(Scale(1, 1, 1), OSD.FromInteger(-1)), 2,
out _, out _, out _), "negative mesh index accepted");
Assert(!ModelCost.TryParseModelInstance(
Instance(Scale(1, 1, 1), OSD.FromString("0")), 2,
out _, out _, out _), "noninteger mesh reference accepted");
Assert(!ModelCost.TryParseModelInstance(
Instance(new OSDArray { OSD.FromInteger(1) }), 2,
out _, out _, out _), "truncated scale accepted");
Assert(!ModelCost.TryParseModelInstance(
Instance(Scale(1, 0, 1)), 1,
out _, out _, out _), "zero scale accepted");
Assert(!ModelCost.TryParseModelInstance(
Instance(Scale(double.NaN, 1, 1)), 1,
out _, out _, out _), "NaN scale accepted");
Assert(!ModelCost.TryParseModelInstance(
Instance(Scale(double.PositiveInfinity, 1, 1)), 1,
out _, out _, out _), "infinite scale accepted");
Assert(!ModelCost.TryParseModelInstance(
Instance(Scale(double.MaxValue, 1, 1)), 1,
out _, out _, out _), "overflow scale accepted");
Assert(!ModelCost.TryParseModelInstance(new OSDMap(), 1,
out _, out _, out _), "missing scale accepted");
Assert(!ModelCost.TryParseModelInstance(OSD.FromString("bad"), 1,
out _, out _, out _), "non-map instance accepted");
Console.WriteLine("OpenGenesisLINK Mesh upload fee LLSD instance regression: OK");
}
}