Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ip header parsing/header reporting #2503

Merged
merged 5 commits into from
Feb 19, 2024
Merged

Conversation

cataphract
Copy link
Contributor

@cataphract cataphract commented Feb 2, 2024

See APPSEC-51370 APPSEC-51531

Description

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2024

Codecov Report

Merging #2503 (4a96aa9) into master (60100d9) will increase coverage by 1.99%.
The diff coverage is 90.59%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2503      +/-   ##
============================================
+ Coverage     76.71%   78.71%   +1.99%     
  Complexity      267      267              
============================================
  Files           138      112      -26     
  Lines         17641    13459    -4182     
  Branches       1034        0    -1034     
============================================
- Hits          13533    10594    -2939     
+ Misses         3571     2865     -706     
+ Partials        537        0     -537     
Flag Coverage Δ
appsec-extension ?
tracer-extension 78.66% <90.59%> (-0.03%) ⬇️
tracer-integrations 79.49% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
ext/configuration.c 78.46% <ø> (ø)
ext/configuration.h 100.00% <ø> (ø)
ext/request_hooks.c 93.24% <100.00%> (ø)
ext/user_request.c 14.40% <0.00%> (-0.36%) ⬇️
ext/ip_extraction.c 95.41% <93.75%> (-1.87%) ⬇️

... and 26 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60100d9...4a96aa9. Read the comment docs.

@cataphract cataphract changed the title Collect X-Amzn-Trace-Id Change ip header parsing/header reporting Feb 5, 2024
@cataphract cataphract force-pushed the glopes/x-amzn-trace-id branch 2 times, most recently from f94a7e2 to ce70294 Compare February 5, 2024 11:57
memcpy(out, &cur, sizeof *out);
return EXTRACT_SUCCESS_PUBLIC;
}
// else is private
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the previous conditional is readable enough that this comment is not adding anything

@@ -17,6 +17,7 @@
#include <arpa/inet.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We manually keep this script aligned with ext/ip_extraction.c so I think you should add this new header there as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm is there any reason to have this duplicated rather than in only one place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC when we implemented this we were still in separate repositories and APM needs to collect the client IP using the same strategy when ASM is disabled but DD_TRACE_CLIENT_IP_ENABLED is set to true. Feel free to change it to a common implementation.

@cataphract cataphract requested a review from a team as a code owner February 8, 2024 13:42
@cataphract cataphract force-pushed the glopes/x-amzn-trace-id branch 2 times, most recently from 3b09812 to f2c81d0 Compare February 8, 2024 15:32
@cataphract cataphract requested a review from a team as a code owner February 9, 2024 15:28
@pr-commenter
Copy link

pr-commenter bot commented Feb 9, 2024

Benchmarks

Benchmark execution time: 2024-02-19 15:07:17

Comparing candidate commit cb94096 in PR branch glopes/x-amzn-trace-id with baseline commit 60100d9 in branch master.

Some scenarios are present only in baseline or only in candidate runs. If you didn't create or remove some scenarios in your branch, this maybe a sign of crashed benchmarks 💥💥💥
Check Gitlab CI job log to find if any benchmark has crashed.

Scenarios present only in baseline:

  • BM_TeaSapiSpindown
  • BM_TeaSapiSpinup

Found 0 performance improvements and 0 performance regressions! Performance is the same for 42 metrics, 50 unstable metrics.

@@ -89,6 +91,12 @@ static void dd_trace_load_symbols(void)
dlerror()); // NOLINT(concurrency-mt-unsafe)
}

_ddtrace_ip_extraction_find = dlsym(handle, "ddtrace_ip_extraction_find");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the backlog but we're reaching the point where it would be useful to have some macros to do this and generate the relevant passthrough functions as well.

@@ -418,11 +458,11 @@ static bool dd_is_private_v6(const struct in6_addr *addr) {
static const struct {
union {
struct in6_addr base;
uint64_t base_i[2];
unsigned __int128 base_i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe @bwoebi had some concerns about the __int128:

#1621 (comment)

@@ -123,12 +123,17 @@ PHP_FUNCTION(DDTrace_UserRequest_notify_commit)
}
}

if (status < 100 || status > 599) {
zend_type_error("Status code must be between 100 and 599");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have zend_value_error here and polyfill it in compatibility.h with #define zend_value_error zend_type_error - this was added with PHP 8 and existing "misuses" of TypeError replaced by it in php-src.

Copy link
Contributor

@Anilm3 Anilm3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If @bwoebi has no more concerns, lgtm

Copy link
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, looks good to me too now :-)

@cataphract cataphract merged commit 8e82b6b into master Feb 19, 2024
588 of 594 checks passed
@cataphract cataphract deleted the glopes/x-amzn-trace-id branch February 19, 2024 15:52
@github-actions github-actions bot added this to the 0.98.0 milestone Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants