fix(upload): consistently enforce Permissions LevelUpload in UDP and CAPS (#217)
* fix(upload): centralize upload level configuration parsing with Permissions precedence * fix(upload): consistently honor Permissions LevelUpload across UDP and CAPS * fix(upload): consistently honor Permissions LevelUpload across UDP and CAPS * fix(upload): consistently honor Permissions LevelUpload across UDP and CAPS * fix(upload): consistently honor Permissions LevelUpload across UDP and CAPS * test(upload): verify Permissions precedence and legacy Startup fallback * test(upload): verify Permissions precedence and legacy Startup fallback * ci(upload): gate shared LevelUpload policy across UDP and CAPS * ci(upload): run real configuration precedence and consistency regressions * docs(upload): explain fixed LevelUpload precedence and known enforcement scope
This commit is contained in:
1 parent
41bfb0eb59
commit
5416edf301
10 files changed
+214
-18
No files matched your search
@@ -103,6 +103,13 @@ jobs:
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_no_remote_asset_delete_09312.py
|
||||
|
||||
- name: Verify LevelUpload precedence for UDP and CAPS
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python3 tools/ci/verify_asset_upload_level_consistency.py
|
||||
dotnet run --configuration Release --project tools/ci/AssetUploadLevelRegression/AssetUploadLevelRegression.csproj
|
||||
|
||||
- name: Verify runtime secrets are not committed
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_no_plaintext_runtime_secrets.py
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the original license notices
|
||||
* are retained. See CONTRIBUTORS.TXT.
|
||||
*/
|
||||
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads the simulator's minimum user level for permanent asset uploads.
|
||||
/// [Permissions] is the documented owner of LevelUpload. Keep [Startup]
|
||||
/// as a backwards-compatible fallback for installations using older INIs.
|
||||
/// An explicit zero in [Permissions] MUST override an older nonzero value.
|
||||
/// </summary>
|
||||
public static class AssetUploadLevelPolicy
|
||||
{
|
||||
public static int Resolve(IConfigSource config)
|
||||
{
|
||||
if (config == null)
|
||||
return 0;
|
||||
|
||||
IConfig permissions = config.Configs["Permissions"];
|
||||
if (permissions != null && permissions.Contains("LevelUpload"))
|
||||
return permissions.GetInt("LevelUpload", 0);
|
||||
|
||||
IConfig startup = config.Configs["Startup"];
|
||||
return startup != null ? startup.GetInt("LevelUpload", 0) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssetUploadLevelPolicy.cs" />
|
||||
<Compile Include="OfflineImMailRelayToken.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -100,16 +100,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
IConfigSource config = m_Scene.Config;
|
||||
if (config is not null)
|
||||
{
|
||||
IConfig sconfig = config.Configs["Startup"];
|
||||
if (sconfig is not null)
|
||||
ConfigOptions.levelUpload = sconfig.GetInt("LevelUpload", 0);
|
||||
|
||||
if (ConfigOptions.levelUpload == 0)
|
||||
{
|
||||
IConfig pconfig = config.Configs["Permissions"];
|
||||
if (pconfig is not null)
|
||||
ConfigOptions.levelUpload = pconfig.GetInt("LevelUpload", 0);
|
||||
}
|
||||
// Same minimum upload user level as UDP asset transactions.
|
||||
ConfigOptions.levelUpload = AssetUploadLevelPolicy.Resolve(config);
|
||||
|
||||
IConfig appearanceConfig = config.Configs["Appearance"];
|
||||
if (appearanceConfig is not null)
|
||||
|
||||
@@ -58,11 +58,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig sconfig = source.Configs["Startup"];
|
||||
if (sconfig != null)
|
||||
{
|
||||
m_levelUpload = sconfig.GetInt("LevelUpload", 0);
|
||||
}
|
||||
// Shared with CAPS: [Permissions] takes priority over legacy [Startup].
|
||||
m_levelUpload = AssetUploadLevelPolicy.Resolve(source);
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
|
||||
@@ -644,7 +644,10 @@
|
||||
; Disabled by default
|
||||
; simple_build_permissions = False
|
||||
|
||||
; Minimum user level required to upload assets
|
||||
; Minimum UserLevel for normal texture, sound, animation and mesh uploads.
|
||||
; Applies to both UDP asset transactions and viewer CAPS uploads.
|
||||
; Set this under [Permissions] in OpenSim.ini (default: 0).
|
||||
; [Startup] LevelUpload is recognized only as a legacy fallback.
|
||||
;LevelUpload = 0
|
||||
|
||||
[RegionReady]
|
||||
@@ -1054,8 +1057,8 @@
|
||||
; default is true
|
||||
AllowMeshUpload = true
|
||||
|
||||
; Minimum user level required to upload meshes
|
||||
;LevelUpload = 0
|
||||
; Mesh uploads use [Permissions] LevelUpload (see above).
|
||||
; A separate [Mesh] LevelUpload is NOT implemented.
|
||||
|
||||
; support meshes on physics
|
||||
;UseMeshiesPhysicsMesh = true
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# OGL Asset Upload: UserLevel-Schwelle (`LevelUpload`)
|
||||
|
||||
## Korrektur
|
||||
|
||||
Im bisherigen Code las `AssetTransactionModule` die Upload-Schwelle nur aus
|
||||
`[Startup]`; der moderne Viewer-CAPS-Pfad (`BunchOfCapsModule`)
|
||||
verwendete `[Startup]` und nur bei Wert `0` einen Fallback auf
|
||||
`[Permissions]`. Der dokumentierte Wert in `[Permissions]` schützte
|
||||
klassische UDP-Uploads deshalb nicht zuverlässig.
|
||||
|
||||
Beide Transportwege verwenden jetzt
|
||||
`OpenSim.Framework.AssetUploadLevelPolicy.Resolve` mit einheitlicher
|
||||
Reihenfolge:
|
||||
|
||||
1. Ist `LevelUpload` in `[Permissions]` ausdrücklich gesetzt,
|
||||
gilt genau dieser Wert (auch `0`).
|
||||
2. Sonst wird ein vorhandener `[Startup] LevelUpload`-Wert verwendet
|
||||
(Abwärtskompatibilität mit älteren Installationen).
|
||||
3. Ohne Einstellung gilt weiterhin `0`.
|
||||
|
||||
## Beispiel für die Simulator-OpenSim.ini
|
||||
|
||||
```ini
|
||||
[Permissions]
|
||||
LevelUpload = 200
|
||||
```
|
||||
|
||||
`0` erlaubt gewöhnlichen Usern die von dieser Regel erfassten Uploads;
|
||||
`200` verlangt `UserLevel >= 200`. Änderungen greifen nach einem
|
||||
Neustart des jeweiligen **Simulators**; ein reiner ROBUST-Neustart
|
||||
reicht nicht.
|
||||
|
||||
**Wichtig:** Das ist eine **Upload-Schwelle und kein globales Asset-Schreibverbot**.
|
||||
Die bisherigen Prüfungen betreffen im UDP-Pfad normale, nicht temporäre
|
||||
Texturen, TGA-Texturen, Sounds und Animationen. Im Viewer-CAPS-Pfad
|
||||
werden Texturen, Sounds, Animationen und Mesh beim Upload-Request
|
||||
kontrolliert. Andere Upload- und Update-Wege (beispielsweise bestimmte
|
||||
Skript-, Notizkarten-, Bekleidungs-/Bodypart-Updates, temporäre Assets,
|
||||
administrative Imports und serviceinterne Asset-Schreibzugriffe) werden
|
||||
durch `LevelUpload` **nicht durchgängig** gesperrt. Eine vollständige
|
||||
Upload-Policy erfordert gesonderte, serverseitige Autorisierung für
|
||||
alle relevanten Pfade.
|
||||
|
||||
Eine eigenständige `[Mesh] LevelUpload`-Schwelle wird nicht
|
||||
ausgewertet; die frühere missverständliche Kommentarzeile in
|
||||
`OpenSimDefaults.ini` wurde berichtigt. Mesh nutzt denselben
|
||||
`[Permissions] LevelUpload` wie die anderen genannten CAPS-Uploads.
|
||||
|
||||
## Tests
|
||||
|
||||
```bash
|
||||
python3 tools/ci/verify_asset_upload_level_consistency.py
|
||||
dotnet run -c Release --project tools/ci/AssetUploadLevelRegression/AssetUploadLevelRegression.csproj
|
||||
```
|
||||
|
||||
Die Tests prüfen die gemeinsame Verwendung im UDP- und CAPS-Modul,
|
||||
fehlen-de Werte, `[Startup]`-Fallback, `[Permissions]`-Vorrang,
|
||||
und ein ausdrücklich gesetztes `[Permissions] LevelUpload = 0`.
|
||||
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Nini">
|
||||
<HintPath>../../../bin/Nini.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<ProjectReference Include="../../../OpenSim/Framework/OpenSim.Framework.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,61 @@
|
||||
// Upload Level configuration contract shared by UDP and viewer CAPS.
|
||||
using System;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private static int checks;
|
||||
|
||||
private static void Check(int expected, IConfigSource source, string description)
|
||||
{
|
||||
checks++;
|
||||
int actual = AssetUploadLevelPolicy.Resolve(source);
|
||||
if (expected != actual)
|
||||
throw new Exception(description + ": expected " + expected + ", got " + actual);
|
||||
}
|
||||
|
||||
public static int Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Check(0, null, "No configuration");
|
||||
Check(0, new IniConfigSource(), "No sections");
|
||||
|
||||
IniConfigSource startupOnly = new IniConfigSource();
|
||||
startupOnly.AddConfig("Startup").Set("LevelUpload", 150);
|
||||
Check(150, startupOnly, "Legacy Startup setting");
|
||||
|
||||
IniConfigSource permissionsOnly = new IniConfigSource();
|
||||
permissionsOnly.AddConfig("Permissions").Set("LevelUpload", 200);
|
||||
Check(200, permissionsOnly, "Documented Permissions setting");
|
||||
|
||||
IniConfigSource permissionsWin = new IniConfigSource();
|
||||
permissionsWin.AddConfig("Startup").Set("LevelUpload", 100);
|
||||
permissionsWin.AddConfig("Permissions").Set("LevelUpload", 200);
|
||||
Check(200, permissionsWin, "Permissions overrides Startup");
|
||||
|
||||
IniConfigSource explicitZero = new IniConfigSource();
|
||||
explicitZero.AddConfig("Startup").Set("LevelUpload", 200);
|
||||
explicitZero.AddConfig("Permissions").Set("LevelUpload", 0);
|
||||
Check(0, explicitZero, "Explicit Permissions zero must override Startup");
|
||||
|
||||
IniConfigSource missingKey = new IniConfigSource();
|
||||
missingKey.AddConfig("Startup").Set("LevelUpload", 50);
|
||||
missingKey.AddConfig("Permissions").Set("serverside_object_permissions", true);
|
||||
Check(50, missingKey, "Empty Permissions falls back to Startup");
|
||||
|
||||
IniConfigSource mesh = new IniConfigSource();
|
||||
mesh.AddConfig("Mesh").Set("LevelUpload", 250);
|
||||
Check(0, mesh, "Mesh is not a separate LevelUpload configuration section");
|
||||
|
||||
Console.WriteLine("Asset upload policy: PASS (" + checks + " checks)");
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine("Asset upload policy FAIL: " + ex);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard both uploader transports against divergent LevelUpload configuration."""
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
read = lambda path: (root / path).read_text(encoding="utf-8")
|
||||
|
||||
helper = read("OpenSim/Framework/AssetUploadLevelPolicy.cs")
|
||||
udp = read("OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs")
|
||||
caps_module = read("OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs")
|
||||
caps = read("OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs")
|
||||
framework_project = read("OpenSim/Framework/OpenSim.Framework.csproj")
|
||||
defaults = read("bin/OpenSimDefaults.ini")
|
||||
|
||||
assert '<Compile Include="AssetUploadLevelPolicy.cs"' in framework_project
|
||||
assert 'config.Configs["Permissions"]' in helper
|
||||
assert 'permissions.Contains("LevelUpload")' in helper
|
||||
assert 'permissions.GetInt("LevelUpload", 0)' in helper
|
||||
assert 'config.Configs["Startup"]' in helper
|
||||
assert 'startup.GetInt("LevelUpload", 0)' in helper
|
||||
assert helper.index('permissions.GetInt("LevelUpload", 0)') < helper.index('startup.GetInt("LevelUpload", 0)')
|
||||
assert 'm_levelUpload = AssetUploadLevelPolicy.Resolve(source);' in udp
|
||||
assert 'ConfigOptions.levelUpload = AssetUploadLevelPolicy.Resolve(config);' in caps_module
|
||||
assert 'GodController.UserLevel < m_levelUpload' in udp
|
||||
assert 'GodController.UserLevel < ConfigOptions.levelUpload' in caps
|
||||
assert '[Permissions]' in defaults and ';LevelUpload = 0' in defaults
|
||||
assert 'A separate [Mesh] LevelUpload is NOT implemented.' in defaults
|
||||
print("Asset upload LevelUpload UDP/CAPS consistency: OK")
|
||||
Reference in new issue
Block a user