@@ -603,14 +603,17 @@ static size_t num_logging_frameworks
603
603
typedef struct _nr_vuln_mgmt_table_t {
604
604
const char * package_name ;
605
605
const char * file_to_check ;
606
+ size_t file_to_check_len ;
606
607
nr_vuln_mgmt_enable_fn_t enable ;
607
608
} nr_vuln_mgmt_table_t ;
608
609
609
610
/* Note that all paths should be in lowercase. */
611
+ // clang-format: off
610
612
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 },
613
+ {"Drupal" , NR_PSTR ( "drupal/component/dependencyinjection/container.php" ) , nr_drupal_version },
614
+ {"Wordpress" , NR_PSTR ( "wp-includes/version.php" ) , nr_wordpress_version },
613
615
};
616
+ // clang-format: on
614
617
615
618
static const size_t num_packages
616
619
= sizeof (vuln_mgmt_packages ) / sizeof (nr_vuln_mgmt_table_t );
@@ -990,28 +993,22 @@ static void nr_execute_handle_logging_framework(const char* filename,
990
993
}
991
994
}
992
995
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 );
996
+ static void nr_execute_handle_package (const char * filename ,
997
+ const size_t filename_len ) {
1002
998
size_t i = 0 ;
1003
999
1004
1000
for (i = 0 ; i < num_packages ; i ++ ) {
1005
- if (nr_stridx (filename_lower , vuln_mgmt_packages [i ].file_to_check ) >= 0 ) {
1001
+ if (nr_striendswith (STR_AND_LEN (filename ),
1002
+ STR_AND_LEN (vuln_mgmt_packages [i ].file_to_check ))) {
1006
1003
if (NULL != vuln_mgmt_packages [i ].enable ) {
1007
1004
vuln_mgmt_packages [i ].enable ();
1008
1005
}
1009
1006
}
1010
1007
}
1011
-
1012
- nr_free (filename_lower );
1013
1008
}
1014
1009
1010
+ #undef STR_AND_LEN
1011
+
1015
1012
/*
1016
1013
* Purpose : Detect library and framework usage from a PHP file.
1017
1014
*
@@ -1036,7 +1033,7 @@ static void nr_php_user_instrumentation_from_file(const char* filename,
1036
1033
nr_execute_handle_autoload (filename , filename_len );
1037
1034
nr_execute_handle_logging_framework (filename , filename_len TSRMLS_CC );
1038
1035
if (NRINI (vulnerability_management_package_detection_enabled )) {
1039
- nr_execute_handle_package (filename );
1036
+ nr_execute_handle_package (filename , filename_len );
1040
1037
}
1041
1038
}
1042
1039
0 commit comments