<?php
declare(strict_types=1);
namespace App\Controllers;
use App\Core\Auth;use App\Core\Controller;use App\Core\Csrf;use App\Core\Permission;use App\Services\ThreatIntelligenceService;
final class ThreatIntelligenceController extends Controller
{
 public function index(): void{Auth::requireLogin();Permission::require('soc.threat.view');$this->view('security/threat_intelligence',['pageTitle'=>'Threat Intelligence','report'=>(new ThreatIntelligenceService())->dashboard($_GET)]);}
 public function add(): void{Auth::requireRecentAuthentication();Permission::require('soc.threat.manage');Csrf::verify($_POST['_csrf']??null);(new ThreatIntelligenceService())->addIndicator($_POST,(int)(Auth::id()??0));$_SESSION['success']='Indicateur enregistré.';$this->redirect('/administration/securite/soc/threat-intelligence');}
 public function detect(): void{Auth::requireRecentAuthentication();Permission::require('soc.detections.run');Csrf::verify($_POST['_csrf']??null);$r=(new ThreatIntelligenceService())->runDetection((int)(Auth::id()??0));$_SESSION['success']='Analyse terminée : '.(int)$r['created'].' nouvelle(s) détection(s).';$this->redirect('/administration/securite/soc/threat-intelligence');}
}
