lynis/plugins/custom_plugin.template

86 lines
3.6 KiB
Plaintext
Raw Normal View History

2014-08-26 17:33:55 +02:00
#!/bin/sh
2016-03-24 10:34:16 +01:00
2014-08-26 17:33:55 +02:00
# -------------------------- CUT THIS SECTION ---------------------------
2016-03-24 10:34:16 +01:00
# This is a template to create a customized plugin
2014-08-26 17:33:55 +02:00
#
# Each plugin should at least have several variables defined with the
# prefix PLUGIN_* (see below)
#
2016-03-24 10:34:16 +01:00
# If you want to learn what functions you can use, check include/functions
2014-08-26 17:33:55 +02:00
#
# -------------------------- CUT THIS SECTION ---------------------------
#########################################################################
#
# * DO NOT REMOVE *
#-----------------------------------------------------
# PLUGIN_AUTHOR=___firstname_lastname_<email>___
# PLUGIN_CATEGORY=[category]
# PLUGIN_DESC=[description]
# PLUGIN_NAME=[plugin_name]
# PLUGIN_REQUIRED_TESTS=
#-----------------------------------------------------
#
2016-03-24 10:34:16 +01:00
#########################################################################
2014-08-26 17:33:55 +02:00
#
2016-03-24 10:34:16 +01:00
# Add custom section to screen output
InsertSection "Custom Plugin"
2014-08-26 17:33:55 +02:00
#
2016-03-24 10:34:16 +01:00
#################################################################################
2014-08-26 17:33:55 +02:00
#
2016-03-24 10:34:16 +01:00
# Test : CUST-0001
# Description : We show some lines on the screen
# Register our first custom test
# We consider it to be a lightweight test (no heavy IO, or long searches), no network connection needed
Register --test-no CUST-0001 --weight L --network NO --description "A test case for colors and text display"
if [ ${SKIPTEST} -eq 0 ]; then
# The Display function makes it easy to show something on screen, with colors.
# --indent defines amount of spaces
# --text text to be displayed on screen
# --result text at end of line
# --color color of result text
Display --indent 2 --text "- Checking if everything is OK..." --result OK --color GREEN
Display --indent 4 --text "This shows one level deeper " --result NOTICE --color YELLOW
Display --indent 6 --text "And even deeper" --result WARNING --color RED
# Show a warning on screen and in the report. We can specify a detail and how to solve it.
ReportWarning "${TEST_NO}" "Something was wrong and should be fixed" "/etc/motd" "text:Change your motd"
ReportSuggestion "${TEST_NO}" "Check if this process is running" "apache" "url:https://cisofy.com/support/"
fi
2014-08-26 17:33:55 +02:00
#
#################################################################################
#
# First check if OPENSSLBINARY is known as a prerequisite for this test.
if [ ! -z "${OPENSSLBINARY}" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
2016-03-24 10:34:16 +01:00
Register --test-no CUST-0001 --preqs-met ${PREQS_MET} --weight M --network NO --description "Description of custom test"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
FOUNDPROBLEM=0
2016-03-24 10:34:16 +01:00
DIR="/my/path"
LogText "Test: we are going to check if we can find a particular directory (${DIR})"
2014-08-26 17:33:55 +02:00
# Check if a directory exists
2016-03-24 10:34:16 +01:00
if [ -d ${DIR} ]; then
LogText "Result: log entry for easier debugging or additional information"
else
2016-03-24 10:34:16 +01:00
FOUNDPROBLEM=1
LogText "Result: directory ${DIR} was not found!"
ReportWarning "${TEST_NO}" "This is a test warning line" "${DIR}" "text:Create directory ${DIR}"
2014-08-26 17:33:55 +02:00
fi
if [ ${FOUNDPROBLEM} -eq 0 ]; then
2016-03-24 10:34:16 +01:00
Display --indent 2 --text "- Checking if everything is OK..." --result OK --color GREEN
else
2016-03-24 10:34:16 +01:00
Display --indent 2 --text "- Checking if everything is OK..." --result WARNING --color RED
2019-12-18 12:17:46 +01:00
ReportSuggestion "${TEST_NO}" "This is a suggestion"
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Wait for keypress (unless --quick is being used)
WaitForKeyPress
2014-08-26 17:33:55 +02:00
#EOF