Skip to content

Instantly share code, notes, and snippets.

@CelticParser
Created October 22, 2015 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CelticParser/a4e48480439db3e7af0b to your computer and use it in GitHub Desktop.
Save CelticParser/a4e48480439db3e7af0b to your computer and use it in GitHub Desktop.
Check for vulnerabilities in npm shrinkwrap-package dependencies
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