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

feat(git-node): verify tag signature during release promotion #879

Merged
merged 1 commit into from
Dec 20, 2024
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
23 changes: 23 additions & 0 deletions lib/promote_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default class ReleasePromotion extends Session {
throw new Error('Aborted');
}
await this.secureTagRelease();
await this.verifyTagSignature();

// Set up for next release.
cli.startSpinner('Setting up for next release');
Expand Down Expand Up @@ -223,6 +224,28 @@ export default class ReleasePromotion extends Session {
this.isLTS ? '=false' : ''} --title=${JSON.stringify(this.releaseTitle)} --notes-file -`);
}

async verifyTagSignature() {
const { cli, version } = this;
const [needle, haystack] = await Promise.all([forceRunAsync(
'git', ['--no-pager',
'log', '-1',
`refs/tags/v${version}`,
'--format=* **%an** <<%ae>>\n `%GF`'
], { captureStdout: true }), fs.readFile('README.md')]);
if (haystack.includes(needle)) {
return;
}
cli.warn('Tag was signed with an undocumented identity/key pair!');
cli.info('Expected to find the following entry in the README:');
cli.info(needle);
cli.info('If you are using a subkey, it might be OK.');
cli.info(`Otherwise consider removing the tag (git tag -d v${version
}), check your local config, and start the process over.`);
if (!await cli.prompt('Do you want to proceed anyway?', { defaultAnswer: false })) {
throw new Error('Aborted');
}
}

async verifyPRAttributes() {
const { cli, prid, owner, repo, req } = this;

Expand Down
Loading