Move vulnwhisperer tests to a script
This commit is contained in:
20
.travis.yml
20
.travis.yml
@ -29,25 +29,7 @@ before_script:
|
|||||||
- flake8 . --count --exit-zero --exclude=deps/qualysapi --max-complexity=10 --max-line-length=127 --statistics
|
- flake8 . --count --exit-zero --exclude=deps/qualysapi --max-complexity=10 --max-line-length=127 --statistics
|
||||||
script:
|
script:
|
||||||
- python setup.py install
|
- python setup.py install
|
||||||
# Test successful scan download and parsing
|
- bash tests/test-vuln_whisperer.sh
|
||||||
- rm -rf /opt/VulnWhisperer
|
|
||||||
- vuln_whisperer -F -c configs/test.ini --mock --mock_dir ${TEST_PATH}
|
|
||||||
# Run a second time with no scans to import
|
|
||||||
- vuln_whisperer -F -c configs/test.ini --mock --mock_dir ${TEST_PATH}
|
|
||||||
# Test one failed scan
|
|
||||||
- rm -rf /opt/VulnWhisperer
|
|
||||||
- rm -f ${TEST_PATH}/nessus/GET_scans_exports_164_download
|
|
||||||
- vuln_whisperer -F -c configs/test.ini --mock --mock_dir ${TEST_PATH}; [[ $? -eq 1 ]]
|
|
||||||
# Test two failed scans
|
|
||||||
- rm -rf /opt/VulnWhisperer
|
|
||||||
- rm -f ${TEST_PATH}/qualys_vuln/scan_1553941061.87241
|
|
||||||
- vuln_whisperer -F -c configs/test.ini --mock --mock_dir ${TEST_PATH}; [[ $? -eq 2 ]]
|
|
||||||
# Test only nessus
|
|
||||||
- rm -rf /opt/VulnWhisperer
|
|
||||||
- vuln_whisperer -F -c configs/test.ini -s nessus --mock --mock_dir ${TEST_PATH}; [[ $? -eq 1 ]]
|
|
||||||
# Test only qualy_vuln
|
|
||||||
- rm -rf /opt/VulnWhisperer
|
|
||||||
- vuln_whisperer -F -c configs/test.ini -s qualys_vuln --mock --mock_dir ${TEST_PATH}; [[ $? -eq 1 ]]
|
|
||||||
- bash tests/test-docker.sh
|
- bash tests/test-docker.sh
|
||||||
notifications:
|
notifications:
|
||||||
on_success: change
|
on_success: change
|
||||||
|
@ -17,23 +17,22 @@ function yellow() {
|
|||||||
echo -e "$YELLOW$*$NORMAL"
|
echo -e "$YELLOW$*$NORMAL"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return_code=0
|
||||||
|
|
||||||
elasticsearch_url="localhost:9200"
|
elasticsearch_url="localhost:9200"
|
||||||
logstash_url="localhost:9600"
|
logstash_url="localhost:9600"
|
||||||
|
|
||||||
until curl -s "$elasticsearch_url/_cluster/health?pretty" | grep '"status"' | grep -qE "green|yellow"; do
|
until curl -s "$elasticsearch_url/_cluster/health?pretty" | grep '"status"' | grep -qE "green|yellow"; do
|
||||||
yellow $(curl -s "$elasticsearch_url/_cluster/health?pretty")
|
yellow "Waiting for Elasticsearch..."
|
||||||
yellow "\nWaiting for Elasticsearch..."
|
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
curl -s "$elasticsearch_url/_cluster/health?pretty"
|
curl -s "$elasticsearch_url/_cluster/health?pretty"
|
||||||
|
|
||||||
until [[ $(curl -s "$logstash_url/_node/stats" | jq '.events.out') == 1236 ]] ; do
|
until [[ $(curl -s "$logstash_url/_node/stats" | jq '.events.out') == 1236 ]] ; do
|
||||||
yellow $(curl -s "$logstash_url/_node/stats" | jq '.events')
|
yellow "Waiting for Logstash load to finish..."
|
||||||
yellow "\nWaiting for Logstash load to finish..."
|
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
|
curl -s "$logstash_url/_node/stats" | jq '.events'
|
||||||
return_code=0
|
|
||||||
|
|
||||||
if [[ $(curl -s "$elasticsearch_url/logstash-vulnwhisperer-2019.03/_count" | jq '.count') == 1232 ]]; then
|
if [[ $(curl -s "$elasticsearch_url/logstash-vulnwhisperer-2019.03/_count" | jq '.count') == 1232 ]]; then
|
||||||
green "✅ Passed logstash-vulnwhisperer-2019.03 document count == 1232"
|
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