From f8bee58ade73437c9e9e176b85eb29fe290f39fb Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Tue, 5 Jul 2016 18:18:54 +0200 Subject: [PATCH] Implement tooltips --- include/consts | 1 + include/functions | 25 ++++--------------------- include/helper_show | 2 +- include/parameters | 14 +++++++------- lynis | 2 ++ 5 files changed, 15 insertions(+), 29 deletions(-) diff --git a/include/consts b/include/consts index d4d61482..e54c5032 100644 --- a/include/consts +++ b/include/consts @@ -180,6 +180,7 @@ unset LANG TESTS_EXECUTED="" TESTS_SKIPPED="" TMPFILE="" + TOOLTIP_SHOWED=0 TOTAL_SUGGESTIONS=0 TOTAL_WARNINGS=0 TRIPWIREBINARY="" diff --git a/include/functions b/include/functions index 66b20715..29104c0e 100644 --- a/include/functions +++ b/include/functions @@ -444,25 +444,6 @@ } - ################################################################################ - # Name : DisplayToolTip() - # Description : Show tooltip on screen - # - # Input : $1 = text - # Returns : - ################################################################################ - - DisplayToolTip() { - if [ ${SHOW_TOOL_TIPS} -eq 1 ]; then - if [ ${CRONJOB} -eq 0 ]; then - # Check if we already have already discovered a proper echo command tool. It not, set it default to 'echo'. - if [ "${ECHOCMD}" = "" ]; then ECHOCMD="echo"; fi - ${ECHOCMD} "${WHITE}[${BLUE}Tool Tip${NORMAL}${WHITE}]${NORMAL}: $1" - else - echo "${TEXT}${RESULTPART}" - fi - fi - } ################################################################################ @@ -567,14 +548,16 @@ ################################################################################ DisplayToolTip() { - if [ ${SHOW_TOOL_TIPS} -eq 1 ]; then + # Display tooltip when enabled and no tip has been displayed yet + if [ ${SHOW_TOOL_TIPS} -eq 1 -a ${TOOLTIP_SHOWED} -eq 0 ]; then if [ ${CRONJOB} -eq 0 ]; then # Check if we already have already discovered a proper echo command tool. It not, set it default to 'echo'. if [ "${ECHOCMD}" = "" ]; then ECHOCMD="echo"; fi - ${ECHOCMD} "${WHITE}[${BLUE}TOOLTIP${NORMAL}${WHITE}]${NORMAL} ${WHITE}$1${NORMAL}" + ${ECHOCMD} "${WHITE}[${BLUE}TIP${NORMAL}${WHITE}]${NORMAL}: $1" else echo "${TEXT}${RESULTPART}" fi + TOOLTIP_SHOWED=1 fi } diff --git a/include/helper_show b/include/helper_show index 8acb69f5..74ece537 100644 --- a/include/helper_show +++ b/include/helper_show @@ -30,7 +30,7 @@ COMMANDS="audit show update" HELPERS="audit configure show update" -OPTIONS="--auditor\n--check-all (-c)\n--config\n--cronjob (--cron)\n--debug\n--developer\n--help (-h)\n--info\n--license-key --log-file\n--manpage_(--man)\n--no-colors --no-log\n--pentest\n--profile\n--plugins-dir\n--quiet (-q)\n--quick (-Q)\n--report-file\n--reverse-colors\n--tests\n--tests-category\n--upload\n--verbose\n--version (-V)\n--view-categories" +OPTIONS="--auditor\n--check-all (-c)\n--config\n--cronjob (--cron)\n--debug\n--developer\n--help (-h)\n--info\n--license-key --log-file\n--manpage (--man)\n--no-colors --no-log\n--pentest\n--profile\n--plugins-dir\n--quiet (-q)\n--quick (-Q)\n--report-file\n--reverse-colors\n--tests\n--tests-category\n--upload\n--verbose\n--version (-V)\n--view-categories" SHOW_ARGS="commands dbdir help hostids includedir license man options pidfile plugindir profiles release releasedate settings tests version workdir" SHOW_HELP="lynis show ${BROWN}commands${NORMAL} (all available commands) diff --git a/include/parameters b/include/parameters index af697c9c..2b115e06 100644 --- a/include/parameters +++ b/include/parameters @@ -31,7 +31,7 @@ CHECK_BINARIES=0 RUN_HELPERS=1 HELPER="audit" - RUN_PLUGINS=0 + SKIP_PLUGINS=1 RUN_TESTS=0 if [ ! $2 = "" ]; then case $2 in @@ -71,7 +71,7 @@ CHECK_BINARIES=0 QUIET=1 RUN_HELPERS=1 - RUN_PLUGINS=0 + SKIP_PLUGINS=1 RUN_TESTS=0 SHOW_PROGRAM_DETAILS=0 break @@ -80,7 +80,7 @@ CHECK=1 CHECK_BINARIES=1 HELPER="" - RUN_PLUGINS=1 + SKIP_PLUGINS=0 RUN_TESTS=1 shift ;; @@ -100,7 +100,7 @@ CHECK_BINARIES=0 RUN_HELPERS=1 QUIET=1 - RUN_PLUGINS=0 + SKIP_PLUGINS=1 RUN_TESTS=0 SHOW_PROGRAM_DETAILS=0 if [ $# -gt 0 ]; then shift; fi @@ -114,7 +114,7 @@ CHECK_BINARIES=0 RUN_HELPERS=1 HELPER="show" - RUN_PLUGINS=0 + SKIP_PLUGINS=1 RUN_TESTS=0 QUIET=1 SHOW_PROGRAM_DETAILS=0 @@ -141,7 +141,7 @@ RUN_HELPERS=1 HELPER="update" QUIET=1 - RUN_PLUGINS=0 + SKIP_PLUGINS=1 RUN_TESTS=0 SHOW_PROGRAM_DETAILS=0 if [ ! $2 = "" ]; then @@ -298,7 +298,7 @@ # Skip execution of plugins --skip-plugins | --no-plugins) - RUN_PLUGINS=0 + SKIP_PLUGINS=1 ;; # Only scan these tests diff --git a/lynis b/lynis index 3e4b47b3..4dd79c2a 100755 --- a/lynis +++ b/lynis @@ -983,6 +983,8 @@ ${NORMAL} LogText "Program ended successfully" LogText "================================================================================" + if [ -z "${CUSTOM_PROFILE}" ]; then DisplayToolTip "Enhance ${PROGRAM_NAME} audits by adding your settings to custom.prf (see ${DEFAULT_PROFILE} for all settings)"; fi + # Clean exit (Delete PID file) if [ ${TOTAL_WARNINGS} -gt 0 ]; then # Use exit code 78 if we found any warnings (and enabled)