@@ -523,59 +523,7 @@ static nr_library_table_t libraries[] = {
523
523
*/
524
524
{"Laminas_Http" , NR_PSTR ("laminas-http/src/client.php" ), nr_laminas_http_enable },
525
525
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 },
535
526
{"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 },
579
527
};
580
528
// clang-format: on
581
529
@@ -590,9 +538,6 @@ static nr_library_table_t logging_frameworks[] = {
590
538
/* laminas-log - Logging for PHP */
591
539
{"laminas-log" , NR_PSTR ("laminas-log/src/logger.php" ), NULL },
592
540
/* 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 },
596
541
};
597
542
// clang-format: on
598
543
@@ -603,14 +548,17 @@ static size_t num_logging_frameworks
603
548
typedef struct _nr_vuln_mgmt_table_t {
604
549
const char * package_name ;
605
550
const char * file_to_check ;
551
+ size_t file_to_check_len ;
606
552
nr_vuln_mgmt_enable_fn_t enable ;
607
553
} nr_vuln_mgmt_table_t ;
608
554
609
555
/* Note that all paths should be in lowercase. */
556
+ // clang-format: off
610
557
static 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 },
613
560
};
561
+ // clang-format: on
614
562
615
563
static const size_t num_packages
616
564
= sizeof (vuln_mgmt_packages ) / sizeof (nr_vuln_mgmt_table_t );
@@ -990,28 +938,22 @@ static void nr_execute_handle_logging_framework(const char* filename,
990
938
}
991
939
}
992
940
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 ) {
1002
943
size_t i = 0 ;
1003
944
1004
945
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 ))) {
1006
948
if (NULL != vuln_mgmt_packages [i ].enable ) {
1007
949
vuln_mgmt_packages [i ].enable ();
1008
950
}
1009
951
}
1010
952
}
1011
-
1012
- nr_free (filename_lower );
1013
953
}
1014
954
955
+ #undef STR_AND_LEN
956
+
1015
957
/*
1016
958
* Purpose : Detect library and framework usage from a PHP file.
1017
959
*
@@ -1036,7 +978,7 @@ static void nr_php_user_instrumentation_from_file(const char* filename,
1036
978
nr_execute_handle_autoload (filename , filename_len );
1037
979
nr_execute_handle_logging_framework (filename , filename_len TSRMLS_CC );
1038
980
if (NRINI (vulnerability_management_package_detection_enabled )) {
1039
- nr_execute_handle_package (filename );
981
+ nr_execute_handle_package (filename , filename_len );
1040
982
}
1041
983
}
1042
984
0 commit comments