-
Notifications
You must be signed in to change notification settings - Fork 375
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
[APPSEC-7946] Update the client IP extraction resolution base on the latest RFC. #2665
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2665 +/- ##
==========================================
- Coverage 98.07% 98.06% -0.01%
==========================================
Files 1166 1168 +2
Lines 63832 63872 +40
Branches 2849 2856 +7
==========================================
+ Hits 62605 62638 +33
- Misses 1227 1234 +7
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
def set_client_ip_tag(span, headers: nil, remote_ip: nil) | ||
return unless configuration.enabled | ||
|
||
set_client_ip_tag!(span, headers: headers, remote_ip: remote_ip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to check on something internally for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few notes :)
def self.from_hash: (untyped hash) -> HashHeaderCollection | ||
end | ||
|
||
class HashHeaderCollection < HeaderCollection | ||
def initialize: (untyped hash) -> void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I guess the hash
could be ::Hash
? Although any duck type of Hash
that provides each_pair
would work as well I guess :) (I don't know if rbs provides such duck types or not)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any duck type of Hash that provides each_pair would work as well I guess :) (I don't know if rbs provides such duck types or not)
RBS provides interfaces! I have yet to make use of those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
f2be200
to
fc3877b
Compare
- Update the list of HTTP headers to look for IP - Add support to parsing HTTP IP Headers with multiple IP addresses - Update specs - Change Tracing::ClientIp module methods visibility
fc3877b
to
85ee26e
Compare
…:AddressFamilyError" **What does this PR do?**: This PR fixes a bug in the recently-introduced `IPAddr` module. During review of #2665 the `IPAddr` module was introduced, and while experimenting with the steep type checker, I noticed there was a collision between our `IPAddr` module and the `IPAddr` module where we were looking for execptions. I'm not sure if this would happen in production, since we always created an `IPAddr` instance with an IP, never a specific `family`, but let's fix this anyway. **Motivation**: Less bugs! **Additional Notes**: (N/A) **How to test the change?**: This module is a backport of `IPAddr` to older Rubies. Previously, we only tested it indirectly. I added a minimal test to validate this change.
What does this PR do?
Tracing::ClientIp
module methods visibilityDatadog::Core::Utils::Network
module. Main functionality is parsing and extraction IP information for HTTP request headersrbs
filesI had to vendor the code from IPAddr default gem into the re; Because the ruby version below 2.5 does not have the methods:
private?
,link_local?
, andloopback?
That code should be temporary until we deprecated those old ruby versions
Motivation
Fixing a bug found with the IP extraction resolution logic. Not supporting an HTTP header with multiple IPs MDN
Additional Notes
How to test the change?
CI