mirror of
https://github.com/ovh/debian-cis.git
synced 2024-11-22 05:27:01 +01:00
Add silent mode and json summary (#128)
Co-authored-by: GoldenKiwi <thibault.dewailly@corp.ovh.com>
This commit is contained in:
parent
3d2d97a727
commit
ad192c9457
@ -26,6 +26,7 @@ ALLOW_SERVICE_LIST=0
|
|||||||
SET_HARDENING_LEVEL=0
|
SET_HARDENING_LEVEL=0
|
||||||
SUDO_MODE=''
|
SUDO_MODE=''
|
||||||
BATCH_MODE=''
|
BATCH_MODE=''
|
||||||
|
SUMMARY_JSON=''
|
||||||
ASK_LOGLEVEL=''
|
ASK_LOGLEVEL=''
|
||||||
ALLOW_UNSUPPORTED_DISTRIBUTION=0
|
ALLOW_UNSUPPORTED_DISTRIBUTION=0
|
||||||
|
|
||||||
@ -101,9 +102,13 @@ OPTIONS:
|
|||||||
Finally note that '--sudo' mode only works for audit mode.
|
Finally note that '--sudo' mode only works for audit mode.
|
||||||
|
|
||||||
--set-log-level <level>
|
--set-log-level <level>
|
||||||
This option sets LOGLEVEL, you can choose : info, warning, error, ok, debug.
|
This option sets LOGLEVEL, you can choose : info, warning, error, ok, debug or silent.
|
||||||
Default value is : info
|
Default value is : info
|
||||||
|
|
||||||
|
--summary-json
|
||||||
|
While performing system audit, this option sets LOGLEVEL to silent and
|
||||||
|
only output a json summary at the end
|
||||||
|
|
||||||
--batch
|
--batch
|
||||||
While performing system audit, this option sets LOGLEVEL to 'ok' and
|
While performing system audit, this option sets LOGLEVEL to 'ok' and
|
||||||
captures all output to print only one line once the check is done, formatted like :
|
captures all output to print only one line once the check is done, formatted like :
|
||||||
@ -165,6 +170,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
--sudo)
|
--sudo)
|
||||||
SUDO_MODE='--sudo'
|
SUDO_MODE='--sudo'
|
||||||
;;
|
;;
|
||||||
|
--summary-json)
|
||||||
|
SUMMARY_JSON='--summary-json'
|
||||||
|
ASK_LOGLEVEL=silent
|
||||||
|
;;
|
||||||
--batch)
|
--batch)
|
||||||
BATCH_MODE='--batch'
|
BATCH_MODE='--batch'
|
||||||
ASK_LOGLEVEL=ok
|
ASK_LOGLEVEL=ok
|
||||||
@ -355,6 +364,18 @@ if [ "$BATCH_MODE" ]; then
|
|||||||
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:N.A" # No check runned, avoid division by 0
|
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:N.A" # No check runned, avoid division by 0
|
||||||
fi
|
fi
|
||||||
becho "$BATCH_SUMMARY"
|
becho "$BATCH_SUMMARY"
|
||||||
|
elif [ "$SUMMARY_JSON" ]; then
|
||||||
|
if [ "$TOTAL_TREATED_CHECKS" != 0 ]; then
|
||||||
|
CONFORMITY_PERCENTAGE=$(div $((PASSED_CHECKS * 100)) $TOTAL_TREATED_CHECKS)
|
||||||
|
else
|
||||||
|
CONFORMITY_PERCENTAGE=0 # No check runned, avoid division by 0
|
||||||
|
fi
|
||||||
|
printf '{'
|
||||||
|
printf '"available_checks": %s, ' "$TOTAL_CHECKS"
|
||||||
|
printf '"run_checks": %s, ' "$TOTAL_TREATED_CHECKS"
|
||||||
|
printf '"passed_checks": %s, ' "$PASSED_CHECKS"
|
||||||
|
printf '"conformity_percentage": %s' "$CONFORMITY_PERCENTAGE"
|
||||||
|
printf '}\n'
|
||||||
else
|
else
|
||||||
printf "%40s\n" "################### SUMMARY ###################"
|
printf "%40s\n" "################### SUMMARY ###################"
|
||||||
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
|
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
|
||||||
|
@ -25,6 +25,9 @@ backup_file() {
|
|||||||
#
|
#
|
||||||
|
|
||||||
case $LOGLEVEL in
|
case $LOGLEVEL in
|
||||||
|
silent)
|
||||||
|
MACHINE_LOG_LEVEL=0
|
||||||
|
;;
|
||||||
error)
|
error)
|
||||||
MACHINE_LOG_LEVEL=1
|
MACHINE_LOG_LEVEL=1
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user