mirror of https://github.com/CISOfy/lynis.git
Improve help output and error messages
This commit is contained in:
parent
be5e9f6e54
commit
b72b510301
|
@ -47,19 +47,48 @@ lynis show ${BROWN}version${NORMAL} (${PROGRAM_NAME} version)"
|
||||||
|
|
||||||
AUDIT_ARGS="( dockerfile | system )"
|
AUDIT_ARGS="( dockerfile | system )"
|
||||||
AUDIT_HELP="
|
AUDIT_HELP="
|
||||||
audit ${CYAN}dockerfile${NORMAL}
|
${WHITE}lynis audit <target>${NORMAL}
|
||||||
|
|
||||||
Perform audit on a Docker build file
|
${CYAN}audit dockerfile ${BROWN}<file>${NORMAL}
|
||||||
${GRAY}Usage:${NORMAL} lynis audit dockerfile ${BROWN}<file>${NORMAL}
|
|
||||||
|
Perform security audit on a Docker build file
|
||||||
|
${GRAY}Example:${NORMAL}
|
||||||
|
lynis audit dockerfile Dockerfile
|
||||||
|
|
||||||
|
|
||||||
audit ${CYAN}system${NORMAL}
|
${CYAN}audit system ${GRAY}[options]${NORMAL}
|
||||||
|
|
||||||
|
Perform security system audit
|
||||||
|
|
||||||
|
${GRAY}Examples:${NORMAL}
|
||||||
|
lynis audit system
|
||||||
|
lynis audit system --cronjob
|
||||||
|
lynis audit system --profile developer.prf
|
||||||
|
lynis audit system --quick
|
||||||
|
|
||||||
|
|
||||||
|
${CYAN}audit system remote ${BROWN}<target> ${GRAY}[options]${NORMAL}
|
||||||
|
|
||||||
|
Perform security system audit on a remote target
|
||||||
|
|
||||||
|
${GRAY}Examples:${NORMAL}
|
||||||
|
lynis audit system remote 192.168.1.100
|
||||||
|
lynis audit system remote 192.168.1.100 --no-colors
|
||||||
|
|
||||||
Perform system audit
|
|
||||||
${DARKGRAY}Usage:${NORMAL} lynis audit system
|
|
||||||
"
|
"
|
||||||
|
|
||||||
UPDATE_ARGS="info release"
|
UPDATE_ARGS="info release"
|
||||||
|
UPDATE_HELP="
|
||||||
|
${CYAN}update info${NORMAL}
|
||||||
|
|
||||||
|
Check version information
|
||||||
|
|
||||||
|
|
||||||
|
${CYAN}update release${NORMAL}
|
||||||
|
|
||||||
|
Perform update of release
|
||||||
|
|
||||||
|
"
|
||||||
|
|
||||||
SHOW_TESTS_ARGS="skipped"
|
SHOW_TESTS_ARGS="skipped"
|
||||||
|
|
||||||
|
@ -70,30 +99,30 @@ if [ $# -gt 0 ]; then
|
||||||
case $1 in
|
case $1 in
|
||||||
"commands")
|
"commands")
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
echo "\n${WHITE}Commands:${NORMAL}"
|
${ECHOCMD} "\n${WHITE}Commands:${NORMAL}"
|
||||||
for I in ${COMMANDS}; do
|
for I in ${COMMANDS}; do
|
||||||
echo "lynis ${CYAN}${I}${NORMAL}"
|
${ECHOCMD} "lynis ${CYAN}${I}${NORMAL}"
|
||||||
done
|
done
|
||||||
echo ""
|
${ECHOCMD} ""
|
||||||
else
|
else
|
||||||
shift
|
shift
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
case $1 in
|
case $1 in
|
||||||
"audit") echo "${AUDIT_HELP}" ;;
|
"audit") ${ECHOCMD} "${AUDIT_HELP}" ;;
|
||||||
"show") echo "${SHOW_HELP}" ;;
|
"show") ${ECHOCMD} "${SHOW_HELP}" ;;
|
||||||
*) echo "Unknown argument for 'commands'"
|
*) ${ECHOCMD} "Unknown argument for 'commands'"
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
shift
|
shift
|
||||||
case $1 in
|
case $1 in
|
||||||
"dockerfile")
|
"dockerfile")
|
||||||
echo "Usage: lynis audit dockerfile <file>"
|
${ECHOCMD} "Usage: lynis audit dockerfile <file>"
|
||||||
;;
|
;;
|
||||||
"system")
|
"system")
|
||||||
echo "${COMMANDS_AUDIT_SYSTEM_USAGE}\n${COMMANDS_AUDIT_SYSTEM_FUNCTION}\n"
|
${ECHOCMD} "${COMMANDS_AUDIT_SYSTEM_USAGE}\n${COMMANDS_AUDIT_SYSTEM_FUNCTION}\n"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown argument for 'commands'"
|
${ECHOCMD} "Unknown argument for 'commands'"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
@ -101,57 +130,61 @@ if [ $# -gt 0 ]; then
|
||||||
;;
|
;;
|
||||||
"help")
|
"help")
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
echo "${WHITE}Commands${NORMAL}:"
|
${ECHOCMD} "${PROGRAM_NAME} ${PROGRAM_VERSION} - Help"
|
||||||
|
${ECHOCMD} "=========================="
|
||||||
|
${ECHOCMD} ""
|
||||||
|
${ECHOCMD} "${WHITE}Commands${NORMAL}:"
|
||||||
for I in ${COMMANDS}; do
|
for I in ${COMMANDS}; do
|
||||||
echo "lynis ${CYAN}${I}${NORMAL}"
|
${ECHOCMD} "${CYAN}${I}${NORMAL}"
|
||||||
done
|
done
|
||||||
echo ""
|
${ECHOCMD} ""
|
||||||
echo "${WHITE}Options${NORMAL}:\n${BLUE}${OPTIONS}${NORMAL}"
|
${ECHOCMD} "Use 'lynis show help <command>' to see details"
|
||||||
|
${ECHOCMD} ""; ${ECHOCMD} ""
|
||||||
|
${ECHOCMD} "${WHITE}Options${NORMAL}:\n${GRAY}${OPTIONS}${NORMAL}"
|
||||||
else
|
else
|
||||||
shift
|
shift
|
||||||
case $1 in
|
case $1 in
|
||||||
"audit") echo "${AUDIT_HELP}" ;;
|
"audit") ${ECHOCMD} "${AUDIT_HELP}" ;;
|
||||||
"show") echo "${SHOW_ARGS}" ;;
|
"show") ${ECHOCMD} "${SHOW_HELP}" ;;
|
||||||
"update") echo "${UPDATE_ARGS}" ;;
|
"update") ${ECHOCMD} "${UPDATE_HELP}" ;;
|
||||||
"?") echo "${SHOW_ARGS}" ;;
|
"?") ${ECHOCMD} "${SHOW_ARGS}" ;;
|
||||||
*) echo "Invalid argument provided for lynis show help" ;;
|
*) ${ECHOCMD} "Invalid argument provided for lynis show help" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"license") echo "${PROGRAM_LICENSE}" ;;
|
"license") ${ECHOCMD} "${PROGRAM_LICENSE}" ;;
|
||||||
"man") echo "Use ./lynis --man or man lynis" ;;
|
"man") ${ECHOCMD} "Use ./lynis --man or man lynis" ;;
|
||||||
"options") echo "${OPTIONS}" ;;
|
"options") ${ECHOCMD} "${OPTIONS}" ;;
|
||||||
"pidfile") echo "${PIDFILE}" ;;
|
"pidfile") ${ECHOCMD} "${PIDFILE}" ;;
|
||||||
"profile" | "profiles") for I in ${PROFILES}; do echo ${I}; done ;;
|
"profile" | "profiles") for I in ${PROFILES}; do ${ECHOCMD} ${I}; done ;;
|
||||||
"plugindir") echo "${PLUGINDIR}" ;;
|
"plugindir") ${ECHOCMD} "${PLUGINDIR}" ;;
|
||||||
"release" | "version") echo "${PROGRAM_VERSION}" ;;
|
"release" | "version") ${ECHOCMD} "${PROGRAM_VERSION}" ;;
|
||||||
"releasedate") echo "${PROGRAM_RELEASE_DATE}" ;;
|
"releasedate") ${ECHOCMD} "${PROGRAM_RELEASE_DATE}" ;;
|
||||||
"tests")
|
"tests")
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
shift
|
shift
|
||||||
case $1 in
|
case $1 in
|
||||||
"skipped") echo "${SKIP_TESTS}" ;;
|
"skipped") ${ECHOCMD} "${SKIP_TESTS}" ;;
|
||||||
*) echo "Invalid argument provided to lynis show tests\n\n"
|
*)
|
||||||
echo "Suggestions:\n"
|
${ECHOCMD} "Invalid argument provided to lynis show tests\n\n"
|
||||||
for I in ${SHOW_TESTS_ARGS}; do
|
${ECHOCMD} "Suggestions:\n"
|
||||||
echo "lynis show tests ${I}"
|
for I in ${SHOW_TESTS_ARGS}; do ${ECHOCMD} "lynis show tests ${I}"; done
|
||||||
done
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "Need more arguments"
|
${ECHOCMD} "Need more arguments"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"?") echo "${SHOW_ARGS}" ;;
|
"?") ${ECHOCMD} "${SHOW_ARGS}" ;;
|
||||||
*) echo "Unknown option" ;;
|
*) ${ECHOCMD} "Unknown argument '$1'" ;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "\n ${WHITE}Provide an additional argument${NORMAL}\n\n"
|
${ECHOCMD} "\n ${WHITE}Provide an additional argument${NORMAL}\n\n"
|
||||||
for I in ${SHOW_ARGS}; do
|
for I in ${SHOW_ARGS}; do
|
||||||
echo " lynis show ${BROWN}${I}${NORMAL}"
|
${ECHOCMD} " lynis show ${BROWN}${I}${NORMAL}"
|
||||||
done
|
done
|
||||||
echo "\n"
|
${ECHOCMD} "\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue