Skip to content

Commit 9514a6f

Browse files
committed
feat(agent): Adds package supportability metric
1 parent 547ff56 commit 9514a6f

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

agent/fw_drupal.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "util_memory.h"
2121
#include "util_strings.h"
2222

23+
#define PHP_PACKAGE_NAME "drupal/drupal"
24+
2325
/*
2426
* Set the Web Transaction (WT) name to "(cached page)"
2527
*
@@ -879,4 +881,15 @@ void nr_drupal_enable(TSRMLS_D) {
879881
nr_php_user_function_add_declared_callback(
880882
NR_PSTR("drupal_http_request"), nr_drupal_replace_http_request TSRMLS_CC);
881883
#endif
884+
885+
if (NRINI(vulnerability_management_package_detection_enabled)) {
886+
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
887+
PHP_PACKAGE_VERSION_UNKNOWN);
888+
}
889+
890+
nr_fw_support_add_package_supportability_metric(
891+
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
892+
nr_php_packages_get_package(NRPRG(txn)->php_packages,
893+
PHP_PACKAGE_NAME));
894+
882895
}

agent/fw_laminas3.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "util_logging.h"
1414
#include "util_memory.h"
1515

16+
#define PHP_PACKAGE_NAME "laminas/laminas-mvc"
17+
1618
/*
1719
* Laminas is a rebranding of Zend, but the logic remains the same,
1820
* it is simply a name change and corresponds directly to Zend 3.x.
@@ -163,7 +165,11 @@ void nr_laminas3_enable(TSRMLS_D) {
163165
nr_laminas3_name_the_wt TSRMLS_CC);
164166

165167
if (NRINI(vulnerability_management_package_detection_enabled)) {
166-
nr_txn_add_php_package(NRPRG(txn), "laminas/laminas-mvc",
168+
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
167169
PHP_PACKAGE_VERSION_UNKNOWN);
168170
}
171+
nr_fw_support_add_package_supportability_metric(
172+
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
173+
nr_php_packages_get_package(NRPRG(txn)->php_packages,
174+
PHP_PACKAGE_NAME));
169175
}

agent/fw_symfony4.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "fw_support.h"
1111
#include "fw_symfony_common.h"
1212

13+
#define PHP_PACKAGE_NAME "symfony/http-kernel"
14+
1315
NR_PHP_WRAPPER(nr_symfony4_exception) {
1416
int priority = nr_php_error_get_priority(E_ERROR);
1517
zval* event = NULL;
@@ -277,7 +279,12 @@ void nr_symfony4_enable(TSRMLS_D) {
277279
#endif
278280

279281
if (NRINI(vulnerability_management_package_detection_enabled)) {
280-
nr_txn_add_php_package(NRPRG(txn), "symfony/http-kernel",
282+
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
281283
PHP_PACKAGE_VERSION_UNKNOWN);
282284
}
285+
286+
nr_fw_support_add_package_supportability_metric(
287+
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
288+
nr_php_packages_get_package(NRPRG(txn)->php_packages,
289+
PHP_PACKAGE_NAME));
283290
}

agent/fw_yii.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "util_memory.h"
1515
#include "util_strings.h"
1616

17+
#define PHP_PACKAGE_NAME "yiisoft/yii2"
1718
/*
1819
* Yii1: Set the web transaction name from the controllerId + actionId combo.
1920
*
@@ -221,4 +222,14 @@ void nr_yii2_enable(TSRMLS_D) {
221222
nr_php_wrap_user_function(NR_PSTR("yii\\base\\ErrorHandler::logException"),
222223
nr_yii2_error_handler_wrapper TSRMLS_CC);
223224
#endif
225+
226+
if (NRINI(vulnerability_management_package_detection_enabled)) {
227+
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
228+
PHP_PACKAGE_VERSION_UNKNOWN);
229+
}
230+
231+
nr_fw_support_add_package_supportability_metric(
232+
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
233+
nr_php_packages_get_package(NRPRG(txn)->php_packages,
234+
PHP_PACKAGE_NAME));
224235
}

agent/lib_doctrine2.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "php_call.h"
1717
#include "lib_doctrine2.h"
1818

19+
#define PHP_PACKAGE_NAME "doctrine/orm"
20+
1921
/*
2022
* This answers the somewhat complicated question of whether we should
2123
* instrument DQL, which is dependent on the input query setting as well as SQL
@@ -106,7 +108,11 @@ void nr_doctrine2_enable(TSRMLS_D) {
106108
#endif /* OAPI */
107109

108110
if (NRINI(vulnerability_management_package_detection_enabled)) {
109-
nr_txn_add_php_package(NRPRG(txn), "doctrine/orm",
111+
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
110112
PHP_PACKAGE_VERSION_UNKNOWN);
111113
}
114+
nr_fw_support_add_package_supportability_metric(
115+
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
116+
nr_php_packages_get_package(NRPRG(txn)->php_packages,
117+
PHP_PACKAGE_NAME));
112118
}

agent/lib_guzzle4.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include "util_logging.h"
3434
#include "util_memory.h"
3535

36+
#define PHP_PACKAGE_NAME "guzzlehttp/guzzle"
37+
3638
/*
3739
* We rely on the const correctness of certain Zend functions that weren't
3840
* const correct before 5.3 and/or 5.4: since Guzzle 4 requires 5.4.0 anyway,
@@ -520,9 +522,14 @@ void nr_guzzle4_enable(TSRMLS_D) {
520522
nr_guzzle_client_construct TSRMLS_CC);
521523

522524
if (NRINI(vulnerability_management_package_detection_enabled)) {
523-
nr_txn_add_php_package(NRPRG(txn), "guzzlehttp/guzzle",
525+
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
524526
PHP_PACKAGE_VERSION_UNKNOWN);
525527
}
528+
529+
nr_fw_support_add_package_supportability_metric(
530+
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
531+
nr_php_packages_get_package(NRPRG(txn)->php_packages,
532+
PHP_PACKAGE_NAME));
526533
}
527534

528535
void nr_guzzle4_minit(TSRMLS_D) {

0 commit comments

Comments
 (0)