lib/hackerone/client/report.rb in hackerone-client-0.4.0 vs lib/hackerone/client/report.rb in hackerone-client-0.5.0
- old
+ new
@@ -73,10 +73,28 @@
Activities.build(activity_data)
end
end
end
+ def program
+ @program || Program.find(relationships[:program][:data][:attributes][:handle])
+ end
+
+ def assign_to_user(name)
+ member = program.find_member(name)
+ _assign_to(member.user.id, :user)
+ end
+
+ def assign_to_group(name)
+ group = program.find_group(name)
+ _assign_to(group.id, :group)
+ end
+
+ def unassign
+ _assign_to(nil, :nobody)
+ end
+
private
def payments
activities.select { |activity| activity.is_a? Activities::BountyAwarded }
end
@@ -93,9 +111,25 @@
@report[:relationships]
end
def vulnerability_types
relationships.fetch(:vulnerability_types, {}).fetch(:data, [])
+ end
+
+ def _assign_to(assignee_id, assignee_type)
+ request_body = {
+ type: assignee_type,
+ }
+ request_body[:id] = assignee_id if assignee_id
+
+ response = HackerOne::Client::Api.hackerone_api_connection.put do |req|
+ req.headers['Content-Type'] = 'application/json'
+ req.url "reports/#{id}/assignee"
+ req.body = { data: request_body }.to_json
+ end
+ unless response.success?
+ fail("Unable to assign report #{id} to #{assignee_type} with id '#{assignee_id}'. Response status: #{response.status}, body: #{response.body}")
+ end
end
end
end
end