Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Implemented comprehensive unit tests for RabbitMqTransportServer, covering constructor, disposal, connection management, event handlers, and exception handling. - Added configuration tests for RabbitMqTransportServer to validate SSL, durable queues, auto-recovery, and custom virtual host options. - Created unit tests for UdpFrameProtocol, including frame parsing and serialization, header size validation, and round-trip data preservation. - Developed tests for UdpTransportClient, focusing on connection handling, event subscriptions, and exception scenarios. - Established tests for UdpTransportServer, ensuring proper start/stop behavior, connection state management, and event handling. - Included tests for UdpTransportOptions to verify default values and modification capabilities. - Enhanced service registration tests for Udp transport services in the dependency injection container.
71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
namespace StellaOps.Cryptography;
|
|
|
|
/// <summary>
|
|
/// Configuration options for cryptographic compliance.
|
|
/// </summary>
|
|
public sealed class CryptoComplianceOptions
|
|
{
|
|
/// <summary>
|
|
/// The configuration section key for binding.
|
|
/// </summary>
|
|
public const string SectionKey = "Crypto:Compliance";
|
|
|
|
/// <summary>
|
|
/// Active compliance profile ID.
|
|
/// Valid values: "world", "fips", "gost", "sm", "kcmvp", "eidas".
|
|
/// Default: "world".
|
|
/// Can be overridden by STELLAOPS_CRYPTO_COMPLIANCE_PROFILE environment variable.
|
|
/// </summary>
|
|
public string ProfileId { get; set; } = "world";
|
|
|
|
/// <summary>
|
|
/// When true, fail on non-compliant algorithm usage.
|
|
/// Default: true.
|
|
/// Can be overridden by STELLAOPS_CRYPTO_STRICT_VALIDATION environment variable.
|
|
/// </summary>
|
|
public bool StrictValidation { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// When StrictValidation=false, emit warning instead of silently proceeding.
|
|
/// Default: true.
|
|
/// </summary>
|
|
public bool WarnOnNonCompliant { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Allow Interop purpose to override profile algorithm with SHA-256.
|
|
/// Default: true.
|
|
/// </summary>
|
|
public bool AllowInteropOverride { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Enable telemetry for all crypto operations.
|
|
/// Default: true.
|
|
/// </summary>
|
|
public bool EnableTelemetry { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Custom purpose-to-algorithm overrides that take precedence over profile defaults.
|
|
/// Keys are from <see cref="HashPurpose"/>, values are from <see cref="HashAlgorithms"/>.
|
|
/// </summary>
|
|
public Dictionary<string, string>? PurposeOverrides { get; set; }
|
|
|
|
/// <summary>
|
|
/// Applies environment variable overrides.
|
|
/// </summary>
|
|
public void ApplyEnvironmentOverrides()
|
|
{
|
|
var profileEnv = Environment.GetEnvironmentVariable("STELLAOPS_CRYPTO_COMPLIANCE_PROFILE");
|
|
if (!string.IsNullOrWhiteSpace(profileEnv))
|
|
{
|
|
ProfileId = profileEnv.Trim().ToLowerInvariant();
|
|
}
|
|
|
|
var strictEnv = Environment.GetEnvironmentVariable("STELLAOPS_CRYPTO_STRICT_VALIDATION");
|
|
if (!string.IsNullOrWhiteSpace(strictEnv) &&
|
|
bool.TryParse(strictEnv, out var strict))
|
|
{
|
|
StrictValidation = strict;
|
|
}
|
|
}
|
|
}
|