Skip to content

Instantly share code, notes, and snippets.

@aomoriringo
Last active April 30, 2023 06:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aomoriringo/2ec69042d8330dbce0ae6097288a6ce4 to your computer and use it in GitHub Desktop.
Save aomoriringo/2ec69042d8330dbce0ae6097288a6ce4 to your computer and use it in GitHub Desktop.
vuls scan&zabbixにsend

config.tomlでサーバ名をZabbix上の名前と一致させておくこと zabbix上で以下のitemを作成しておく

  • number of vulnerabilities

    • Type: Zabbix Trapper
    • Key: nvd_count
    • Type of information: Numeric (unsigned)
    • Data type: Decimal
  • max vulnerability

    • Type: Zabbix Trapper
    • Key: nvd_max
    • Type of information: Numeric (unsigned)
    • Data type: Decimal

この状態でbenri.shをcronで毎日実行とかさせるようにする

#/bin/bash
VULS_ROOT="/root/vuls"
VULS_RESULT_DIR="$VULS_ROOT/results"
vuls scan -cve-dictionary-dbpath=$VULS_ROOT/cve.sqlite3 -report-json
files="$VULS_RESULT_DIR/current/*"
for filepath in $files; do
TARGET_NAME=`basename $filepath .json`
if [ "$TARGET_NAME" == "all" ]
then
continue
fi
zabbix_sender -z localhost -s $TARGET_NAME -k nvd_count -o `cat $filepath | jq '[.KnownCves[]?, .UnknownCves[]? | .CveDetail.CveID] | length'`
zabbix_sender -z localhost -s $TARGET_NAME -k nvd_max -o `cat $filepath | jq '[.KnownCves[]?, .UnknownCves[]? | .CveDetail.Nvd.Score]+[0] | max'`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment