Class: Danger::DangerBrakemanScanner

Inherits:
Plugin
  • Object
show all
Defined in:
lib/danger_plugin.rb

Overview

Run ruby files through Brakeman

Examples:

Run with default configuration in application directory


brakeman_scanner.run

See Also:

Direct Known Subclasses

DangerBrakeman

Instance Method Summary collapse

Instance Method Details

#run(options = File.dirname(Kernel.caller_locations.first.absolute_path)) ⇒ void

This method returns an undefined value.

Run a Brakeman scan over current application.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/danger_plugin.rb', line 18

def run(options = File.dirname(Kernel.caller_locations.first.absolute_path))
  tracker = Brakeman.run(options)

  warnings = if tracker.ignored_filter
               tracker.warnings.reject do |warning|
                 tracker.ignored_filter.ignored_warnings.include?(warning)
               end
             else
               tracker.warnings
             end
  return if warnings.empty? && tracker.errors.empty?

  markdown tracker.report.to_markdown
  failure "Brakeman static analysis detected issues in the code. " \
          "If this is a false positive, [mark it as such]" \
          "(https://brakemanscanner.org/docs/ignoring_false_positives/)."
end