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
32 changes: 29 additions & 3 deletions lib/security_blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
PLACEHOLDERS,
checkoutOnSecurityReleaseBranch,
validateDate,
SecurityRelease
SecurityRelease,
commitAndPushVulnerabilitiesJSON,
} from './security-release/security-release.js';
import auth from './auth.js';
import Request from './request.js';
Expand Down Expand Up @@ -56,16 +57,41 @@ export default class SecurityBlog extends SecurityRelease {
const endDate = new Date(data.annoucementDate);
endDate.setDate(endDate.getDate() + 7);

const link = `https://nodejs.org/en/blog/vulnerability/${fileName}`;
this.updateWebsiteBanner(site, {
startDate: data.annoucementDate,
endDate: endDate.toISOString(),
text: `New security releases to be made available ${data.releaseDate}`,
link: `https://nodejs.org/en/blog/vulnerability/${fileName}`,
link,
type: 'warning'
});

fs.writeFileSync(file, preRelease);

cli.ok(`Announcement file created and banner has been updated. Folder: ${nodejsOrgFolder}`);
await this.updateAnnouncementLink(link);
}

async updateAnnouncementLink(link) {
const vulnerabilitiesJSONPath = this.getVulnerabilitiesJSONPath();
const content = this.readVulnerabilitiesJSON(vulnerabilitiesJSONPath);
let shouldCommit = false;
for (let i = 0; i < content.reports.length; ++i) {
if (content.reports[i].announcement !== link) {
content.reports[i].announcement = link;
shouldCommit = true;
}
};

if (shouldCommit) {
fs.writeFileSync(vulnerabilitiesJSONPath, JSON.stringify(content, null, 2));
const commitMessage = 'chore: add announcement link';
commitAndPushVulnerabilitiesJSON([vulnerabilitiesJSONPath],
commitMessage, { cli: this.cli, repository: this.repository });

this.cli.ok('Updated the announcement link in vulnerabilities.json');
}

return [vulnerabilitiesJSONPath];
}

async createPostRelease(nodejsOrgFolder) {
Expand Down
Loading