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

add verify-signature command. Fixes #1044 #1045

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import program from 'commander';
import leven from 'leven';
import { packageCommand, ls, Targets, generateManifest } from './package';
import { packageCommand, ls, Targets, generateManifest, verifySignature } from './package';
import { publish, unpublish } from './publish';
import { show } from './show';
import { search } from './search';
Expand Down Expand Up @@ -317,6 +317,14 @@ module.exports = function (argv: string[]): void {
.option('-o, --out <path>', 'Output the extension manifest to <path> location (defaults to <packagename>.manifest)')
.action(({ packagePath, out }) => main(generateManifest(packagePath, out)));

program
.command('verify-signature')
.description('Verifies the provided signature file against the provided VSIX package and manifest.')
.requiredOption('-i, --packagePath <path>', 'Path to the VSIX package')
.requiredOption('-m, --manifestPath <path>', 'Path to the Manifest file')
.requiredOption('-s, --signaturePath <path>', 'Path to the Signature file')
.action(({ packagePath, manifestPath, signaturePath }) => main(verifySignature(packagePath, manifestPath, signaturePath)));

program
.command('ls-publishers')
.description('Lists all known publishers')
Expand Down
13 changes: 13 additions & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,19 @@ export function generateManifest(packageFile: string, outputFile?: string): Prom
return vsceSign.generateManifest(packageFile, outputFile);
}

export async function verifySignature(packageFile: string, manifestFile: string, signatureFile: string): Promise<void> {
const sigzipPath = await createSignatureArchive(manifestFile, signatureFile);
try {
const result = await vsceSign.verify(packageFile, sigzipPath, true);
console.log(`Signature verification result: ${result.code}`);
if (result.output) {
console.log(result.output)
}
} finally {
await fs.promises.unlink(sigzipPath);
}
}

// Create a signature zip file containing the manifest and signature file
export async function createSignatureArchive(manifestFile: string, signatureFile: string, outputFile?: string): Promise<string> {
return vsceSign.zip(manifestFile, signatureFile, outputFile)
Expand Down