0642d3b988
#05-T24. Three low-severity cleanups, each TDD'd: - TransportOptions.MaxConcurrentImportSessions (8): BundleSessionStore.Open rejects a new session past the cap (evicting expired entries first), bounding the N×~200 MB decrypted-content footprint. Soft cap (count/add not atomic). - ScriptCompiler.TryCompile now joins ALL forbidden-API violations / compile errors (string.Join instead of [0]) so an operator sees every problem at once; the T15 verdict cache stores the joined string. - SemanticValidator emits an advisory warning when a CallScript target resolves ONLY via the composed leaf-name fallback (dynamic child path, not statically verified) instead of silently accepting it. Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
56 lines
3.2 KiB
C#
56 lines
3.2 KiB
C#
namespace ZB.MOM.WW.ScadaBridge.Transport;
|
||
|
||
public sealed class TransportOptions
|
||
{
|
||
/// <summary>Gets or sets the TTL in minutes for an in-progress import session.</summary>
|
||
public int BundleSessionTtlMinutes { get; set; } = 30;
|
||
/// <summary>Gets or sets the maximum allowed bundle size in megabytes.</summary>
|
||
public int MaxBundleSizeMb { get; set; } = 100;
|
||
/// <summary>
|
||
/// T-006: maximum allowed decompressed size of any single zip entry in megabytes.
|
||
/// A 100 MB DEFLATE-compressed bundle can decompress to gigabytes; this cap
|
||
/// stops a malicious bundle from OOM-ing the central node before its entries
|
||
/// are decompressed.
|
||
/// </summary>
|
||
public int MaxBundleEntryDecompressedMb { get; set; } = 200;
|
||
/// <summary>
|
||
/// T-006: maximum permitted number of entries inside a bundle zip. A well-formed
|
||
/// bundle has exactly two (<c>manifest.json</c> plus <c>content.json</c> or
|
||
/// <c>content.enc</c>); a small upper bound limits the surface a zip-bomb can
|
||
/// exploit without rejecting future schema additions out of hand.
|
||
/// </summary>
|
||
public int MaxBundleEntryCount { get; set; } = 4;
|
||
/// <summary>
|
||
/// T-006: maximum permitted compression ratio (uncompressed length / compressed
|
||
/// length) per zip entry. Defence-in-depth against decompression bombs whose
|
||
/// declared <see cref="System.IO.Compression.ZipArchiveEntry.Length"/> is
|
||
/// trustworthy on read; legitimate JSON compresses around 5–10x, so 50x has
|
||
/// generous headroom for unusually compressible bundles.
|
||
/// </summary>
|
||
public int MaxBundleEntryCompressionRatio { get; set; } = 50;
|
||
/// <summary>
|
||
/// #05-T24: maximum number of concurrently-open import sessions. Each open
|
||
/// session pins a fully-decrypted bundle (up to <see cref="MaxBundleSizeMb"/>
|
||
/// of plaintext) in memory until it expires or is applied/cancelled, so this
|
||
/// bounds the N×~200 MB decrypted-content footprint the central node can hold.
|
||
/// </summary>
|
||
public int MaxConcurrentImportSessions { get; set; } = 8;
|
||
/// <summary>Gets or sets the maximum number of failed passphrase unlock attempts before a session is locked.</summary>
|
||
public int MaxUnlockAttemptsPerSession { get; set; } = 3;
|
||
/// <summary>Gets or sets the maximum number of unlock attempts allowed per IP address per hour.</summary>
|
||
public int MaxUnlockAttemptsPerIpPerHour { get; set; } = 10;
|
||
/// <summary>Gets or sets the PBKDF2 iteration count used for passphrase key derivation.</summary>
|
||
public int Pbkdf2Iterations { get; set; } = 600_000;
|
||
/// <summary>Gets or sets the major version of the bundle schema this instance produces and accepts.</summary>
|
||
public int SchemaVersionMajor { get; set; } = 1;
|
||
|
||
/// <summary>
|
||
/// Human-readable name of the cluster/environment producing bundles. Stamped
|
||
/// into <c>BundleManifest.SourceEnvironment</c> and surfaced in the export
|
||
/// filename (<c>scadabundle-{SourceEnvironment}-{yyyy-MM-dd-HHmmss}.scadabundle</c>).
|
||
/// Bound from <c>Transport:SourceEnvironment</c> in <c>appsettings*.json</c>;
|
||
/// the default placeholder is fine for single-cluster deployments.
|
||
/// </summary>
|
||
public string SourceEnvironment { get; set; } = "scadabridge";
|
||
}
|