up
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using StellaOps.Plugin.Security;
|
||||
|
||||
namespace StellaOps.Plugin.Hosting;
|
||||
|
||||
public sealed class PluginHostOptions
|
||||
{
|
||||
private readonly List<string> additionalPrefixes = new();
|
||||
private readonly List<string> pluginOrder = new();
|
||||
private readonly List<string> searchPatterns = new();
|
||||
private readonly List<string> _additionalPrefixes = new();
|
||||
private readonly List<string> _pluginOrder = new();
|
||||
private readonly List<string> _searchPatterns = new();
|
||||
|
||||
/// <summary>
|
||||
/// Optional base directory used for resolving relative plugin paths. Defaults to <see cref="AppContext.BaseDirectory" />.
|
||||
@@ -29,18 +30,18 @@ public sealed class PluginHostOptions
|
||||
/// <summary>
|
||||
/// Additional prefixes that should be considered when building search patterns.
|
||||
/// </summary>
|
||||
public IList<string> AdditionalPrefixes => additionalPrefixes;
|
||||
public IList<string> AdditionalPrefixes => _additionalPrefixes;
|
||||
|
||||
/// <summary>
|
||||
/// Explicit plugin ordering expressed as assembly names without extension.
|
||||
/// Entries that are not discovered will be reported in <see cref="PluginHostResult.MissingOrderedPlugins" />.
|
||||
/// </summary>
|
||||
public IList<string> PluginOrder => pluginOrder;
|
||||
public IList<string> PluginOrder => _pluginOrder;
|
||||
|
||||
/// <summary>
|
||||
/// Optional explicit search patterns. When empty, they are derived from prefix settings.
|
||||
/// </summary>
|
||||
public IList<string> SearchPatterns => searchPatterns;
|
||||
public IList<string> SearchPatterns => _searchPatterns;
|
||||
|
||||
/// <summary>
|
||||
/// When true (default) the plugin directory will be created if it does not exist.
|
||||
@@ -52,6 +53,46 @@ public sealed class PluginHostOptions
|
||||
/// </summary>
|
||||
public bool RecursiveSearch { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The host application version used for plugin compatibility checking.
|
||||
/// When set, plugins with <see cref="Versioning.StellaPluginVersionAttribute"/> will be validated.
|
||||
/// </summary>
|
||||
public Version? HostVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enforce version compatibility checking. Defaults to true.
|
||||
/// When false, incompatible plugins will be loaded with a warning.
|
||||
/// </summary>
|
||||
public bool EnforceVersionCompatibility { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether plugins must declare a <see cref="Versioning.StellaPluginVersionAttribute"/>. Defaults to true.
|
||||
/// When true, plugins without the version attribute will be rejected.
|
||||
/// This is recommended for production deployments to ensure all plugins are properly versioned.
|
||||
/// </summary>
|
||||
public bool RequireVersionAttribute { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enforce strict major version checking. Defaults to true.
|
||||
/// When true and a plugin does not specify MaximumHostVersion, the loader assumes
|
||||
/// the plugin only supports host versions with the same major version as MinimumHostVersion.
|
||||
/// This prevents loading plugins designed for host 1.x on host 2.x without explicit compatibility declaration.
|
||||
/// </summary>
|
||||
public bool StrictMajorVersionCheck { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The signature verifier to use for plugin validation.
|
||||
/// Defaults to <see cref="NullPluginVerifier"/> (no verification).
|
||||
/// Set to <see cref="CosignPluginVerifier"/> for production use.
|
||||
/// </summary>
|
||||
public IPluginSignatureVerifier? SignatureVerifier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enforce signature verification. Defaults to false.
|
||||
/// When true and <see cref="SignatureVerifier"/> is set, plugins without valid signatures will be rejected.
|
||||
/// </summary>
|
||||
public bool EnforceSignatureVerification { get; set; }
|
||||
|
||||
internal string ResolveBaseDirectory()
|
||||
=> string.IsNullOrWhiteSpace(BaseDirectory)
|
||||
? AppContext.BaseDirectory
|
||||
|
||||
Reference in New Issue
Block a user