Created
October 22, 2015 23:50
-
-
Save CelticParser/a4e48480439db3e7af0b to your computer and use it in GitHub Desktop.
Check for vulnerabilities in npm shrinkwrap-package dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task_security() { | |
# Reference: http://blog.nodesecurity.io/2014/02/01/new-feature-validate-modules-with-npm-shrinkwrap | |
if [ ! -f 'npm-shrinkwrap.json' ]; then | |
echo -e "\n\e[40mAudit: \e[101m[FAIL]\e[0;49;93;1m Create npm-shrinkwrap.json by running: \e[0m\n | |
$ npmflat --production\n" | |
exit 1; | |
fi | |
VULNERABILITIES=$(curl -s -XPOST \ | |
-d@npm-shrinkwrap.json \ | |
-HContent-type:application/json \ | |
https://nodesecurity.io/validate/shrinkwrap) | |
size=${#VULNERABILITIES} | |
if [ "$size" -eq "2" ]; then | |
echo -e "\n\e[40mAudit: \e[42m[PASS]\e[0;49;34;1m No vulnerabilities found in listed dependencies!\e[0m\n" | |
exit 0; | |
else | |
echo -e "\n\e[40mAudit: \e[101m[FAIL]\e[0;49;91;1;5m Vulnerabilities discovered in shrinkwrapped dependencies!\n" | |
echo "$VULNERABILITIES" | |
exit 1; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment