@vscode/vsce 3.3.3-5 → 3.3.3-6

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.
package/dist/vsce.d.ts CHANGED
@@ -122,6 +122,9 @@ export declare interface IPackageOptions {
122
122
  readonly allowStarActivation?: boolean;
123
123
  readonly allowMissingRepository?: boolean;
124
124
  readonly allowUnusedFilesPattern?: boolean;
125
+ readonly allowPackageSecrets?: string[];
126
+ readonly allowPackageAllSecrets?: boolean;
127
+ readonly allowPackageEnvFile?: boolean;
125
128
  readonly skipLicense?: boolean;
126
129
  readonly signTool?: string;
127
130
  }
@@ -177,6 +180,9 @@ export declare interface IPublishOptions {
177
180
  readonly noVerify?: boolean;
178
181
  readonly allowProposedApis?: string[];
179
182
  readonly allowAllProposedApis?: boolean;
183
+ readonly allowPackageSecrets?: string[];
184
+ readonly allowPackageAllSecrets?: boolean;
185
+ readonly allowPackageEnvFile?: boolean;
180
186
  readonly dependencies?: boolean;
181
187
  readonly preRelease?: boolean;
182
188
  readonly allowStarActivation?: boolean;
package/out/main.js CHANGED
@@ -121,10 +121,13 @@ module.exports = function (argv) {
121
121
  .option('--allow-star-activation', 'Allow using * in activation events')
122
122
  .option('--allow-missing-repository', 'Allow missing a repository URL in package.json')
123
123
  .option('--allow-unused-files-pattern', 'Allow include patterns for the files field in package.json that does not match any file')
124
+ .option('--allow-package-secrets <secrets...>', 'Allow packaging specific secrets. The names of the secrets can be found in the error message ([SECRET_NAME]).')
125
+ .option('--allow-package-all-secrets', 'Allow to package all kinds of secrets')
126
+ .option('--allow-package-env-file', 'Allow packaging .env files')
124
127
  .option('--skip-license', 'Allow packaging without license file')
125
128
  .option('--sign-tool <path>', 'Path to the VSIX signing tool. Will be invoked with two arguments: `SIGNTOOL <path/to/extension.signature.manifest> <path/to/extension.signature.p7s>`.')
126
129
  .option('--follow-symlinks', 'Recurse into symlinked directories instead of treating them as files')
127
- .action((version, { out, target, ignoreOtherTargetFolders, readmePath, changelogPath, message, gitTagVersion, updatePackageJson, githubBranch, gitlabBranch, rewriteRelativeLinks, baseContentUrl, baseImagesUrl, yarn, ignoreFile, gitHubIssueLinking, gitLabIssueLinking, dependencies, preRelease, allowStarActivation, allowMissingRepository, allowUnusedFilesPattern, skipLicense, signTool, followSymlinks, }) => main((0, package_1.packageCommand)({
130
+ .action((version, { out, target, ignoreOtherTargetFolders, readmePath, changelogPath, message, gitTagVersion, updatePackageJson, githubBranch, gitlabBranch, rewriteRelativeLinks, baseContentUrl, baseImagesUrl, yarn, ignoreFile, gitHubIssueLinking, gitLabIssueLinking, dependencies, preRelease, allowStarActivation, allowMissingRepository, allowUnusedFilesPattern, allowPackageSecrets, allowPackageAllSecrets, allowPackageEnvFile, skipLicense, signTool, followSymlinks, }) => main((0, package_1.packageCommand)({
128
131
  packagePath: out,
129
132
  version,
130
133
  target,
@@ -148,6 +151,9 @@ module.exports = function (argv) {
148
151
  allowStarActivation,
149
152
  allowMissingRepository,
150
153
  allowUnusedFilesPattern,
154
+ allowPackageSecrets,
155
+ allowPackageAllSecrets,
156
+ allowPackageEnvFile,
151
157
  skipLicense,
152
158
  signTool,
153
159
  followSymlinks,
@@ -179,6 +185,9 @@ module.exports = function (argv) {
179
185
  .addOption(new commander_1.Option('--noVerify', 'Allow all proposed APIs (deprecated: use --allow-all-proposed-apis instead)').hideHelp(true))
180
186
  .option('--allow-proposed-apis <apis...>', 'Allow specific proposed APIs')
181
187
  .option('--allow-all-proposed-apis', 'Allow all proposed APIs')
188
+ .option('--allow-package-secrets <secrets...>', 'Allow packaging specific secrets. The names of the secrets can be found in the error message ([SECRET_NAME]).')
189
+ .option('--allow-package-all-secrets', 'Allow to package all kinds of secrets')
190
+ .option('--allow-package-env-file', 'Allow packaging .env files')
182
191
  .option('--ignoreFile <path>', 'Indicate alternative .vscodeignore')
183
192
  // default must remain undefined for dependencies or we will fail to load defaults from package.json
184
193
  .option('--dependencies', 'Enable dependency detection via npm or yarn', undefined)
@@ -190,7 +199,7 @@ module.exports = function (argv) {
190
199
  .option('--skip-duplicate', 'Fail silently if version already exists on the marketplace')
191
200
  .option('--skip-license', 'Allow publishing without license file')
192
201
  .option('--follow-symlinks', 'Recurse into symlinked directories instead of treating them as files')
193
- .action((version, { pat, azureCredential, target, ignoreOtherTargetFolders, readmePath, changelogPath, message, gitTagVersion, updatePackageJson, packagePath, manifestPath, signaturePath, sigzipPath, githubBranch, gitlabBranch, baseContentUrl, baseImagesUrl, yarn, verify, noVerify, allowProposedApis, allowAllProposedApis, ignoreFile, dependencies, preRelease, allowStarActivation, allowMissingRepository, allowUnusedFilesPattern, skipDuplicate, skipLicense, signTool, followSymlinks, }) => main((0, publish_1.publish)({
202
+ .action((version, { pat, azureCredential, target, ignoreOtherTargetFolders, readmePath, changelogPath, message, gitTagVersion, updatePackageJson, packagePath, manifestPath, signaturePath, sigzipPath, githubBranch, gitlabBranch, baseContentUrl, baseImagesUrl, yarn, verify, noVerify, allowProposedApis, allowAllProposedApis, allowPackageSecrets, allowPackageAllSecrets, allowPackageEnvFile, ignoreFile, dependencies, preRelease, allowStarActivation, allowMissingRepository, allowUnusedFilesPattern, skipDuplicate, skipLicense, signTool, followSymlinks, }) => main((0, publish_1.publish)({
194
203
  pat,
195
204
  azureCredential,
196
205
  version,
@@ -213,6 +222,9 @@ module.exports = function (argv) {
213
222
  noVerify: noVerify || !verify,
214
223
  allowProposedApis,
215
224
  allowAllProposedApis,
225
+ allowPackageSecrets,
226
+ allowPackageAllSecrets,
227
+ allowPackageEnvFile,
216
228
  ignoreFile,
217
229
  dependencies,
218
230
  preRelease,
package/out/package.js CHANGED
@@ -1557,33 +1557,59 @@ async function printAndValidatePackagedFiles(files, cwd, manifest, options) {
1557
1557
  }
1558
1558
  message += '\n';
1559
1559
  util.log.info(message);
1560
- await scanFilesForSecrets(files);
1560
+ const fileExclusion = hasIgnoreFile ? FileExclusionType.VSCodeIgnore : manifest.files ? FileExclusionType.PackageFiles : FileExclusionType.None;
1561
+ await scanFilesForSecrets(files, fileExclusion, options);
1561
1562
  }
1562
1563
  exports.printAndValidatePackagedFiles = printAndValidatePackagedFiles;
1563
- async function scanFilesForSecrets(files) {
1564
+ var FileExclusionType;
1565
+ (function (FileExclusionType) {
1566
+ FileExclusionType["None"] = "none";
1567
+ FileExclusionType["VSCodeIgnore"] = "vscodeIgnore";
1568
+ FileExclusionType["PackageFiles"] = "package.files";
1569
+ })(FileExclusionType || (FileExclusionType = {}));
1570
+ async function scanFilesForSecrets(files, fileExclusion, options) {
1564
1571
  const onDiskFiles = files.filter(file => !isInMemoryFile(file));
1565
1572
  const inMemoryFiles = files.filter(file => isInMemoryFile(file));
1566
1573
  const onDiskResult = await (0, secretLint_1.lintFiles)(onDiskFiles.map(file => file.localPath));
1567
1574
  const inMemoryResults = await Promise.all(inMemoryFiles.map(file => (0, secretLint_1.lintText)(typeof file.contents === 'string' ? file.contents : file.contents.toString('utf8'), file.path)));
1568
1575
  const secretsFound = [...inMemoryResults, onDiskResult].filter(result => !result.ok).flatMap(result => result.results);
1569
- if (secretsFound.length === 0) {
1570
- return;
1571
- }
1572
1576
  // secrets found
1573
- const noneDotEnvSecretsFound = secretsFound.filter(result => result.ruleId !== '@secretlint/secretlint-rule-no-dotenv');
1577
+ const noneDotEnvSecretsFound = secretsFound.filter(result => result.ruleId &&
1578
+ result.ruleId !== '@secretlint/secretlint-rule-no-dotenv' &&
1579
+ !options.allowPackageAllSecrets &&
1580
+ !options.allowPackageSecrets?.includes((0, secretLint_1.getRuleNameFromRuleId)(result.ruleId)));
1574
1581
  if (noneDotEnvSecretsFound.length > 0) {
1575
- let errorOutput = '';
1576
- for (const secret of noneDotEnvSecretsFound) {
1577
- errorOutput += '\n' + (0, secretLint_1.prettyPrintLintResult)(secret);
1578
- }
1579
- util.log.error(`Secrets have been detected in the files which are being packaged:\n\n${errorOutput}`);
1582
+ const uniqueSecretIds = new Set(noneDotEnvSecretsFound.map(result => result.ruleId));
1583
+ const secretsFoundRuleNames = Array.from(uniqueSecretIds).map(secretLint_1.getRuleNameFromRuleId);
1584
+ let errorMessage = `${chalk_1.default.bold('Potential security issue detected:')}`;
1585
+ errorMessage += ` Your extension package contains sensitive information that should not be published.`;
1586
+ errorMessage += ` Please remove these secrets before packaging.`;
1587
+ errorMessage += `\n` + noneDotEnvSecretsFound.map(secretLint_1.prettyPrintLintResult).join('\n');
1588
+ let hintMessage = `\nIn case of a false positives, you can allowlist secrets with `;
1589
+ hintMessage += secretsFoundRuleNames.map(name => `--allow-package-secrets ${name}`).join(' ');
1590
+ hintMessage += ` or use --allow-package-all-secrets to skip this check (not recommended).`;
1591
+ util.log.error(errorMessage + chalk_1.default.italic(hintMessage));
1592
+ process.exit(1);
1580
1593
  }
1581
1594
  // .env file found
1582
1595
  const allRuleIds = new Set(secretsFound.map(result => result.ruleId).filter(Boolean));
1583
- if (allRuleIds.has('@secretlint/secretlint-rule-no-dotenv')) {
1584
- util.log.error(`${chalk_1.default.bold.red('.env')} files should not be packaged. Ignore them in your ${chalk_1.default.bold('.vscodeignore')} file or exclude them from the package.json ${chalk_1.default.bold('files')} property.`);
1596
+ if (!options.allowPackageEnvFile && allRuleIds.has('@secretlint/secretlint-rule-no-dotenv')) {
1597
+ let errorMessage = `${chalk_1.default.bold.red('.env')} files should not be packaged.`;
1598
+ switch (fileExclusion) {
1599
+ case FileExclusionType.None:
1600
+ errorMessage += ` Ignore the file in your ${chalk_1.default.bold('.vscodeignore')} or exclude it from the package.json ${chalk_1.default.bold('files')} property.`;
1601
+ break;
1602
+ case FileExclusionType.VSCodeIgnore:
1603
+ errorMessage += ` Ignore the file in your ${chalk_1.default.bold('.vscodeignore')}.`;
1604
+ break;
1605
+ case FileExclusionType.PackageFiles:
1606
+ errorMessage += ` Do not include the file in your package.json ${chalk_1.default.bold('files')} property.`;
1607
+ break;
1608
+ }
1609
+ const hintMessage = `\nTo ignore this check, you can use --allow-package-env-file (not recommended).`;
1610
+ util.log.error(errorMessage + chalk_1.default.italic(hintMessage));
1611
+ process.exit(1);
1585
1612
  }
1586
- process.exit(1);
1587
1613
  }
1588
1614
  exports.scanFilesForSecrets = scanFilesForSecrets;
1589
1615
  //# sourceMappingURL=package.js.map
package/out/secretLint.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.prettyPrintLintResult = exports.lintText = exports.lintFiles = void 0;
6
+ exports.prettyPrintLintResult = exports.getRuleNameFromRuleId = exports.lintText = exports.lintFiles = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const secret_lint_types_1 = require("./typings/secret-lint-types");
9
9
  const lintConfig = {
@@ -57,6 +57,11 @@ function parseResult(result) {
57
57
  const results = output.runs.at(0)?.results ?? [];
58
58
  return { ok: result.ok, results };
59
59
  }
60
+ function getRuleNameFromRuleId(ruleId) {
61
+ const parts = ruleId.split('-rule-');
62
+ return parts[parts.length - 1];
63
+ }
64
+ exports.getRuleNameFromRuleId = getRuleNameFromRuleId;
60
65
  function prettyPrintLintResult(result) {
61
66
  if (!result.message.text) {
62
67
  return JSON.stringify(result);
@@ -64,7 +69,8 @@ function prettyPrintLintResult(result) {
64
69
  const text = result.message.text;
65
70
  const titleColor = result.level === undefined || result.level === secret_lint_types_1.Level.Error ? chalk_1.default.bold.red : chalk_1.default.bold.yellow;
66
71
  const title = text.length > 54 ? text.slice(0, 50) + '...' : text;
67
- let output = `\t${titleColor(title)}\n`;
72
+ const ruleName = result.ruleId ? getRuleNameFromRuleId(result.ruleId) : 'unknown';
73
+ let output = `\t${titleColor(title)} [${ruleName}]\n`;
68
74
  if (result.locations) {
69
75
  result.locations.forEach(location => {
70
76
  output += `\t${prettyPrintLocation(location)}\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/vsce",
3
- "version": "3.3.3-5",
3
+ "version": "3.3.3-6",
4
4
  "description": "VS Code Extensions Manager",
5
5
  "repository": {
6
6
  "type": "git",