@rhize/skill-forge 0.11.1 → 0.11.2
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/cli.js +51 -4
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -131,7 +131,32 @@ function collectNpxPackageSpecs(args) {
|
|
|
131
131
|
}
|
|
132
132
|
return { packageFlagSpecs, positionalSpec };
|
|
133
133
|
}
|
|
134
|
+
var ISO_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
135
|
+
var PATH_SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
|
|
136
|
+
function looksLikeFsPath(v) {
|
|
137
|
+
if (!/^(?:\/|~\/|\.\.?\/)/.test(v)) return false;
|
|
138
|
+
const segments = v.replace(/^~/, "").split("/").filter(Boolean);
|
|
139
|
+
return segments.length >= 2 && segments.every((seg) => PATH_SEGMENT_RE.test(seg));
|
|
140
|
+
}
|
|
141
|
+
function looksLikeBareUrl(v) {
|
|
142
|
+
let url;
|
|
143
|
+
try {
|
|
144
|
+
url = new URL(v);
|
|
145
|
+
} catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (!["http:", "https:", "ws:", "wss:", "file:"].includes(url.protocol)) return false;
|
|
149
|
+
if (url.username !== "" || url.password !== "") return false;
|
|
150
|
+
if (url.search !== "") return false;
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
function looksStructuredNonSecret(value) {
|
|
154
|
+
const v = value.trim().replace(/^[[\s'"]+/, "").replace(/[\]\s'",]+$/, "");
|
|
155
|
+
if (v === "") return false;
|
|
156
|
+
return ISO_TIMESTAMP_RE.test(v) || looksLikeBareUrl(v) || looksLikeFsPath(v);
|
|
157
|
+
}
|
|
134
158
|
function looksHighEntropy(value) {
|
|
159
|
+
if (looksStructuredNonSecret(value)) return false;
|
|
135
160
|
if (/\s/.test(value)) return false;
|
|
136
161
|
if (value.length < 20) return false;
|
|
137
162
|
const hasLower = /[a-z]/.test(value);
|
|
@@ -1243,14 +1268,22 @@ function scanJsonConfig(file, parsed) {
|
|
|
1243
1268
|
}
|
|
1244
1269
|
if (node.env && typeof node.env === "object" && !Array.isArray(node.env)) {
|
|
1245
1270
|
for (const [key, value] of Object.entries(node.env)) {
|
|
1246
|
-
if (typeof value !== "string"
|
|
1247
|
-
|
|
1271
|
+
if (typeof value !== "string") continue;
|
|
1272
|
+
const kind = classifyCredentialAssignment(key, value);
|
|
1273
|
+
if (kind === "inline-secret") {
|
|
1248
1274
|
findings.push({
|
|
1249
1275
|
severity: "HIGH",
|
|
1250
1276
|
rule: "mcp-inline-credential-value",
|
|
1251
1277
|
file,
|
|
1252
1278
|
detail: `env.${key} has an inline credential value \u2014 emit an empty string and document that the user must fill it in`
|
|
1253
1279
|
});
|
|
1280
|
+
} else if (kind === "file-path") {
|
|
1281
|
+
findings.push({
|
|
1282
|
+
severity: "LOW",
|
|
1283
|
+
rule: "mcp-credential-file-path",
|
|
1284
|
+
file,
|
|
1285
|
+
detail: `env.${key} points at a credential file rather than an inline secret \u2014 the value leaks nothing, but keep that file out of version control`
|
|
1286
|
+
});
|
|
1254
1287
|
}
|
|
1255
1288
|
}
|
|
1256
1289
|
}
|
|
@@ -1262,15 +1295,29 @@ var DANGEROUS_FLAG_RE = /--dangerously-[\w-]+|--no-sandbox\b/g;
|
|
|
1262
1295
|
var CREDENTIAL_ASSIGNMENT_RE = /["']?([A-Za-z][A-Za-z0-9_]*)["']?\s*[:=]\s*["']([^"']{6,})["']/g;
|
|
1263
1296
|
var CREDENTIAL_ASSIGNMENT_UNQUOTED_RE = /^\s*(?:export\s+|-\s+)?([A-Za-z][A-Za-z0-9_]*)\s*[:=]\s*(\S+)/;
|
|
1264
1297
|
var LEADING_QUOTE_RE = /^["']/;
|
|
1298
|
+
function classifyCredentialAssignment(key, value) {
|
|
1299
|
+
if (isPlaceholderValue(value)) return "none";
|
|
1300
|
+
const credentialKey = looksCredentialKey(key);
|
|
1301
|
+
if (credentialKey && looksStructuredNonSecret(value) && !/^[a-z]+:\/\//i.test(value.trim())) return "file-path";
|
|
1302
|
+
if (credentialKey || looksHighEntropy(value)) return "inline-secret";
|
|
1303
|
+
return "none";
|
|
1304
|
+
}
|
|
1265
1305
|
function pushCredentialFinding(findings, file, lineNo, varName, value) {
|
|
1266
|
-
|
|
1267
|
-
if (
|
|
1306
|
+
const kind = classifyCredentialAssignment(varName, value);
|
|
1307
|
+
if (kind === "inline-secret") {
|
|
1268
1308
|
findings.push({
|
|
1269
1309
|
severity: "HIGH",
|
|
1270
1310
|
rule: "mcp-inline-credential-value",
|
|
1271
1311
|
file,
|
|
1272
1312
|
detail: `line ${lineNo}: inline credential value assigned to ${varName}`
|
|
1273
1313
|
});
|
|
1314
|
+
} else if (kind === "file-path") {
|
|
1315
|
+
findings.push({
|
|
1316
|
+
severity: "LOW",
|
|
1317
|
+
rule: "mcp-credential-file-path",
|
|
1318
|
+
file,
|
|
1319
|
+
detail: `line ${lineNo}: ${varName} points at a credential file rather than an inline secret \u2014 the value leaks nothing, but keep that file out of version control`
|
|
1320
|
+
});
|
|
1274
1321
|
}
|
|
1275
1322
|
}
|
|
1276
1323
|
function scanTextFile(file, content, allowCredentialCheck) {
|