class Pipeline::Brakeman
Public Class Methods
new(trigger, tracker)
click to toggle source
Calls superclass method
Pipeline::BaseTask::new
# File lib/pipeline/tasks/brakeman.rb, line 11 def initialize(trigger, tracker) super(trigger, tracker) @name = "Brakeman" @description = "Source analysis for Ruby" @stage = :code @labels << "code" << "ruby" << "rails" end
Public Instance Methods
analyze()
click to toggle source
# File lib/pipeline/tasks/brakeman.rb, line 24 def analyze # puts @result begin parsed = JSON.parse(@result) parsed["warnings"].each do |warning| file = relative_path(warning['file'], @trigger.path) detail = "#{warning['message']}\n#{warning['link']}" if ! warning['line'] warning['line'] = "0" end if ! warning['code'] warning['code'] = "" end source = { :scanner => @name, :file => file, :line => warning['line'], :code => warning['code'].lstrip } report warning["warning_type"], detail, source, severity(warning["confidence"]), fingerprint("#{warning['message']}#{warning['link']}#{severity(warning["confidence"])}#{source}") end rescue Exception => e Pipeline.warn e.message Pipeline.warn e.backtrace end end
run()
click to toggle source
# File lib/pipeline/tasks/brakeman.rb, line 19 def run rootpath = @trigger.path @result=runsystem(true, "brakeman", "-A", "-q", "-f", "json", "#{rootpath}") end
supported?()
click to toggle source
# File lib/pipeline/tasks/brakeman.rb, line 48 def supported? supported=runsystem(true, "brakeman", "-v") if supported =~ /command not found/ Pipeline.notify "Run: gem install brakeman" return false else return true end end