class Glue::JiraReporter

Attributes

format[RW]
name[RW]

Public Class Methods

new() click to toggle source
# File lib/glue/reporters/jira_reporter.rb, line 12
def initialize()
  @name = "JiraReporter"
  @format = :to_jira
end

Public Instance Methods

report(finding) click to toggle source
# File lib/glue/reporters/jira_reporter.rb, line 29
def report(finding)
      json = get_jira_json(finding)
      http = Curl.post("#{@api}/issue/", json.to_s) do |http|
              http.headers['Content-Type'] = "application/json"
              http.headers['Cookie'] = @cookie
      end
      if http.response_code != 201 # Created ...
              Glue.error "Problem with HTTP #{http.response_code} - #{http.body_str}"
      end
end
run_report(tracker) click to toggle source
# File lib/glue/reporters/jira_reporter.rb, line 17
def run_report(tracker)
  @project = tracker.options[:jira_project.to_s]
  @api = tracker.options[:jira_api_url.to_s]
  @cookie = tracker.options[:jira_cookie.to_s]
  @component = tracker.options[:jira_component.to_s]

  tracker.findings.each do |finding|
      report finding
  end
  "Results are in JIRA"
end

Private Instance Methods

get_jira_json(finding) click to toggle source
# File lib/glue/reporters/jira_reporter.rb, line 41
def get_jira_json(finding)
      json = {
      "fields": {
              "project":
              {
                      "key": "#{@project}"
              },
              "summary": "#{finding.appname} - #{finding.description}",
              "description": "#{finding.to_string}\n\nFINGERPRINT: #{finding.fingerprint}",
              "issuetype": {
                      "name": "Task"
              },
              "labels":["Glue","#{finding.appname}"],
              "components": [ { "name": "#{@component}" } ]
      }
      }.to_json
      json
end