hackerone-client 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19b5c8045568698cffb058a287be354b48252d72
4
- data.tar.gz: 1a839adb7d84c5c61ac7f019f31a752425c9c3fc
3
+ metadata.gz: 794e38d3185f76e57cc54c068d18aa55c47f1603
4
+ data.tar.gz: b27ec2e1e57def5a56f4c6ea05f64c434ba361b5
5
5
  SHA512:
6
- metadata.gz: eddbaa770af39b40503c29ced0b963b40c673fff48312114f806c040d13fddfd6f24d1cfac1c06f74c6b45ddf3561c9d1228e087ec41d0b2a4144821b0d83350
7
- data.tar.gz: 0ddc584b516d072e2c8e32f216be16d4e16dc38d39ee99b0e52bf89737a79ec948ccd044c8ef4bf5b1a919c35ffda3a795695955ef46151279af744d88c5b4a0
6
+ metadata.gz: 2a6a4da87504cf4768308a779e4d620464b3eaba5c7e22ae623bcb44f96c4bceb66fe9a30f2515d019a28a0a73598612de5ab740752c60f3172fa5b1084b9a49
7
+ data.tar.gz: 961ffd6216a04ee835e37818a362c9b2472e9affd6f830cfd603fc0a0a5f1f0fbbaa9def0f024d1b009f15bf7268af54feff348976dacb006737d27394374908
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.8.0] - 2017-09-05
2
+
3
+ - Feature: add ability to suggest and award swag, cash, and bonuses (@esjee)
4
+
1
5
  ## [0.7.0] - 2017-08-28
2
6
 
3
7
  - Feature: retrieve common responses (@esjee)
data/README.md CHANGED
@@ -15,6 +15,15 @@ report = client.report(id)
15
15
  report.assign_to_user("username")
16
16
  report.assign_to_group("groupname")
17
17
 
18
+ # POST /reports/{id}/bounty_suggestions
19
+ report.suggest_bounty(message: "I suggest $500 with a small bonus. Report is well-written.", amount: 500, bonus_amount: 50)
20
+
21
+ # POST /reports/{id}/bounties
22
+ report.award_bounty(message: "Here's your bounty!", amount: 500, bonus_amount: 50)
23
+
24
+ # POST /reports/{id}/swags
25
+ report.award_swag(message: "Here's your T-Shirt")
26
+
18
27
  # POST '/reports/#{id}/activities'
19
28
 
20
29
  client.add_comment(id, message, internal: false) # internal is true by default
@@ -0,0 +1,78 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.hackerone.com/v1/reports/200/bounties
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"message":"Thanks for the great report!","amount":1330,"bonus_amount":7}}'
9
+ headers:
10
+ Authorization:
11
+ - Basic NOPE
12
+ User-Agent:
13
+ - Faraday v0.13.0
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Date:
26
+ - Tue, 22 Aug 2017 15:03:46 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Set-Cookie:
34
+ - __cfduid=d068dbf4c0fe50bf2d44f3cb68388bbd11503414225; expires=Wed, 22-Aug-18
35
+ 15:03:45 GMT; path=/; Domain=api.hackerone.com; HttpOnly
36
+ X-Request-Id:
37
+ - 723974f5-3988-4f59-ae9e-70198ab702d9
38
+ Etag:
39
+ - W/"f8d7a0dd4f35f9a89533b12bc651ccca"
40
+ Cache-Control:
41
+ - max-age=0, private, must-revalidate
42
+ Strict-Transport-Security:
43
+ - max-age=31536000; includeSubDomains; preload
44
+ Content-Security-Policy:
45
+ - 'default-src ''none''; base-uri ''self''; block-all-mixed-content; child-src
46
+ www.youtube-nocookie.com; connect-src ''self'' www.google-analytics.com errors.hackerone.net;
47
+ font-src ''self''; form-action ''self''; frame-ancestors ''none''; img-src
48
+ ''self'' data: cover-photos.hackerone-user-content.com hackathon-photos.hackerone-user-content.com
49
+ profile-photos.hackerone-user-content.com hackerone-attachments.s3.amazonaws.com;
50
+ media-src ''self'' hackerone-attachments.s3.amazonaws.com; script-src ''self''
51
+ www.google-analytics.com; style-src ''self'' ''unsafe-inline''; report-uri
52
+ https://errors.hackerone.net/api/30/csp-report/?sentry_key=61c1e2f50d21487c97a071737701f598'
53
+ X-Content-Type-Options:
54
+ - nosniff
55
+ X-Download-Options:
56
+ - noopen
57
+ X-Frame-Options:
58
+ - DENY
59
+ X-Permitted-Cross-Domain-Policies:
60
+ - none
61
+ X-Xss-Protection:
62
+ - 1; mode=block
63
+ Public-Key-Pins-Report-Only:
64
+ - pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=";
65
+ pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=";
66
+ pin-sha256="cGuxAXyFXFkWm61cF4HPWX8S0srS9j0aSqN0k4AP+4A="; pin-sha256="bIlWcjiKq1mftH/xd7Hw1JO77Cr+Gv+XYcGUQWwO+A4=";
67
+ pin-sha256="tXD+dGAP8rGY4PW1be90cOYEwg7pZ4G+yPZmIZWPTSg="; max-age=600; includeSubDomains;
68
+ report-uri="https://hackerone.report-uri.io/r/default/hpkp/reportOnly"
69
+ Server:
70
+ - cloudflare-nginx
71
+ Cf-Ray:
72
+ - 3926b87dce5c0761-AMS
73
+ body:
74
+ encoding: UTF-8
75
+ string: '{"data":{"id":"58549","type":"bounty","attributes":{"amount":"1330.00","bonus_amount":"7.00","awarded_amount":"1330.00","awarded_bonus_amount":"7.00","awarded_currency":"USD","created_at":"2017-08-22T15:03:46.183Z"}}}'
76
+ http_version:
77
+ recorded_at: Tue, 22 Aug 2017 15:03:45 GMT
78
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,78 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.hackerone.com/v1/reports/200/swags
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"message":"Enjoy this cool swag!"}}'
9
+ headers:
10
+ Authorization:
11
+ - Basic NOPE
12
+ User-Agent:
13
+ - Faraday v0.13.0
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Date:
26
+ - Tue, 22 Aug 2017 15:09:44 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Set-Cookie:
34
+ - __cfduid=d09e856041f6ae0c3a2a91e50ba326b211503414583; expires=Wed, 22-Aug-18
35
+ 15:09:43 GMT; path=/; Domain=api.hackerone.com; HttpOnly
36
+ X-Request-Id:
37
+ - 8d9d9f70-ee1e-49a8-b396-0d763383d9e2
38
+ Etag:
39
+ - W/"31f75873e2b18f42b69b8d094d270f58"
40
+ Cache-Control:
41
+ - max-age=0, private, must-revalidate
42
+ Strict-Transport-Security:
43
+ - max-age=31536000; includeSubDomains; preload
44
+ Content-Security-Policy:
45
+ - 'default-src ''none''; base-uri ''self''; block-all-mixed-content; child-src
46
+ www.youtube-nocookie.com; connect-src ''self'' www.google-analytics.com errors.hackerone.net;
47
+ font-src ''self''; form-action ''self''; frame-ancestors ''none''; img-src
48
+ ''self'' data: cover-photos.hackerone-user-content.com hackathon-photos.hackerone-user-content.com
49
+ profile-photos.hackerone-user-content.com hackerone-attachments.s3.amazonaws.com;
50
+ media-src ''self'' hackerone-attachments.s3.amazonaws.com; script-src ''self''
51
+ www.google-analytics.com; style-src ''self'' ''unsafe-inline''; report-uri
52
+ https://errors.hackerone.net/api/30/csp-report/?sentry_key=61c1e2f50d21487c97a071737701f598'
53
+ X-Content-Type-Options:
54
+ - nosniff
55
+ X-Download-Options:
56
+ - noopen
57
+ X-Frame-Options:
58
+ - DENY
59
+ X-Permitted-Cross-Domain-Policies:
60
+ - none
61
+ X-Xss-Protection:
62
+ - 1; mode=block
63
+ Public-Key-Pins-Report-Only:
64
+ - pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=";
65
+ pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=";
66
+ pin-sha256="cGuxAXyFXFkWm61cF4HPWX8S0srS9j0aSqN0k4AP+4A="; pin-sha256="bIlWcjiKq1mftH/xd7Hw1JO77Cr+Gv+XYcGUQWwO+A4=";
67
+ pin-sha256="tXD+dGAP8rGY4PW1be90cOYEwg7pZ4G+yPZmIZWPTSg="; max-age=600; includeSubDomains;
68
+ report-uri="https://hackerone.report-uri.io/r/default/hpkp/reportOnly"
69
+ Server:
70
+ - cloudflare-nginx
71
+ Cf-Ray:
72
+ - 3926c13b49050761-AMS
73
+ body:
74
+ encoding: UTF-8
75
+ string: '{"data":{"id":"2057","type":"swag","attributes":{"sent":false,"created_at":"2017-08-22T15:09:44.176Z"}}}'
76
+ http_version:
77
+ recorded_at: Tue, 22 Aug 2017 15:09:43 GMT
78
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,80 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.hackerone.com/v1/reports/200/bounty_suggestions
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"message":"This report is great, I think we should award a
9
+ high bounty.","amount":5000,"bonus_amount":2500}}'
10
+ headers:
11
+ Authorization:
12
+ - Basic NOPE
13
+ User-Agent:
14
+ - Faraday v0.13.0
15
+ Content-Type:
16
+ - application/json
17
+ Accept-Encoding:
18
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
19
+ Accept:
20
+ - "*/*"
21
+ response:
22
+ status:
23
+ code: 201
24
+ message: Created
25
+ headers:
26
+ Date:
27
+ - Tue, 22 Aug 2017 15:10:02 GMT
28
+ Content-Type:
29
+ - application/json; charset=utf-8
30
+ Transfer-Encoding:
31
+ - chunked
32
+ Connection:
33
+ - keep-alive
34
+ Set-Cookie:
35
+ - __cfduid=d024b34c2f975a4ee9ede2a5bc288fdc11503414602; expires=Wed, 22-Aug-18
36
+ 15:10:02 GMT; path=/; Domain=api.hackerone.com; HttpOnly
37
+ X-Request-Id:
38
+ - 6114bb66-4dad-4bb0-8913-530c38758156
39
+ Etag:
40
+ - W/"554f310fcd9c49f5d069ea686e38e8e2"
41
+ Cache-Control:
42
+ - max-age=0, private, must-revalidate
43
+ Strict-Transport-Security:
44
+ - max-age=31536000; includeSubDomains; preload
45
+ Content-Security-Policy:
46
+ - 'default-src ''none''; base-uri ''self''; block-all-mixed-content; child-src
47
+ www.youtube-nocookie.com; connect-src ''self'' www.google-analytics.com errors.hackerone.net;
48
+ font-src ''self''; form-action ''self''; frame-ancestors ''none''; img-src
49
+ ''self'' data: cover-photos.hackerone-user-content.com hackathon-photos.hackerone-user-content.com
50
+ profile-photos.hackerone-user-content.com hackerone-attachments.s3.amazonaws.com;
51
+ media-src ''self'' hackerone-attachments.s3.amazonaws.com; script-src ''self''
52
+ www.google-analytics.com; style-src ''self'' ''unsafe-inline''; report-uri
53
+ https://errors.hackerone.net/api/30/csp-report/?sentry_key=61c1e2f50d21487c97a071737701f598'
54
+ X-Content-Type-Options:
55
+ - nosniff
56
+ X-Download-Options:
57
+ - noopen
58
+ X-Frame-Options:
59
+ - DENY
60
+ X-Permitted-Cross-Domain-Policies:
61
+ - none
62
+ X-Xss-Protection:
63
+ - 1; mode=block
64
+ Public-Key-Pins-Report-Only:
65
+ - pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=";
66
+ pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=";
67
+ pin-sha256="cGuxAXyFXFkWm61cF4HPWX8S0srS9j0aSqN0k4AP+4A="; pin-sha256="bIlWcjiKq1mftH/xd7Hw1JO77Cr+Gv+XYcGUQWwO+A4=";
68
+ pin-sha256="tXD+dGAP8rGY4PW1be90cOYEwg7pZ4G+yPZmIZWPTSg="; max-age=600; includeSubDomains;
69
+ report-uri="https://hackerone.report-uri.io/r/default/hpkp/reportOnly"
70
+ Server:
71
+ - cloudflare-nginx
72
+ Cf-Ray:
73
+ - 3926c1aecfdb2c72-AMS
74
+ body:
75
+ encoding: UTF-8
76
+ string: '{"data":{"type":"activity-bounty-suggested","id":"1946481","attributes":{"message":"This
77
+ report is great, I think we should award a high bounty.","created_at":"2017-08-22T15:10:02.699Z","updated_at":"2017-08-22T15:10:02.699Z","internal":true,"bounty_amount":"5,000","bonus_amount":"2,500"},"relationships":{"actor":{"data":{"type":"user","id":"193855","attributes":{"username":"sjors","name":null,"disabled":false,"created_at":"2017-08-22T13:18:29.084Z","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"}}}}}}}'
78
+ http_version:
79
+ recorded_at: Tue, 22 Aug 2017 15:10:02 GMT
80
+ recorded_with: VCR 3.0.3
@@ -10,6 +10,8 @@ require_relative "client/member"
10
10
  require_relative "client/user"
11
11
  require_relative "client/group"
12
12
  require_relative "client/structured_scope"
13
+ require_relative "client/swag"
14
+ require_relative "client/bounty"
13
15
 
14
16
  module HackerOne
15
17
  module Client
@@ -57,13 +57,18 @@ module HackerOne
57
57
  delegate :message, :internal, to: :attributes
58
58
  end
59
59
 
60
+ class BountySuggested < Activity
61
+ delegate :message, :bounty_amount, :bonus_amount, to: :attributes
62
+ end
63
+
60
64
  ACTIVITY_TYPE_CLASS_MAPPING = {
61
65
  'activity-bounty-awarded' => BountyAwarded,
62
66
  'activity-swag-awarded' => SwagAwarded,
63
67
  'activity-user-assigned-to-bug' => UserAssignedToBug,
64
68
  'activity-bug-triaged' => BugTriaged,
65
69
  'activity-reference-id-added' => ReferenceIdAdded,
66
- 'activity-comment' => CommentAdded
70
+ 'activity-comment' => CommentAdded,
71
+ 'activity-bounty-suggested' => BountySuggested
67
72
  }.freeze
68
73
 
69
74
  def self.build(activity_data)
@@ -0,0 +1,29 @@
1
+ module HackerOne
2
+ module Client
3
+ class Bounty
4
+ delegate(
5
+ :amount,
6
+ :bonus_amount,
7
+ :awarded_amount,
8
+ :awarded_bonus_amount,
9
+ :awarded_currency,
10
+ :created_at,
11
+ to: :attributes
12
+ )
13
+
14
+ def initialize(bounty)
15
+ @bounty = bounty
16
+ end
17
+
18
+ def id
19
+ @bounty[:id]
20
+ end
21
+
22
+ private
23
+
24
+ def attributes
25
+ OpenStruct.new(@bounty[:attributes])
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,9 +1,12 @@
1
+ require_relative './resource_helper'
1
2
  require_relative './weakness'
2
3
  require_relative './activity'
3
4
 
4
5
  module HackerOne
5
6
  module Client
6
7
  class Report
8
+ include ResourceHelper
9
+
7
10
  def initialize(report)
8
11
  @report = report
9
12
  end
@@ -83,6 +86,46 @@ module HackerOne
83
86
  @program || Program.find(relationships[:program][:data][:attributes][:handle])
84
87
  end
85
88
 
89
+ def award_bounty(message:, amount:, bonus_amount: nil)
90
+ request_body = {
91
+ message: message,
92
+ amount: amount,
93
+ bonus_amount: bonus_amount
94
+ }
95
+
96
+ response_body = make_post_request(
97
+ "reports/#{id}/bounties",
98
+ request_body: request_body
99
+ )
100
+ Bounty.new(response_body)
101
+ end
102
+
103
+ def award_swag(message:)
104
+ request_body = {
105
+ message: message
106
+ }
107
+
108
+ response_body = make_post_request(
109
+ "reports/#{id}/swags",
110
+ request_body: request_body
111
+ )
112
+ Swag.new(response_body)
113
+ end
114
+
115
+ def suggest_bounty(message:, amount:, bonus_amount: nil)
116
+ request_body = {
117
+ message: message,
118
+ amount: amount,
119
+ bonus_amount: bonus_amount
120
+ }
121
+
122
+ response_body = make_post_request(
123
+ "reports/#{id}/bounty_suggestions",
124
+ request_body: request_body
125
+ )
126
+ Activities.build(response_body)
127
+ end
128
+
86
129
  def assign_to_user(name)
87
130
  member = program.find_member(name)
88
131
  _assign_to(member.user.id, :user)
@@ -0,0 +1,21 @@
1
+ module HackerOne
2
+ module Client
3
+ class Swag
4
+ delegate :sent, :created_at, to: :attributes
5
+
6
+ def initialize(swag)
7
+ @swag = swag
8
+ end
9
+
10
+ def id
11
+ @swag[:id]
12
+ end
13
+
14
+ private
15
+
16
+ def attributes
17
+ OpenStruct.new(@swag[:attributes])
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module Hackerone
2
2
  module Client
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.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.7.0
4
+ version: 0.8.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-08-28 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,6 +142,8 @@ files:
142
142
  - fixtures/vcr_cassettes/assign_report_to_nobody_no_permission.yml
143
143
  - fixtures/vcr_cassettes/assign_report_to_user.yml
144
144
  - fixtures/vcr_cassettes/assign_report_to_user_no_permission.yml
145
+ - fixtures/vcr_cassettes/award_a_bounty.yml
146
+ - fixtures/vcr_cassettes/award_swag.yml
145
147
  - fixtures/vcr_cassettes/common_responses.yml
146
148
  - fixtures/vcr_cassettes/empty_report_list.yml
147
149
  - fixtures/vcr_cassettes/missing_report.yml
@@ -152,9 +154,11 @@ files:
152
154
  - fixtures/vcr_cassettes/server_error.yml
153
155
  - fixtures/vcr_cassettes/server_error_when_assigning_report_to_user.yml
154
156
  - fixtures/vcr_cassettes/stage_change.yml
157
+ - fixtures/vcr_cassettes/suggest_a_bounty.yml
155
158
  - hackerone-client.gemspec
156
159
  - lib/hackerone/client.rb
157
160
  - lib/hackerone/client/activity.rb
161
+ - lib/hackerone/client/bounty.rb
158
162
  - lib/hackerone/client/group.rb
159
163
  - lib/hackerone/client/member.rb
160
164
  - lib/hackerone/client/program.rb
@@ -162,6 +166,7 @@ files:
162
166
  - lib/hackerone/client/reporter.rb
163
167
  - lib/hackerone/client/resource_helper.rb
164
168
  - lib/hackerone/client/structured_scope.rb
169
+ - lib/hackerone/client/swag.rb
165
170
  - lib/hackerone/client/user.rb
166
171
  - lib/hackerone/client/version.rb
167
172
  - lib/hackerone/client/weakness.rb
@@ -185,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
190
  version: '0'
186
191
  requirements: []
187
192
  rubyforge_project:
188
- rubygems_version: 2.4.5.1
193
+ rubygems_version: 2.2.0
189
194
  signing_key:
190
195
  specification_version: 4
191
196
  summary: A limited client for the HackerOne API