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

redo IP parsing for changed requirements #362

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

irshadaj
Copy link
Contributor

  • Return all IPs in the X-Forwarded-For header
  • Always return Hostname field, whether or not the X-Forwarded-For is populated
  • Return all of these as a single string

The result of the parseUserIP function will be in the format:
"X-Forwarded-For: 192.168.1.1:8080,192.168.1.2,192.168.1.3; Hostname: www.google.com"

@irshadaj irshadaj merged commit 2a14ff5 into populate-audit-log-fields Jan 29, 2024
2 of 3 checks passed
@irshadaj irshadaj deleted the ip_parsing branch January 29, 2024 21:59
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2024
Copy link
Contributor

@computator computator left a comment

Choose a reason for hiding this comment

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

Added comments for a few small issues.

I believe the current code is fine with IPv6 but perhaps the tests should incorporate some IPv6 addresses to prevent future regressions.

If it's helpful, the 2001:db8::/32 network for IPv6 and the 192.0.2.0/24 network for IPv4 are reserved for documentation and tests like this. https://en.wikipedia.org/wiki/Reserved_IP_addresses

The IPv6 format for RemoteAddr will be like [2001:db8::abcd:45]:12345 (I.E. URL Format. Verified here) and in X-Forwarded-For it will usually just be plain addresses such as: X-Forwarded-For: 192.0.2.25, 2001:db8::efg:23, 192.0.2.84

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants