Class: HackerOne::Client::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/hackerone/client/report.rb

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ Report

Returns a new instance of Report.



7
8
9
# File 'lib/hackerone/client/report.rb', line 7

def initialize(report)
  @report = report
end

Instance Method Details

#activitiesObject



70
71
72
73
74
# File 'lib/hackerone/client/report.rb', line 70

def activities
  relationships.dig(:activities, :data)&.map do |activity_data|
    Activities.build(activity_data)
  end
end

#classification_labelObject



61
62
63
# File 'lib/hackerone/client/report.rb', line 61

def classification_label
  weakness.to_owasp
end

#created_atObject



19
20
21
# File 'lib/hackerone/client/report.rb', line 19

def created_at
  attributes[:created_at]
end

#idObject



11
12
13
# File 'lib/hackerone/client/report.rb', line 11

def id
  @report[:id]
end

#issue_tracker_reference_urlObject



23
24
25
# File 'lib/hackerone/client/report.rb', line 23

def issue_tracker_reference_url
  attributes[:issue_tracker_reference_url]
end

#payment_totalObject



34
35
36
# File 'lib/hackerone/client/report.rb', line 34

def payment_total
  payments.reduce(0) { |total, payment| total + payment_amount(payment) }
end

#reporterObject



27
28
29
30
31
32
# File 'lib/hackerone/client/report.rb', line 27

def reporter
  relationships
    .fetch(:reporter, {})
    .fetch(:data, {})
    .fetch(:attributes, {})
end

#riskObject

Excludes reports where the payout amount is 0 indicating swag-only or no payout for the issue supplied



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hackerone/client/report.rb', line 40

def risk
  case payment_total
  when HackerOne::Client.low_range || DEFAULT_LOW_RANGE
    "low"
  when HackerOne::Client.medium_range || DEFAULT_MEDIUM_RANGE
    "medium"
  when HackerOne::Client.high_range || DEFAULT_HIGH_RANGE
    "high"
  when HackerOne::Client.critical_range || DEFAULT_CRITICAL_RANGE
    "critical"
  end
end

#summaryObject



53
54
55
# File 'lib/hackerone/client/report.rb', line 53

def summary
  attributes[:vulnerability_information]
end

#titleObject



15
16
17
# File 'lib/hackerone/client/report.rb', line 15

def title
  attributes[:title]
end

#weaknessObject



57
58
59
# File 'lib/hackerone/client/report.rb', line 57

def weakness
  @weakness ||= Weakness.new(relationships.fetch(:weakness, {}).fetch(:data, {}).fetch(:attributes, {}))
end

#writeup_classificationObject

Bounty writeups just use the key, and not the label value.



66
67
68
# File 'lib/hackerone/client/report.rb', line 66

def writeup_classification
  classification_label().split("-").first
end