package com.hiveops.aria.repository;

import com.hiveops.aria.entity.ThreatIoc;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface ThreatIocRepository extends JpaRepository<ThreatIoc, Long> {

    List<ThreatIoc> findByActiveTrue();

    List<ThreatIoc> findByActiveTrueAndIocType(ThreatIoc.IocType iocType);

    Optional<ThreatIoc> findByActiveTrueAndIocTypeAndValueIgnoreCase(ThreatIoc.IocType iocType, String value);

    @Query("SELECT i FROM ThreatIoc i WHERE i.active = true AND i.iocType IN ('FILENAME', 'MD5', 'FILE_PATH')")
    List<ThreatIoc> findActiveExecutableIocs();
}
