xploitscan-shared-rules 2.4.19 → 2.4.20
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/index.cjs +359 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +358 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -153,6 +153,7 @@ __export(index_exports, {
|
|
|
153
153
|
tryParse: () => tryParse,
|
|
154
154
|
unmeasuredQualityRules: () => unmeasuredQualityRules,
|
|
155
155
|
unvalidatedRedirect: () => unvalidatedRedirect,
|
|
156
|
+
vc001TestFixtureSeverity: () => vc001TestFixtureSeverity,
|
|
156
157
|
vendoredReason: () => vendoredReason,
|
|
157
158
|
visitBinary: () => visitBinary,
|
|
158
159
|
visitCalls: () => visitCalls,
|
|
@@ -162,7 +163,7 @@ __export(index_exports, {
|
|
|
162
163
|
module.exports = __toCommonJS(index_exports);
|
|
163
164
|
|
|
164
165
|
// src/version.ts
|
|
165
|
-
var SCANNER_VERSION = "2.4.
|
|
166
|
+
var SCANNER_VERSION = "2.4.20";
|
|
166
167
|
|
|
167
168
|
// src/snippet.ts
|
|
168
169
|
var cacheContent = null;
|
|
@@ -870,6 +871,10 @@ function isUngradedFinding(finding, options = {}) {
|
|
|
870
871
|
if (options.gradeVendored) return false;
|
|
871
872
|
return isVendoredFinding(finding);
|
|
872
873
|
}
|
|
874
|
+
function vc001TestFixtureSeverity(rule, testFile, severity) {
|
|
875
|
+
if (rule === "VC001" && testFile === true) return "low";
|
|
876
|
+
return severity;
|
|
877
|
+
}
|
|
873
878
|
|
|
874
879
|
// src/routes.ts
|
|
875
880
|
var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
|
|
@@ -2229,6 +2234,308 @@ function noteHardcodedSecret(secret) {
|
|
|
2229
2234
|
const sink = hardcodedSecretValueSink[hardcodedSecretValueSink.length - 1];
|
|
2230
2235
|
if (sink && secret) sink.push(secret);
|
|
2231
2236
|
}
|
|
2237
|
+
var LOCKED_PLACEHOLDER_TOKENS = /* @__PURE__ */ new Set([
|
|
2238
|
+
"your_api_key_here",
|
|
2239
|
+
"your-key-here",
|
|
2240
|
+
"your_key",
|
|
2241
|
+
"<your_key>",
|
|
2242
|
+
"changeme"
|
|
2243
|
+
]);
|
|
2244
|
+
function isEntireXBody(value) {
|
|
2245
|
+
if (!value) return false;
|
|
2246
|
+
for (let i = 0; i < value.length; i++) {
|
|
2247
|
+
const code = value.charCodeAt(i);
|
|
2248
|
+
if (code !== 120 && code !== 88) return false;
|
|
2249
|
+
}
|
|
2250
|
+
return true;
|
|
2251
|
+
}
|
|
2252
|
+
function bodyAfterKnownPrefix(token) {
|
|
2253
|
+
const lower = token.toLowerCase();
|
|
2254
|
+
const prefixes = ["sk_live_", "pk_live_", "sk_test_", "pk_test_", "rk_live_", "rk_test_"];
|
|
2255
|
+
for (const prefix of prefixes) {
|
|
2256
|
+
if (lower.startsWith(prefix)) return token.slice(prefix.length);
|
|
2257
|
+
}
|
|
2258
|
+
return null;
|
|
2259
|
+
}
|
|
2260
|
+
function isLockedVc001Placeholder(token) {
|
|
2261
|
+
if (!token) return false;
|
|
2262
|
+
const trimmed = token.trim();
|
|
2263
|
+
if (!trimmed) return false;
|
|
2264
|
+
const lower = trimmed.toLowerCase();
|
|
2265
|
+
if (LOCKED_PLACEHOLDER_TOKENS.has(lower) || isEntireXBody(trimmed)) return true;
|
|
2266
|
+
const body = bodyAfterKnownPrefix(trimmed);
|
|
2267
|
+
if (body === null || body.length === 0) return false;
|
|
2268
|
+
return LOCKED_PLACEHOLDER_TOKENS.has(body.toLowerCase()) || isEntireXBody(body);
|
|
2269
|
+
}
|
|
2270
|
+
function collapseIdenticalRuns(token) {
|
|
2271
|
+
let out = "";
|
|
2272
|
+
let i = 0;
|
|
2273
|
+
while (i < token.length) {
|
|
2274
|
+
let j = i + 1;
|
|
2275
|
+
while (j < token.length && token[j] === token[i]) j += 1;
|
|
2276
|
+
const keep = j - i >= 8 ? 7 : j - i;
|
|
2277
|
+
out += token[i].repeat(keep);
|
|
2278
|
+
i = j;
|
|
2279
|
+
}
|
|
2280
|
+
return out;
|
|
2281
|
+
}
|
|
2282
|
+
function liveDespiteIdenticalRun(text) {
|
|
2283
|
+
if (!text || textHasLiveCredential(text)) return false;
|
|
2284
|
+
const re = /(?:sk_live_|rk_live_)[A-Za-z0-9]{20,}/g;
|
|
2285
|
+
let found;
|
|
2286
|
+
while ((found = re.exec(text)) !== null) {
|
|
2287
|
+
const token = found[0];
|
|
2288
|
+
if (isLockedVc001Placeholder(token)) continue;
|
|
2289
|
+
const collapsed = collapseIdenticalRuns(token);
|
|
2290
|
+
if (collapsed === token) continue;
|
|
2291
|
+
if (!isPlaceholderToken(collapsed)) return true;
|
|
2292
|
+
}
|
|
2293
|
+
return false;
|
|
2294
|
+
}
|
|
2295
|
+
function stripeReportedSeverity(text) {
|
|
2296
|
+
if (/pk_live_[A-Za-z0-9]{20,}/.test(text)) return "low";
|
|
2297
|
+
if (/sk_test_[A-Za-z0-9]{20,}/.test(text)) return "medium";
|
|
2298
|
+
return void 0;
|
|
2299
|
+
}
|
|
2300
|
+
function decodeBase64UrlJson(segment) {
|
|
2301
|
+
try {
|
|
2302
|
+
if (!segment || segment.length > 8192) return null;
|
|
2303
|
+
const pad = segment.length % 4 === 0 ? "" : "=".repeat(4 - segment.length % 4);
|
|
2304
|
+
const b64 = segment.replace(/-/g, "+").replace(/_/g, "/") + pad;
|
|
2305
|
+
const binary = atob(b64);
|
|
2306
|
+
const bytes = new Uint8Array(binary.length);
|
|
2307
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i) & 255;
|
|
2308
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
2309
|
+
} catch {
|
|
2310
|
+
return null;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
function decodeSupabaseJwt(token) {
|
|
2314
|
+
const parts = token.split(".");
|
|
2315
|
+
if (parts.length !== 3) return null;
|
|
2316
|
+
if (parts.some((part) => !/^[A-Za-z0-9_-]{8,}$/.test(part))) return null;
|
|
2317
|
+
const payload = decodeBase64UrlJson(parts[1]);
|
|
2318
|
+
if (!payload || typeof payload !== "object") return null;
|
|
2319
|
+
const rec = payload;
|
|
2320
|
+
return {
|
|
2321
|
+
role: typeof rec.role === "string" ? rec.role : void 0,
|
|
2322
|
+
iss: typeof rec.iss === "string" ? rec.iss : void 0,
|
|
2323
|
+
payloadText: JSON.stringify(payload)
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
var STRING_CONST_VALUE_MAX = 4096;
|
|
2327
|
+
var CREATE_CLIENT_CALL_CAP = 200;
|
|
2328
|
+
function collectStringConsts(content) {
|
|
2329
|
+
const map = /* @__PURE__ */ new Map();
|
|
2330
|
+
const head = /(?:const|let|var)\s+([A-Za-z_$][\w$]{0,64})\s*=\s*(['"`])/g;
|
|
2331
|
+
let match;
|
|
2332
|
+
while ((match = head.exec(content)) !== null) {
|
|
2333
|
+
const name = match[1];
|
|
2334
|
+
const quote = match[2];
|
|
2335
|
+
const valueStart = match.index + match[0].length;
|
|
2336
|
+
const limit = Math.min(content.length, valueStart + STRING_CONST_VALUE_MAX);
|
|
2337
|
+
let end = valueStart;
|
|
2338
|
+
while (end < limit && content[end] !== quote) end += 1;
|
|
2339
|
+
if (end >= limit || content[end] !== quote) continue;
|
|
2340
|
+
if (!map.has(name)) map.set(name, { value: content.slice(valueStart, end), index: valueStart });
|
|
2341
|
+
head.lastIndex = end + 1;
|
|
2342
|
+
}
|
|
2343
|
+
return map;
|
|
2344
|
+
}
|
|
2345
|
+
function stringConstValue(consts, name) {
|
|
2346
|
+
if (!/^[A-Za-z_$][\w$]{0,64}$/.test(name)) return null;
|
|
2347
|
+
const found = consts.get(name);
|
|
2348
|
+
return found ? found.value : null;
|
|
2349
|
+
}
|
|
2350
|
+
function isLoopbackClientUrl(raw) {
|
|
2351
|
+
const match = /^[a-z][a-z0-9+.-]*:\/\/([^/?#\s]+)/i.exec(raw.trim());
|
|
2352
|
+
if (!match) return false;
|
|
2353
|
+
let host = match[1];
|
|
2354
|
+
if (host.startsWith("[")) {
|
|
2355
|
+
const end = host.indexOf("]");
|
|
2356
|
+
if (end < 0) return false;
|
|
2357
|
+
host = host.slice(1, end);
|
|
2358
|
+
} else {
|
|
2359
|
+
host = host.replace(/:\d+$/, "");
|
|
2360
|
+
}
|
|
2361
|
+
host = host.toLowerCase();
|
|
2362
|
+
return host === "localhost" || host === "127.0.0.1" || host === "::1";
|
|
2363
|
+
}
|
|
2364
|
+
function quotedValue(text) {
|
|
2365
|
+
const trimmed = text.trim();
|
|
2366
|
+
if (!trimmed) return null;
|
|
2367
|
+
const lead = text.indexOf(trimmed);
|
|
2368
|
+
if (/^(?:process\.env|import\.meta\.env)\.[A-Za-z0-9_]+!?$/.test(trimmed)) return null;
|
|
2369
|
+
const fallback = /(?:process\.env|import\.meta\.env)\.[A-Za-z0-9_]+!?\s*(?:\?\?|\|\|)\s*(['"`])([\s\S]*?)\1/.exec(trimmed);
|
|
2370
|
+
if (fallback?.[2]) {
|
|
2371
|
+
const rel = text.indexOf(fallback[2]);
|
|
2372
|
+
return { token: fallback[2], rel: rel < 0 ? lead : rel };
|
|
2373
|
+
}
|
|
2374
|
+
const literal = /^(['"`])([\s\S]*)\1$/.exec(trimmed);
|
|
2375
|
+
if (literal) {
|
|
2376
|
+
const rel = text.indexOf(literal[2]);
|
|
2377
|
+
return { token: literal[2], rel: rel < 0 ? lead + 1 : rel };
|
|
2378
|
+
}
|
|
2379
|
+
return null;
|
|
2380
|
+
}
|
|
2381
|
+
function splitCallArgs(content, openParen, cap) {
|
|
2382
|
+
const endLimit = Math.min(content.length, openParen + cap);
|
|
2383
|
+
const args = [];
|
|
2384
|
+
let start = openParen + 1;
|
|
2385
|
+
let depth = 1;
|
|
2386
|
+
let quote = null;
|
|
2387
|
+
let i = openParen + 1;
|
|
2388
|
+
while (i < endLimit && depth > 0) {
|
|
2389
|
+
const ch = content[i];
|
|
2390
|
+
if (quote) {
|
|
2391
|
+
if (ch === "\\") {
|
|
2392
|
+
i += 2;
|
|
2393
|
+
continue;
|
|
2394
|
+
}
|
|
2395
|
+
if (ch === quote) quote = null;
|
|
2396
|
+
i++;
|
|
2397
|
+
continue;
|
|
2398
|
+
}
|
|
2399
|
+
if (ch === "'" || ch === '"' || ch === "`") {
|
|
2400
|
+
quote = ch;
|
|
2401
|
+
i++;
|
|
2402
|
+
continue;
|
|
2403
|
+
}
|
|
2404
|
+
if (ch === "(" || ch === "[" || ch === "{") {
|
|
2405
|
+
depth++;
|
|
2406
|
+
i++;
|
|
2407
|
+
continue;
|
|
2408
|
+
}
|
|
2409
|
+
if (ch === ")" || ch === "]" || ch === "}") {
|
|
2410
|
+
depth--;
|
|
2411
|
+
if (depth === 0) {
|
|
2412
|
+
args.push({ text: content.slice(start, i), start });
|
|
2413
|
+
return { args, end: i + 1 };
|
|
2414
|
+
}
|
|
2415
|
+
i++;
|
|
2416
|
+
continue;
|
|
2417
|
+
}
|
|
2418
|
+
if (ch === "," && depth === 1) {
|
|
2419
|
+
args.push({ text: content.slice(start, i), start });
|
|
2420
|
+
start = i + 1;
|
|
2421
|
+
if (args.length >= 4) {
|
|
2422
|
+
return { args, end: i + 1 };
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
i++;
|
|
2426
|
+
}
|
|
2427
|
+
return { args, end: i };
|
|
2428
|
+
}
|
|
2429
|
+
function objectKeyToken(arg, consts) {
|
|
2430
|
+
const named = /\b(?:supabaseKey|serviceRoleKey|service_role_key|apiKey|key)\s*:\s*(?:(['"`])([\s\S]*?)\1|([A-Za-z_$][\w$]{0,64}))/.exec(arg.text);
|
|
2431
|
+
if (!named) return null;
|
|
2432
|
+
if (named[2]) {
|
|
2433
|
+
const rel2 = arg.text.indexOf(named[2]);
|
|
2434
|
+
return { token: named[2], index: arg.start + (rel2 < 0 ? 0 : rel2) };
|
|
2435
|
+
}
|
|
2436
|
+
const ident = named[3];
|
|
2437
|
+
if (!ident) return null;
|
|
2438
|
+
const resolved = stringConstValue(consts, ident);
|
|
2439
|
+
if (resolved === null) return null;
|
|
2440
|
+
const rel = arg.text.indexOf(ident);
|
|
2441
|
+
return { token: resolved, index: arg.start + (rel < 0 ? 0 : rel) };
|
|
2442
|
+
}
|
|
2443
|
+
function valueToken(arg, consts) {
|
|
2444
|
+
const quoted = quotedValue(arg.text);
|
|
2445
|
+
if (quoted) return { token: quoted.token, index: arg.start + quoted.rel };
|
|
2446
|
+
const trimmed = arg.text.trim();
|
|
2447
|
+
if (/^[A-Za-z_$][\w$]{0,64}$/.test(trimmed)) {
|
|
2448
|
+
const resolved = stringConstValue(consts, trimmed);
|
|
2449
|
+
if (resolved === null) return null;
|
|
2450
|
+
const rel = arg.text.indexOf(trimmed);
|
|
2451
|
+
return { token: resolved, index: arg.start + (rel < 0 ? 0 : rel) };
|
|
2452
|
+
}
|
|
2453
|
+
if (trimmed.startsWith("{")) return objectKeyToken(arg, consts);
|
|
2454
|
+
return null;
|
|
2455
|
+
}
|
|
2456
|
+
function clientUrl(args) {
|
|
2457
|
+
if (args.length === 0) return "";
|
|
2458
|
+
const first = args[0].text.trim();
|
|
2459
|
+
const literal = /^(['"`])([\s\S]*)\1$/.exec(first);
|
|
2460
|
+
if (literal) return literal[2];
|
|
2461
|
+
if (first.startsWith("{")) {
|
|
2462
|
+
const url = /\b(?:supabaseUrl|url)\s*:\s*(['"`])([\s\S]*?)\1/.exec(first);
|
|
2463
|
+
return url?.[2] ?? "";
|
|
2464
|
+
}
|
|
2465
|
+
return "";
|
|
2466
|
+
}
|
|
2467
|
+
function nextCreateClient(content, from, cursor) {
|
|
2468
|
+
if (cursor.camel >= 0 && cursor.camel < from) {
|
|
2469
|
+
cursor.camel = content.indexOf("createClient", from);
|
|
2470
|
+
}
|
|
2471
|
+
if (cursor.snake >= 0 && cursor.snake < from) {
|
|
2472
|
+
cursor.snake = content.indexOf("create_client", from);
|
|
2473
|
+
}
|
|
2474
|
+
if (cursor.camel < 0) return cursor.snake;
|
|
2475
|
+
if (cursor.snake < 0) return cursor.camel;
|
|
2476
|
+
return cursor.camel < cursor.snake ? cursor.camel : cursor.snake;
|
|
2477
|
+
}
|
|
2478
|
+
function collectSupabaseCreateClientKeys(content, filePath, matches, rule, fix) {
|
|
2479
|
+
if (!content.includes("createClient") && !content.includes("create_client")) return;
|
|
2480
|
+
const consts = content.includes("createClient") ? collectStringConsts(content) : /* @__PURE__ */ new Map();
|
|
2481
|
+
const cap = 2e4;
|
|
2482
|
+
let from = 0;
|
|
2483
|
+
let calls = 0;
|
|
2484
|
+
const cursor = {
|
|
2485
|
+
camel: content.indexOf("createClient"),
|
|
2486
|
+
snake: content.indexOf("create_client")
|
|
2487
|
+
};
|
|
2488
|
+
while (from < content.length) {
|
|
2489
|
+
const at = nextCreateClient(content, from, cursor);
|
|
2490
|
+
if (at < 0) break;
|
|
2491
|
+
const nameLen = content.startsWith("create_client", at) ? "create_client".length : "createClient".length;
|
|
2492
|
+
const before = at === 0 ? "" : content[at - 1];
|
|
2493
|
+
const afterName = at + nameLen;
|
|
2494
|
+
if (before && /[A-Za-z0-9_$]/.test(before) || /[A-Za-z0-9_$]/.test(content[afterName] ?? "")) {
|
|
2495
|
+
from = afterName;
|
|
2496
|
+
continue;
|
|
2497
|
+
}
|
|
2498
|
+
let i = afterName;
|
|
2499
|
+
while (i < content.length && (content[i] === " " || content[i] === " " || content[i] === "\n" || content[i] === "\r")) i++;
|
|
2500
|
+
if (content[i] !== "(") {
|
|
2501
|
+
from = afterName;
|
|
2502
|
+
continue;
|
|
2503
|
+
}
|
|
2504
|
+
calls += 1;
|
|
2505
|
+
if (calls > CREATE_CLIENT_CALL_CAP) break;
|
|
2506
|
+
const parsed = splitCallArgs(content, i, cap);
|
|
2507
|
+
from = parsed?.end ?? Math.min(content.length, i + cap);
|
|
2508
|
+
if (!parsed || parsed.args.length === 0) continue;
|
|
2509
|
+
if (isCommentLine(content, at) || isInsideFixMessage(content, at)) continue;
|
|
2510
|
+
const first = parsed.args[0].text.trim();
|
|
2511
|
+
const keyArg = first.startsWith("{") ? parsed.args[0] : parsed.args[1];
|
|
2512
|
+
if (!keyArg) continue;
|
|
2513
|
+
const extracted = first.startsWith("{") ? objectKeyToken(keyArg, consts) : valueToken(keyArg, consts);
|
|
2514
|
+
if (!extracted || !extracted.token) continue;
|
|
2515
|
+
const token = extracted.token.trim();
|
|
2516
|
+
if (isPlaceholderToken(token) || isLockedVc001Placeholder(token)) continue;
|
|
2517
|
+
const decoded = decodeSupabaseJwt(token);
|
|
2518
|
+
if (!decoded || decoded.role !== "service_role") continue;
|
|
2519
|
+
const url = clientUrl(parsed.args);
|
|
2520
|
+
const downgrade = isTestPath(filePath) && (decoded.iss === "supabase-demo" || isLoopbackClientUrl(url));
|
|
2521
|
+
const line = lineNumberAt(content, extracted.index);
|
|
2522
|
+
const lineStart = content.lastIndexOf("\n", Math.max(0, extracted.index - 1)) + 1;
|
|
2523
|
+
const column = extracted.index - lineStart + 1;
|
|
2524
|
+
matches.push({
|
|
2525
|
+
rule: rule.id,
|
|
2526
|
+
title: rule.title,
|
|
2527
|
+
severity: downgrade ? "low" : "critical",
|
|
2528
|
+
category: rule.category,
|
|
2529
|
+
file: filePath,
|
|
2530
|
+
line,
|
|
2531
|
+
column,
|
|
2532
|
+
snippet: getSnippet(content, line),
|
|
2533
|
+
fix,
|
|
2534
|
+
...downgrade ? {} : { live: true }
|
|
2535
|
+
});
|
|
2536
|
+
noteHardcodedSecret(token);
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2232
2539
|
var hardcodedSecrets = {
|
|
2233
2540
|
id: "VC001",
|
|
2234
2541
|
title: "Hardcoded API Key or Secret",
|
|
@@ -2330,10 +2637,9 @@ var hardcodedSecrets = {
|
|
|
2330
2637
|
50,
|
|
2331
2638
|
// [3] Supabase JWT
|
|
2332
2639
|
// [4] OpenAI and [11]–[14] fixed-prefix tokens: the regex already
|
|
2333
|
-
// fixes the length
|
|
2334
|
-
//
|
|
2335
|
-
//
|
|
2336
|
-
// made redundant everywhere except that misread.)
|
|
2640
|
+
// fixes the length, so the floor is 0. Every other floor measures this
|
|
2641
|
+
// match's own value. A live credential skips the floor. A placeholder
|
|
2642
|
+
// is dropped first, so a template key is never reported.
|
|
2337
2643
|
0,
|
|
2338
2644
|
20,
|
|
2339
2645
|
// [5] generic tokens with {20,} in the regex
|
|
@@ -2360,6 +2666,27 @@ var hardcodedSecrets = {
|
|
|
2360
2666
|
const lines = content.split("\n");
|
|
2361
2667
|
const fileIsGemini = GEMINI_FILE_CONTEXT_RE.test(content);
|
|
2362
2668
|
const matches = [];
|
|
2669
|
+
const columnFrom = /* @__PURE__ */ new Map();
|
|
2670
|
+
const locate = (lineNo, line, secret) => {
|
|
2671
|
+
if (!secret) return void 0;
|
|
2672
|
+
const key = `${lineNo}\0${secret}`;
|
|
2673
|
+
const start = columnFrom.get(key) ?? 0;
|
|
2674
|
+
const at = line.indexOf(secret, start);
|
|
2675
|
+
if (at < 0) return void 0;
|
|
2676
|
+
columnFrom.set(key, at + secret.length);
|
|
2677
|
+
return at + 1;
|
|
2678
|
+
};
|
|
2679
|
+
const emit = (rm, secret, extra = {}) => {
|
|
2680
|
+
const column = locate(rm.line, lines[rm.line - 1] || "", secret);
|
|
2681
|
+
const stripeSev = extra.live || extra.severity ? void 0 : stripeReportedSeverity(secret);
|
|
2682
|
+
matches.push({
|
|
2683
|
+
...rm,
|
|
2684
|
+
...extra,
|
|
2685
|
+
...stripeSev ? { severity: stripeSev } : {},
|
|
2686
|
+
...column ? { column } : {}
|
|
2687
|
+
});
|
|
2688
|
+
noteHardcodedSecret(secret);
|
|
2689
|
+
};
|
|
2363
2690
|
for (let pi = 0; pi < patterns.length; pi++) {
|
|
2364
2691
|
const pattern = patterns[pi];
|
|
2365
2692
|
if (pi === GOOGLE_PI && !fileIsGemini && !GEMINI_NAME_RE.test(content)) continue;
|
|
@@ -2384,30 +2711,27 @@ var hardcodedSecrets = {
|
|
|
2384
2711
|
if (isPlaceholderToken(token)) continue;
|
|
2385
2712
|
if (pi === GOOGLE_PI) {
|
|
2386
2713
|
if (!isGeminiKeyContext(lines, rm.line, fileIsGemini)) continue;
|
|
2387
|
-
|
|
2388
|
-
noteHardcodedSecret(secretText[ri] ?? "");
|
|
2714
|
+
emit(rm, secretText[ri] ?? token, textHasLiveCredential(token) ? { severity: "high", live: true } : { severity: "high" });
|
|
2389
2715
|
continue;
|
|
2390
2716
|
}
|
|
2391
2717
|
if (pi === STRIPE_RESTRICTED_PI && !token.startsWith("rk_live_")) {
|
|
2392
|
-
|
|
2393
|
-
noteHardcodedSecret(secretText[ri] ?? "");
|
|
2718
|
+
emit(rm, secretText[ri] ?? token, { severity: "high" });
|
|
2394
2719
|
continue;
|
|
2395
2720
|
}
|
|
2396
2721
|
if (textHasLiveCredential(token)) {
|
|
2397
|
-
|
|
2398
|
-
noteHardcodedSecret(secretText[ri] ?? "");
|
|
2722
|
+
emit(rm, secretText[ri] ?? token, { live: true });
|
|
2399
2723
|
continue;
|
|
2400
2724
|
}
|
|
2401
2725
|
}
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2726
|
+
const judged = secretText[ri] && secretText[ri].length > 0 ? secretText[ri] : matchedText[ri] ?? "";
|
|
2727
|
+
const judgedLive = textHasLiveCredential(judged) || liveDespiteIdenticalRun(judged);
|
|
2728
|
+
if (pi !== 9 && pi !== 10 && !judgedLive && isLockedVc001Placeholder(judged)) continue;
|
|
2729
|
+
const matchedLive = textHasLiveCredential(matchedText[ri] ?? "") || judgedLive;
|
|
2730
|
+
if (!matchedLive && floor > 0 && judged.length < floor) continue;
|
|
2406
2731
|
if (pi === 6) {
|
|
2407
|
-
const
|
|
2732
|
+
const value = judged;
|
|
2408
2733
|
const nameMatch = (matchedText[ri] ?? "").match(/^[A-Z][A-Z0-9_]{0,64}_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD)\b/);
|
|
2409
|
-
if (
|
|
2410
|
-
const value = valMatch[1];
|
|
2734
|
+
if (value && nameMatch) {
|
|
2411
2735
|
const isKeySuffix = nameMatch[0].endsWith("_KEY");
|
|
2412
2736
|
const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[0], value));
|
|
2413
2737
|
if (isKeySuffix && isSlotIdentifier) continue;
|
|
@@ -2416,15 +2740,18 @@ var hardcodedSecrets = {
|
|
|
2416
2740
|
if (pi === 10) {
|
|
2417
2741
|
const url = matchedText[ri] ?? "";
|
|
2418
2742
|
if (dbUrlLacksRealCredential(url)) continue;
|
|
2419
|
-
|
|
2420
|
-
|
|
2743
|
+
emit(
|
|
2744
|
+
rm,
|
|
2745
|
+
secretText[ri] ?? url,
|
|
2746
|
+
isLoopbackDevDefault(url) ? { severity: "low" } : textHasLiveCredential(url) ? { live: true } : {}
|
|
2747
|
+
);
|
|
2421
2748
|
continue;
|
|
2422
2749
|
}
|
|
2423
2750
|
const matched = matchedText[ri] ?? "";
|
|
2424
|
-
|
|
2425
|
-
noteHardcodedSecret(secretText[ri] ?? "");
|
|
2751
|
+
emit(rm, judged, textHasLiveCredential(matched) || matchedLive ? { live: true } : {});
|
|
2426
2752
|
}
|
|
2427
2753
|
}
|
|
2754
|
+
collectSupabaseCreateClientKeys(content, filePath, matches, hardcodedSecrets, fixMessages[3]);
|
|
2428
2755
|
return matches;
|
|
2429
2756
|
}
|
|
2430
2757
|
};
|
|
@@ -4001,7 +4328,7 @@ var hardcodedJWTSecret = {
|
|
|
4001
4328
|
category: "Secrets",
|
|
4002
4329
|
description: "JWT tokens signed with a hardcoded string secret can be forged by anyone who reads the source code.",
|
|
4003
4330
|
check(content, filePath) {
|
|
4004
|
-
if (filePath.endsWith(".example") || filePath.endsWith(".template") || filePath
|
|
4331
|
+
if (filePath.endsWith(".example") || filePath.endsWith(".template") || isTestFile(filePath)) return [];
|
|
4005
4332
|
const patterns = [
|
|
4006
4333
|
/jwt\.sign\s*\([^,]{1,300},\s*["'`][^"'`]{3,}["'`]/g,
|
|
4007
4334
|
/jwt\.verify\s*\([^,]{1,300},\s*["'`][^"'`]{3,}["'`]/g,
|
|
@@ -4093,7 +4420,7 @@ var exposedDebugMode = {
|
|
|
4093
4420
|
category: "Configuration",
|
|
4094
4421
|
description: "Debug mode, verbose logging, or development configuration left in production code exposes internal details and may enable debug endpoints.",
|
|
4095
4422
|
check(content, filePath) {
|
|
4096
|
-
if (filePath
|
|
4423
|
+
if (isTestFile(filePath) || filePath.endsWith(".example") || filePath.includes("node_modules")) return [];
|
|
4097
4424
|
if (filePath.match(/\.env\.development$/)) return [];
|
|
4098
4425
|
const matches = [];
|
|
4099
4426
|
const patterns = [
|
|
@@ -4257,7 +4584,7 @@ var weakHashing = {
|
|
|
4257
4584
|
category: "Cryptography",
|
|
4258
4585
|
description: "MD5 and SHA1/SHA256 are too fast for password hashing \u2014 they can be brute-forced at billions of attempts per second. Use bcrypt, scrypt, or argon2 instead.",
|
|
4259
4586
|
check(content, filePath) {
|
|
4260
|
-
if (
|
|
4587
|
+
if (isTestFile(filePath)) return [];
|
|
4261
4588
|
if (/bcrypt|scrypt|argon2/i.test(content)) return [];
|
|
4262
4589
|
const matches = [];
|
|
4263
4590
|
const inlinePatterns = [
|
|
@@ -5031,13 +5358,14 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
5031
5358
|
live: match.live,
|
|
5032
5359
|
snippet: match.snippet
|
|
5033
5360
|
});
|
|
5361
|
+
const testFixture = onTestPath && !live;
|
|
5034
5362
|
findings.push({
|
|
5035
5363
|
...vendored ? { vendored: true } : {},
|
|
5036
|
-
...
|
|
5364
|
+
...testFixture ? { testFile: true } : {},
|
|
5037
5365
|
...live ? { live: true } : {},
|
|
5038
5366
|
id: `${match.rule}-${match.file}:${match.line}`,
|
|
5039
5367
|
rule: match.rule,
|
|
5040
|
-
severity: match.severity,
|
|
5368
|
+
severity: vc001TestFixtureSeverity(match.rule, testFixture ? true : void 0, match.severity),
|
|
5041
5369
|
title: match.title,
|
|
5042
5370
|
description: rule.description,
|
|
5043
5371
|
file: match.file,
|
|
@@ -8244,10 +8572,10 @@ var READ_VERB = /\b(?:select|from|find\w*|query|scan|rows|fetchAll|getAll|list)\
|
|
|
8244
8572
|
function repoReselects(files, originPath, originIndex, table, value) {
|
|
8245
8573
|
const tableToken = table.replace(/["'`]/g, "");
|
|
8246
8574
|
if (tableToken.length < 3) return false;
|
|
8247
|
-
const
|
|
8248
|
-
if (!
|
|
8575
|
+
const valueToken2 = normValue(value);
|
|
8576
|
+
if (!valueToken2 || valueToken2.length < 2) return false;
|
|
8249
8577
|
const tableRe = new RegExp(`\\b${escapeRe(tableToken)}s?\\b`, "gi");
|
|
8250
|
-
const valueRe = new RegExp(`\\b${escapeRe(
|
|
8578
|
+
const valueRe = new RegExp(`\\b${escapeRe(valueToken2)}\\b`, "i");
|
|
8251
8579
|
for (const f of files) {
|
|
8252
8580
|
if (f.excluded) continue;
|
|
8253
8581
|
for (const m of f.code.matchAll(tableRe)) {
|
|
@@ -10897,6 +11225,7 @@ function scanQuality(input, rules = qualityRules) {
|
|
|
10897
11225
|
tryParse,
|
|
10898
11226
|
unmeasuredQualityRules,
|
|
10899
11227
|
unvalidatedRedirect,
|
|
11228
|
+
vc001TestFixtureSeverity,
|
|
10900
11229
|
vendoredReason,
|
|
10901
11230
|
visitBinary,
|
|
10902
11231
|
visitCalls,
|