1
0
mirror of https://github.com/speed47/spectre-meltdown-checker synced 2024-12-22 04:13:38 +01:00

feat(batch): Add a batch short option for one line result (#243)

When using this script on a large amount a machine (via clustershell or
instance) it can be easier to have a very short result on one line
showing only the vulnerabilities
This commit is contained in:
Pierre Gaxatte 2018-09-15 15:45:10 +02:00 committed by Stéphane Lesimple
parent 96798b1932
commit 8f31634df6

View File

@ -68,6 +68,7 @@ show_usage()
--arch-prefix PREFIX specify a prefix for cross-inspecting a kernel of a different arch, for example "aarch64-linux-gnu-",
so that invoked tools will be prefixed with this (i.e. aarch64-linux-gnu-objdump)
--batch text produce machine readable output, this is the default if --batch is specified alone
--batch short produce only one line with the vulnerabilities separated by spaces
--batch json produce JSON output formatted for Puppet, Ansible, Chef...
--batch nrpe produce machine readable output formatted for NRPE
--batch prometheus produce output for consumption by prometheus-node-exporter
@ -642,7 +643,7 @@ while [ -n "$1" ]; do
opt_no_color=1
shift
case "$1" in
text|nrpe|json|prometheus) opt_batch_format="$1"; shift;;
text|short|nrpe|json|prometheus) opt_batch_format="$1"; shift;;
--*) ;; # allow subsequent flags
'') ;; # allow nothing at all
*)
@ -741,6 +742,7 @@ pvulnstatus()
case "$opt_batch_format" in
text) _echo 0 "$1: $2 ($3)";;
short) short_output="${short_output}$1 ";;
json)
case "$2" in
UNK) is_vuln="null";;
@ -3423,6 +3425,10 @@ if [ "$opt_batch" = 1 ] && [ "$opt_batch_format" = "nrpe" ]; then
fi
fi
if [ "$opt_batch" = 1 ] && [ "$opt_batch_format" = "short" ]; then
_echo 0 "${short_output% }"
fi
if [ "$opt_batch" = 1 ] && [ "$opt_batch_format" = "json" ]; then
_echo 0 "${json_output%?}]"
fi