Skip to content

Commit c54e208

Browse files
committed
don't call composer when package detection is off
don't collect package info with composer api when vulnerability management package detection is disabled.
1 parent 2713cd3 commit c54e208

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

agent/lib_composer.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ static void nr_execute_handle_autoload_composer_get_packages_information(
107107
// It will only be set if the result of the eval is SUCCESS.
108108
int result = -1;
109109

110+
// nurunlikely because this should alredy be ensured by the caller
111+
if (nrunlikely(!NRINI(vulnerability_management_package_detection_enabled))) {
112+
// do nothing when collecting package information for vulnerability management is disabled
113+
return;
114+
}
115+
116+
// nurunlikely because this should alredy be ensured by the caller
117+
if (nrunlikely(!NRINI(vulnerability_management_composer_detection_enabled))) {
118+
// do nothing when use of composer to collect package info is disabled
119+
return;
120+
}
121+
110122
#if 0
111123
char* getpackagename
112124
= ""
@@ -230,10 +242,8 @@ static void nr_execute_handle_autoload_composer_get_packages_information(
230242
nrl_verbosedebug(NRL_INSTRUMENT, "package %s, version %s",
231243
NRSAFESTR(ZSTR_VAL(package_name)),
232244
NRSAFESTR(Z_STRVAL_P(package_version)));
233-
if (NRINI(vulnerability_management_package_detection_enabled)) {
234-
nr_txn_add_php_package_from_source(NRPRG(txn), NRSAFESTR(ZSTR_VAL(package_name)),
235-
NRSAFESTR(Z_STRVAL_P(package_version)), NR_PHP_PACKAGE_SOURCE_COMPOSER);
236-
}
245+
nr_txn_add_php_package_from_source(NRPRG(txn), NRSAFESTR(ZSTR_VAL(package_name)),
246+
NRSAFESTR(Z_STRVAL_P(package_version)), NR_PHP_PACKAGE_SOURCE_COMPOSER);
237247
nr_fw_support_add_package_supportability_metric(
238248
NRPRG(txn), NRSAFESTR(ZSTR_VAL(package_name)),
239249
NRSAFESTR(Z_STRVAL_P(package_version)));

agent/php_execute.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,11 @@ static void nr_execute_handle_autoload(const char* filename, const size_t filena
935935
#define AUTOLOAD_MAGIC_FILE "vendor/autoload.php"
936936
#define AUTOLOAD_MAGIC_FILE_LEN (sizeof(AUTOLOAD_MAGIC_FILE) - 1)
937937

938+
if (!NRINI(vulnerability_management_package_detection_enabled)) {
939+
// do nothing when vulnerability management package detection is disabled
940+
return;
941+
}
942+
938943
if (!NRINI(vulnerability_management_composer_detection_enabled)) {
939944
// do nothing when use of composer to collect package info is disabled
940945
return;

0 commit comments

Comments
 (0)