|
| 1 | +#include "csec_metadata.h" |
| 2 | +#include "util_strings.h" |
| 3 | +#include "php_hash.h" |
| 4 | +#include "php_api_internal.h" |
| 5 | + |
| 6 | +static void nr_csec_php_add_assoc_string_const(zval* arr, |
| 7 | + const char* key, |
| 8 | + const char* value) { |
| 9 | + char* val = NULL; |
| 10 | + |
| 11 | + if (NULL == arr || NULL == key || NULL == value) { |
| 12 | + return; |
| 13 | + } |
| 14 | + |
| 15 | + val = nr_strdup(value); |
| 16 | + nr_php_add_assoc_string(arr, key, val); |
| 17 | + nr_free(val); |
| 18 | +} |
| 19 | + |
| 20 | +#ifdef TAGS |
| 21 | +void zif_newrelic_get_security_metadata(void); /* ctags landing pad only */ |
| 22 | +void newrelic_get_security_metadata(void); /* ctags landing pad only */ |
| 23 | +#endif |
| 24 | +PHP_FUNCTION(newrelic_get_security_metadata) { |
| 25 | + |
| 26 | + NR_UNUSED_RETURN_VALUE; |
| 27 | + NR_UNUSED_RETURN_VALUE_PTR; |
| 28 | + NR_UNUSED_RETURN_VALUE_USED; |
| 29 | + NR_UNUSED_THIS_PTR; |
| 30 | + NR_UNUSED_EXECUTE_DATA; |
| 31 | + |
| 32 | + array_init(return_value); |
| 33 | + |
| 34 | + nr_csec_php_add_assoc_string_const(return_value, KEY_ENTITY_NAME, nr_app_get_entity_name(NRPRG(app))); |
| 35 | + nr_csec_php_add_assoc_string_const(return_value, KEY_ENTITY_TYPE, nr_app_get_entity_type(NRPRG(app))); |
| 36 | + nr_csec_php_add_assoc_string_const(return_value, KEY_ENTITY_GUID, nr_app_get_entity_guid(NRPRG(app))); |
| 37 | + nr_csec_php_add_assoc_string_const(return_value, KEY_HOSTNAME, nr_app_get_host_name(NRPRG(app))); |
| 38 | + nr_csec_php_add_assoc_string_const(return_value, KEY_LICENSE, NRPRG(license).value); |
| 39 | + |
| 40 | + if (NRPRG(app)) { |
| 41 | + nr_csec_php_add_assoc_string_const(return_value, KEY_AGENT_RUN_ID, NRPRG(app)->agent_run_id); |
| 42 | + nr_csec_php_add_assoc_string_const(return_value, KEY_ACCOUNT_ID, NRPRG(app)->account_id); |
| 43 | + nr_csec_php_add_assoc_string_const(return_value, KEY_PLICENSE, NRPRG(app)->plicense); |
| 44 | + int high_security = NRPRG(app)->info.high_security; |
| 45 | + add_assoc_long(return_value, KEY_HIGH_SECURITY, (long)high_security); |
| 46 | + } |
| 47 | + |
| 48 | +} |
0 commit comments