Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pre-release crashing on missing vulnerability rating #790

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 7 additions & 4 deletions lib/prepare_security.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class PrepareSecurityRelease {
async promptReleaseDate(cli) {
return cli.prompt('Enter target release date in YYYY/MM/DD format:', {
questionType: 'input',
defaultAnswer: 'TBD'
defaultAnswer: ''
marco-ippolito marked this conversation as resolved.
Show resolved Hide resolved
});
}

Expand Down Expand Up @@ -173,7 +173,11 @@ class PrepareSecurityRelease {
relationships: { severity, weakness, reporter }
} = report;
const link = `https://hackerone.com/reports/${id}`;
let reportSeverity = 'TBD';
let reportSeverity = {
rating: '',
cvss_vector_string: '',
weakness_id: ''
};
if (severity?.data?.attributes?.cvss_vector_string) {
const { cvss_vector_string, rating } = severity.data.attributes;
reportSeverity = {
Expand All @@ -184,8 +188,7 @@ class PrepareSecurityRelease {
}

cli.separator();
cli.info(`Report: ${link} - ${title} (${
reportSeverity?.rating?.toUpperCase() || reportSeverity})`);
cli.info(`Report: ${link} - ${title} (${reportSeverity?.rating})`);
const include = await cli.prompt(
'Would you like to include this report to the next security release?',
{ defaultAnswer: true });
Expand Down
10 changes: 8 additions & 2 deletions lib/security_blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ export default class SecurityBlog {
}

promptAnnouncementDate(cli) {
const today = new Date().toISOString().substring(0, 10).replace(/-/g, '/');
return cli.prompt('When is the security release going to be announced? ' +
'Enter in YYYY-MM-DD format:', {
'Enter in YYYY/MM/DD format:', {
questionType: 'input',
defaultAnswer: PLACEHOLDERS.annoucementDate
defaultAnswer: today
});
}

Expand All @@ -135,6 +136,11 @@ export default class SecurityBlog {
for (const [key, value] of Object.entries(impact)) {
const groupedByRating = Object.values(_.groupBy(value, 'severity.rating'))
.map(severity => {
if (!severity[0]?.severity?.rating) {
this.cli.error(`severity.rating not found for the report ${severity[0].id}. \
Please add it manually before continuing.`);
process.exit(1);
}
const firstSeverityRating = severity[0].severity.rating.toLocaleLowerCase();
return `${severity.length} ${firstSeverityRating} severity issues`;
}).join(', ');
Expand Down
Loading