Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 6 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ jobs:
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

- name: Provision agent's build dependencies
if: ${{ matrix.language == 'c-cpp' }}
run: |
sudo apt-get update
sudo apt-get install -y libprotobuf-c-dev protobuf-c-compiler

- name: Build
run: |
make ${{ matrix.language == 'go' && 'daemon' || 'agent' }}
Expand Down
33 changes: 12 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ bin/:
#

.PHONY: axiom
axiom: vendor
axiom: protobuf-c
$(MAKE) -C axiom

#
Expand All @@ -238,15 +238,15 @@ axiom: vendor
# TESTARGS =

.PHONY: axiom-tests
axiom-tests: vendor
axiom-tests: protobuf-c
$(MAKE) -C axiom tests

.PHONY: axiom-check axiom-run-tests
axiom-check axiom-run-tests: vendor axiom/tests/cross_agent_tests
axiom-check axiom-run-tests: protobuf-c axiom/tests/cross_agent_tests
$(MAKE) -C axiom run_tests

.PHONY: axiom-valgrind
axiom-valgrind: vendor axiom/tests/cross_agent_tests
axiom-valgrind: protobuf-c axiom/tests/cross_agent_tests
$(MAKE) -C axiom valgrind

.PHONY: tests
Expand Down Expand Up @@ -279,9 +279,7 @@ axiom-clean:
daemon-protobuf: daemon/internal/newrelic/infinite_tracing/com_newrelic_trace_v1/v1.pb.go

daemon/internal/newrelic/infinite_tracing/com_newrelic_trace_v1/v1.pb.go: protocol/infinite_tracing/v1.proto
$(MAKE) vendor # Only build vendor stuff if v1.proto has changed. Otherwise
# this rule will be triggered every time the daemon is built.
$(VENDOR_PREFIX)/bin/protoc \
protoc \
-I=./protocol/infinite_tracing \
--go_out="paths=source_relative,plugins=grpc:daemon/internal/newrelic/infinite_tracing/com_newrelic_trace_v1" \
protocol/infinite_tracing/v1.proto
Expand Down Expand Up @@ -403,7 +401,7 @@ coverage:
#

.PHONY: clean
clean: agent-clean axiom-clean daemon-clean package-clean coverage-clean vendor-clean
clean: agent-clean axiom-clean daemon-clean package-clean coverage-clean
rm -rf releases
rm -f agent/newrelic.map agent/LicenseData/license_errors.txt

Expand Down Expand Up @@ -441,21 +439,14 @@ lasp-test-all:
$(MAKE) lasp-test SUITE_LASP=suite-random-3

#
# Vendored libraries
# Check for protobuf-c (HAVE_PROTOBUF_C):
# - axiom build needs protoc-c (protobuf-c-compiler)
# - agent build needs protobuf-c static library (protobuf-c-devel)
#
export GIT

.PHONY: vendor vendor-clean
.PHONY: protobuf-c
protobuf-c:
ifeq (0,$(HAVE_PROTOBUF_C))
vendor:
$(MAKE) -C vendor all

vendor-clean:
$(MAKE) -C vendor clean
else
vendor: ;

vendor-clean: ;
$(error Build dependency 'protobuf-c' not found.)
endif

#
Expand Down
41 changes: 41 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ by e-mailing [[email protected]](mailto:[email protected]).
* [PCRE](#pcre)
* [PHP](#php)
* [Portable OpenSSH](#portable-openssh)
* [protobuf-c](#protobuf-c)
* [TSRM](#tsrm)
* [Symfony](#symfony)

Expand Down Expand Up @@ -895,6 +896,46 @@ under
*/
```

## protobuf-c

This product includes [protobuf-c]https://github.com/protobuf-c/protobuf-c) ([v1.3.3](https://github.com/protobuf-c/protobuf-c/tree/v1.3.3)),
distributed under the [protobuf-c license](https://github.com/protobuf-c/protobuf-c/blob/v1.3.3/LICENSE):

```
Copyright (c) 2008-2016, Dave Benson and the protobuf-c authors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The code generated by the protoc-gen-c code generator and by the
protoc-c compiler is owned by the owner of the input files used when
generating it. This code is not standalone and requires a support
library to be linked with it. This support library is covered by the
above license.
```

## TSRM

This product includes source derived from
Expand Down
3 changes: 1 addition & 2 deletions agent/fw_drupal.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,7 @@ static void nr_drupal_wrap_hook_within_module_invoke_all(
*/
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
zval* curr_hook
= (zval*)nr_stack_get_top(&NRPRG(drupal_invoke_all_hooks));
zval* curr_hook = (zval*)nr_stack_get_top(&NRPRG(drupal_invoke_all_hooks));
if (!nr_php_is_zval_non_empty_string(curr_hook)) {
nrl_verbosedebug(NRL_FRAMEWORK,
"%s: cannot extract hook name from global stack",
Expand Down
61 changes: 30 additions & 31 deletions agent/fw_drupal8.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ NR_PHP_WRAPPER(nr_drupal_exception) {

if (NR_SUCCESS
!= nr_php_error_record_exception(NRPRG(txn), exception, priority, true,
NULL,
&NRPRG(exception_filters))) {
NULL, &NRPRG(exception_filters))) {
nrl_verbosedebug(NRL_TXN, "Drupal: unable to record exception");
}

Expand Down Expand Up @@ -134,12 +133,12 @@ static void nr_drupal8_add_method_callback(const zend_class_entry* ce,
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
static void nr_drupal8_add_method_callback_before_after_clean(
const zend_class_entry* ce,
const char* method,
size_t method_len,
nrspecialfn_t before_callback,
nrspecialfn_t after_callback,
nrspecialfn_t clean_callback) {
const zend_class_entry* ce,
const char* method,
size_t method_len,
nrspecialfn_t before_callback,
nrspecialfn_t after_callback,
nrspecialfn_t clean_callback) {
zend_function* function = NULL;

if (NULL == ce) {
Expand All @@ -164,13 +163,13 @@ static void nr_drupal8_add_method_callback_before_after_clean(
nr_php_class_entry_name(ce), NRSAFELEN(method_len), method);

nr_php_wrap_user_function_before_after_clean(
class_method, nr_strlen(class_method),
before_callback, after_callback, clean_callback);
class_method, nr_strlen(class_method), before_callback, after_callback,
clean_callback);

nr_free(class_method);
}
}
#endif // OAPI
#endif // OAPI

/*
* Purpose : Check if the given function or method is in the current call
Expand Down Expand Up @@ -501,8 +500,7 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with_callback) {

#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
zval* curr_hook
= (zval*)nr_stack_get_top(&NRPRG(drupal_invoke_all_hooks));
zval* curr_hook = (zval*)nr_stack_get_top(&NRPRG(drupal_invoke_all_hooks));
if (UNEXPECTED(!nr_php_is_zval_non_empty_string(curr_hook))) {
nrl_verbosedebug(NRL_FRAMEWORK,
"%s: cannot extract hook name from global stack",
Expand All @@ -515,7 +513,7 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with_callback) {
nr_drupal_hook_instrument(Z_STRVAL_P(module), Z_STRLEN_P(module),
NRPRG(drupal_invoke_all_hook),
NRPRG(drupal_invoke_all_hook_len) TSRMLS_CC);
#endif // OAPI
#endif // OAPI

leave:
NR_PHP_WRAPPER_CALL;
Expand All @@ -536,7 +534,7 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with) {
|| defined OVERWRITE_ZEND_EXECUTE_DATA
char* prev_hook = NULL;
int prev_hook_len;
#endif // not OAPI
#endif // not OAPI

(void)wraprec;

Expand All @@ -547,7 +545,7 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with) {
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
nr_php_arg_release(&hook);
#endif // OAPI
#endif // OAPI
goto leave;
}

Expand All @@ -561,7 +559,7 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with) {
= nr_strndup(Z_STRVAL_P(hook), Z_STRLEN_P(hook));
NRPRG(drupal_invoke_all_hook_len) = Z_STRLEN_P(hook);
NRPRG(check_cufa) = true;
#endif // OAPI
#endif // OAPI
callback = nr_php_arg_get(2, NR_EXECUTE_ORIG_ARGS TSRMLS_CC);

/* This instrumentation will fail if callback has already been wrapped
Expand All @@ -581,14 +579,14 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with) {
if (NULL == NRPRG(drupal_invoke_all_hook)) {
NRPRG(check_cufa) = false;
}
#endif // not OAPI
#endif // not OAPI

leave: ;
leave:;
#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO \
|| defined OVERWRITE_ZEND_EXECUTE_DATA
/* for OAPI, the _after callback handles this free */
nr_php_arg_release(&hook);
#endif // not OAPI
#endif // not OAPI
}
NR_PHP_WRAPPER_END

Expand All @@ -605,7 +603,7 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with_clean) {
nr_drupal_invoke_all_hook_stacks_pop();
}
NR_PHP_WRAPPER_END
#endif // OAPI
#endif // OAPI

/*
* Purpose : Wrap the invoke() method of the module handler instance in use.
Expand Down Expand Up @@ -642,10 +640,8 @@ NR_PHP_WRAPPER(nr_drupal8_module_handler) {
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
nr_drupal8_add_method_callback_before_after_clean(
ce, NR_PSTR("invokeallwith"),
nr_drupal94_invoke_all_with,
nr_drupal94_invoke_all_with_after,
nr_drupal94_invoke_all_with_clean);
ce, NR_PSTR("invokeallwith"), nr_drupal94_invoke_all_with,
nr_drupal94_invoke_all_with_after, nr_drupal94_invoke_all_with_clean);
#else
nr_drupal8_add_method_callback(ce, NR_PSTR("invokeallwith"),
nr_drupal94_invoke_all_with TSRMLS_CC);
Expand Down Expand Up @@ -766,14 +762,16 @@ void nr_drupal8_enable(TSRMLS_D) {
*/
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
// clang-format off
nr_php_wrap_user_function_before_after_clean(
NR_PSTR("Symfony\\Component\\HttpKernel\\EventListe"
"ner\\RouterListener::onKernelRequest"),
NR_PSTR("Symfony\\Component\\HttpKernel\\EventListener\\RouterListener::onKernelRequest"),
nr_drupal8_name_the_wt_via_symfony, NULL, NULL);
// clang-format on
#else
nr_php_wrap_user_function(NR_PSTR("Symfony\\Component\\HttpKernel\\EventListe"
"ner\\RouterListener::onKernelRequest"),
// clang-format off
nr_php_wrap_user_function(NR_PSTR("Symfony\\Component\\HttpKernel\\EventListener\\RouterListener::onKernelRequest"),
nr_drupal8_name_the_wt_via_symfony TSRMLS_CC);
// clang-format on
#endif

/*
Expand All @@ -783,9 +781,10 @@ void nr_drupal8_enable(TSRMLS_D) {
* above, but kicks in for use cases where the RouterListener is not
* involved.
*/
nr_php_wrap_user_function(NR_PSTR("Drupal\\Core\\Controller\\ControllerResolv"
"er::getControllerFromDefinition"),
// clang-format off
nr_php_wrap_user_function(NR_PSTR("Drupal\\Core\\Controller\\ControllerResolver::getControllerFromDefinition"),
nr_drupal8_name_the_wt TSRMLS_CC);
// clang-format on

/*
* ExceptionSubscribers handle Drupal errors and exceptions before
Expand Down
5 changes: 3 additions & 2 deletions agent/fw_drupal_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ nr_status_t module_invoke_all_parse_module_and_hook_from_strings(
nrl_verbosedebug(NRL_FRAMEWORK,
"%s: module len is %d; ; "
"hook='%.*s'; module_hook='%.*s'",
__func__, (int)module_len, NRSAFELEN(hook_len), NRSAFESTR(hook),
NRSAFELEN(module_hook_len), NRSAFESTR(module_hook));
__func__, (int)module_len, NRSAFELEN(hook_len),
NRSAFESTR(hook), NRSAFELEN(module_hook_len),
NRSAFESTR(module_hook));

return NR_FAILURE;
}
Expand Down
18 changes: 10 additions & 8 deletions agent/fw_drupal_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,25 @@ nr_status_t module_invoke_all_parse_module_and_hook_from_strings(
*/
void nr_drupal_headers_add(zval* arg, bool is_drupal_7 TSRMLS_DC);


#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
/*
* Purpose: Before an invoke_all style call, adds the hook to that hook states stacks
* Purpose: Before an invoke_all style call, adds the hook to that hook states
* stacks
*
* Params : 1. A zval holding a copy of the hook invoked, to be managed by the hook
* states stacks and freed by nr_drupal_invoke_all_hook_stacks_pop() after the
* invoke_all call completes
* Params : 1. A zval holding a copy of the hook invoked, to be managed by the
* hook states stacks and freed by
* nr_drupal_invoke_all_hook_stacks_pop() after the invoke_all call
* completes
*/
void nr_drupal_invoke_all_hook_stacks_push(zval* hook_copy);

/*
* Purpose: After an invoke_all style call, pops that states stack and conditionally
* pops the hook stack based on the previously popped state
* Purpose: After an invoke_all style call, pops that states stack and
* conditionally pops the hook stack based on the previously
* popped state
*/
void nr_drupal_invoke_all_hook_stacks_pop();
#endif // OAPI
#endif // OAPI

#endif /* FW_DRUPAL_COMMON_HDR */
Loading
Loading