Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Created CycloneDX and SPDX SBOM files for both reachable and unreachable images. - Added symbols.json detailing function entry and sink points in the WordPress code. - Included runtime traces for function calls in both reachable and unreachable scenarios. - Developed OpenVEX files indicating vulnerability status and justification for both cases. - Updated README for evaluator harness to guide integration with scanner output.
62 lines
2.0 KiB
C#
62 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
|
|
namespace StellaOps.Cryptography.DependencyInjection;
|
|
|
|
/// <summary>
|
|
/// Options controlling crypto provider registry ordering and selection.
|
|
/// </summary>
|
|
public sealed class CryptoProviderRegistryOptions
|
|
{
|
|
private readonly Dictionary<string, CryptoProviderProfileOptions> profiles =
|
|
new(StringComparer.OrdinalIgnoreCase);
|
|
|
|
/// <summary>
|
|
/// Ordered list of preferred provider names. Providers appearing here are consulted first.
|
|
/// </summary>
|
|
public IList<string> PreferredProviders { get; } = new List<string>();
|
|
|
|
/// <summary>
|
|
/// Optional active profile name (e.g. "ru-offline") that overrides <see cref="PreferredProviders"/>.
|
|
/// </summary>
|
|
public string? ActiveProfile { get; set; }
|
|
|
|
/// <summary>
|
|
/// Regional or environment-specific provider preference profiles.
|
|
/// </summary>
|
|
public IDictionary<string, CryptoProviderProfileOptions> Profiles => profiles;
|
|
|
|
public IReadOnlyList<string> ResolvePreferredProviders()
|
|
{
|
|
static IReadOnlyList<string> Normalise(IEnumerable<string> items)
|
|
=> new ReadOnlyCollection<string>(
|
|
items.Where(static value => !string.IsNullOrWhiteSpace(value))
|
|
.Select(static value => value.Trim())
|
|
.ToArray());
|
|
|
|
if (!string.IsNullOrWhiteSpace(ActiveProfile) &&
|
|
profiles.TryGetValue(ActiveProfile, out var profile) &&
|
|
profile.PreferredProviders.Count > 0)
|
|
{
|
|
return Normalise(profile.PreferredProviders);
|
|
}
|
|
|
|
if (PreferredProviders.Count > 0)
|
|
{
|
|
return Normalise(PreferredProviders);
|
|
}
|
|
|
|
return Array.Empty<string>();
|
|
}
|
|
}
|
|
|
|
public sealed class CryptoProviderProfileOptions
|
|
{
|
|
/// <summary>
|
|
/// Ordered list of preferred provider names for the profile.
|
|
/// </summary>
|
|
public IList<string> PreferredProviders { get; } = new List<string>();
|
|
}
|