class Gergich::Capture::BrakemanCapture

Constants

SEVERITY_MAP

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

Public Instance Methods

run(output) click to toggle source
# 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 = "#{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"]],
      source: "brakeman"
    }
  }.compact
end