Merge PR #380: fix .NET 10 build warnings and vulnerable SQLite dependency
Upgrade OGL AssetService to SQLite 10.0.14 and patched native SQLitePCLRaw 2.1.13. Guard native copy from the restored NuGet graph. Resolve six inexact stream reads and switch TLS PFX loading to X509CertificateLoader. Seven PR CI workflows passed.
This commit is contained in:
13 files changed
+114
-27
No files matched your search
@@ -690,6 +690,13 @@ jobs:
|
||||
run: dotnet build --configuration Release OpenSim.sln
|
||||
|
||||
|
||||
- name: Verify patched SQLite dependencies on all AssetService projects
|
||||
shell: bash
|
||||
run: |
|
||||
dotnet restore addons/OGLAssetService.Migration/OGLAssetService.Migration.csproj
|
||||
dotnet restore addons/OGLAssetService.Tests/OGLAssetService.Tests.csproj
|
||||
python3 tools/ci/verify_sqlite_native_dependency.py --require-addon
|
||||
|
||||
- name: Smoke-test real .NET 10 ROBUST with isolated loopback HTTP
|
||||
shell: bash
|
||||
run: python3 tools/gen11/robust_runtime_smoke.py
|
||||
|
||||
@@ -51,6 +51,8 @@ jobs:
|
||||
run: dotnet build addons/OGLAssetService.Tests/OGLAssetService.Tests.csproj --configuration Release
|
||||
- name: Build standalone migration CLI
|
||||
run: dotnet build addons/OGLAssetService.Migration/OGLAssetService.Migration.csproj --configuration Release
|
||||
- name: Verify patched native SQLite dependency for isolated tools
|
||||
run: python3 tools/ci/verify_sqlite_native_dependency.py
|
||||
- name: CLI dry-run and verified copy
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
try
|
||||
{
|
||||
m_cert = new X509Certificate2(CPath, CPass);
|
||||
m_cert = X509CertificateLoader.LoadPkcs12FromFile(CPath, CPass);
|
||||
X509Extension ext = m_cert.Extensions["2.5.29.17"];
|
||||
if(ext != null)
|
||||
{
|
||||
|
||||
@@ -235,7 +235,17 @@ namespace OSHttpServer
|
||||
}
|
||||
|
||||
var buffer = new byte[m_body.Length];
|
||||
m_body.Read(buffer, 0, (int)m_body.Length);
|
||||
// Preserve the original request stream position while cloning its full body.
|
||||
long originalPosition = m_body.Position;
|
||||
try
|
||||
{
|
||||
m_body.Position = 0;
|
||||
m_body.ReadExactly(buffer);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_body.Position = originalPosition;
|
||||
}
|
||||
request.Body = new MemoryStream();
|
||||
request.Body.Write(buffer, 0, buffer.Length);
|
||||
request.Body.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
@@ -2581,7 +2581,7 @@ namespace OpenSim.Framework
|
||||
|
||||
memory.Position = 0;
|
||||
using GZipStream decompressor = new(memory, CompressionMode.Decompress);
|
||||
decompressor.Read(buffer, 0, buffer.Length);
|
||||
decompressor.ReadExactly(buffer);
|
||||
|
||||
return Util.UTF8.GetString(buffer);
|
||||
}
|
||||
@@ -2884,7 +2884,7 @@ namespace OpenSim.Framework
|
||||
public static OSDMap GetOSDMap(Stream stream, int length)
|
||||
{
|
||||
byte[] data = new byte[length];
|
||||
stream.Read(data, 0, length);
|
||||
stream.ReadExactly(data);
|
||||
string strdata = Util.UTF8.GetString(data);
|
||||
OSDMap args;
|
||||
OSD buffer;
|
||||
|
||||
@@ -1426,7 +1426,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||
using(FileStream input = new FileStream(Util.dataDir() + "/terrain.raw",FileMode.Open))
|
||||
{
|
||||
bdata = new byte[input.Length];
|
||||
input.Read(bdata, 0, (int)input.Length);
|
||||
input.ReadExactly(bdata);
|
||||
}
|
||||
if(bdata == null || bdata.Length == 0)
|
||||
{
|
||||
|
||||
@@ -398,7 +398,6 @@ namespace OpenSim.Region.DataSnapshot
|
||||
#region External data services
|
||||
private void NotifyDataServices(string servicesStr, string serviceName)
|
||||
{
|
||||
Stream reply = null;
|
||||
string delimStr = ";";
|
||||
char [] delimiter = delimStr.ToCharArray();
|
||||
|
||||
@@ -416,10 +415,11 @@ namespace OpenSim.Region.DataSnapshot
|
||||
cli.RequestMethod = "GET";
|
||||
try
|
||||
{
|
||||
using(reply = cli.Request(null))
|
||||
// The notification response body is not used. Disposing the
|
||||
// response stream is sufficient; do not require a fixed
|
||||
// response length from third-party services.
|
||||
using (Stream reply = cli.Request(null))
|
||||
{
|
||||
byte[] response = new byte[1024];
|
||||
reply.Read(response, 0, 1024);
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException)
|
||||
@@ -433,7 +433,7 @@ namespace OpenSim.Region.DataSnapshot
|
||||
|
||||
// This is not quite working, so...
|
||||
// string responseStr = Util.UTF8.GetString(response);
|
||||
m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret);
|
||||
m_log.Info("[DATASNAPSHOT]: data service " + url + " notified.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,11 +88,11 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
return DoPlainMethods(body);
|
||||
|
||||
case "crypt":
|
||||
byte[] buffer = new byte[request.Length];
|
||||
long length = request.Length;
|
||||
if (length > 16384)
|
||||
length = 16384;
|
||||
request.Read(buffer, 0, (int)length);
|
||||
// Encrypted requests have a strict 16 KiB processing limit.
|
||||
// Allocate only the bytes that are actually consumed.
|
||||
int length = checked((int)Math.Min(request.Length, 16384L));
|
||||
byte[] buffer = new byte[length];
|
||||
request.ReadExactly(buffer);
|
||||
|
||||
return DoEncryptedMethods(buffer);
|
||||
}
|
||||
|
||||
@@ -34,19 +34,37 @@ case "$(uname -m)" in
|
||||
esac
|
||||
sqlite_rid="${sqlite_os}-${sqlite_arch}"
|
||||
nuget_root="$(dotnet nuget locals global-packages --list | sed -n 's/^global-packages: //p' | head -n 1)"
|
||||
sqlite_pkg="${nuget_root%/}/sqlitepclraw.lib.e_sqlite3"
|
||||
if [ ! -d "$sqlite_pkg" ]; then
|
||||
echo "Restored SQLitePCLRaw.lib.e_sqlite3 native package not found: $sqlite_pkg" >&2
|
||||
exit 1
|
||||
fi
|
||||
sqlite_native="$(find "$sqlite_pkg" -type f -path "*/runtimes/$sqlite_rid/native/$sqlite_lib" -print | sort -V | tail -n 1)"
|
||||
if [ -z "$sqlite_native" ] || [ ! -s "$sqlite_native" ]; then
|
||||
echo "Missing native $sqlite_lib in SQLitePCLRaw for $sqlite_rid" >&2
|
||||
# Resolve the exact package selected by NuGet for this addon build, never an
|
||||
# arbitrary cached DLL. An older vulnerable e_sqlite3 may still be installed
|
||||
# in the global NuGet cache after an upgrade.
|
||||
sqlite_version="$(python3 - "$ROOT/addons/OGLAssetService/obj/project.assets.json" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
assets = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
|
||||
versions = [key.partition("/")[2]
|
||||
for key in assets["libraries"]
|
||||
if key.lower().startswith("sqlitepclraw.lib.e_sqlite3/")]
|
||||
if len(versions) != 1:
|
||||
raise SystemExit("Expected one NuGet-resolved SQLitePCLRaw.lib.e_sqlite3 native package")
|
||||
version = versions[0]
|
||||
parts = version.split(".")
|
||||
if len(parts) < 3 or not all(x.isdecimal() for x in parts[:3]) or tuple(map(int, parts[:3])) < (2, 1, 12):
|
||||
raise SystemExit(f"Refusing vulnerable SQLitePCLRaw native package {version}")
|
||||
print(version)
|
||||
PY
|
||||
)"
|
||||
sqlite_pkg="${nuget_root%/}/sqlitepclraw.lib.e_sqlite3/$sqlite_version"
|
||||
sqlite_native="$sqlite_pkg/runtimes/$sqlite_rid/native/$sqlite_lib"
|
||||
if [ ! -s "$sqlite_native" ]; then
|
||||
echo "Missing NuGet-resolved SQLite native runtime $sqlite_native" >&2
|
||||
exit 1
|
||||
fi
|
||||
cp -f -- "$sqlite_native" "$OUT/$sqlite_lib"
|
||||
chmod 644 "$OUT/$sqlite_lib"
|
||||
echo "Installed SQLite native runtime for $sqlite_rid into shared ROBUST bin/."
|
||||
cmp -- "$sqlite_native" "$OUT/$sqlite_lib"
|
||||
echo "Installed SQLite native runtime $sqlite_version for $sqlite_rid into shared ROBUST bin/."
|
||||
|
||||
for dll in \
|
||||
OpenGenesisLINK.Addons.OGLAssetService.dll \
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.11" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.14" />
|
||||
<Compile Include="../OGLAssetService/IOGLAssetLocationDirectory.cs" Link="IOGLAssetLocationDirectory.cs" />
|
||||
<Compile Include="../OGLAssetService/OGLAssetLocationDirectory.cs" Link="OGLAssetLocationDirectory.cs" />
|
||||
<Compile Include="../OGLAssetService/OGLSqliteAssetLocationDirectory.cs" Link="OGLSqliteAssetLocationDirectory.cs" />
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.8.24" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.11" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.14" />
|
||||
<Compile Include="../OGLAssetService/IOGLAssetLocationDirectory.cs" Link="IOGLAssetLocationDirectory.cs" />
|
||||
<Compile Include="../OGLAssetService/OGLAssetLocationDirectory.cs" Link="OGLAssetLocationDirectory.cs" />
|
||||
<Compile Include="../OGLAssetService/OGLSqliteAssetLocationDirectory.cs" Link="OGLSqliteAssetLocationDirectory.cs" />
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.8.24" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.11" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.14" />
|
||||
<ProjectReference Include="../../OpenSim/Services/FSAssetService/OpenSim.Services.FSAssetService.csproj" />
|
||||
<Reference Include="OpenMetaverse">
|
||||
<HintPath>../../bin/OpenMetaverse.dll</HintPath>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fail builds that reintroduce the high-severity e_sqlite3 NuGet dependency.
|
||||
|
||||
GHSA-2m69-gcr7-jv3q affects SQLitePCLRaw.lib.e_sqlite3 <= 2.1.11.
|
||||
The native addon build copies exactly the version resolved by the project assets.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import json
|
||||
import sys
|
||||
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
projects = [
|
||||
root / "addons/OGLAssetService.Migration/OGLAssetService.Migration.csproj",
|
||||
root / "addons/OGLAssetService.Tests/OGLAssetService.Tests.csproj",
|
||||
]
|
||||
# The standalone CLI/cache test does not prebuild the full OpenSim solution.
|
||||
# In full-server CI the addon is also built and MUST be audited explicitly.
|
||||
if sys.argv[1:] == ["--require-addon"]:
|
||||
projects.insert(0, root / "addons/OGLAssetService/OGLAssetService.csproj")
|
||||
elif sys.argv[1:]:
|
||||
raise SystemExit("Usage: verify_sqlite_native_dependency.py [--require-addon]")
|
||||
|
||||
def version_tuple(v):
|
||||
nums = v.split(".")[:3]
|
||||
if len(nums) != 3 or not all(p.isdecimal() for p in nums):
|
||||
raise AssertionError(f"Unexpected NuGet package version {v}")
|
||||
return tuple(map(int, nums))
|
||||
|
||||
versions = {}
|
||||
for project in projects:
|
||||
assets_file = project.parent / "obj/project.assets.json"
|
||||
if not assets_file.exists():
|
||||
raise SystemExit(f"Run dotnet restore first: {assets_file}")
|
||||
assets = json.loads(assets_file.read_text(encoding="utf-8"))
|
||||
libraries = assets["libraries"]
|
||||
for package, minimum in (
|
||||
("microsoft.data.sqlite", (10, 0, 14)),
|
||||
("sqlitepclraw.lib.e_sqlite3", (2, 1, 12)),
|
||||
):
|
||||
matches = [entry.partition("/")[2] for entry in libraries
|
||||
if entry.lower().startswith(package + "/")]
|
||||
if len(matches) != 1 or version_tuple(matches[0]) < minimum:
|
||||
raise SystemExit(f"FAIL: {project.name}: require {package} >= {minimum}, resolved: {matches}")
|
||||
if package == "sqlitepclraw.lib.e_sqlite3":
|
||||
versions[project.name] = matches[0]
|
||||
|
||||
if len(set(versions.values())) != 1:
|
||||
raise SystemExit(f"FAIL: inconsistent native SQLite versions: {versions}")
|
||||
print("PASS: audited OGL AssetService projects use non-vulnerable SQLitePCLRaw native dependency " +
|
||||
next(iter(versions.values())))
|
||||
Reference in new issue
Block a user