Skip to content

Commit b867248

Browse files
lavaroumfulb
andcommitted
only report packages that have version set
According to Composer's runtime API documentation: > If the package is being replaced or provided but is not really installed, > null will be returned as version. This means that packages without versions are not interesting because they're not really installed. -- Co-authored-by: Michael Fulbright <[email protected]>
1 parent 40fde89 commit b867248

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

agent/lib_composer.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,25 @@ static void nr_execute_handle_autoload_composer_get_packages_information(
151151
if (SUCCESS == result2) {
152152
if (nr_php_is_zval_valid_string(&retval2)) {
153153
version = Z_STRVAL(retval2);
154+
} else if (nr_php_is_zval_null(&retval2)) {
155+
nrl_verbose(NRL_INSTRUMENT,
156+
"version was IS_NULL for package %s",
157+
Z_STRVAL_P(value));
158+
version = NULL;
154159
}
155160
}
156161
}
157162
zval_dtor(&retval2);
158163
nrl_verbosedebug(NRL_INSTRUMENT, "package %s, version %s",
159164
NRSAFESTR(Z_STRVAL_P(value)), NRSAFESTR(version));
160-
if (NRINI(vulnerability_management_package_detection_enabled)) {
161-
nr_txn_add_php_package(NRPRG(txn), NRSAFESTR(Z_STRVAL_P(value)),
162-
NRSAFESTR(version));
165+
if (NULL != version) {
166+
if (NRINI(vulnerability_management_package_detection_enabled)) {
167+
nr_txn_add_php_package(NRPRG(txn), NRSAFESTR(Z_STRVAL_P(value)),
168+
NRSAFESTR(version));
169+
}
170+
nr_fw_support_add_package_supportability_metric(
171+
NRPRG(txn), NRSAFESTR(Z_STRVAL_P(value)), NRSAFESTR(version));
163172
}
164-
nr_fw_support_add_package_supportability_metric(
165-
NRPRG(txn), NRSAFESTR(Z_STRVAL_P(value)), NRSAFESTR(version));
166173
}
167174
ZEND_HASH_FOREACH_END();
168175
} else {

0 commit comments

Comments
 (0)