22
33namespace CleantalkSP \SpbctWP \VulnerabilityAlarm ;
44
5+ use CleantalkSP \SpbctWP \LinkConstructor ;
56use CleantalkSP \SpbctWP \VulnerabilityAlarm \Dto \ItemReport ;
67use CleantalkSP \SpbctWP \VulnerabilityAlarm \Dto \PluginReport ;
78use CleantalkSP \SpbctWP \UsersPassCheckModule \UsersPassCheckHandler ;
@@ -338,6 +339,37 @@ private static function getPscModules()
338339 return VulnerabilityAlarm::getPSCSafePluginsOnly ();
339340 }
340341
342+ /**
343+ * Direct link to the research site report.
344+ *
345+ * The report page of the exact certificate is available by its ID (PSC-2024-26398, CVE-2024-1234).
346+ * If the certificate ID is unknown, the link leads to the list of all the module reports.
347+ *
348+ * @param string $module_slug
349+ * @param string $certificate_id PSC or CVE identifier
350+ * @param string $module_id Research ID of the module report, used as an anchor of the fallback link
351+ *
352+ * @return string
353+ */
354+ private static function getResearchReportUrl ($ module_slug = '' , $ certificate_id = '' , $ module_id = '' )
355+ {
356+ if ( empty ($ module_slug ) ) {
357+ return LinkConstructor::buildSimpleLink (static ::RESEARCH_SITE_URL , 'reports/ ' );
358+ }
359+
360+ if ( ! empty ($ certificate_id ) ) {
361+ return LinkConstructor::buildSimpleLink (
362+ static ::RESEARCH_SITE_URL ,
363+ 'reports/search/ ' . $ module_slug . '/ ' . $ certificate_id
364+ );
365+ }
366+
367+ return LinkConstructor::buildSimpleLink (
368+ static ::RESEARCH_SITE_URL ,
369+ 'reports/app/ ' . $ module_slug . (! empty ($ module_id ) ? '# ' . $ module_id : '' )
370+ );
371+ }
372+
341373 public static function getCountOfCurrnetlyVulnerableModules ()
342374 {
343375 return count (static ::getVulnerablePluginsStatic ()) + count (static ::getVulnerableThemesStatic ());
@@ -460,7 +492,11 @@ public static function getTabCriticalUpdatesData()
460492 'version_from ' => !empty ($ plugin ->rs_app_version_min ) ? $ plugin ->rs_app_version_min : '0.0 ' ,
461493 'version_to ' => !empty ($ plugin ->rs_app_version_max ) ? $ plugin ->rs_app_version_max : 'unknown ' ,
462494 'cve ' => !empty ($ plugin ->CVE ) ? $ plugin ->CVE : 'CVE- ' . $ plugin ->id ,
463- 'cve_url ' => 'https://research.cleantalk.org/reports/app/ ' . $ plugin ->slug . '# ' . $ plugin ->id ,
495+ 'cve_url ' => static ::getResearchReportUrl (
496+ $ plugin ->slug ,
497+ !empty ($ plugin ->CVE ) ? $ plugin ->CVE : '' ,
498+ $ plugin ->id
499+ ),
464500 'recommendation ' => !empty ($ plugin ->rs_app_version_max ) ? 'update ' : 'delete ' ,
465501 ];
466502 }
@@ -474,26 +510,35 @@ public static function getTabCriticalUpdatesData()
474510 'version_from ' => !empty ($ theme ->rs_app_version_min ) ? $ theme ->rs_app_version_min : '0.0 ' ,
475511 'version_to ' => !empty ($ theme ->rs_app_version_max ) ? $ theme ->rs_app_version_max : 'unknown ' ,
476512 'cve ' => !empty ($ theme ->CVE ) ? $ theme ->CVE : 'CVE- ' . $ theme ->id ,
477- 'cve_url ' => 'https://research.cleantalk.org/reports/app/ ' . $ theme ->slug . '# ' . $ theme ->id ,
513+ 'cve_url ' => static ::getResearchReportUrl (
514+ $ theme ->slug ,
515+ !empty ($ theme ->CVE ) ? $ theme ->CVE : '' ,
516+ $ theme ->id
517+ ),
478518 'recommendation ' => !empty ($ theme ->rs_app_version_max ) ? 'update ' : 'delete ' ,
479519 ];
480520 }
481521
482522 // PSC
483523 $ psc_modules = static ::getPscModules ();
484- $ psc = array_map (function ($ module ) {
524+ $ psc_certificates = ! empty ($ psc_modules )
525+ ? PscCertifiedPluginsCache::getCertificatesMap (array_column ($ psc_modules , 'slug ' ))
526+ : array ();
527+ $ psc = array_map (function ($ module ) use ($ psc_certificates ) {
528+ $ certificate = isset ($ psc_certificates [$ module ['slug ' ]]) ? $ psc_certificates [$ module ['slug ' ]] : '' ;
529+
485530 return [
486531 'type ' => !empty ($ module ['type ' ]) ? $ module ['type ' ] : 'plugin ' ,
487532 'name ' => $ module ['slug ' ],
488533 'version ' => $ module ['version ' ],
489534 'psc ' => $ module ['psc ' ],
490- 'psc_url ' => ' https://research.cleantalk.org/reports/app/ ' . $ module ['slug ' ],
535+ 'psc_url ' => static :: getResearchReportUrl ( $ module ['slug ' ], $ certificate ) ,
491536 ];
492537 }, $ psc_modules );
493538
494539 // Legend
495540 $ legend = [
496- 'db_link ' => ' https://research.cleantalk.org/reports/ ' ,
541+ 'db_link ' => static :: getResearchReportUrl () ,
497542 ];
498543
499544 return [
0 commit comments