Skip to content

Commit

Permalink
Merge branch 'main' into sync-sec-release
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Jun 13, 2024
2 parents cef5010 + e3e19b3 commit 424d2e7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
4 changes: 4 additions & 0 deletions lib/github/templates/security-pre-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ releases lines on or shortly after, %RELEASE_DATE% in order to address:

%IMPACT%

It's important to note that End-of-Life versions are always affected when a security release occurs.
To ensure your system's security, please use an up-to-date version as outlined in our
[Release Schedule](https://github.com/nodejs/release#release-schedule).

## Release timing

Releases will be available on, or shortly after, %RELEASE_DATE%.
Expand Down
3 changes: 1 addition & 2 deletions lib/prepare_security.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ export default class PrepareSecurityRelease {
});

try {
const prUrl = dep.replace('https://github.com/', 'https://api.github.com/repos/').replace('pull', 'pulls');
const res = await this.req.getPullRequest(prUrl);
const res = await this.req.getPullRequest(dep);
const { html_url, title } = res;
deps.push({
name,
Expand Down
5 changes: 3 additions & 2 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export default class Request {
return this.json(url, options);
}

async getPullRequest(url) {
async getPullRequest(fullUrl) {
const prUrl = fullUrl.replace('https://github.com/', 'https://api.github.com/repos/').replace('pull', 'pulls');
const options = {
method: 'GET',
headers: {
Expand All @@ -86,7 +87,7 @@ export default class Request {
Accept: 'application/vnd.github+json'
}
};
return this.json(url, options);
return this.json(prUrl, options);
}

async createPullRequest(title, body, { owner, repo, head, base }) {
Expand Down
27 changes: 18 additions & 9 deletions lib/security-release/security-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,24 @@ export async function pickReport(report, { cli }) {
defaultAnswer: await getSupportedVersions()
});

let patchAuthors = await cli.prompt(
'Add github username of the authors of the patch (split by comma if multiple)', {
questionType: 'input',
defaultAnswer: ''
});

if (!patchAuthors) {
patchAuthors = [];
let prURL = '';
let patchAuthors = [];
if (custom_field_values.data.length) {

Check failure on line 178 in lib/security-release/security-release.js

View workflow job for this annotation

GitHub Actions / Lint using ESLint

'custom_field_values' is not defined
prURL = custom_field_values.data[0].attributes.value;

Check failure on line 179 in lib/security-release/security-release.js

View workflow job for this annotation

GitHub Actions / Lint using ESLint

'custom_field_values' is not defined
const { user } = await req.getPullRequest(prURL);

Check failure on line 180 in lib/security-release/security-release.js

View workflow job for this annotation

GitHub Actions / Lint using ESLint

'req' is not defined
patchAuthors = [user.login];
} else {
patchAuthors = patchAuthors.split(',').map((p) => p.trim());
patchAuthors = await cli.prompt(
'Add github username of the authors of the patch (split by comma if multiple)', {
questionType: 'input',
defaultAnswer: ''
});

if (!patchAuthors) {
patchAuthors = [];
} else {
patchAuthors = patchAuthors.split(',').map((p) => p.trim());
}
}

const summaryContent = getSummary(report);
Expand All @@ -194,6 +202,7 @@ export async function pickReport(report, { cli }) {
severity: reportSeverity,
summary: summaryContent ?? '',
patchAuthors,
prURL,
affectedVersions: versions.split(',').map((v) => v.replace('v', '').trim()),
link,
reporter: reporter.data.attributes.username
Expand Down
16 changes: 13 additions & 3 deletions lib/voting_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class VotingSession extends Session {
const body = 'I would like to close this vote, and for this effect, I\'m revealing my ' +
`key part:\n\n${'```'}\n${keyPart}\n${'```'}\n`;
if (this.postComment) {
const { html_url } = await this.req.json(`https://api.github.com/repos/${this.owner}/${this.repo}/issues/${this.prid}/comments`, {
const { message, html_url } = await this.req.json(`https://api.github.com/repos/${this.owner}/${this.repo}/issues/${this.prid}/comments`, {
agent: this.req.proxyAgent,
method: 'POST',
headers: {
Expand All @@ -124,13 +124,23 @@ export default class VotingSession extends Session {
},
body: JSON.stringify({ body })
});
this.cli.log('Comment posted at:', html_url);
} else if (isGhAvailable()) {
if (html_url) {
this.cli.log(`Comment posted at: ${html_url}`);
return;
} else {
this.cli.warn(message);
this.cli.error('Failed to post comment');
}
}
if (isGhAvailable()) {
this.cli.log('\nRun the following command to post the comment:\n');
this.cli.log(
`gh pr comment ${this.prid} --repo ${this.owner}/${this.repo} ` +
`--body-file - <<'EOF'\n${body}\nEOF`
);
} else {
this.cli.log('\nPost the following comment on the PR thread:\n');
this.cli.log(body);
}
}
}

0 comments on commit 424d2e7

Please sign in to comment.