@@ -476,6 +476,7 @@ typedef struct _nr_library_table_t {
476
476
const char * library_name ;
477
477
const char * file_to_check ;
478
478
size_t file_to_check_len ;
479
+ nr_composer_special_fn_t special ;
479
480
nr_library_enable_fn_t enable ;
480
481
} nr_library_table_t ;
481
482
@@ -485,97 +486,97 @@ typedef struct _nr_library_table_t {
485
486
// clang-format: off
486
487
static nr_library_table_t libraries [] = {
487
488
/* AWS-SDK-PHP 3 */
488
- {"AWS-SDK-PHP" , NR_PSTR ("aws-sdk-php/src/awsclient.php" ), nr_aws_sdk_php_enable },
489
+ {"AWS-SDK-PHP" , NR_PSTR ("aws-sdk-php/src/awsclient.php" ), 0 , nr_aws_sdk_php_enable },
489
490
490
491
/* Doctrine < 2.18 */
491
- {"Doctrine 2" , NR_PSTR ("doctrine/orm/query.php" ), nr_doctrine2_enable },
492
+ {"Doctrine 2" , NR_PSTR ("doctrine/orm/query.php" ), 0 , nr_doctrine2_enable },
492
493
/* Doctrine 2.18 reworked the directory structure */
493
- {"Doctrine 2" , NR_PSTR ("doctrine/orm/src/query.php" ), nr_doctrine2_enable },
494
+ {"Doctrine 2" , NR_PSTR ("doctrine/orm/src/query.php" ), 0 , nr_doctrine2_enable },
494
495
495
- {"Guzzle 3" , NR_PSTR ("guzzle/http/client.php" ), nr_guzzle3_enable },
496
- {"Guzzle 4-5" , NR_PSTR ("hasemitterinterface.php" ), nr_guzzle4_enable },
497
- {"Guzzle 6" , NR_PSTR ("guzzle/src/functions_include.php" ), nr_guzzle6_enable },
496
+ {"Guzzle 3" , NR_PSTR ("guzzle/http/client.php" ), 0 , nr_guzzle3_enable },
497
+ {"Guzzle 4-5" , NR_PSTR ("hasemitterinterface.php" ), 0 , nr_guzzle4_enable },
498
+ {"Guzzle 6" , NR_PSTR ("guzzle/src/functions_include.php" ), 0 , nr_guzzle6_enable },
498
499
499
- {"MongoDB" , NR_PSTR ("mongodb/src/client.php" ), nr_mongodb_enable },
500
+ {"MongoDB" , NR_PSTR ("mongodb/src/client.php" ), 0 , nr_mongodb_enable },
500
501
501
502
/*
502
503
* The first path is for Composer installs, the second is for
503
504
* /usr/local/bin.
504
505
*/
505
- {"PHPUnit" , NR_PSTR ("phpunit/src/framework/test.php" ), nr_phpunit_enable },
506
- {"PHPUnit" , NR_PSTR ("phpunit/framework/test.php" ), nr_phpunit_enable },
506
+ {"PHPUnit" , NR_PSTR ("phpunit/src/framework/test.php" ), 0 , nr_phpunit_enable },
507
+ {"PHPUnit" , NR_PSTR ("phpunit/framework/test.php" ), 0 , nr_phpunit_enable },
507
508
508
- {"Predis" , NR_PSTR ("predis/src/client.php" ), nr_predis_enable },
509
- {"Predis" , NR_PSTR ("predis/client.php" ), nr_predis_enable },
509
+ {"Predis" , NR_PSTR ("predis/src/client.php" ), 0 , nr_predis_enable },
510
+ {"Predis" , NR_PSTR ("predis/client.php" ), 0 , nr_predis_enable },
510
511
511
512
/*
512
513
* Allow Zend Framework 1.x to be detected as a library as well as a
513
514
* framework. This allows Zend_Http_Client to be instrumented when used
514
515
* with other frameworks or even without a framework at all. This is
515
516
* necessary for Magento in particular, which is built on ZF1.
516
517
*/
517
- {"Zend_Http" , NR_PSTR ("zend/http/client.php" ), nr_zend_http_enable },
518
+ {"Zend_Http" , NR_PSTR ("zend/http/client.php" ), 0 , nr_zend_http_enable },
518
519
519
520
/*
520
521
* Allow Laminas Framework 3.x to be detected as a library as well as a
521
522
* framework. This allows Laminas_Http_Client to be instrumented when used
522
523
* with other frameworks or even without a framework at all.
523
524
*/
524
- {"Laminas_Http" , NR_PSTR ("laminas-http/src/client.php" ), nr_laminas_http_enable },
525
+ {"Laminas_Http" , NR_PSTR ("laminas-http/src/client.php" ), 0 , nr_laminas_http_enable },
525
526
526
527
/*
527
528
* Other frameworks, detected only, but not specifically
528
529
* instrumented. We detect these as libraries so that we don't prevent
529
530
* detection of a supported framework or library later (since a transaction
530
531
* can only have one framework).
531
532
*/
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
- {"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 },
533
+ {"Aura1" , NR_PSTR ("aura/framework/system.php" ), 0 , NULL },
534
+ {"Aura2" , NR_PSTR ("aura/di/src/containerinterface.php" ), 0 , NULL },
535
+ {"Aura3" , NR_PSTR ("aura/di/src/containerconfiginterface.php" ), 0 , NULL },
536
+ {"CakePHP3" , NR_PSTR ("cakephp/src/core/functions.php" ), 0 , NULL },
537
+ {"Fuel" , NR_PSTR ("fuel/core/classes/fuel.php" ), 0 , NULL },
538
+ {"Lithium" , NR_PSTR ("lithium/core/libraries.php" ), 0 , NULL },
539
+ {"Phpbb" , NR_PSTR ("phpbb/request/request.php" ), 0 , NULL },
540
+ {"Phpixie2" , NR_PSTR ("phpixie/core/classes/phpixie/pixie.php" ), 0 , NULL },
541
+ {"Phpixie3" , NR_PSTR ("phpixie/framework.php" ), 0 , NULL },
542
+ {"React" , NR_PSTR ("react/event-loop/src/loopinterface.php" ), 0 , NULL },
543
+ {"SilverStripe" , NR_PSTR ("injector/silverstripeinjectioncreator.php" ), 0 , NULL },
544
+ {"SilverStripe4" , NR_PSTR ("silverstripeserviceconfigurationlocator.php" ), 0 , NULL },
545
+ {"Typo3" , NR_PSTR ("classes/typo3/flow/core/bootstrap.php" ), 0 , NULL },
546
+ {"Typo3" , NR_PSTR ("typo3/sysext/core/classes/core/bootstrap.php" ), 0 , NULL },
546
547
547
548
/*
548
549
* Other CMS (content management systems), detected only, but
549
550
* not specifically instrumented.
550
551
*/
551
- {"Moodle" , NR_PSTR ("moodlelib.php" ), NULL },
552
+ {"Moodle" , NR_PSTR ("moodlelib.php" ), 0 , NULL },
552
553
/*
553
554
* It is likely that this will never be found, since the CodeIgniter.php
554
555
* will get loaded first, and as such mark this transaction as belonging to
555
556
* CodeIgniter, and not Expession Engine.
556
557
*/
557
- {"ExpressionEngine" , NR_PSTR ("system/expressionengine/config/config.php" ), NULL },
558
+ {"ExpressionEngine" , NR_PSTR ("system/expressionengine/config/config.php" ), 0 , NULL },
558
559
/*
559
560
* ExpressionEngine 5, however, has a very obvious file we can look for.
560
561
*/
561
- {"ExpressionEngine5" , NR_PSTR ("expressionengine/boot/boot.php" ), NULL },
562
+ {"ExpressionEngine5" , NR_PSTR ("expressionengine/boot/boot.php" ), 0 , NULL },
562
563
/*
563
564
* DokuWiki uses doku.php as an entry point, but has other files that are
564
565
* loaded directly that this won't pick up. That's probably OK for
565
566
* supportability metrics, but we'll add the most common name for the
566
567
* configuration file as well just in case.
567
568
*/
568
- {"DokuWiki" , NR_PSTR ("doku.php" ), NULL },
569
- {"DokuWiki" , NR_PSTR ("conf/dokuwiki.php" ), NULL },
569
+ {"DokuWiki" , NR_PSTR ("doku.php" ), 0 , NULL },
570
+ {"DokuWiki" , NR_PSTR ("conf/dokuwiki.php" ), 0 , NULL },
570
571
571
572
/*
572
573
* SugarCRM no longer has a community edition, so this likely only works
573
574
* with older versions.
574
575
*/
575
- {"SugarCRM" , NR_PSTR ("sugarobjects/sugarconfig.php" ), NULL },
576
+ {"SugarCRM" , NR_PSTR ("sugarobjects/sugarconfig.php" ), 0 , NULL },
576
577
577
- {"Xoops" , NR_PSTR ("class/xoopsload.php" ), NULL },
578
- {"E107" , NR_PSTR ("e107_handlers/e107_class.php" ), NULL },
578
+ {"Xoops" , NR_PSTR ("class/xoopsload.php" ), 0 , NULL },
579
+ {"E107" , NR_PSTR ("e107_handlers/e107_class.php" ), 0 , NULL },
579
580
};
580
581
// clang-format: on
581
582
@@ -584,15 +585,15 @@ static size_t num_libraries = sizeof(libraries) / sizeof(nr_library_table_t);
584
585
// clang-format: off
585
586
static nr_library_table_t logging_frameworks [] = {
586
587
/* Monolog - Logging for PHP */
587
- {"Monolog" , NR_PSTR ("monolog/logger.php" ), nr_monolog_enable },
588
+ {"Monolog" , NR_PSTR ("monolog/logger.php" ), 0 , nr_monolog_enable },
588
589
/* Consolidation/Log - Logging for PHP */
589
- {"Consolidation/Log" , NR_PSTR ("consolidation/log/src/logger.php" ), NULL },
590
+ {"Consolidation/Log" , NR_PSTR ("consolidation/log/src/logger.php" ), 0 , NULL },
590
591
/* laminas-log - Logging for PHP */
591
- {"laminas-log" , NR_PSTR ("laminas-log/src/logger.php" ), NULL },
592
+ {"laminas-log" , NR_PSTR ("laminas-log/src/logger.php" ), 0 , NULL },
592
593
/* cakephp-log - Logging for PHP */
593
- {"cakephp-log" , NR_PSTR ("cakephp/log/log.php" ), NULL },
594
+ {"cakephp-log" , NR_PSTR ("cakephp/log/log.php" ), 0 , NULL },
594
595
/* Analog - Logging for PHP */
595
- {"Analog" , NR_PSTR ("analog/analog.php" ), NULL },
596
+ {"Analog" , NR_PSTR ("analog/analog.php" ), 0 , NULL },
596
597
};
597
598
// clang-format: on
598
599
@@ -931,6 +932,28 @@ static void nr_execute_handle_library(const char* filename,
931
932
}
932
933
}
933
934
935
+ static void nr_execute_handle_composer (const char * filename ,
936
+ const size_t filename_len TSRMLS_DC ) {
937
+ size_t i ;
938
+
939
+ for (i = 0 ; i < num_libraries ; i ++ ) {
940
+ if (nr_striendswith (STR_AND_LEN (filename ),
941
+ STR_AND_LEN (libraries [i ].file_to_check ))) {
942
+ if (libraries [i ].special ) {
943
+ nr_composer_classification_t special
944
+ = libraries [i ].special (filename TSRMLS_CC );
945
+ if (FILE_EXISTS == special ) {
946
+ nr_fw_support_add_library_supportability_metric (
947
+ NRPRG (txn ), libraries [i ].library_name );
948
+ if (NULL != libraries [i ].enable ) {
949
+ libraries [i ].enable (TSRMLS_C );
950
+ }
951
+ }
952
+ }
953
+ }
954
+ }
955
+ }
956
+
934
957
static void nr_execute_handle_logging_framework (const char * filename ,
935
958
const size_t filename_len
936
959
TSRMLS_DC ) {
@@ -999,6 +1022,7 @@ static void nr_php_user_instrumentation_from_file(const char* filename,
999
1022
nr_execute_handle_framework (all_frameworks , num_all_frameworks , filename ,
1000
1023
filename_len TSRMLS_CC );
1001
1024
nr_execute_handle_library (filename , filename_len TSRMLS_CC );
1025
+ nr_execute_handle_composer (filename , filename_len );
1002
1026
nr_execute_handle_logging_framework (filename , filename_len TSRMLS_CC );
1003
1027
if (NRINI (vulnerability_management_package_detection_enabled )) {
1004
1028
nr_execute_handle_package (filename );
0 commit comments