Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions lib/prepare_security.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class PrepareSecurityRelease {
async createIssue(content, { cli }) {
const data = await this.req.createIssue(this.title, content, this.repository);
if (data.html_url) {
cli.ok('Created: ' + data.html_url);
cli.ok(`Created: ${data.html_url}`);
} else {
cli.error(data);
process.exit(1);
Expand All @@ -155,16 +155,29 @@ class PrepareSecurityRelease {
cli.info('Getting triaged H1 reports...');
const reports = await this.req.getTriagedReports();
const supportedVersions = (await nv('supported'))
.map((v) => v.versionName + '.x')
.map((v) => `${v.versionName}.x`)
.join(',');
const selectedReports = [];

for (const report of reports.data) {
const { id, attributes: { title, cve_ids }, relationships: { severity, reporter } } = report;
const {
id, attributes: { title, cve_ids, created_at },
relationships: { severity, weakness, reporter }
} = report;
const link = `https://hackerone.com/reports/${id}`;
const reportLevel = severity ? severity.data.attributes.rating : 'TBD';
let reportSeverity = 'TBD';
if (severity?.data?.attributes?.cvss_vector_string) {
const { cvss_vector_string, rating } = severity.data.attributes;
reportSeverity = {
cvss_vector_string,
rating,
weakness_id: weakness?.data?.id
};
}

cli.separator();
cli.info(`Report: ${link} - ${title} (${reportLevel})`);
cli.info(`Report: ${link} - ${title} (${
reportSeverity?.rating?.toUpperCase() || reportSeverity})`);
const include = await cli.prompt(
'Would you like to include this report to the next security release?',
{ defaultAnswer: true });
Expand All @@ -182,11 +195,12 @@ class PrepareSecurityRelease {
id,
title,
cve_ids,
severity: reportLevel,
severity: reportSeverity,
summary: summaryContent ?? '',
affectedVersions: versions.split(',').map((v) => v.replace('v', '').trim()),
link,
reporter: reporter.data.attributes.username
reporter: reporter.data.attributes.username,
created_at // when we request CVE we need to input vulnerability_discovered_at
});
}
return selectedReports;
Expand Down Expand Up @@ -227,17 +241,16 @@ class PrepareSecurityRelease {
);
const url = response?.html_url;
if (url) {
cli.ok('Created: ' + url);
cli.ok(`Created: ${url}`);
return url;
} else {
if (response?.errors) {
for (const error of response.errors) {
cli.error(error.message);
}
} else {
cli.error(response);
}
if (response?.errors) {
for (const error of response.errors) {
cli.error(error.message);
}
process.exit(1);
} else {
cli.error(response);
}
process.exit(1);
}
}