Skip to content

Commit

Permalink
feat(agent): remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
hahuja2 committed Aug 16, 2024
1 parent ec10d19 commit b1eafdc
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 95 deletions.
1 change: 0 additions & 1 deletion agent/fw_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ extern void nr_phpunit_enable(TSRMLS_D);
extern void nr_predis_enable(TSRMLS_D);
extern void nr_zend_http_enable(TSRMLS_D);
extern void nr_monolog_enable(TSRMLS_D);
extern void nr_get_package_information(TSRMLS_D);

/* Vulnerability Management Packages */
extern void nr_drupal_version(void);
Expand Down
50 changes: 0 additions & 50 deletions agent/fw_symfony4.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,56 +215,6 @@ NR_PHP_WRAPPER(nr_symfony4_name_the_wt) {
}
NR_PHP_WRAPPER_END

void nr_get_package_information() {
zval retval;
int result = -1;
char* func_string
= ""
"(function() {"
" try {"
" if (class_exists('Composer\\InstalledVersions')) {"
" if (method_exists('Composer\\InstalledVersions', "
" 'getInstalledPackages') && method_exists('Composer\\InstalledVersions', "
" 'getVersion')) {"
" return Composer\\InstalledVersions::getInstalledPackages();"
" } else {"
" return NULL;"
" }"
" } else {"
" return NULL;"
" }"
" } catch (Exception $e) {"
" return NULL;"
" }"
"})();";

char* getVersion = "Composer\\InstalledVersions::getVersion(\"%s\");";
zend_eval_string(func_string, &retval, "Retrieve symfony package name");

if (result == SUCCESS) {
if (Z_TYPE(retval) == IS_ARRAY) {
zval* value;
char buf[512];
int result2;
zval retval2;
char* version;
(void)version;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(retval), value) {
if (Z_TYPE_P(value) == IS_STRING) {
snprintf(buf, sizeof(buf), getVersion, Z_STRVAL_P(value));
result2 = zend_eval_string(buf, &retval2, "Retrieve symfony Version");
if (SUCCESS == result2) {
if (nr_php_is_zval_valid_string(&retval2)) {
version = Z_STRVAL(retval2);
}
}
}
} ZEND_HASH_FOREACH_END();
}
zval_dtor(&retval);
}
}

void nr_symfony4_enable(TSRMLS_D) {
/*
* We set the path to 'unknown' to prevent having to name routing errors.
Expand Down
33 changes: 0 additions & 33 deletions agent/php_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,36 +1229,3 @@ bool nr_php_function_is_static_method(const zend_function* func) {

return (func->common.fn_flags & ZEND_ACC_STATIC);
}

nr_composer_classification_t nr_composer_special(
const char* filename TSRMLS_DC) {
NR_UNUSED_TSRMLS;

if (nr_strcaseidx(filename, "vendor/composer/") >= 0) {
zval retval;
int result = -1;
char* func_string
= ""
"(function() {"
" try {"
" if (file_exists('vendor/composer/installed.php')) {"
" return 'SUCCESS';"
" } else {"
" return NULL;"
" }"
" } catch (exception $e) {"
" return NULL;"
" }"
"})();";
result = zend_eval_string(func_string, &retval, "check if file exists" TSRMLS_CC);
if (result == SUCCESS) {
NR_PHP_PROCESS_GLOBALS(composer_exists) = 1;
return FILE_EXISTS;
} else {
NR_PHP_PROCESS_GLOBALS(composer_exists) = 0;
return FILE_DOES_NOT_EXIST;
}
}

return FILE_DOES_NOT_EXIST;
}
3 changes: 0 additions & 3 deletions agent/php_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -847,9 +847,6 @@ extern zval* nr_php_parse_str(const char* str, size_t len TSRMLS_DC);
*/
extern bool nr_php_function_is_static_method(const zend_function* func);

extern nr_composer_classification_t nr_composer_special(
const char* filename TSRMLS_DC);

/*
* Purpose : Get the execution data for the current PHP environment.
*
Expand Down
7 changes: 0 additions & 7 deletions agent/php_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ typedef enum {
typedef nr_framework_classification_t (*nr_framework_special_fn_t)(
const char* filename TSRMLS_DC);

typedef enum {
FILE_EXISTS, /* The file we are looking for exists */
FILE_DOES_NOT_EXIST, /* The file we are looking for does not exist */
} nr_composer_classification_t;
typedef nr_composer_classification_t (*nr_composer_special_fn_t)(
const char* filename);

/*
* Version specific metadata that we have to gather before we call the original
* execute_ex handler, as different versions of PHP behave differently in terms
Expand Down
1 change: 0 additions & 1 deletion agent/php_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ typedef struct _nrphpglobals_t {
int preload_framework_library_detection; /* Enables preloading framework and
library detection */
char* docker_id; /* 64 byte hex docker ID parsed from /proc/self/mountinfo */
int composer_exists; /* Check if composer exists*/

/* Original PHP callback pointer contents */
nrphperrfn_t orig_error_cb;
Expand Down

0 comments on commit b1eafdc

Please sign in to comment.