module CC::Service::VulnerabilityHelper
  def vulnerability
    vulnerabilities.first || {}
  end

  def vulnerabilities
    payload.fetch("vulnerabilities", [])
  end

  def multiple?
    vulnerabilities.size > 1
  end

  def location_info
    if vulnerability["location"]
      " in #{vulnerability["location"]}"
    else
      ""
    end
  end

  def warning_type
    if multiple?
      payload["warning_type"]
    else
      vulnerability["warning_type"]
    end
  end
end
