Nebo15 / logger_json

JSON logger formatter with support for Google Cloud, DataDog and other for Elixir.
https://nebo15.github.io/logger_json/
MIT License
237 stars 92 forks source link

fix x-forwarded-for returning a list of ip addresses #67

Closed btkostner closed 3 years ago

btkostner commented 3 years ago

I created a LoggerJSON.PlugUtils module to match the LoggerJSON.FormatterUtils module. I then moved the get_header/2 function into it, and moved the common (same in all plug formatters) remote_ip/1 function in it as well.

I updated the remote_ip/1 function to only return the client IP address if it was sent through a proxy. According to MDN and our System76 logs, this header can return a list of IP addresses. Datadog and Google Cloud Logger both document this field as a simple string, not a list of them.

Let me know if this module change is too much and I can undo it. As well as any changes you need. 🎊

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.9%) to 74.667% when pulling fc6cfe08c978ab89c9aa79b3e1d0f1884776d867 on btkostner:fix-forwarded-ip-header into c2512dee7880b6cecccc17093eff9e243077fba7 on Nebo15:master.

AndrewDryga commented 3 years ago

This LGTM @btkostner, thank you. Can you please rebase it so we can get it merged?

AndrewDryga commented 3 years ago

❤️ thank you