Last active
August 29, 2015 14:14
-
-
Save sho-h/e73c7cd9f01f781716ec to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
export PATH="/usr/local/bin/:$PATH" | |
eval "$(rbenv init - zsh)" | |
# Syntax check | |
ruby -w -c $1 | |
rc_exitcode=$? | |
# Brakeman vulnerability check | |
rails_root=`bundle exec rake about 2>/dev/null | grep "Application root" | awk '{print $3}'` | |
if [ "x${rails_root}" != "x" ]; then | |
bundle exec brakeman ${rails_root} -f json -z --only-files $1 | ruby -r json -e 'JSON.parse(STDIN.read)["warnings"].collect {|h| path = h["file"].gsub(File.dirname(h["file"]), File.dirname(ARGV[0])); [path, h["line"], h["warning_type"], h["message"]].join(":")}.each {|s| STDERR.puts s}' $1 | |
exit $? || $rc_exitcode | |
fi | |
exit $rc_exitcode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment