diff options
author | Michael Boelen <michael.boelen@cisofy.com> | 2020-08-07 12:39:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-07 12:39:39 +0300 |
commit | 343e9bdc1c569f9a1590079e646c285542297e7e (patch) | |
tree | 5b871a44d3194e5747779e9c9a1eb73a15af3b9f | |
parent | 3173dd801017c1a0a2b679ed3de84735b0ee1448 (diff) | |
parent | f94817f66f4344e9fee676480bf4e04167ebc52c (diff) |
Merge pull request #974 from igloonet/feature/warn-slow-settting
Command line option for slow test threshold
-rw-r--r-- | extras/bash_completion.d/lynis | 2 | ||||
-rw-r--r-- | include/consts | 1 | ||||
-rw-r--r-- | include/functions | 2 | ||||
-rw-r--r-- | include/parameters | 17 | ||||
-rwxr-xr-x | lynis | 1 |
5 files changed, 21 insertions, 2 deletions
diff --git a/extras/bash_completion.d/lynis b/extras/bash_completion.d/lynis index 8732ede3..7eee7375 100644 --- a/extras/bash_completion.d/lynis +++ b/extras/bash_completion.d/lynis @@ -179,7 +179,7 @@ _lynis() *) COMPREPLY=( $( compgen -W ' \ --auditor --cronjob --debug --quick --quiet --logfile --no-colors --no-log --pentest --reverse-colors \ - --tests --tests-from-category --tests-from-group --upload --verbose' -- "$cur" ) ) + --tests --tests-from-category --tests-from-group --upload --verbose --slow-warning' -- "$cur" ) ) ;; esac diff --git a/include/consts b/include/consts index 1a75ae68..053147a4 100644 --- a/include/consts +++ b/include/consts @@ -273,6 +273,7 @@ ETC_PATHS="/etc /usr/local/etc" SKIP_VM_DETECTION=0 SKIPREASON="" SKIPPED_TESTS_ROOTONLY="" + SLOW_TEST_THRESHOLD=10 SMTPCTLBINARY="" SNORTBINARY="" SSHKEYSCANBINARY="" diff --git a/include/functions b/include/functions index 4ff5b43a..e0f75a64 100644 --- a/include/functions +++ b/include/functions @@ -2586,7 +2586,7 @@ CURRENT_TS=$(GetTimestamp) if [ ${PREVIOUS_TS} -gt 0 ]; then SLOW_TEST=0 - TIME_THRESHOLD=10 # seconds + TIME_THRESHOLD=$SLOW_TEST_THRESHOLD # seconds # Calculate timing and determine if we use seconds or nanoseconds (more precise) TIME_DIFF=$((CURRENT_TS - PREVIOUS_TS)) diff --git a/include/parameters b/include/parameters index 8668b683..242899e6 100644 --- a/include/parameters +++ b/include/parameters @@ -423,6 +423,23 @@ QUIET=1 ;; + # Warning when test is slow + --slow-warning) + if [ $# -gt 1 ]; then + shift + + if [ "$1" -gt 0 ] 2>/dev/null; then + SLOW_TEST_THRESHOLD="$1" + else + echo "Argument has to be number." + exit 1 + fi + else + echo "Specify threshold as number of seconds above which should Lynis warn about long test." + exit 1 + fi + ;; + --tests-category | --tests-categories | --view-categories | --list-categories | --show-categories) echo "Error: Deprecated option ($1)" exit 1 @@ -453,6 +453,7 @@ ${YELLOW}Note: ${WHITE}Cancelling the program can leave temporary files behind${ ${GRAY}--verbose${NORMAL} : Show more details on screen ${GRAY}--version (-V)${NORMAL} : Display version number and quit ${GRAY}--wait${NORMAL} : Wait between a set of tests + ${GRAY}--slow-warning ${BROWN}<seconds>${NORMAL} : Threshold for slow test warning in seconds (default 10) ${WHITE}Enterprise options${NORMAL} ${GRAY}--plugindir ${BROWN}<path>${NORMAL} : Define path of available plugins |