// -----------------------------------------------------------------------------
// DriftGateOptions.cs
// Sprint: SPRINT_3600_0005_0001_policy_ci_gate_integration
// Description: Configuration options for drift gate evaluation.
// -----------------------------------------------------------------------------
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
namespace StellaOps.Policy.Engine.Gates;
///
/// Configuration options for drift gate evaluation.
///
public sealed class DriftGateOptions
{
///
/// Configuration section name.
///
public const string SectionName = "SmartDiff:Gates";
///
/// Whether drift gates are enabled.
///
public bool Enabled { get; set; } = true;
///
/// Custom gate definitions.
///
public List Gates { get; set; } = [];
///
/// Default action when no gate matches.
///
public DriftGateAction DefaultAction { get; set; } = DriftGateAction.Warn;
///
/// Whether to block on KEV reachable by default.
///
public bool BlockOnKev { get; set; } = true;
///
/// Whether to block when affected vulnerabilities become reachable.
///
public bool BlockOnAffectedReachable { get; set; } = true;
///
/// Whether to auto-emit VEX candidates for unreachable sinks.
///
public bool AutoEmitVexForUnreachable { get; set; } = true;
///
/// Minimum CVSS score to trigger block action.
///
public double? CvssBlockThreshold { get; set; } = 9.0;
///
/// Minimum EPSS score to trigger block action.
///
public double? EpssBlockThreshold { get; set; } = 0.5;
}
///
/// A custom gate definition from policy configuration.
///
public sealed class DriftGateDefinition
{
///
/// Gate identifier.
///
[Required]
public string Id { get; set; } = string.Empty;
///
/// Condition expression (e.g., "delta_reachable > 0 AND is_kev = true").
///
[Required]
public string Condition { get; set; } = string.Empty;
///
/// Action to take when condition matches.
///
public DriftGateAction Action { get; set; } = DriftGateAction.Warn;
///
/// Message to display when gate triggers.
///
public string Message { get; set; } = string.Empty;
///
/// Severity level.
///
public DriftGateSeverity Severity { get; set; } = DriftGateSeverity.Medium;
///
/// Whether to auto-mitigate (emit VEX) when condition matches.
///
public bool AutoMitigate { get; set; }
}
///
/// Actions that can be taken by drift gates.
///
public enum DriftGateAction
{
///
/// Allow the drift to proceed.
///
Allow,
///
/// Allow with a warning.
///
Warn,
///
/// Block the drift.
///
Block
}
///
/// Severity levels for drift gates.
///
public enum DriftGateSeverity
{
///
/// Informational.
///
Info,
///
/// Low severity.
///
Low,
///
/// Medium severity.
///
Medium,
///
/// High severity.
///
High,
///
/// Critical severity.
///
Critical
}