package com.psg.dlsysinfo.dl_sysinfo_server.controller;

import com.psg.dlsysinfo.dl_sysinfo_server.entity.CveMatchResult;
import com.psg.dlsysinfo.dl_sysinfo_server.service.VulnerabilityScannerService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/test")
@RequiredArgsConstructor
public class VulnerabilityTestController {

    private final VulnerabilityScannerService vulnerabilityScannerService;

    @GetMapping("/vulnerabilities/{deviceId}")
    public ResponseEntity<List<CveMatchResult>> testVulns(@PathVariable Long deviceId) {
        List<CveMatchResult> results = vulnerabilityScannerService.getVulnerabilitiesForDevice(deviceId);
        return ResponseEntity.ok(results);
    }
}
