Class: Pipeline::Brakeman
- Includes:
- Util
- Defined in:
- lib/pipeline/tasks/brakeman.rb
Instance Attribute Summary
Attributes inherited from BaseTask
#appname, #description, #findings, #labels, #name, #stage, #trigger, #warnings
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(trigger, tracker) ⇒ Brakeman
constructor
A new instance of Brakeman.
- #run ⇒ Object
- #supported? ⇒ Boolean
Methods included from Util
#fingerprint, #relative_path, #runsystem, #strip_archive_path
Methods inherited from BaseTask
#directories_with?, #report, #severity, #warn
Constructor Details
#initialize(trigger, tracker) ⇒ Brakeman
Returns a new instance of Brakeman.
11 12 13 14 15 16 17 |
# 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 |
Instance Method Details
#analyze ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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. Pipeline.warn e.backtrace end end |
#run ⇒ Object
19 20 21 22 |
# File 'lib/pipeline/tasks/brakeman.rb', line 19 def run rootpath = @trigger.path @result=runsystem(true, "brakeman", "-A", "-q", "-f", "json", "#{rootpath}") end |