A script to help make OpenLDAP access logs more readable for humans and machines
Перейти к файлу
Greg Cox 0a09e3c76b Bump RPM iteration since we edited packaging 2022-02-22 18:09:23 +00:00
examples Update examples to reflect latest humanizer runs 2018-11-01 00:37:48 -04:00
ldap_access_log_humanizer Remove mozdef references 2022-01-31 21:08:07 +00:00
tests/unit-tests Remove mozdef references 2022-01-31 21:08:07 +00:00
.gitignore Add sane gitignore 2019-06-05 10:25:50 -04:00
.travis.yml Fix typo 2019-01-08 13:57:36 -05:00
LICENSE Initial commit 2018-10-26 07:07:46 -07:00
Makefile Bump RPM iteration since we edited packaging 2022-02-22 18:09:23 +00:00
README.md Remove mozdef references 2022-01-31 21:08:07 +00:00
humanizer-logrotate adding logrotate config 2019-06-07 14:47:27 -07:00
humanizer-rsyslog.conf updating argparse logic, fixing bugs and adding rsyslogd config 2019-06-07 07:39:48 -07:00
humanizer.py Remove mozdef references 2022-01-31 21:08:07 +00:00
humanizer.service adding systemd service 2019-06-04 12:52:18 -07:00
humanizer_settings.json.default Remove mozdef references 2022-01-31 21:08:07 +00:00
requirements.txt Add requests as a requirement 2019-06-05 10:00:33 -04:00
restart.sh Add a 'systemctl daemon-reload' to RPM upgrades 2022-02-22 18:09:23 +00:00
setup.py Modernize setup.py 2022-02-22 18:09:23 +00:00

README.md

ldap-access-log-humanizer

A script to help make OpenLDAP access logs more readable for humans and machines

Example


This will convert LDAP access logs in this format:

Oct 26 03:30:53 ldap.example.com slapd[11086]: conn=6832973 fd=24 ACCEPT from IP=192.168.1.1:43050 (IP=0.0.0.0:389)
Oct 26 03:30:53 ldap.example.com slapd[11086]: conn=6832973 op=0 EXT oid=1.3.6.1.4.1.1466.20037 
Oct 26 03:30:53 ldap.example.com slapd[11086]: conn=6832973 op=0 STARTTLS 
Oct 26 03:30:53 ldap.example.com slapd[11086]: conn=6832973 op=0 RESULT oid= err=0 text=  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 fd=24 TLS established tls_ssf=256 ssf=256  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=1 BIND n="uid=bind-generateusers,ou=logins,dc=example" method=128  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=1 BIND dn="uid=bind-generateusers,ou=logins,dc=example" mech=SIMPLE ssf=0  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=1 RESULT tag=97 err=0 text=  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=2 SRCH base="ou=groups,dc=example" scope=2 deref=0 filter="(cn=group_name)"  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=2 SRCH attr=memberUid  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=2 SEARCH RESULT tag=101 err=0 nentries=1 text=  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=3 SRCH base="o=net,dc=example" scope=2 deref=0 filter="(objectClass=posixAccount)"  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=3 SRCH attr=sshPublicKey loginShell homeDirectory mail uidNumber uid  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=3 SEARCH RESULT tag=101 err=0 nentries=1626 text=  
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 op=4 UNBIND 
Oct 26 03:30:54 ldap.example.com slapd[11086]: conn=6832973 fd=24 closed  

to something that looks like this:

{'conn_id': '6832973', 'time': 'Oct 26 03:30:53', 'client': '192.168.1.1', 'server': 'ldap.example.com', 'tls': False, 'fd_id': 24, 'verb': 'ACCEPT', 'details': 'from IP=192.168.1.1:43050 (IP=0.0.0.0:389)'}
{'conn_id': '6832973', 'time': 'Oct 26 03:30:53', 'client': '192.168.1.1', 'server': 'ldap.example.com', 'tls': False, 'op_id': 0, 'requests': [{'verb': 'EXT', 'details': ['oid=1.3.6.1.4.1.1466.20037']}, {'verb': 'STARTTLS', 'details': []}], 'response': {'verb': 'RESULT', 'details': ['err=0', 'oid=', 'text='], 'error': 'LDAP_SUCCESS'}}
{'conn_id': '6832973', 'time': 'Oct 26 03:30:54', 'client': '192.168.1.1', 'server': 'ldap.example.com', 'tls': True, 'fd_id': 24, 'verb': 'TLS', 'details': 'established tls_ssf=256 ssf=256'}
{'conn_id': '6832973', 'time': 'Oct 26 03:30:54', 'client': '192.168.1.1', 'server': 'ldap.example.com', 'tls': True, 'op_id': 1, 'requests': [{'verb': 'BIND', 'details': ['dn="uid=bind-generateusers,ou=logins,dc=example"', 'method=128']}, {'verb': 'BIND', 'details': ['dn="uid=bind-generateusers,ou=logins,dc=example"', 'mech=SIMPLE', 'ssf=0']}], 'response': {'verb': 'RESULT', 'details': ['err=0', 'tag=97', 'text='], 'error': 'LDAP_SUCCESS'}}
{'conn_id': '6832973', 'time': 'Oct 26 03:30:54', 'client': '192.168.1.1', 'server': 'ldap.example.com', 'tls': True, 'op_id': 2, 'requests': [{'verb': 'SRCH', 'details': ['base="ou=groups,dc=example"', 'scope=2', 'deref=0', 'filter="(cn=group_name)"']}, {'verb': 'SRCH', 'details': ['attr=memberUid']}], 'response': {'verb': 'SEARCH RESULT', 'details': ['err=0', 'nentries=1', 'tag=101', 'text='], 'error': 'LDAP_SUCCESS'}}
{'conn_id': '6832973', 'time': 'Oct 26 03:30:54', 'client': '192.168.1.1', 'server': 'ldap.example.com', 'tls': True, 'op_id': 3, 'requests': [{'verb': 'SRCH', 'details': ['base="o=net,dc=example"', 'scope=2', 'deref=0', 'filter="(objectClass=posixAccount)"']}, {'verb': 'SRCH', 'details': ['attr=sshPublicKey', 'loginShell', 'homeDirectory', 'mail', 'uidNumber', 'uid']}], 'response': {'verb': 'SEARCH RESULT', 'details': ['err=0', 'nentries=1626', 'tag=101', 'text='], 'error': 'LDAP_SUCCESS'}}
{'conn_id': '6832973', 'time': 'Oct 26 03:30:54', 'client': '192.168.1.1', 'server': 'ldap.example.com', 'tls': True, 'fd_id': 24, 'verb': 'closed', 'details': ''}

which is more readable by humans and machines. The benefit to this format is that every operation gets its own line of log output, with all of the relevant metadata included on that line, such as connection number, whether TLS is used for this operation, the client IP, the request and the response.

Usage


For testing purposes, use just the command line utility like this:

python humanizer.py --noconfig --input_file_name /var/log/ldap/ldap.log --output_stdout

This will read the specified OpenLDAP log file and dump the humanized output to stdout

To start a syslog daemon:

python humanizer.py --noconfig --input_type syslog --daemonize --host 0.0.0.0 --port 1514 --output_file /var/log/humanizer.log

This will open a listener on 0.0.0.0:1514 (udp) and accept syslog messages and write the humanized logs to the specified log file.

Quick and dirty:

cat /var/log/ldap/ldap.log | python humanizer.py --noconfig --output_stdout

For production usage, use the humanizer_settings.json file to pass the configuration and use systemd or other tool to start the listener

Supported inputs and outputs


The humanizer can read logs via stdin, a specified file or from syslog over UDP.

The humanizer can output humanized logs to stdout, stderr, a specified file, or forward to another syslog server. It can do any combination of output types, so you can have one instance write a local file, dump to stdout, stderr, or any combination of these.