go-audit is an alternative to the auditd daemon that ships with many distros. After having created an auditd audisp plugin to convert audit logs to json, I became interested in creating a replacement for the existing daemon.
- Safe : Written in a modern language that is type safe and performant
- Fast : Never ever ever ever block if we can avoid it
- Outputs json : Yay
- Pluggable pipelines : Can write to syslog, local file, or stdout. Additional outputs are easily written.
- Connects to the linux kernel via netlink (info here and here)
Install golang, version 1.7 or greater is required
govendorif you haven't already
go get -u github.com/kardianos/govendor
Clone the repo
git clone (this repo) cd go-audit
Build the binary
Copy the binary
go-auditto wherever you'd like
make test- run the unit test suite
make test-cov-html- run the unit tests and open up the code coverage results
make bench- run the benchmark test suite
make bench-cpu- run the benchmark test suite with cpu profiling
make bench-cpulong- run the benchmark test suite with cpu profiling and try to get some gc collection
Running as a service
Check the contrib folder, it contains examples for how to run
go-audit as a proper service on your machine.
I am seeing
Error during message receive: no buffer space available in the logs
This is because
go-audit is not receiving data as quickly as your system is generating it. You can increase
the receive buffer system wide and maybe it will help. Best to try and reduce the amount of data
If reducing audit velocity is not an option you can try increasing
socket_buffer.receive in your config.
See Example Config for more information
socket_buffer: receive: <some number bigger than (the current value * 2)>
Sometime files don't have a
inode, what gives?
The kernel doesn't always know the filename for file access. Figuring out the filename from an inode is expensive and error prone.
You can map back to a filename, possibly not the filename, that triggured the audit line though.
sudo debugfs -R "ncheck <inode to map>" /dev/<your block device here>
I don't like math and want you to tell me the syslog priority to use
Use the default, or consult this handy table.
Wikipedia has a pretty good page on this
|emerg (0)||alert (1)||crit (2)||err (3)||warn (4)||notice (5)||info (6)||debug (7)|
I am seeing duplicate entries in syslog!
This is likely because you are running
journald which is also reading audit events. To disable it you need to disable the functionality in
sudo systemctl mask systemd-journald-audit.socket
To Hardik Juneja, Arun Sori, Aalekh Nigam Aalekhn for the inspiration via https://github.com/mozilla/audit-go