package com.hiveops.aria.entity;

import jakarta.persistence.*;
import lombok.*;

import java.time.Instant;

@Entity
@Table(name = "threat_ioc")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ThreatIoc {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Enumerated(EnumType.STRING)
    @Column(name = "ioc_type", nullable = false, columnDefinition = "ioc_type")
    private IocType iocType;

    @Column(nullable = false)
    private String value;

    private String description;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false, columnDefinition = "ioc_source")
    @Builder.Default
    private IocSource source = IocSource.FBI_FLASH;

    @Column(name = "source_ref")
    private String sourceRef;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false, columnDefinition = "confidence_level")
    @Builder.Default
    private ConfidenceLevel confidence = ConfidenceLevel.HIGH;

    @Column(name = "added_at", nullable = false)
    @Builder.Default
    private Instant addedAt = Instant.now();

    @Column(name = "expires_at")
    private Instant expiresAt;

    @Column(nullable = false)
    @Builder.Default
    private Boolean active = true;

    public enum IocType {
        FILENAME, MD5, REGISTRY_KEY, DIRECTORY, SERVICE_NAME, IP, FILE_PATH
    }

    public enum IocSource {
        FBI_FLASH, FS_ISAC, MANUAL
    }

    public enum ConfidenceLevel {
        HIGH, MEDIUM, LOW
    }
}
