Skip to content

Commit

Permalink
feat(agent): Adds package supportability metric
Browse files Browse the repository at this point in the history
  • Loading branch information
mfulb committed Sep 19, 2024
1 parent 547ff56 commit 9514a6f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 4 deletions.
13 changes: 13 additions & 0 deletions agent/fw_drupal.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "util_memory.h"
#include "util_strings.h"

#define PHP_PACKAGE_NAME "drupal/drupal"

/*
* Set the Web Transaction (WT) name to "(cached page)"
*
Expand Down Expand Up @@ -879,4 +881,15 @@ void nr_drupal_enable(TSRMLS_D) {
nr_php_user_function_add_declared_callback(
NR_PSTR("drupal_http_request"), nr_drupal_replace_http_request TSRMLS_CC);
#endif

if (NRINI(vulnerability_management_package_detection_enabled)) {
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
PHP_PACKAGE_VERSION_UNKNOWN);
}

nr_fw_support_add_package_supportability_metric(
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
nr_php_packages_get_package(NRPRG(txn)->php_packages,
PHP_PACKAGE_NAME));

}
8 changes: 7 additions & 1 deletion agent/fw_laminas3.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "util_logging.h"
#include "util_memory.h"

#define PHP_PACKAGE_NAME "laminas/laminas-mvc"

/*
* Laminas is a rebranding of Zend, but the logic remains the same,
* it is simply a name change and corresponds directly to Zend 3.x.
Expand Down Expand Up @@ -163,7 +165,11 @@ void nr_laminas3_enable(TSRMLS_D) {
nr_laminas3_name_the_wt TSRMLS_CC);

if (NRINI(vulnerability_management_package_detection_enabled)) {
nr_txn_add_php_package(NRPRG(txn), "laminas/laminas-mvc",
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
PHP_PACKAGE_VERSION_UNKNOWN);
}
nr_fw_support_add_package_supportability_metric(
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
nr_php_packages_get_package(NRPRG(txn)->php_packages,
PHP_PACKAGE_NAME));
}
9 changes: 8 additions & 1 deletion agent/fw_symfony4.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "fw_support.h"
#include "fw_symfony_common.h"

#define PHP_PACKAGE_NAME "symfony/http-kernel"

NR_PHP_WRAPPER(nr_symfony4_exception) {
int priority = nr_php_error_get_priority(E_ERROR);
zval* event = NULL;
Expand Down Expand Up @@ -277,7 +279,12 @@ void nr_symfony4_enable(TSRMLS_D) {
#endif

if (NRINI(vulnerability_management_package_detection_enabled)) {
nr_txn_add_php_package(NRPRG(txn), "symfony/http-kernel",
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
PHP_PACKAGE_VERSION_UNKNOWN);
}

nr_fw_support_add_package_supportability_metric(
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
nr_php_packages_get_package(NRPRG(txn)->php_packages,
PHP_PACKAGE_NAME));
}
11 changes: 11 additions & 0 deletions agent/fw_yii.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "util_memory.h"
#include "util_strings.h"

#define PHP_PACKAGE_NAME "yiisoft/yii2"
/*
* Yii1: Set the web transaction name from the controllerId + actionId combo.
*
Expand Down Expand Up @@ -221,4 +222,14 @@ void nr_yii2_enable(TSRMLS_D) {
nr_php_wrap_user_function(NR_PSTR("yii\\base\\ErrorHandler::logException"),
nr_yii2_error_handler_wrapper TSRMLS_CC);
#endif

if (NRINI(vulnerability_management_package_detection_enabled)) {
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
PHP_PACKAGE_VERSION_UNKNOWN);
}

nr_fw_support_add_package_supportability_metric(
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
nr_php_packages_get_package(NRPRG(txn)->php_packages,
PHP_PACKAGE_NAME));
}
8 changes: 7 additions & 1 deletion agent/lib_doctrine2.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "php_call.h"
#include "lib_doctrine2.h"

#define PHP_PACKAGE_NAME "doctrine/orm"

/*
* This answers the somewhat complicated question of whether we should
* instrument DQL, which is dependent on the input query setting as well as SQL
Expand Down Expand Up @@ -106,7 +108,11 @@ void nr_doctrine2_enable(TSRMLS_D) {
#endif /* OAPI */

if (NRINI(vulnerability_management_package_detection_enabled)) {
nr_txn_add_php_package(NRPRG(txn), "doctrine/orm",
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
PHP_PACKAGE_VERSION_UNKNOWN);
}
nr_fw_support_add_package_supportability_metric(
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
nr_php_packages_get_package(NRPRG(txn)->php_packages,
PHP_PACKAGE_NAME));
}
9 changes: 8 additions & 1 deletion agent/lib_guzzle4.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "util_logging.h"
#include "util_memory.h"

#define PHP_PACKAGE_NAME "guzzlehttp/guzzle"

/*
* We rely on the const correctness of certain Zend functions that weren't
* const correct before 5.3 and/or 5.4: since Guzzle 4 requires 5.4.0 anyway,
Expand Down Expand Up @@ -520,9 +522,14 @@ void nr_guzzle4_enable(TSRMLS_D) {
nr_guzzle_client_construct TSRMLS_CC);

if (NRINI(vulnerability_management_package_detection_enabled)) {
nr_txn_add_php_package(NRPRG(txn), "guzzlehttp/guzzle",
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
PHP_PACKAGE_VERSION_UNKNOWN);
}

nr_fw_support_add_package_supportability_metric(
NRPRG(txn), PHP_PACKAGE_NAME, NULL,
nr_php_packages_get_package(NRPRG(txn)->php_packages,
PHP_PACKAGE_NAME));
}

void nr_guzzle4_minit(TSRMLS_D) {
Expand Down

0 comments on commit 9514a6f

Please sign in to comment.