|
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 | | - } |
| 1 | +/* |
| 2 | + * Copyright 2020 New Relic Corporation. All rights reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
14 | 5 |
|
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) { |
| 6 | +#include "csec_metadata.h" |
25 | 7 |
|
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; |
| 8 | +#include "util_memory.h" |
31 | 9 |
|
32 | | - array_init(return_value); |
| 10 | +#include "nr_axiom.h" |
| 11 | +#include "nr_agent.h" |
| 12 | +#include "nr_app.h" |
| 13 | +#include "php_includes.h" |
| 14 | +#include "php_compat.h" |
| 15 | +#include "php_newrelic.h" |
33 | 16 |
|
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); |
| 17 | +int nr_php_csec_get_metadata(nr_php_csec_metadata_t* csec_metadata) { |
| 18 | + if (NULL == csec_metadata) { |
| 19 | + return -1; |
| 20 | + } |
39 | 21 |
|
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); |
| 22 | + if (NULL == NRPRG(app)) { |
| 23 | + return -2; |
46 | 24 | } |
47 | 25 |
|
| 26 | + csec_metadata->high_security = NRPRG(app)->info.high_security; |
| 27 | + csec_metadata->entity_name = nr_strdup(nr_app_get_entity_name(NRPRG(app))); |
| 28 | + csec_metadata->entity_type = nr_strdup(nr_app_get_entity_type(NRPRG(app))); |
| 29 | + csec_metadata->entity_guid = nr_strdup(nr_app_get_entity_guid(NRPRG(app))); |
| 30 | + csec_metadata->host_name = nr_strdup(nr_app_get_host_name(NRPRG(app))); |
| 31 | + csec_metadata->agent_run_id = nr_strdup(NRPRG(app)->agent_run_id); |
| 32 | + csec_metadata->account_id = nr_strdup(NRPRG(app)->account_id); |
| 33 | + csec_metadata->license = nr_strdup(NRPRG(license).value); |
| 34 | + csec_metadata->plicense = nr_strdup(NRPRG(app)->plicense); |
| 35 | + |
| 36 | + return 0; |
48 | 37 | } |
0 commit comments