@vscode/vsce 2.25.1-5 → 2.26.1-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/out/package.js +19 -3
  2. package/package.json +1 -1
package/out/package.js CHANGED
@@ -231,19 +231,35 @@ async function versionBump(options) {
231
231
  }
232
232
  // call `npm version` to do our dirty work
233
233
  const args = ['version', options.version];
234
- if (options.commitMessage) {
235
- args.push('-m', options.commitMessage);
234
+ const isWindows = process.platform === 'win32';
235
+ const commitMessage = isWindows ? sanitizeCommitMessage(options.commitMessage) : options.commitMessage;
236
+ if (commitMessage) {
237
+ args.push('-m', commitMessage);
236
238
  }
237
239
  if (!(options.gitTagVersion ?? true)) {
238
240
  args.push('--no-git-tag-version');
239
241
  }
240
- const { stdout, stderr } = await (0, util_1.promisify)(cp.execFile)(process.platform === 'win32' ? 'npm.cmd' : 'npm', args, { cwd });
242
+ const { stdout, stderr } = await (0, util_1.promisify)(cp.execFile)(isWindows ? 'npm.cmd' : 'npm', args, { cwd, shell: isWindows /* https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2 */ });
241
243
  if (!process.env['VSCE_TESTS']) {
242
244
  process.stdout.write(stdout);
243
245
  process.stderr.write(stderr);
244
246
  }
245
247
  }
246
248
  exports.versionBump = versionBump;
249
+ function sanitizeCommitMessage(message) {
250
+ if (!message) {
251
+ return undefined;
252
+ }
253
+ // Remove any unsafe characters found by the unsafeRegex
254
+ // Check for characters that might escape quotes or introduce shell commands.
255
+ // Don't allow: ', ", `, $, \ (except for \n which is allowed)
256
+ const sanitizedMessage = message.replace(/(?<!\\)\\(?!n)|['"`$]/g, '');
257
+ if (sanitizedMessage.length === 0) {
258
+ return undefined;
259
+ }
260
+ // Add quotes as commit message is passed as a single argument to the shell
261
+ return `"${sanitizedMessage}"`;
262
+ }
247
263
  exports.Targets = new Set([
248
264
  'win32-x64',
249
265
  'win32-arm64',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/vsce",
3
- "version": "2.25.1-5",
3
+ "version": "2.26.1-0",
4
4
  "description": "VS Code Extensions Manager",
5
5
  "repository": {
6
6
  "type": "git",