<?php
namespace App\Controller;
use App\Entity\Component;
use App\Service\CveService;
use App\Service\ScanResultService;
use App\Service\ScanService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class OscController extends AbstractController
{
/**
* @var ScanService $scanService
*/
private $scanService;
/**
* @var ScanResultService $scanResultService
*/
private $scanResultService;
/**
* @var CveService $cveService
*/
private $cveService;
public function __construct(ScanService $scanService, ScanResultService $scanResultService, CveService $cveService)
{
$this->scanService = $scanService;
$this->scanResultService = $scanResultService;
$this->cveService = $cveService;
}
/**
* @Route("/", name="home")
*/
public function home(): Response
{
return $this->render('frontoffice/pages/home.html.twig', [
'searchedComponent' => null
]);
}
/**
* @Route("/getVulnerabilities/{cpe23}/{title}", name="getVulnerabilities")
* @param string $cpe23
* @param string $title
* @return Response
*/
public function getVulnerabilities(string $cpe23, string $title): Response
{
$component = new Component();
$component->setCpe23($cpe23);
return $this->render('frontoffice/pages/search-result.html.twig', [
'searchedComponent' => $title,
'componentScanResult' => $this->scanResultService->getComponentVulnerabilities(
$this->scanService->getComponentScanResult($component)
),
]);
}
/**
* @Route("/getVulnerability/{cve}", name="getVulnerability")
* @param string $cve
* @return Response
*/
public function getVulnerability(string $cve): Response
{
return $this->render('frontoffice/pages/vulnerability-details.html.twig', [
'vulnerability' => $this->cveService->getCVE($cve)
]);
}
}