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



74
75
76
77
78
79
80
# File 'lib/hackerone/client/report.rb', line 74

def activities
  if ships = relationships.fetch(:activities, {}).fetch(:data, [])
    ships.map do |activity_data|
      Activities.build(activity_data)
    end
  end
end

#assign_to_group(name) ⇒ Object



91
92
93
94
# File 'lib/hackerone/client/report.rb', line 91

def assign_to_group(name)
  group = program.find_group(name)
  _assign_to(group.id, :group)
end

#assign_to_user(name) ⇒ Object



86
87
88
89
# File 'lib/hackerone/client/report.rb', line 86

def assign_to_user(name)
  member = program.find_member(name)
  _assign_to(member.user.id, :user)
end

#classification_labelObject



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

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

#programObject



82
83
84
# File 'lib/hackerone/client/report.rb', line 82

def program
  @program || Program.find(relationships[:program][:data][:attributes][:handle])
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



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/hackerone/client/report.rb', line 44

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

#structured_scopeObject



38
39
40
# File 'lib/hackerone/client/report.rb', line 38

def structured_scope
  StructuredScope.new(relationships[:structured_scope].fetch(:data, {}))
end

#summaryObject



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

def summary
  attributes[:vulnerability_information]
end

#titleObject



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

def title
  attributes[:title]
end

#unassignObject



96
97
98
# File 'lib/hackerone/client/report.rb', line 96

def unassign
  _assign_to(nil, :nobody)
end

#weaknessObject



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

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.



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

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