Fix Json output and tabs

This commit is contained in:
Abdoul Bah 2018-01-10 23:15:24 +01:00
parent a3fd044661
commit c48861a5ff
1 changed files with 24 additions and 20 deletions

View File

@ -324,26 +324,26 @@ pvulnstatus()
{ {
if [ "$opt_batch" = 1 ]; then if [ "$opt_batch" = 1 ]; then
case "$opt_batch_format" in case "$opt_batch_format" in
text) _echo 0 "$1: $2 ($3)";; text) _echo 0 "$1: $2 ($3)";;
nrpe) nrpe)
case "$2" in case "$2" in
UKN) nrpe_unknown="1";; UKN) nrpe_unknown="1";;
VULN) nrpe_critical="1"; nrpe_vuln="$nrpe_vuln $1";; VULN) nrpe_critical="1"; nrpe_vuln="$nrpe_vuln $1";;
esac esac
;; ;;
json) json)
case "$1" in case "$1" in
CVE-2017-5753) aka="SPECTRE VARIANT 1";; CVE-2017-5753) aka="SPECTRE VARIANT 1";;
CVE-2017-5715) aka="SPECTRE VARIANT 2";; CVE-2017-5715) aka="SPECTRE VARIANT 2";;
CVE-2017-5754) aka="SPECTRE VARIANT 3";; CVE-2017-5754) aka="MELTDOWN";;
esac esac
case "$2" in case "$2" in
UKN) is_vuln="unknown";; UKN) is_vuln="unknown";;
VULN) is_vuln="true";; VULN) is_vuln="true";;
OK) is_vuln="false";; OK) is_vuln="false";;
esac esac
_echo 0 "{\"NAME\":\""$aka"\",\"CVE\":\""$1"\",\"VULNERABLE\":$is_vuln,\"INFOS\":\""$3"\"}" json_output="${json_output:-[}{\"NAME\":\""$aka"\",\"CVE\":\""$1"\",\"VULNERABLE\":$is_vuln,\"INFOS\":\""$3"\"},"
;; ;;
esac esac
fi fi
@ -855,3 +855,7 @@ if [ "$opt_batch" = 1 -a "$opt_batch_format" = "nrpe" ]; then
[ "$nrpe_unknown" = 1 ] && exit 3 # unknown [ "$nrpe_unknown" = 1 ] && exit 3 # unknown
exit 0 # ok exit 0 # ok
fi fi
if [ "$opt_batch" = 1 -a "$opt_batch_format" = "json" ]; then
_echo 0 ${json_output%?}]
fi