@@ -523,59 +523,7 @@ static nr_library_table_t libraries[] = {
523523 */
524524 {"Laminas_Http" , NR_PSTR ("laminas-http/src/client.php" ), nr_laminas_http_enable },
525525
526- /*
527- * Other frameworks, detected only, but not specifically
528- * instrumented. We detect these as libraries so that we don't prevent
529- * detection of a supported framework or library later (since a transaction
530- * can only have one framework).
531- */
532- {"Aura1" , NR_PSTR ("aura/framework/system.php" ), NULL },
533- {"Aura2" , NR_PSTR ("aura/di/src/containerinterface.php" ), NULL },
534- {"Aura3" , NR_PSTR ("aura/di/src/containerconfiginterface.php" ), NULL },
535526 {"CakePHP3" , NR_PSTR ("cakephp/src/core/functions.php" ), NULL },
536- {"Fuel" , NR_PSTR ("fuel/core/classes/fuel.php" ), NULL },
537- {"Lithium" , NR_PSTR ("lithium/core/libraries.php" ), NULL },
538- {"Phpbb" , NR_PSTR ("phpbb/request/request.php" ), NULL },
539- {"Phpixie2" , NR_PSTR ("phpixie/core/classes/phpixie/pixie.php" ), NULL },
540- {"Phpixie3" , NR_PSTR ("phpixie/framework.php" ), NULL },
541- {"React" , NR_PSTR ("react/event-loop/src/loopinterface.php" ), NULL },
542- {"SilverStripe" , NR_PSTR ("injector/silverstripeinjectioncreator.php" ), NULL },
543- {"SilverStripe4" , NR_PSTR ("silverstripeserviceconfigurationlocator.php" ), NULL },
544- {"Typo3" , NR_PSTR ("classes/typo3/flow/core/bootstrap.php" ), NULL },
545- {"Typo3" , NR_PSTR ("typo3/sysext/core/classes/core/bootstrap.php" ), NULL },
546-
547- /*
548- * Other CMS (content management systems), detected only, but
549- * not specifically instrumented.
550- */
551- {"Moodle" , NR_PSTR ("moodlelib.php" ), NULL },
552- /*
553- * It is likely that this will never be found, since the CodeIgniter.php
554- * will get loaded first, and as such mark this transaction as belonging to
555- * CodeIgniter, and not Expession Engine.
556- */
557- {"ExpressionEngine" , NR_PSTR ("system/expressionengine/config/config.php" ), NULL },
558- /*
559- * ExpressionEngine 5, however, has a very obvious file we can look for.
560- */
561- {"ExpressionEngine5" , NR_PSTR ("expressionengine/boot/boot.php" ), NULL },
562- /*
563- * DokuWiki uses doku.php as an entry point, but has other files that are
564- * loaded directly that this won't pick up. That's probably OK for
565- * supportability metrics, but we'll add the most common name for the
566- * configuration file as well just in case.
567- */
568- {"DokuWiki" , NR_PSTR ("doku.php" ), NULL },
569- {"DokuWiki" , NR_PSTR ("conf/dokuwiki.php" ), NULL },
570-
571- /*
572- * SugarCRM no longer has a community edition, so this likely only works
573- * with older versions.
574- */
575- {"SugarCRM" , NR_PSTR ("sugarobjects/sugarconfig.php" ), NULL },
576-
577- {"Xoops" , NR_PSTR ("class/xoopsload.php" ), NULL },
578- {"E107" , NR_PSTR ("e107_handlers/e107_class.php" ), NULL },
579527};
580528// clang-format: on
581529
@@ -590,9 +538,6 @@ static nr_library_table_t logging_frameworks[] = {
590538 /* laminas-log - Logging for PHP */
591539 {"laminas-log" , NR_PSTR ("laminas-log/src/logger.php" ), NULL },
592540 /* cakephp-log - Logging for PHP */
593- {"cakephp-log" , NR_PSTR ("cakephp/log/log.php" ), NULL },
594- /* Analog - Logging for PHP */
595- {"Analog" , NR_PSTR ("analog/analog.php" ), NULL },
596541};
597542// clang-format: on
598543
@@ -603,14 +548,17 @@ static size_t num_logging_frameworks
603548typedef struct _nr_vuln_mgmt_table_t {
604549 const char * package_name ;
605550 const char * file_to_check ;
551+ size_t file_to_check_len ;
606552 nr_vuln_mgmt_enable_fn_t enable ;
607553} nr_vuln_mgmt_table_t ;
608554
609555/* Note that all paths should be in lowercase. */
556+ // clang-format: off
610557static const nr_vuln_mgmt_table_t vuln_mgmt_packages [] = {
611- {"Drupal" , "drupal/component/dependencyinjection/container.php" , nr_drupal_version },
612- {"Wordpress" , "wp-includes/version.php" , nr_wordpress_version },
558+ {"Drupal" , NR_PSTR ( "drupal/component/dependencyinjection/container.php" ) , nr_drupal_version },
559+ {"Wordpress" , NR_PSTR ( "wp-includes/version.php" ) , nr_wordpress_version },
613560};
561+ // clang-format: on
614562
615563static const size_t num_packages
616564 = sizeof (vuln_mgmt_packages ) / sizeof (nr_vuln_mgmt_table_t );
@@ -990,28 +938,22 @@ static void nr_execute_handle_logging_framework(const char* filename,
990938 }
991939}
992940
993- #undef STR_AND_LEN
994-
995- static void nr_execute_handle_package (const char * filename ) {
996- if (NULL == filename || 0 >= nr_strlen (filename )) {
997- nrl_verbosedebug (NRL_FRAMEWORK , "%s: The file name is NULL" ,
998- __func__ );
999- return ;
1000- }
1001- char * filename_lower = nr_string_to_lowercase (filename );
941+ static void nr_execute_handle_package (const char * filename ,
942+ const size_t filename_len ) {
1002943 size_t i = 0 ;
1003944
1004945 for (i = 0 ; i < num_packages ; i ++ ) {
1005- if (nr_stridx (filename_lower , vuln_mgmt_packages [i ].file_to_check ) >= 0 ) {
946+ if (nr_striendswith (STR_AND_LEN (filename ),
947+ STR_AND_LEN (vuln_mgmt_packages [i ].file_to_check ))) {
1006948 if (NULL != vuln_mgmt_packages [i ].enable ) {
1007949 vuln_mgmt_packages [i ].enable ();
1008950 }
1009951 }
1010952 }
1011-
1012- nr_free (filename_lower );
1013953}
1014954
955+ #undef STR_AND_LEN
956+
1015957/*
1016958 * Purpose : Detect library and framework usage from a PHP file.
1017959 *
@@ -1036,7 +978,7 @@ static void nr_php_user_instrumentation_from_file(const char* filename,
1036978 nr_execute_handle_autoload (filename , filename_len );
1037979 nr_execute_handle_logging_framework (filename , filename_len TSRMLS_CC );
1038980 if (NRINI (vulnerability_management_package_detection_enabled )) {
1039- nr_execute_handle_package (filename );
981+ nr_execute_handle_package (filename , filename_len );
1040982 }
1041983}
1042984
0 commit comments