Introduction into Plugins
Lynis is written in shell script, a versatile scripting language available on all systems running Linux or a UNIX-based operating system. For this reason, most system administrators can easily create their own tests for Lynis. This is useful when you want to write your own tests and plugins, or customizing functionality. In this document we have a look at how to create a plugin, with some custom tests in it.
Lynis runs each time a full cycle of steps. For plugins there are two moments when they can run, which we call phase 1 and phase 2. The complete cycle looks like this:
- OS detection
- Detection of binaries
- Plugins phase 1
- Run built-in tests
- Optional: run any custom tests
- Plugins phase 2
- Show report
The first step is to know where Lynis is installed, and in particular in which directory your plugins are stored. This path is displayed on screen when running Lynis, and stored in your log file (usually /var/log/lynis.log).
grep -i plugin /var/log/lynis.log
Custom plugins can be created by leveraging common shell scripting. This is useful when you want to create your own tests.