@@ -253,7 +253,7 @@ public function api_rmfv4_show($con): Response
253253
254254 $ results ['enhancements ' ] = [];
255255 foreach ($ controls_xml ->xpath ("./aaa:control-enhancements/aaa:control-enhancement " ) as $ enhancement ) {
256- $ results ['enhancements ' ][current ( $ enhancement ->number ) ] = current ( $ enhancement ->title ) ;
256+ $ results ['enhancements ' ][( string ) $ enhancement ->number ] = ( string ) $ enhancement ->title ;
257257 }
258258
259259 return new Response (json_encode ($ results , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ), Response::HTTP_OK , ['content-type ' => 'application/json ' ] );
@@ -385,15 +385,15 @@ public function api_rmf_show($con): Response
385385 $ results ['references ' ] = [];
386386 foreach ($ controls_xml ->xpath ("./xmlns:references/xmlns:reference " ) as $ ref ) {
387387 $ results ['references ' ][] = [
388- "href " => str_replace ("\/ " , "/ " , current ( $ ref ->item ) ['href ' ]),
389- "text " => current ( $ ref ->item ->text ) ,
390- "name " => current ( $ ref ->short_name )
388+ "href " => str_replace ("\/ " , "/ " , ( string ) $ ref ->item ['href ' ]),
389+ "text " => ( string ) $ ref ->item ->text ,
390+ "name " => ( string ) $ ref ->short_name
391391 ];
392392 }
393393
394394 $ results ['enhancements ' ] = [];
395395 foreach ($ controls_xml ->xpath ("./xmlns:control-enhancements/xmlns:control-enhancement " ) as $ enhancement ) {
396- $ results ['enhancements ' ][current ( $ enhancement ->number ) ] = current ( $ enhancement ->title ) ;
396+ $ results ['enhancements ' ][( string ) $ enhancement ->number ] = ( string ) $ enhancement ->title ;
397397 }
398398
399399 return new Response (json_encode ($ results , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ), Response::HTTP_OK , ['content-type ' => 'application/json ' ] );
@@ -541,9 +541,9 @@ public function api_stig_tip(): Response
541541 $ vuln_id = (string )$ group ->attributes ()['id ' ];
542542
543543 $ collection [$ key ]->tip = [
544- "title " => (string )current ( $ group ->Rule ->title ) ,
545- "rule " => (string )current ( $ group ->Rule ->attributes ()['id ' ]) ,
546- "severity " => (string )current ( $ group ->Rule ->attributes ()['severity ' ]) ,
544+ "title " => (string )$ group ->Rule ->title ,
545+ "rule " => (string )$ group ->Rule ->attributes ()['id ' ],
546+ "severity " => (string )$ group ->Rule ->attributes ()['severity ' ],
547547 "vuln_id " => $ vuln_id ,
548548 ];
549549
@@ -573,6 +573,9 @@ public function api_stig_summary($title, $version, $release): Response
573573 return false ;
574574 });
575575 $ stig = array_pop ($ stig );
576+ if ($ stig === null ) {
577+ throw $ this ->createNotFoundException ('The STIG does not exist ' );
578+ }
576579 $ stig_filename = realpath (__DIR__ . "/../../resources/data/stig/ " . $ stig ->filename );
577580 if ($ stig_filename === false || !is_file ($ stig_filename )) {
578581 throw $ this ->createNotFoundException ('The STIG does not exist ' );
@@ -598,17 +601,17 @@ public function api_stig_summary($title, $version, $release): Response
598601
599602 $ results ["profiles " ] = [];
600603 foreach ($ stig_xml ->xpath ('/xmlns:Benchmark/xmlns:Profile ' ) as $ profile ) {
601- $ results ["profiles " ][(string )$ profile ->attributes ()['id ' ]] = (string )current ( $ profile ->title ) ;
604+ $ results ["profiles " ][(string )$ profile ->attributes ()['id ' ]] = (string )$ profile ->title ;
602605 }
603606
604607 $ results ["requirements " ] = [];
605608 foreach ($ stig_xml ->xpath ('/xmlns:Benchmark/xmlns:Group ' ) as $ group ) {
606609 $ vuln_id = (string )$ group ->attributes ()['id ' ];
607610
608611 $ results ["requirements " ][$ vuln_id ] = [
609- "title " => (string )current ( $ group ->Rule ->title ) ,
610- "rule " => (string )current ( $ group ->Rule ->attributes ()['id ' ]) ,
611- "severity " => (string )current ( $ group ->Rule ->attributes ()['severity ' ]) ,
612+ "title " => (string )$ group ->Rule ->title ,
613+ "rule " => (string )$ group ->Rule ->attributes ()['id ' ],
614+ "severity " => (string )$ group ->Rule ->attributes ()['severity ' ],
612615 "link " => "/stig/ {$ title }/ {$ version }/ {$ release }/ {$ vuln_id }"
613616 ];
614617 }
@@ -634,6 +637,9 @@ public function api_stig_vuln(Request $request, $title, $version, $release, $vul
634637 return false ;
635638 });
636639 $ stig = array_pop ($ stig );
640+ if ($ stig === null ) {
641+ throw $ this ->createNotFoundException ('The STIG does not exist ' );
642+ }
637643 $ stig_filename = realpath (__DIR__ . "/../../resources/data/stig/ " . $ stig ->filename );
638644 if ($ stig_filename === false || !is_file ($ stig_filename )) {
639645 throw $ this ->createNotFoundException ('The STIG does not exist ' );
@@ -659,7 +665,7 @@ public function api_stig_vuln(Request $request, $title, $version, $release, $vul
659665 $ results ["stig-published " ] = (string )current ($ stig_xml ->xpath ('/xmlns:Benchmark/xmlns:status/@date ' ));
660666
661667 $ vuln = current ($ stig_xml ->xpath ("/xmlns:Benchmark/xmlns:Group[@id=' {$ vuln }'] " ));
662- $ results ["id " ] = (string )current ( $ vuln ->attributes ()['id ' ]) ;
668+ $ results ["id " ] = (string )$ vuln ->attributes ()['id ' ];
663669 $ results ["group " ] = (string )$ vuln ->title ;
664670 $ results ["rule " ] = (string )$ vuln ->Rule ->attributes ()['id ' ];
665671 $ results ["severity " ] = (string )$ vuln ->Rule ->attributes ()['severity ' ];
@@ -725,6 +731,9 @@ public function api_scap_summary($title, $version, $release): Response
725731 return false ;
726732 });
727733 $ scap = array_pop ($ scap );
734+ if ($ scap === null ) {
735+ throw $ this ->createNotFoundException ('The SCAP does not exist ' );
736+ }
728737 $ scap_filename = realpath (__DIR__ . "/../../resources/data/scap/ " . $ scap ->filename );
729738 if ($ scap_filename === false || !is_file ($ scap_filename )) {
730739 throw $ this ->createNotFoundException ('The SCAP does not exist ' );
@@ -786,6 +795,9 @@ public function api_scap_vuln($title, $version, $release, $vuln): Response
786795 return false ;
787796 });
788797 $ scap = array_pop ($ scap );
798+ if ($ scap === null ) {
799+ throw $ this ->createNotFoundException ('The SCAP does not exist ' );
800+ }
789801 $ scap_filename = realpath (__DIR__ . "/../../resources/data/scap/ " . $ scap ->filename );
790802 if ($ scap_filename === false || !is_file ($ scap_filename )) {
791803 throw $ this ->createNotFoundException ('The SCAP does not exist ' );
@@ -816,7 +828,7 @@ public function api_scap_vuln($title, $version, $release, $vuln): Response
816828
817829 $ vuln = current ($ scap_xml ->xpath ("//xccdf:Benchmark/xccdf:Group[@id='xccdf_mil.disa.stig_group_ {$ vuln }'] " ));
818830
819- $ results ["id " ] = (string )current ( $ vuln ->attributes ()['id ' ]) ;
831+ $ results ["id " ] = (string )$ vuln ->attributes ()['id ' ];
820832 $ results ["group " ] = (string )current ($ vuln ->xpath ("./xccdf:title " ));
821833 $ results ["rule " ] = (string )current ($ vuln ->xpath ("./xccdf:Rule/@id " ));
822834 $ results ["severity " ] = (string )current ($ vuln ->xpath ("./xccdf:Rule/@severity " ));
0 commit comments