@vscode/vsce 3.9.3-8 → 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/secretLint.js +68 -55
- package/package.json +4 -2
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
|
|
83
|
-
const {
|
|
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(
|
|
90
|
+
rules.push({
|
|
91
|
+
...secretsScanningRules[0],
|
|
92
|
+
rule: recommend
|
|
93
|
+
});
|
|
87
94
|
}
|
|
88
95
|
if (scanDotEnv) {
|
|
89
|
-
rules.push(
|
|
96
|
+
rules.push({
|
|
97
|
+
...dotEnvRules[0],
|
|
98
|
+
rule: noDotenv
|
|
99
|
+
});
|
|
90
100
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
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
|
-
|
|
102
|
-
let engineResult;
|
|
120
|
+
let results;
|
|
103
121
|
try {
|
|
104
|
-
|
|
105
|
-
|
|
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(
|
|
139
|
+
return parseResult(results);
|
|
113
140
|
}
|
|
114
141
|
async function lintText(content, fileName, scanSecrets, scanDotEnv) {
|
|
115
|
-
|
|
116
|
-
let engineResult;
|
|
142
|
+
let result;
|
|
117
143
|
try {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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(
|
|
165
|
+
return parseResult([result]);
|
|
128
166
|
}
|
|
129
|
-
function parseResult(
|
|
130
|
-
const
|
|
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 {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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-
|
|
3
|
+
"version": "3.9.3-9",
|
|
4
4
|
"description": "VS Code Extensions Manager",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,9 +41,11 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@azure/identity": "^4.1.0",
|
|
43
43
|
"@napi-rs/keyring": "^1.3.0",
|
|
44
|
-
"@secretlint/
|
|
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",
|