src/Controller/OscController.php line 40

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Component;
  4. use App\Service\CveService;
  5. use App\Service\ScanResultService;
  6. use App\Service\ScanService;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class OscController extends AbstractController
  11. {
  12.     /**
  13.      * @var ScanService $scanService
  14.      */
  15.     private $scanService;
  16.     /**
  17.      * @var ScanResultService $scanResultService
  18.      */
  19.     private $scanResultService;
  20.     /**
  21.      * @var CveService $cveService
  22.      */
  23.     private $cveService;
  24.     public function __construct(ScanService $scanServiceScanResultService $scanResultServiceCveService $cveService)
  25.     {
  26.         $this->scanService $scanService;
  27.         $this->scanResultService $scanResultService;
  28.         $this->cveService $cveService;
  29.     }
  30.     /**
  31.      * @Route("/", name="home")
  32.      */
  33.     public function home(): Response
  34.     {
  35.         return $this->render('frontoffice/pages/home.html.twig', [
  36.             'searchedComponent' => null
  37.         ]);
  38.     }
  39.     /**
  40.      * @Route("/getVulnerabilities/{cpe23}/{title}", name="getVulnerabilities")
  41.      * @param string $cpe23
  42.      * @param string $title
  43.      * @return Response
  44.      */
  45.     public function getVulnerabilities(string $cpe23string $title): Response
  46.     {
  47.         $component = new Component();
  48.         $component->setCpe23($cpe23);
  49.         return $this->render('frontoffice/pages/search-result.html.twig', [
  50.             'searchedComponent' => $title,
  51.             'componentScanResult' => $this->scanResultService->getComponentVulnerabilities(
  52.                 $this->scanService->getComponentScanResult($component)
  53.             ),
  54.         ]);
  55.     }
  56.     /**
  57.      * @Route("/getVulnerability/{cve}", name="getVulnerability")
  58.      * @param string $cve
  59.      * @return Response
  60.      */
  61.     public function getVulnerability(string $cve): Response
  62.     {
  63.         return $this->render('frontoffice/pages/vulnerability-details.html.twig', [
  64.             'vulnerability' => $this->cveService->getCVE($cve)
  65.         ]);
  66.     }
  67. }