xploitscan-shared-rules 2.0.1 → 2.0.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/README.md +1 -1
- package/dist/index.cjs +34 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1589,12 +1589,16 @@ function tryParse(content, filePath) {
|
|
|
1589
1589
|
parseCacheValid = true;
|
|
1590
1590
|
return result;
|
|
1591
1591
|
}
|
|
1592
|
-
function isNamespacedSlotKey(value) {
|
|
1592
|
+
function isNamespacedSlotKey(name, value) {
|
|
1593
|
+
if (CREDENTIAL_NAME.test(name)) return false;
|
|
1593
1594
|
const words = value.split(/[.:/_-]/);
|
|
1594
1595
|
if (words[words.length - 1] === "") words.pop();
|
|
1595
1596
|
if (words.length < 2) return false;
|
|
1597
|
+
if (words.some((w) => CREDENTIAL_WORD.test(w))) return false;
|
|
1596
1598
|
return words.every((w) => /^[a-z]+[0-9]*(?:[A-Z][a-z]+[0-9]*)*$/.test(w));
|
|
1597
1599
|
}
|
|
1600
|
+
var CREDENTIAL_NAME = /SECRET|SIGN|ENCRYPT|CRYPT|CIPHER|HMAC|JWT|PRIVATE|API|ACCESS|AUTH|MASTER|ADMIN|SESSION|PASS|TOKEN|CLIENT|SALT|PEPPER|LICEN[CS]E|WEBHOOK|STRIPE|AWS|SERVICE/;
|
|
1601
|
+
var CREDENTIAL_WORD = /secret|passw|token|private|signing|apikey|credential/i;
|
|
1598
1602
|
var hardcodedSecrets = {
|
|
1599
1603
|
id: "VC001",
|
|
1600
1604
|
title: "Hardcoded API Key or Secret",
|
|
@@ -1690,7 +1694,7 @@ var hardcodedSecrets = {
|
|
|
1690
1694
|
if (valMatch && nameMatch) {
|
|
1691
1695
|
const value = valMatch[1];
|
|
1692
1696
|
const isKeySuffix = nameMatch[1].endsWith("_KEY");
|
|
1693
|
-
const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(value));
|
|
1697
|
+
const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[1], value));
|
|
1694
1698
|
if (isKeySuffix && isSlotIdentifier) continue;
|
|
1695
1699
|
}
|
|
1696
1700
|
}
|
|
@@ -2236,7 +2240,8 @@ var noRateLimiting = {
|
|
|
2236
2240
|
check(content, filePath) {
|
|
2237
2241
|
const isEntryFile = /(?:server|app|index|main)\.[jt]sx?$/.test(filePath) || filePath.includes("middleware");
|
|
2238
2242
|
if (!isEntryFile) return [];
|
|
2239
|
-
const isServer = /(?:from\s+|require\s*\(\s*)["'`](?:express|hono|fastify|koa|@hono\/[\w-]+|next
|
|
2243
|
+
const isServer = /(?:from\s+|require\s*\(\s*)["'`](?:express|hono|fastify|koa|koa-router|@koa\/[\w-]+|@hono\/[\w-]+|next(?:\/server)?|next-auth(?:\/[\w-]+)?|@clerk\/nextjs(?:\/server)?)["'`]/.test(content) || // Case-sensitive framework types — `adNext` and `nextLap` can't match.
|
|
2244
|
+
/\b(?:NextApiRequest|NextApiResponse|NextRequest|NextResponse)\b/.test(content) || /\b(?:express|fastify|createServer)\s*\(/.test(content) || /\bnew\s+(?:Hono|Koa)\s*\(/.test(content) || /\b(?:Deno|Bun)\.serve\s*\(/.test(content) || /\.listen\s*\(/.test(content);
|
|
2240
2245
|
if (!isServer) return [];
|
|
2241
2246
|
const hasRateLimit = /rate.?limit|throttle|express-rate-limit|@elysiajs\/rate-limit|hono.*limiter/i.test(content);
|
|
2242
2247
|
if (hasRateLimit) return [];
|
|
@@ -2515,12 +2520,32 @@ var exposedAuthSecret = {
|
|
|
2515
2520
|
}
|
|
2516
2521
|
};
|
|
2517
2522
|
function cspFixFor(content) {
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
)
|
|
2522
|
-
|
|
2523
|
-
|
|
2523
|
+
const html = content.slice(0, 2e5);
|
|
2524
|
+
const origins = /* @__PURE__ */ new Set();
|
|
2525
|
+
const addOrigin = (url) => {
|
|
2526
|
+
const m2 = url.match(/^(https?:)?\/\/([^/"'`\s>?#]+)/i);
|
|
2527
|
+
if (m2 && origins.size < 10) origins.add(`${(m2[1] ?? "https:").toLowerCase()}//${m2[2].toLowerCase()}`);
|
|
2528
|
+
};
|
|
2529
|
+
let inlineScripts = 0;
|
|
2530
|
+
const openTag = /<script\b([^>]{0,500})>/gi;
|
|
2531
|
+
let m;
|
|
2532
|
+
for (let seen = 0; (m = openTag.exec(html)) && seen < 100; seen++) {
|
|
2533
|
+
const attrs = m[1];
|
|
2534
|
+
const src = attrs.match(/\bsrc\s*=\s*["']?((?:https?:)?\/\/[^"'\s>]+)/i);
|
|
2535
|
+
if (src) {
|
|
2536
|
+
addOrigin(src[1]);
|
|
2537
|
+
continue;
|
|
2538
|
+
}
|
|
2539
|
+
if (/\bsrc\s*=/i.test(attrs)) continue;
|
|
2540
|
+
const close = html.indexOf("</script", openTag.lastIndex);
|
|
2541
|
+
const body = html.slice(openTag.lastIndex, close < 0 ? openTag.lastIndex + 5e4 : close);
|
|
2542
|
+
const type = (attrs.match(/\btype\s*=\s*["']?([^"'\s>]+)/i)?.[1] ?? "").toLowerCase();
|
|
2543
|
+
const runs = type === "" || type === "module" || type === "importmap" || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$/.test(type);
|
|
2544
|
+
if (!runs || !body.trim()) continue;
|
|
2545
|
+
inlineScripts++;
|
|
2546
|
+
const urls = type === "importmap" ? body.matchAll(/["']((?:https?:)?\/\/[^"'\s]+)["']/g) : type === "module" ? body.matchAll(/(?:\bfrom|\bimport\s*\(?)\s*["'`]((?:https?:)?\/\/[^"'`\s]+)["'`]/g) : [];
|
|
2547
|
+
for (const u of urls) addOrigin(u[1]);
|
|
2548
|
+
}
|
|
2524
2549
|
const scriptSrc = ["'self'", ...origins].join(" ");
|
|
2525
2550
|
return [
|
|
2526
2551
|
`Add a Content-Security-Policy. A starting point for this page: \`default-src 'self'; script-src ${scriptSrc}\`, plus any other origins it fetches from, frames or loads styles, fonts and images from.`,
|