Move vulnwhisperer tests to a script
This commit is contained in:
@ -17,23 +17,22 @@ function yellow() {
|
||||
echo -e "$YELLOW$*$NORMAL"
|
||||
}
|
||||
|
||||
return_code=0
|
||||
|
||||
elasticsearch_url="localhost:9200"
|
||||
logstash_url="localhost:9600"
|
||||
|
||||
until curl -s "$elasticsearch_url/_cluster/health?pretty" | grep '"status"' | grep -qE "green|yellow"; do
|
||||
yellow $(curl -s "$elasticsearch_url/_cluster/health?pretty")
|
||||
yellow "\nWaiting for Elasticsearch..."
|
||||
yellow "Waiting for Elasticsearch..."
|
||||
sleep 5
|
||||
done
|
||||
curl -s "$elasticsearch_url/_cluster/health?pretty"
|
||||
|
||||
until [[ $(curl -s "$logstash_url/_node/stats" | jq '.events.out') == 1236 ]] ; do
|
||||
yellow $(curl -s "$logstash_url/_node/stats" | jq '.events')
|
||||
yellow "\nWaiting for Logstash load to finish..."
|
||||
yellow "Waiting for Logstash load to finish..."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
return_code=0
|
||||
curl -s "$logstash_url/_node/stats" | jq '.events'
|
||||
|
||||
if [[ $(curl -s "$elasticsearch_url/logstash-vulnwhisperer-2019.03/_count" | jq '.count') == 1232 ]]; then
|
||||
green "✅ Passed logstash-vulnwhisperer-2019.03 document count == 1232"
|
||||
|
90
tests/test-vuln_whisperer.sh
Executable file
90
tests/test-vuln_whisperer.sh
Executable file
@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
NORMAL=$(tput sgr0)
|
||||
GREEN=$(tput setaf 2)
|
||||
YELLOW=$(tput setaf 3)
|
||||
RED=$(tput setaf 1)
|
||||
|
||||
function red() {
|
||||
echo -e "$RED$*$NORMAL"
|
||||
}
|
||||
|
||||
function green() {
|
||||
echo -e "$GREEN$*$NORMAL"
|
||||
}
|
||||
|
||||
function yellow() {
|
||||
echo -e "$YELLOW$*$NORMAL"
|
||||
}
|
||||
|
||||
return_code=0
|
||||
|
||||
yellow "\n*********************************************"
|
||||
yellow "* Test successful scan download and parsing *"
|
||||
yellow "*********************************************"
|
||||
rm -rf /opt/VulnWhisperer/*
|
||||
if vuln_whisperer -F -c configs/test.ini --mock --mock_dir ${TEST_PATH}; then
|
||||
green "\n✅ Passed: Test successful scan download and parsing"
|
||||
else
|
||||
red "\n❌ Failed: Test successful scan download and parsing"
|
||||
((return_code = return_code + 1))
|
||||
fi
|
||||
|
||||
yellow "\n*********************************************"
|
||||
yellow "* Test run with no scans to import *"
|
||||
yellow "*********************************************"
|
||||
if vuln_whisperer -F -c configs/test.ini --mock --mock_dir ${TEST_PATH}; then
|
||||
green "\n✅ Passed: Test run with no scans to import"
|
||||
else
|
||||
red "\n❌ Failed: Test run with no scans to import"
|
||||
((return_code = return_code + 1))
|
||||
fi
|
||||
|
||||
yellow "\n*********************************************"
|
||||
yellow "* Test one failed scan *"
|
||||
yellow "*********************************************"
|
||||
rm -rf /opt/VulnWhisperer/*
|
||||
rm -f ${TEST_PATH}/nessus/GET_scans_exports_164_download
|
||||
if vuln_whisperer -F -c configs/test.ini --mock --mock_dir ${TEST_PATH}; [[ $? -eq 1 ]]; then
|
||||
green "\n✅ Passed: Test one failed scan"
|
||||
else
|
||||
red "\n❌ Failed: Test one failed scan"
|
||||
((return_code = return_code + 1))
|
||||
fi
|
||||
|
||||
yellow "\n*********************************************"
|
||||
yellow "* Test two failed scans *"
|
||||
yellow "*********************************************"
|
||||
rm -rf /opt/VulnWhisperer/*
|
||||
rm -f ${TEST_PATH}/qualys_vuln/scan_1553941061.87241
|
||||
if vuln_whisperer -F -c configs/test.ini --mock --mock_dir ${TEST_PATH}; [[ $? -eq 2 ]]; then
|
||||
green "\n✅ Passed: Test two failed scans"
|
||||
else
|
||||
red "\n❌ Failed: Test two failed scans"
|
||||
((return_code = return_code + 1))
|
||||
fi
|
||||
|
||||
yellow "\n*********************************************"
|
||||
yellow "* Test only nessus with one failed scan *"
|
||||
yellow "*********************************************"
|
||||
rm -rf /opt/VulnWhisperer/*
|
||||
if vuln_whisperer -F -c configs/test.ini -s nessus --mock --mock_dir ${TEST_PATH}; [[ $? -eq 1 ]]; then
|
||||
green "\n✅ Passed: Test only nessus with one failed scan"
|
||||
else
|
||||
red "\n❌ Failed: Test only nessus with one failed scan"
|
||||
((return_code = return_code + 1))
|
||||
fi
|
||||
|
||||
echo -e "\n\n"
|
||||
yellow "*********************************************"
|
||||
yellow "* Test only Qualys VM with one failed scan *"
|
||||
yellow "*********************************************"
|
||||
rm -rf /opt/VulnWhisperer/*
|
||||
if vuln_whisperer -F -c configs/test.ini -s qualys_vuln --mock --mock_dir ${TEST_PATH}; [[ $? -eq 1 ]]; then
|
||||
green "\n✅ Passed: Test only Qualys VM with one failed scan"
|
||||
else
|
||||
red "\n❌ Failed: Test only Qualys VM with one failed scan"
|
||||
((return_code = return_code + 1))
|
||||
fi
|
||||
|
||||
exit $return_code
|
Reference in New Issue
Block a user