using System.Collections.Immutable;
using System.Text.Json.Serialization;

namespace StellaOps.Feedser.Source.Ru.Bdu.Internal;

internal sealed record RuBduVulnerabilityDto(
    string Identifier,
    string? Name,
    string? Description,
    string? Solution,
    DateTimeOffset? IdentifyDate,
    string? SeverityText,
    string? CvssVector,
    double? CvssScore,
    string? Cvss3Vector,
    double? Cvss3Score,
    string? ExploitStatus,
    int? IncidentCount,
    string? FixStatus,
    string? VulStatus,
    string? VulClass,
    string? VulState,
    string? Other,
    ImmutableArray<RuBduSoftwareDto> Software,
    ImmutableArray<RuBduEnvironmentDto> Environment,
    ImmutableArray<RuBduCweDto> Cwes,
    ImmutableArray<string> Sources,
    ImmutableArray<RuBduExternalIdentifierDto> Identifiers)
{
    [JsonIgnore]
    public bool HasCvss => !string.IsNullOrWhiteSpace(CvssVector) || !string.IsNullOrWhiteSpace(Cvss3Vector);
}

internal sealed record RuBduSoftwareDto(
    string? Vendor,
    string? Name,
    string? Version,
    string? Platform,
    ImmutableArray<string> Types);

internal sealed record RuBduEnvironmentDto(
    string? Vendor,
    string? Name,
    string? Version,
    string? Platform);

internal sealed record RuBduCweDto(string Identifier, string? Name);

internal sealed record RuBduExternalIdentifierDto(
    string Type,
    string Value,
    string? Link);
