Skip to content

Commit 9525d56

Browse files
committed
fixup! feat: add resolve report and close PR
1 parent 74be229 commit 9525d56

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

lib/prepare_security.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,16 @@ export default class PrepareSecurityRelease extends SecurityRelease {
5656

5757
this.req = new Request(credentials);
5858
const vulnerabilityJSON = this.readVulnerabilitiesJSON();
59+
this.cli.info('Closing and request disclosure to HackerOne reports');
5960
await this.closeAndRequestDisclosure(vulnerabilityJSON.reports);
61+
62+
this.cli.info('Closing pull requests');
6063
// For now, close the ones with vN.x label
6164
await this.closePRWithLabel(this.getAffectedVersions(vulnerabilityJSON));
62-
// TODO: Update next-security-release folder to current releaseDate
63-
// TODO: Merge the PR
65+
this.cli.info(`Merge pull request with:
66+
- git checkout main
67+
- git merge --squash ${NEXT_SECURITY_RELEASE_BRANCH}
68+
- git push origin main`);
6469
this.cli.ok('Done!');
6570
}
6671

@@ -278,30 +283,36 @@ export default class PrepareSecurityRelease extends SecurityRelease {
278283
}
279284

280285
async closeAndRequestDisclosure(jsonReports) {
286+
this.cli.startSpinner('Closing HackerOne reports');
281287
for (const report of jsonReports) {
288+
this.cli.updateSpinner(`Closing report ${report.id}...`);
282289
await this.req.updateReportState(
283290
report.id,
284291
'resolved',
285292
'Closing as resolved'
286293
);
287-
// TODO: Request Disclosure
294+
295+
this.cli.updateSpinner(`Requesting disclosure to report ${report.id}...`);
296+
await this.req.requestDisclosure(report.id);
288297
}
298+
this.cli.stopSpinner('Done closing H1 Reports and requesting disclosure');
289299
}
290300

291301
async closePRWithLabel(labels) {
292302
if (typeof labels === 'string') {
293303
labels = [labels];
294304
}
295305

296-
const url = 'https://github.com/nodejs-private/node-private/pulls'
306+
const url = 'https://github.com/nodejs-private/node-private/pulls';
307+
this.cli.startSpinner('Closing GitHub Pull Requests...');
297308
// At this point, GitHub does not provide filters through their REST API
298309
const prs = this.req.getPullRequest(url);
299310
for (const pr of prs) {
300311
if (pr.labels.some((l) => labels.includes(l))) {
301-
this.cli.info(`Closing Pull Request: ${pr.id}`);
302-
// TODO assert
312+
this.cli.updateSpinner(`Closing Pull Request: ${pr.id}`);
303313
await this.req.closePullRequest(pr.id);
304314
}
305315
}
316+
this.cli.startSpinner('Closed GitHub Pull Requests.');
306317
}
307318
}

lib/request.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,27 @@ export default class Request {
239239
return this.json(url, options);
240240
}
241241

242+
async requestDisclosure(reportId) {
243+
const url = `https://api.hackerone.com/v1/reports/${reportId}/disclosure_requests`;
244+
const options = {
245+
method: 'POST',
246+
headers: {
247+
Authorization: `Basic ${this.credentials.h1}`,
248+
'User-Agent': 'node-core-utils',
249+
Accept: 'application/json'
250+
},
251+
body: JSON.stringify({
252+
data: {
253+
attributes: {
254+
// default to limited version
255+
substate: 'no-content'
256+
}
257+
}
258+
})
259+
};
260+
return this.json(url, options);
261+
}
262+
242263
// This is for github v4 API queries, for other types of queries
243264
// use .text or .json
244265
async query(query, variables) {

lib/security-release/security-release.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,4 @@ export class SecurityRelease {
262262
})
263263
.join(', ');
264264
}
265-
266265
}

lib/update_security_release.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
pickReport,
77
getReportSeverity,
88
getSummary,
9-
SecurityRelease,
9+
SecurityRelease
1010
} from './security-release/security-release.js';
1111
import fs from 'node:fs';
1212
import auth from './auth.js';
@@ -44,6 +44,7 @@ export default class UpdateSecurityRelease extends SecurityRelease {
4444
prURL
4545
};
4646
}
47+
const vulnerabilitiesJSONPath = this.getVulnerabilitiesJSONPath();
4748
fs.writeFileSync(vulnerabilitiesJSONPath, JSON.stringify(content, null, 2));
4849
this.cli.ok('Synced vulnerabilities.json with HackerOne');
4950
}

0 commit comments

Comments
 (0)