hackerone-client 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -134,7 +134,7 @@ http_interactions:
134
134
  body:
135
135
  encoding: ASCII-8BIT
136
136
  string: '{"data":[{"id":"3683","type":"user","attributes":{"username":"demo-hacker","name":"Demo
137
- Hacker","disabled":false,"created_at":"2014-03-17T20:14:25.383Z","profile_picture":{"62x62":"https://profile-photos.hackerone-user-content.com/production/000/003/683/93c0f225152f8f18a396f325eca530143719a729_small.png?1423472503","82x82":"https://profile-photos.hackerone-user-content.com/production/000/003/683/d38d82a37a6ac1f2df43b0d36ad8ee8d0acd68d1_medium.png?1423472503","110x110":"https://profile-photos.hackerone-user-content.com/production/000/003/683/6793a1566a8c8ec72a179c63bbd92c1af965a162_large.png?1423472503","260x260":"https://profile-photos.hackerone-user-content.com/production/000/003/683/0201a343075ea8f7feb7aff975c6a48cc53536c7_xtralarge.png?1423472503"}}},{"id":"147515","type":"user","attributes":{"username":"hackhackhackhack","name":"hackhackhackhack","disabled":false,"created_at":"2017-03-04T16:31:33.595Z","profile_picture":{"62x62":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","82x82":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","110x110":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","260x260":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png"}}}],"links":{}}'
137
+ Hacker","disabled":false,"created_at":"2014-03-17T20:14:25.383Z","profile_picture":{"62x62":"https://profile-photos.hackerone-user-content.com/production/000/003/683/93c0f225152f8f18a396f325eca530143719a729_small.png?1423472503","82x82":"https://profile-photos.hackerone-user-content.com/production/000/003/683/d38d82a37a6ac1f2df43b0d36ad8ee8d0acd68d1_medium.png?1423472503","110x110":"https://profile-photos.hackerone-user-content.com/production/000/003/683/6793a1566a8c8ec72a179c63bbd92c1af965a162_large.png?1423472503","260x260":"https://profile-photos.hackerone-user-content.com/production/000/003/683/0201a343075ea8f7feb7aff975c6a48cc53536c7_xtralarge.png?1423472503"}}},{"id":"147515","type":"user","attributes":{"username":"esjee","name":"esjee","disabled":false,"created_at":"2017-03-04T16:31:33.595Z","profile_picture":{"62x62":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","82x82":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","110x110":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","260x260":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png"}}}],"links":{}}'
138
138
  http_version:
139
139
  recorded_at: Sun, 09 Apr 2017 08:58:54 GMT
140
140
  - request:
@@ -271,7 +271,7 @@ http_interactions:
271
271
  body:
272
272
  encoding: ASCII-8BIT
273
273
  string: '{"data":[{"id":"3683","type":"user","attributes":{"username":"demo-hacker","name":"Demo
274
- Hacker","disabled":false,"created_at":"2014-03-17T20:14:25.383Z","profile_picture":{"62x62":"https://profile-photos.hackerone-user-content.com/production/000/003/683/93c0f225152f8f18a396f325eca530143719a729_small.png?1423472503","82x82":"https://profile-photos.hackerone-user-content.com/production/000/003/683/d38d82a37a6ac1f2df43b0d36ad8ee8d0acd68d1_medium.png?1423472503","110x110":"https://profile-photos.hackerone-user-content.com/production/000/003/683/6793a1566a8c8ec72a179c63bbd92c1af965a162_large.png?1423472503","260x260":"https://profile-photos.hackerone-user-content.com/production/000/003/683/0201a343075ea8f7feb7aff975c6a48cc53536c7_xtralarge.png?1423472503"}}},{"id":"147515","type":"user","attributes":{"username":"hackhackhackhack","name":"hackhackhackhack","disabled":false,"created_at":"2017-03-04T16:31:33.595Z","profile_picture":{"62x62":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","82x82":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","110x110":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","260x260":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png"}}}],"links":{}}'
274
+ Hacker","disabled":false,"created_at":"2014-03-17T20:14:25.383Z","profile_picture":{"62x62":"https://profile-photos.hackerone-user-content.com/production/000/003/683/93c0f225152f8f18a396f325eca530143719a729_small.png?1423472503","82x82":"https://profile-photos.hackerone-user-content.com/production/000/003/683/d38d82a37a6ac1f2df43b0d36ad8ee8d0acd68d1_medium.png?1423472503","110x110":"https://profile-photos.hackerone-user-content.com/production/000/003/683/6793a1566a8c8ec72a179c63bbd92c1af965a162_large.png?1423472503","260x260":"https://profile-photos.hackerone-user-content.com/production/000/003/683/0201a343075ea8f7feb7aff975c6a48cc53536c7_xtralarge.png?1423472503"}}},{"id":"147515","type":"user","attributes":{"username":"esjee","name":"esjee","disabled":false,"created_at":"2017-03-04T16:31:33.595Z","profile_picture":{"62x62":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","82x82":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","110x110":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","260x260":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png"}}}],"links":{}}'
275
275
  http_version:
276
276
  recorded_at: Sun, 09 Apr 2017 08:58:57 GMT
277
277
  recorded_with: VCR 3.0.3
@@ -0,0 +1,220 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.hackerone.com/v1/me/programs
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Basic nope
12
+ User-Agent:
13
+ - Faraday v0.12.1
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Mon, 15 May 2017 20:20:31 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - __cfduid=d0d7a99fec927bfdcfe90f873ba28a7521494879631; expires=Tue, 15-May-18
33
+ 20:20:31 GMT; path=/; Domain=api.hackerone.com; HttpOnly
34
+ X-Request-Id:
35
+ - f96eea01-21d7-4a34-8cb4-29f76636de9b
36
+ Etag:
37
+ - W/"9329ef6b8f370e76d96d71977a6480c4"
38
+ Cache-Control:
39
+ - max-age=0, private, must-revalidate
40
+ Strict-Transport-Security:
41
+ - max-age=31536000; includeSubDomains; preload
42
+ Content-Security-Policy:
43
+ - 'default-src ''none''; base-uri ''self''; block-all-mixed-content; child-src
44
+ www.youtube-nocookie.com; connect-src ''self'' www.google-analytics.com errors.hackerone.net;
45
+ font-src ''self''; form-action ''self''; frame-ancestors ''none''; img-src
46
+ ''self'' data: cover-photos.hackerone-user-content.com profile-photos.hackerone-user-content.com
47
+ hackerone-attachments.s3.amazonaws.com; media-src ''self'' hackerone-attachments.s3.amazonaws.com;
48
+ script-src ''self'' www.google-analytics.com; style-src ''self'' ''unsafe-inline'';
49
+ report-uri https://errors.hackerone.net/api/30/csp-report/?sentry_key=61c1e2f50d21487c97a071737701f598'
50
+ X-Content-Type-Options:
51
+ - nosniff
52
+ X-Download-Options:
53
+ - noopen
54
+ X-Frame-Options:
55
+ - DENY
56
+ X-Permitted-Cross-Domain-Policies:
57
+ - none
58
+ X-Xss-Protection:
59
+ - 1; mode=block
60
+ Public-Key-Pins-Report-Only:
61
+ - pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=";
62
+ pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=";
63
+ pin-sha256="cGuxAXyFXFkWm61cF4HPWX8S0srS9j0aSqN0k4AP+4A="; pin-sha256="bIlWcjiKq1mftH/xd7Hw1JO77Cr+Gv+XYcGUQWwO+A4=";
64
+ pin-sha256="tXD+dGAP8rGY4PW1be90cOYEwg7pZ4G+yPZmIZWPTSg="; max-age=600; includeSubDomains;
65
+ report-uri="https://hackerone.report-uri.io/r/default/hpkp/reportOnly"
66
+ Server:
67
+ - cloudflare-nginx
68
+ Cf-Ray:
69
+ - 35f8cc5f2ee7731f-AMS
70
+ body:
71
+ encoding: ASCII-8BIT
72
+ string: '{"data":[{"id":"18969","type":"program","attributes":{"handle":"github","created_at":"2017-03-08T19:22:41.884Z","updated_at":"2017-04-09T08:15:15.228Z"}}],"links":{}}'
73
+ http_version:
74
+ recorded_at: Mon, 15 May 2017 20:19:59 GMT
75
+ - request:
76
+ method: get
77
+ uri: https://api.hackerone.com/v1/programs/18969
78
+ body:
79
+ encoding: US-ASCII
80
+ string: ''
81
+ headers:
82
+ Authorization:
83
+ - Basic nope
84
+ User-Agent:
85
+ - Faraday v0.12.1
86
+ Accept-Encoding:
87
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
88
+ Accept:
89
+ - "*/*"
90
+ response:
91
+ status:
92
+ code: 200
93
+ message: OK
94
+ headers:
95
+ Date:
96
+ - Mon, 15 May 2017 20:20:31 GMT
97
+ Content-Type:
98
+ - application/json; charset=utf-8
99
+ Transfer-Encoding:
100
+ - chunked
101
+ Connection:
102
+ - keep-alive
103
+ Set-Cookie:
104
+ - __cfduid=d7481764f9fe167307e10d54154693b3e1494879631; expires=Tue, 15-May-18
105
+ 20:20:31 GMT; path=/; Domain=api.hackerone.com; HttpOnly
106
+ X-Request-Id:
107
+ - 8a0439ed-d918-48e7-8cd2-c7de461490f1
108
+ Etag:
109
+ - W/"83a960a017993aaa92b252a3d4665ec0"
110
+ Cache-Control:
111
+ - max-age=0, private, must-revalidate
112
+ Strict-Transport-Security:
113
+ - max-age=31536000; includeSubDomains; preload
114
+ Content-Security-Policy:
115
+ - 'default-src ''none''; base-uri ''self''; block-all-mixed-content; child-src
116
+ www.youtube-nocookie.com; connect-src ''self'' www.google-analytics.com errors.hackerone.net;
117
+ font-src ''self''; form-action ''self''; frame-ancestors ''none''; img-src
118
+ ''self'' data: cover-photos.hackerone-user-content.com profile-photos.hackerone-user-content.com
119
+ hackerone-attachments.s3.amazonaws.com; media-src ''self'' hackerone-attachments.s3.amazonaws.com;
120
+ script-src ''self'' www.google-analytics.com; style-src ''self'' ''unsafe-inline'';
121
+ report-uri https://errors.hackerone.net/api/30/csp-report/?sentry_key=61c1e2f50d21487c97a071737701f598'
122
+ X-Content-Type-Options:
123
+ - nosniff
124
+ X-Download-Options:
125
+ - noopen
126
+ X-Frame-Options:
127
+ - DENY
128
+ X-Permitted-Cross-Domain-Policies:
129
+ - none
130
+ X-Xss-Protection:
131
+ - 1; mode=block
132
+ Public-Key-Pins-Report-Only:
133
+ - pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=";
134
+ pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=";
135
+ pin-sha256="cGuxAXyFXFkWm61cF4HPWX8S0srS9j0aSqN0k4AP+4A="; pin-sha256="bIlWcjiKq1mftH/xd7Hw1JO77Cr+Gv+XYcGUQWwO+A4=";
136
+ pin-sha256="tXD+dGAP8rGY4PW1be90cOYEwg7pZ4G+yPZmIZWPTSg="; max-age=600; includeSubDomains;
137
+ report-uri="https://hackerone.report-uri.io/r/default/hpkp/reportOnly"
138
+ Server:
139
+ - cloudflare-nginx
140
+ Cf-Ray:
141
+ - 35f8cc611dc5722f-AMS
142
+ body:
143
+ encoding: ASCII-8BIT
144
+ string: '{"data":{"id":"18969","type":"program","attributes":{"handle":"github","created_at":"2017-03-08T19:22:41.884Z","updated_at":"2017-04-09T08:15:15.228Z"},"relationships":{"groups":{"data":[{"id":"23579","type":"group","attributes":{"name":"Standard","created_at":"2017-03-08T19:22:43.259Z","permissions":["report_management","reward_management"]}},{"id":"23578","type":"group","attributes":{"name":"Admin","created_at":"2017-03-08T19:22:43.243Z","permissions":["user_management","program_management"]}}]},"members":{"data":[{"id":"35928","type":"member","attributes":{"created_at":"2017-04-20T19:25:29.188Z","permissions":["program_management","report_management","reward_management","user_management"]},"relationships":{"user":{"data":{"id":"160844","type":"user","attributes":{"username":"esjee","name":null,"disabled":false,"created_at":"2017-04-20T19:25:29.165Z","profile_picture":{"62x62":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","82x82":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","110x110":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","260x260":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png"}}}}}},{"id":"32557","type":"member","attributes":{"created_at":"2017-03-08T19:22:44.421Z","permissions":["program_management","report_management","reward_management","user_management"]},"relationships":{"user":{"data":{"id":"147515","type":"user","attributes":{"username":"esjee","name":"esjee","disabled":false,"created_at":"2017-03-04T16:31:33.595Z","profile_picture":{"62x62":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","82x82":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","110x110":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png","260x260":"/assets/avatars/default-71a302d706457f3d3a31eb30fa3e73e6cf0b1d677b8fa218eaeaffd67ae97918.png"}}}}}},{"id":"32556","type":"member","attributes":{"created_at":"2017-03-08T19:22:43.226Z","permissions":["program_management","report_management","reward_management","user_management"]},"relationships":{"user":{"data":{"id":"4954","type":"user","attributes":{"username":"demo-member","name":"Demo
145
+ Member","disabled":false,"created_at":"2014-04-14T11:45:00.949Z","profile_picture":{"62x62":"https://profile-photos.hackerone-user-content.com/production/000/004/954/76e628d12eaacde79878b890df02c065f740b1a4_small.png?1423472456","82x82":"https://profile-photos.hackerone-user-content.com/production/000/004/954/75e4cf2599f591e618646429db57d986e496ccee_medium.png?1423472456","110x110":"https://profile-photos.hackerone-user-content.com/production/000/004/954/25f5c8af70323cacb2c2ffa17d68cac2500dc410_large.png?1423472456","260x260":"https://profile-photos.hackerone-user-content.com/production/000/004/954/d903c042cdc7798ad76684563624ee7ea071aed8_xtralarge.png?1423472456"}}}}}}]}}}}'
146
+ http_version:
147
+ recorded_at: Mon, 15 May 2017 20:19:59 GMT
148
+ - request:
149
+ method: put
150
+ uri: https://api.hackerone.com/v1/reports/200/assignee
151
+ body:
152
+ encoding: UTF-8
153
+ string: '{"data":{"id":"160844","type":"user"}}'
154
+ headers:
155
+ Authorization:
156
+ - Basic nope
157
+ User-Agent:
158
+ - Faraday v0.12.1
159
+ Content-Type:
160
+ - application/json
161
+ Accept-Encoding:
162
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
163
+ Accept:
164
+ - "*/*"
165
+ response:
166
+ status:
167
+ code: 500
168
+ message: Internal Server Error
169
+ headers:
170
+ Date:
171
+ - Mon, 15 May 2017 20:20:32 GMT
172
+ Content-Type:
173
+ - application/json; charset=utf-8
174
+ Transfer-Encoding:
175
+ - chunked
176
+ Connection:
177
+ - keep-alive
178
+ Set-Cookie:
179
+ - __cfduid=dde3c2d8330ab3c5d345982fe936253711494879631; expires=Tue, 15-May-18
180
+ 20:20:31 GMT; path=/; Domain=api.hackerone.com; HttpOnly
181
+ X-Request-Id:
182
+ - 714868f6-b785-4d49-984f-1df4e01c170f
183
+ Cache-Control:
184
+ - no-cache
185
+ Strict-Transport-Security:
186
+ - max-age=31536000; includeSubDomains; preload
187
+ Content-Security-Policy:
188
+ - 'default-src ''none''; base-uri ''self''; block-all-mixed-content; child-src
189
+ www.youtube-nocookie.com; connect-src ''self'' www.google-analytics.com errors.hackerone.net;
190
+ font-src ''self''; form-action ''self''; frame-ancestors ''none''; img-src
191
+ ''self'' data: cover-photos.hackerone-user-content.com profile-photos.hackerone-user-content.com
192
+ hackerone-attachments.s3.amazonaws.com; media-src ''self'' hackerone-attachments.s3.amazonaws.com;
193
+ script-src ''self'' www.google-analytics.com; style-src ''self'' ''unsafe-inline'';
194
+ report-uri https://errors.hackerone.net/api/30/csp-report/?sentry_key=61c1e2f50d21487c97a071737701f598'
195
+ X-Content-Type-Options:
196
+ - nosniff
197
+ X-Download-Options:
198
+ - noopen
199
+ X-Frame-Options:
200
+ - DENY
201
+ X-Permitted-Cross-Domain-Policies:
202
+ - none
203
+ X-Xss-Protection:
204
+ - 1; mode=block
205
+ Public-Key-Pins-Report-Only:
206
+ - pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=";
207
+ pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=";
208
+ pin-sha256="cGuxAXyFXFkWm61cF4HPWX8S0srS9j0aSqN0k4AP+4A="; pin-sha256="bIlWcjiKq1mftH/xd7Hw1JO77Cr+Gv+XYcGUQWwO+A4=";
209
+ pin-sha256="tXD+dGAP8rGY4PW1be90cOYEwg7pZ4G+yPZmIZWPTSg="; max-age=600; includeSubDomains;
210
+ report-uri="https://hackerone.report-uri.io/r/default/hpkp/reportOnly"
211
+ Server:
212
+ - cloudflare-nginx
213
+ Cf-Ray:
214
+ - 35f8cc634e9b2bee-AMS
215
+ body:
216
+ encoding: UTF-8
217
+ string: '{"errors":[{"status":500}]}'
218
+ http_version:
219
+ recorded_at: Mon, 15 May 2017 20:20:01 GMT
220
+ recorded_with: VCR 3.0.3
@@ -6,6 +6,9 @@ require_relative "client/report"
6
6
  require_relative "client/activity"
7
7
  require_relative "client/program"
8
8
  require_relative "client/reporter"
9
+ require_relative "client/member"
10
+ require_relative "client/user"
11
+ require_relative "client/group"
9
12
 
10
13
  module HackerOne
11
14
  module Client
@@ -0,0 +1,21 @@
1
+ module HackerOne
2
+ module Client
3
+ class Group
4
+ delegate :name, :permissions, to: :attributes
5
+
6
+ def initialize(group)
7
+ @group = group
8
+ end
9
+
10
+ def id
11
+ @group[:id]
12
+ end
13
+
14
+ private
15
+
16
+ def attributes
17
+ OpenStruct.new(@group[:attributes])
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ module HackerOne
2
+ module Client
3
+ class Member
4
+ delegate :permissions, to: :attributes
5
+
6
+ def initialize(member)
7
+ @member = member
8
+ end
9
+
10
+ def user
11
+ @user ||= User.new(relationships.user[:data])
12
+ end
13
+
14
+ def id
15
+ @member[:id]
16
+ end
17
+
18
+ private
19
+
20
+ def attributes
21
+ OpenStruct.new(@member[:attributes])
22
+ end
23
+
24
+ def relationships
25
+ OpenStruct.new(@member[:relationships])
26
+ end
27
+ end
28
+ end
29
+ end
@@ -21,8 +21,45 @@ module HackerOne
21
21
  OpenStruct.new(@program[:attributes])
22
22
  end
23
23
 
24
+ def member?(username)
25
+ find_member(username).present?
26
+ end
27
+
28
+ def group?(groupname)
29
+ find_group(groupname).present?
30
+ end
31
+
32
+ def find_member(username)
33
+ members.find { |member| member.user.username == username }
34
+ end
35
+
36
+ def find_group(groupname)
37
+ groups.find { |group| group.name == groupname }
38
+ end
39
+
24
40
  private
25
41
 
42
+ def members
43
+ @members ||= relationships.members[:data].map { |member_data| Member.new(member_data) }
44
+ end
45
+
46
+ def groups
47
+ @groups ||= relationships.groups[:data].map { |group_data| Group.new(group_data) }
48
+ end
49
+
50
+ def relationships
51
+ # Relationships are only included in the /programs/:id call,
52
+ # which is why we need to do a separate call here.
53
+ @relationships ||= begin
54
+ response = HackerOne::Client::Api.hackerone_api_connection.get do |req|
55
+ req.url "programs/#{id}"
56
+ end
57
+
58
+ data = HackerOne::Client::Api.parse_response(response)
59
+ OpenStruct.new(data[:relationships])
60
+ end
61
+ end
62
+
26
63
  def self.my_programs
27
64
  @my_programs ||= begin
28
65
  response = HackerOne::Client::Api.hackerone_api_connection.get do |req|
@@ -75,6 +75,24 @@ module HackerOne
75
75
  end
76
76
  end
77
77
 
78
+ def program
79
+ @program || Program.find(relationships[:program][:data][:attributes][:handle])
80
+ end
81
+
82
+ def assign_to_user(name)
83
+ member = program.find_member(name)
84
+ _assign_to(member.user.id, :user)
85
+ end
86
+
87
+ def assign_to_group(name)
88
+ group = program.find_group(name)
89
+ _assign_to(group.id, :group)
90
+ end
91
+
92
+ def unassign
93
+ _assign_to(nil, :nobody)
94
+ end
95
+
78
96
  private
79
97
 
80
98
  def payments
@@ -96,6 +114,22 @@ module HackerOne
96
114
  def vulnerability_types
97
115
  relationships.fetch(:vulnerability_types, {}).fetch(:data, [])
98
116
  end
117
+
118
+ def _assign_to(assignee_id, assignee_type)
119
+ request_body = {
120
+ type: assignee_type,
121
+ }
122
+ request_body[:id] = assignee_id if assignee_id
123
+
124
+ response = HackerOne::Client::Api.hackerone_api_connection.put do |req|
125
+ req.headers['Content-Type'] = 'application/json'
126
+ req.url "reports/#{id}/assignee"
127
+ req.body = { data: request_body }.to_json
128
+ end
129
+ unless response.success?
130
+ fail("Unable to assign report #{id} to #{assignee_type} with id '#{assignee_id}'. Response status: #{response.status}, body: #{response.body}")
131
+ end
132
+ end
99
133
  end
100
134
  end
101
135
  end
@@ -0,0 +1,21 @@
1
+ module HackerOne
2
+ module Client
3
+ class User
4
+ delegate :username, to: :attributes
5
+
6
+ def initialize(user)
7
+ @user = user
8
+ end
9
+
10
+ def id
11
+ @user[:id]
12
+ end
13
+
14
+ private
15
+
16
+ def attributes
17
+ OpenStruct.new(@user[:attributes])
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module Hackerone
2
2
  module Client
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackerone-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Matatall
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-21 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -126,6 +126,7 @@ files:
126
126
  - ".travis.yml"
127
127
  - CHANGELOG.md
128
128
  - CODE_OF_CONDUCT.md
129
+ - CONTRIBUTING.md
129
130
  - Gemfile
130
131
  - Guardfile
131
132
  - LICENSE.txt
@@ -134,6 +135,12 @@ files:
134
135
  - bin/console
135
136
  - bin/setup
136
137
  - fixtures/vcr_cassettes/add_report_reference.yml
138
+ - fixtures/vcr_cassettes/assign_report_to_group.yml
139
+ - fixtures/vcr_cassettes/assign_report_to_group_no_permission.yml
140
+ - fixtures/vcr_cassettes/assign_report_to_nobody.yml
141
+ - fixtures/vcr_cassettes/assign_report_to_nobody_no_permission.yml
142
+ - fixtures/vcr_cassettes/assign_report_to_user.yml
143
+ - fixtures/vcr_cassettes/assign_report_to_user_no_permission.yml
137
144
  - fixtures/vcr_cassettes/empty_report_list.yml
138
145
  - fixtures/vcr_cassettes/missing_report.yml
139
146
  - fixtures/vcr_cassettes/programs.yml
@@ -141,13 +148,17 @@ files:
141
148
  - fixtures/vcr_cassettes/report_list.yml
142
149
  - fixtures/vcr_cassettes/reporters.yml
143
150
  - fixtures/vcr_cassettes/server_error.yml
151
+ - fixtures/vcr_cassettes/server_error_when_assigning_report_to_user.yml
144
152
  - fixtures/vcr_cassettes/stage_change.yml
145
153
  - hackerone-client.gemspec
146
154
  - lib/hackerone/client.rb
147
155
  - lib/hackerone/client/activity.rb
156
+ - lib/hackerone/client/group.rb
157
+ - lib/hackerone/client/member.rb
148
158
  - lib/hackerone/client/program.rb
149
159
  - lib/hackerone/client/report.rb
150
160
  - lib/hackerone/client/reporter.rb
161
+ - lib/hackerone/client/user.rb
151
162
  - lib/hackerone/client/version.rb
152
163
  - lib/hackerone/client/weakness.rb
153
164
  homepage: https://github.com/oreoshake/hackerone-client
@@ -170,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
181
  version: '0'
171
182
  requirements: []
172
183
  rubyforge_project:
173
- rubygems_version: 2.4.5.1
184
+ rubygems_version: 2.2.0
174
185
  signing_key:
175
186
  specification_version: 4
176
187
  summary: A limited client for the HackerOne API