Skip to content

Instantly share code, notes, and snippets.

@sho-h
Last active August 29, 2015 14:14
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 sho-h/e73c7cd9f01f781716ec to your computer and use it in GitHub Desktop.
Save sho-h/e73c7cd9f01f781716ec to your computer and use it in GitHub Desktop.
#!/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