netbox icon indicating copy to clipboard operation
netbox copied to clipboard

LDAP authentication logging in DEBUG by default

Open niamtokik opened this issue 6 years ago • 5 comments

  • Python version: 3.7.3
  • NetBox version: 2.9.3
  • Debian: 10.6

During deployment, the LDAP authentication logging feature present in netbox/netbox/authentication.pyis set by default to DEBUG. This can be problematic in different context, in particular in production environment. In particularly dynamic environment with many users, it can make the different log files growing exponentially.

Steps to Reproduce

  1. Run netbox with LDAP backend support
  2. Logs files will increase in size when someone will connect
  3. Too many information are printed by default with DEBUG mode

Expected Behavior

By default, the application should not be in DEBUG mode, but more in INFO or WARNING, except if a "switch" could be easily modified.

I have made a quick modification there: https://github.com/niamtokik/netbox/tree/authentication-debug-logging-removal

Observed Behavior

  • Logging files growing exponentially.
  • Too many information logged

niamtokik avatar Sep 30 '20 14:09 niamtokik

See also #5192, #5194

glennmatthews avatar Sep 30 '20 14:09 glennmatthews

This issue managed to create 10GB+ syslog files on our server in a matter of an hour or 2... with just 1 person working on documenting parts of our network. Doing a quick analysis of one of these files showed large entries of LDAP search results, sometimes being written to the log 20k+ times per second. The lines all indicated gunicorn was the source and most of them started with search_s(

@glennmatthews - Thanks for finding this... I knew something had its logging set in debug mode, but I couldn't figure out where the setting was.

n0creativity avatar Sep 30 '20 22:09 n0creativity

The lines all indicated gunicorn was the source and most of them started with search_s(

it's probably due to the DEBUG level used in LDAP authentication part. This snippet use another handler to log message, and should be configured to send them to stdin or stderr by default.

niamtokik avatar Oct 01 '20 06:10 niamtokik

@niamtokik Were you going to commit your changes as a PR? If not, I'll snap it up...

stuntguy3000 avatar Oct 01 '20 10:10 stuntguy3000

Were you going to commit your changes as a PR? If not, I'll snap it up...

Yes, I will create the PR right now.

niamtokik avatar Oct 01 '20 15:10 niamtokik