Skip to content

Commit c4e7c03

Browse files
authored
feat: add PR_URL to vuln.json and fetch from H1 (#815)
1 parent 8673073 commit c4e7c03

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

lib/prepare_security.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ export default class PrepareSecurityRelease {
248248
});
249249

250250
try {
251-
const prUrl = dep.replace('https://github.com/', 'https://api.github.com/repos/').replace('pull', 'pulls');
252-
const res = await this.req.getPullRequest(prUrl);
251+
const res = await this.req.getPullRequest(dep);
253252
const { html_url, title } = res;
254253
deps.push({
255254
name,

lib/request.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export default class Request {
7777
return this.json(url, options);
7878
}
7979

80-
async getPullRequest(url) {
80+
async getPullRequest(fullUrl) {
81+
const prUrl = fullUrl.replace('https://github.com/', 'https://api.github.com/repos/').replace('pull', 'pulls');
8182
const options = {
8283
method: 'GET',
8384
headers: {
@@ -86,7 +87,7 @@ export default class Request {
8687
Accept: 'application/vnd.github+json'
8788
}
8889
};
89-
return this.json(url, options);
90+
return this.json(prUrl, options);
9091
}
9192

9293
async createPullRequest(title, body, { owner, repo, head, base }) {

lib/security-release/security-release.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export async function createIssue(title, content, repository, { cli, req }) {
142142
export async function pickReport(report, { cli, req }) {
143143
const {
144144
id, attributes: { title, cve_ids },
145-
relationships: { severity, weakness, reporter }
145+
relationships: { severity, weakness, reporter, custom_field_values }
146146
} = report;
147147
const link = `https://hackerone.com/reports/${id}`;
148148
const reportSeverity = {
@@ -165,16 +165,24 @@ export async function pickReport(report, { cli, req }) {
165165
defaultAnswer: await getSupportedVersions()
166166
});
167167

168-
let patchAuthors = await cli.prompt(
169-
'Add github username of the authors of the patch (split by comma if multiple)', {
170-
questionType: 'input',
171-
defaultAnswer: ''
172-
});
173-
174-
if (!patchAuthors) {
175-
patchAuthors = [];
168+
let prURL = '';
169+
let patchAuthors = [];
170+
if (custom_field_values.data.length) {
171+
prURL = custom_field_values.data[0].attributes.value;
172+
const { user } = await req.getPullRequest(prURL);
173+
patchAuthors = [user.login];
176174
} else {
177-
patchAuthors = patchAuthors.split(',').map((p) => p.trim());
175+
patchAuthors = await cli.prompt(
176+
'Add github username of the authors of the patch (split by comma if multiple)', {
177+
questionType: 'input',
178+
defaultAnswer: ''
179+
});
180+
181+
if (!patchAuthors) {
182+
patchAuthors = [];
183+
} else {
184+
patchAuthors = patchAuthors.split(',').map((p) => p.trim());
185+
}
178186
}
179187

180188
const summaryContent = await getSummary(id, req);
@@ -186,6 +194,7 @@ export async function pickReport(report, { cli, req }) {
186194
severity: reportSeverity,
187195
summary: summaryContent ?? '',
188196
patchAuthors,
197+
prURL,
189198
affectedVersions: versions.split(',').map((v) => v.replace('v', '').trim()),
190199
link,
191200
reporter: reporter.data.attributes.username

0 commit comments

Comments
 (0)