feat(security): 仅加载显式授权的外部 DLL
Publish UPM package / publish (push) Successful in 2s

This commit is contained in:
2026-08-28 03:44:10 +08:00
parent 39f6f97707
commit f6688ce573
13 changed files with 352 additions and 74 deletions
@@ -12,10 +12,13 @@ namespace ShrinkModFramework
/// </summary>
internal static class ShrinkModComponentDiscovery
{
public static IReadOnlyList<ShrinkModComponentSource> Discover(ShrinkModFrameworkSettings settings,
bool verboseLogging)
public static IReadOnlyList<ShrinkModComponentSource> Discover(
ShrinkModFrameworkSettings settings,
bool verboseLogging,
IEnumerable<string> authorizedDllPaths)
{
ShrinkExternalModAssemblyLoader.ScanExternalAssemblyRevisions(settings, verboseLogging);
ShrinkExternalModAssemblyLoader.ScanExternalAssemblyRevisions(
settings, verboseLogging, authorizedDllPaths);
var results = new List<ShrinkModComponentSource>();
var prefixes = settings?.assemblyNamePrefixes;
+6 -2
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Cysharp.Threading.Tasks;
namespace ShrinkModFramework
@@ -19,7 +20,8 @@ namespace ShrinkModFramework
new Dictionary<string, ShrinkModHandle>();
public static async UniTask<IReadOnlyDictionary<string, ShrinkModHandle>> ApplyDiscoveredAsync(
ShrinkModFrameworkSettings settings = null)
ShrinkModFrameworkSettings settings = null,
IEnumerable<string> authorizedDllPaths = null)
{
settings ??= ShrinkModFrameworkSettings.Instance;
var verboseLogging = settings == null || settings.verboseLogging;
@@ -34,7 +36,9 @@ namespace ShrinkModFramework
ShrinkModNetworkManager.Configure(settings == null || settings.enableNetworkSync, verboseLogging);
try
{
var sources = ShrinkModComponentDiscovery.Discover(settings, verboseLogging);
var authorizedPaths = authorizedDllPaths?.ToArray() ?? Array.Empty<string>();
var sources = ShrinkModComponentDiscovery.Discover(
settings, verboseLogging, authorizedPaths);
await _host.ApplyAsync(sources);
}
catch