@vscode/vsce 3.9.3-7 → 3.9.3-9

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/out/package.js CHANGED
@@ -65,7 +65,7 @@ const cp = __importStar(require("child_process"));
65
65
  const yazl = __importStar(require("yazl"));
66
66
  const nls_1 = require("./nls");
67
67
  const util = __importStar(require("./util"));
68
- const glob_1 = require("glob");
68
+ const tinyglobby_1 = require("tinyglobby");
69
69
  const minimatch_1 = require("minimatch");
70
70
  const parse5_1 = require("parse5");
71
71
  const marked_1 = require("marked");
@@ -1285,9 +1285,46 @@ const defaultIgnore = [
1285
1285
  '**/.vscode-test/**',
1286
1286
  '**/.vscode-test-web/**',
1287
1287
  ];
1288
+ /**
1289
+ * `tinyglobby` skips symbolic links altogether when `followSymbolicLinks` is disabled, while
1290
+ * vsce treats them as regular files instead (see the `--follow-symlinks` option). Presenting
1291
+ * symbolic links to the crawler as regular files keeps them in the result without recursing
1292
+ * into symlinked directories.
1293
+ */
1294
+ const symlinksAsFilesFileSystem = {
1295
+ readdir: (dir, options, callback) => fs.readdir(dir, options, (err, entries) => callback(err, err ? entries : entries.map(asFile))),
1296
+ readdirSync: (dir, options) => fs.readdirSync(dir, options).map(asFile),
1297
+ };
1298
+ function asFile(entry) {
1299
+ if (!entry.isSymbolicLink()) {
1300
+ return entry;
1301
+ }
1302
+ return Object.create(entry, {
1303
+ isFile: { value: () => true },
1304
+ isDirectory: { value: () => false },
1305
+ isSymbolicLink: { value: () => false },
1306
+ });
1307
+ }
1308
+ /**
1309
+ * `glob` matched patterns case-insensitively on Windows and macOS and case-sensitively
1310
+ * everywhere else, based on `process.platform` rather than on the actual filesystem.
1311
+ * `tinyglobby` always matches case-sensitively, so this keeps the previous behaviour, which
1312
+ * matters for the `node_modules` folder being ignored regardless of how it is cased on disk.
1313
+ * Keep this keyed off the platform: probing the filesystem instead would change what is
1314
+ * packaged on case-sensitive macOS volumes and case-insensitive Linux mounts.
1315
+ */
1316
+ const caseSensitiveMatch = process.platform !== 'win32' && process.platform !== 'darwin';
1288
1317
  async function collectAllFiles(cwd, dependencies, dependencyEntryPoints, followSymlinks = true) {
1289
1318
  const deps = await (0, npm_1.getDependencies)(cwd, dependencies, dependencyEntryPoints);
1290
- const promises = deps.map(dep => (0, glob_1.glob)('**', { cwd: dep, nodir: true, follow: followSymlinks, dot: true, ignore: 'node_modules/**' }).then(files => files.map(f => path.relative(cwd, path.join(dep, f))).map(f => f.replace(/\\/g, '/'))));
1319
+ const promises = deps.map(dep => (0, tinyglobby_1.glob)('**', {
1320
+ cwd: dep,
1321
+ onlyFiles: true,
1322
+ followSymbolicLinks: followSymlinks,
1323
+ fs: followSymlinks ? undefined : symlinksAsFilesFileSystem,
1324
+ caseSensitiveMatch,
1325
+ dot: true,
1326
+ ignore: ['node_modules/**'],
1327
+ }).then(files => files.map(f => path.relative(cwd, path.join(dep, f))).map(f => f.replace(/\\/g, '/'))));
1291
1328
  return Promise.all(promises).then(util.flatten);
1292
1329
  }
1293
1330
  function getDependenciesOption(options) {
package/out/secretLint.js CHANGED
@@ -41,6 +41,7 @@ exports.lintText = lintText;
41
41
  exports.getRuleNameFromRuleId = getRuleNameFromRuleId;
42
42
  exports.prettyPrintLintResult = prettyPrintLintResult;
43
43
  const chalk_1 = __importDefault(require("chalk"));
44
+ const os = __importStar(require("os"));
44
45
  const path = __importStar(require("path"));
45
46
  const url_1 = require("url");
46
47
  const util_1 = require("./util");
@@ -79,59 +80,92 @@ const dotEnvRules = [
79
80
  id: "@secretlint/secretlint-rule-no-dotenv"
80
81
  }
81
82
  ];
82
- async function getEngine(scanSecrets, scanDotEnv) {
83
- const { createEngine } = require("@secretlint/node");
83
+ async function getConfig(scanSecrets, scanDotEnv) {
84
+ const [{ creator: recommend }, { creator: noDotenv }] = await Promise.all([
85
+ importSecretLintRule("@secretlint/secretlint-rule-preset-recommend"),
86
+ importSecretLintRule("@secretlint/secretlint-rule-no-dotenv")
87
+ ]);
84
88
  const rules = [];
85
89
  if (scanSecrets) {
86
- rules.push(...secretsScanningRules);
90
+ rules.push({
91
+ ...secretsScanningRules[0],
92
+ rule: recommend
93
+ });
87
94
  }
88
95
  if (scanDotEnv) {
89
- rules.push(...dotEnvRules);
96
+ rules.push({
97
+ ...dotEnvRules[0],
98
+ rule: noDotenv
99
+ });
90
100
  }
91
- const lintOptions = {
92
- configFileJSON: { rules: rules },
93
- formatter: "json",
94
- color: true,
95
- maskSecrets: false
96
- };
97
- const engine = await createEngine(lintOptions);
98
- return engine;
101
+ return { rules };
102
+ }
103
+ function importSecretLintRule(packageName) {
104
+ return import(packageName);
105
+ }
106
+ async function mapConcurrently(values, mapper) {
107
+ const results = new Array(values.length);
108
+ let nextIndex = 0;
109
+ async function worker() {
110
+ while (nextIndex < values.length) {
111
+ const index = nextIndex++;
112
+ results[index] = await mapper(values[index]);
113
+ }
114
+ }
115
+ const workerCount = Math.min(os.availableParallelism(), values.length);
116
+ await Promise.all(Array.from({ length: workerCount }, worker));
117
+ return results;
99
118
  }
100
119
  async function lintFiles(filePaths, scanSecrets, scanDotEnv) {
101
- const engine = await getEngine(scanSecrets, scanDotEnv);
102
- let engineResult;
120
+ let results;
103
121
  try {
104
- engineResult = await engine.executeOnFiles({
105
- filePathList: filePaths
106
- });
122
+ const [{ lintSource }, { createRawSource }, config] = await Promise.all([
123
+ import("@secretlint/core"),
124
+ import("@secretlint/source-creator"),
125
+ getConfig(scanSecrets, scanDotEnv)
126
+ ]);
127
+ results = await mapConcurrently(filePaths, async (filePath) => lintSource({
128
+ source: await createRawSource(filePath),
129
+ options: {
130
+ config,
131
+ maskSecrets: false
132
+ }
133
+ }));
107
134
  }
108
135
  catch (error) {
109
136
  util_1.log.error('Error occurred while scanning secrets (files):', error);
110
137
  process.exit(1);
111
138
  }
112
- return parseResult(engineResult);
139
+ return parseResult(results);
113
140
  }
114
141
  async function lintText(content, fileName, scanSecrets, scanDotEnv) {
115
- const engine = await getEngine(scanSecrets, scanDotEnv);
116
- let engineResult;
142
+ let result;
117
143
  try {
118
- engineResult = await engine.executeOnContent({
119
- content,
120
- filePath: fileName
144
+ const [{ lintSource }, config] = await Promise.all([
145
+ import("@secretlint/core"),
146
+ getConfig(scanSecrets, scanDotEnv)
147
+ ]);
148
+ result = await lintSource({
149
+ source: {
150
+ content,
151
+ filePath: fileName,
152
+ ext: path.extname(fileName),
153
+ contentType: "text"
154
+ },
155
+ options: {
156
+ config,
157
+ maskSecrets: false
158
+ }
121
159
  });
122
160
  }
123
161
  catch (error) {
124
162
  util_1.log.error('Error occurred while scanning secrets (content):', error);
125
163
  process.exit(1);
126
164
  }
127
- return parseResult(engineResult);
165
+ return parseResult([result]);
128
166
  }
129
- function parseResult(result) {
130
- const output = JSON.parse(result.output);
131
- if (!Array.isArray(output) || !output.every(isSecretLintFileResult)) {
132
- throw new Error("Unexpected output from secretlint");
133
- }
134
- const results = output.flatMap(fileResult => fileResult.messages.map((message) => ({
167
+ function parseResult(fileResults) {
168
+ const results = fileResults.flatMap(fileResult => fileResult.messages.map((message) => ({
135
169
  message: message.message,
136
170
  ruleId: message.ruleParentId ? `${message.ruleParentId} > ${message.ruleId}` : message.ruleId,
137
171
  level: message.severity === "info" ? "note" : message.severity,
@@ -143,31 +177,10 @@ function parseResult(result) {
143
177
  endLine: fixLine(message.loc.end.line),
144
178
  endColumn: fixColumn(message.loc.end.column)
145
179
  })));
146
- return { ok: result.ok, results };
147
- }
148
- function isSecretLintFileResult(value) {
149
- return isRecord(value)
150
- && typeof value.filePath === "string"
151
- && Array.isArray(value.messages)
152
- && value.messages.every(isSecretLintMessage);
153
- }
154
- function isSecretLintMessage(value) {
155
- return isRecord(value)
156
- && typeof value.message === "string"
157
- && typeof value.ruleId === "string"
158
- && (value.ruleParentId === undefined || typeof value.ruleParentId === "string")
159
- && isRecord(value.loc)
160
- && isSecretLintPosition(value.loc.start)
161
- && isSecretLintPosition(value.loc.end)
162
- && (value.severity === "error" || value.severity === "warning" || value.severity === "info");
163
- }
164
- function isSecretLintPosition(value) {
165
- return isRecord(value)
166
- && (value.line === null || typeof value.line === "number")
167
- && (value.column === null || typeof value.column === "number");
168
- }
169
- function isRecord(value) {
170
- return typeof value === "object" && value !== null;
180
+ return {
181
+ ok: !fileResults.some(fileResult => fileResult.messages.some(message => message.severity === "error")),
182
+ results
183
+ };
171
184
  }
172
185
  function fixLine(value) {
173
186
  return value === null ? undefined : value === 0 ? 1 : value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/vsce",
3
- "version": "3.9.3-7",
3
+ "version": "3.9.3-9",
4
4
  "description": "VS Code Extensions Manager",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,16 +41,17 @@
41
41
  "dependencies": {
42
42
  "@azure/identity": "^4.1.0",
43
43
  "@napi-rs/keyring": "^1.3.0",
44
- "@secretlint/node": "^10.1.2",
44
+ "@secretlint/core": "^10.1.2",
45
45
  "@secretlint/secretlint-rule-no-dotenv": "^10.1.2",
46
46
  "@secretlint/secretlint-rule-preset-recommend": "^10.1.2",
47
+ "@secretlint/source-creator": "^10.1.2",
48
+ "@secretlint/types": "^10.1.2",
47
49
  "@vscode/vsce-sign": "^2.0.0",
48
50
  "azure-devops-node-api": "^12.5.0",
49
51
  "chalk": "^4.1.2",
50
52
  "cockatiel": "^3.1.2",
51
53
  "commander": "^12.1.0",
52
54
  "form-data": "^4.0.0",
53
- "glob": "^13.0.6",
54
55
  "hosted-git-info": "^4.0.2",
55
56
  "jsonc-parser": "^3.2.0",
56
57
  "leven": "^3.1.0",
@@ -61,6 +62,7 @@
61
62
  "parse5": "^8.0.1",
62
63
  "read": "^1.0.7",
63
64
  "semver": "^7.5.2",
65
+ "tinyglobby": "^0.2.17",
64
66
  "typed-rest-client": "^1.8.4",
65
67
  "url-join": "^4.0.1",
66
68
  "xml2js": "^0.5.0",
@@ -73,6 +75,7 @@
73
75
  "@types/mime": "^1",
74
76
  "@types/mocha": "^7.0.2",
75
77
  "@types/node": "^22.0.0",
78
+ "@types/picomatch": "^4.0.3",
76
79
  "@types/read": "^0.0.28",
77
80
  "@types/semver": "^6.0.0",
78
81
  "@types/url-join": "^4.0.1",