Class: Gergich::Capture::BrakemanCapture

Inherits:
BaseCapture show all
Defined in:
lib/gergich/capture/brakeman_capture.rb

Constant Summary collapse

SEVERITY_MAP =

Map Brakeman “confidence level” to severity. brakemanscanner.org/docs/confidence/

{
  "Weak" => "warn",
  "Medium" => "warn",
  "High" => "error"
}.freeze

Instance Method Summary collapse

Methods inherited from BaseCapture

inherited, normalize_captor_class_name

Instance Method Details

#run(output) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gergich/capture/brakeman_capture.rb', line 14

def run(output)
  # See brakeman_example.json for sample output.
  JSON.parse(output)["warnings"].map { |warning|
    message = "[brakeman] #{warning['warning_type']}: #{warning['message']}"
    message += "\n  Code: #{warning['code']}" if warning["code"]
    message += "\n  User Input: #{warning['user_input']}" if warning["user_input"]
    message += "\n  See: #{warning['link']}" if warning["link"]
    {
      path: warning["file"],
      position: warning["line"] || 0,
      message: message,
      severity: SEVERITY_MAP[warning["confidence"]]
    }
  }.compact
end