connormcd / audit_utility

Automatic generator for the typical audit triggers we have on Oracle tables with lots of options
51 stars 20 forks source link

Improve IP Address Capture #7

Closed juliusbsimon closed 2 years ago

juliusbsimon commented 3 years ago

For systems behind proxies the IP address will usually by the proxy IP. This applies to anyone using APEX and ORDS.

The following can be used instead.

l_headers(l_idx).host := nvl(NVL(owa_util.get_cgi_env('X-Forwarded-For'),OWA_UTIL.get_cgi_env('REMOTE_ADDR')),sys_context('userenv','host'));

mortenbra commented 3 years ago

The COALESCE function is perfect for code like this. It returns the first non-null value, and it doesn't even have to evaluate/execute all the options if a non-null value is found. It's both faster and easier to read.

l_headers(l_idx).host := coalesce(owa_util.get_cgi_env('X-Forwarded-For'), owa_util.get_cgi_env('REMOTE_ADDR'), sys_context('userenv','host'));

connormcd commented 2 years ago

Added to V2 of the audit tool