xploitscan-shared-rules 1.27.3 → 1.27.5
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 +24 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2305,11 +2305,12 @@ var stripeWebhookUnprotected = {
|
|
|
2305
2305
|
check(content, filePath) {
|
|
2306
2306
|
if (!filePath.match(/\.(js|ts|jsx|tsx|py|rb|go|java|php)$/)) return [];
|
|
2307
2307
|
if (isTestFile(filePath)) return [];
|
|
2308
|
+
const code = maskComments(content);
|
|
2308
2309
|
const pathSaysStripeWebhook = /(?:^|\/)(?:stripe[_-]?webhooks?|webhooks?[_-]?stripe)(?:\/|\.|$)/i.test(filePath) || /webhooks?\/stripe/i.test(filePath) || /stripe\/webhooks?/i.test(filePath);
|
|
2309
|
-
if (!/stripe/i.test(
|
|
2310
|
-
const hasStripeWebhookHandler = pathSaysStripeWebhook || /(?:stripe.*webhook|webhook.*stripe)/i.test(
|
|
2310
|
+
if (!/stripe/i.test(code) && !pathSaysStripeWebhook) return [];
|
|
2311
|
+
const hasStripeWebhookHandler = pathSaysStripeWebhook || /(?:stripe.*webhook|webhook.*stripe)/i.test(code) || /(?:checkout\.session\.completed|invoice\.paid|payment_intent|customer\.subscription)/i.test(code);
|
|
2311
2312
|
if (!hasStripeWebhookHandler) return [];
|
|
2312
|
-
if (/constructEvent|verifyHeader|stripe[_-]?signature|webhook[_-]?secret|STRIPE_WEBHOOK_SECRET/i.test(
|
|
2313
|
+
if (/constructEvent|verifyHeader|stripe[_-]?signature|webhook[_-]?secret|STRIPE_WEBHOOK_SECRET/i.test(code) || /\b\w*verif\w*\s*\(/i.test(code) && /\bverif\w*(?:stripe|webhook|signature|sig)\w*\s*\(/i.test(code)) return [];
|
|
2313
2314
|
const handlerPatterns = [
|
|
2314
2315
|
// POST handler that processes Stripe events
|
|
2315
2316
|
/export\s+(?:async\s+)?function\s+POST\s*\(/g,
|
|
@@ -2327,7 +2328,7 @@ var stripeWebhookUnprotected = {
|
|
|
2327
2328
|
for (const pattern of handlerPatterns) {
|
|
2328
2329
|
matches.push(
|
|
2329
2330
|
...findMatches(
|
|
2330
|
-
|
|
2331
|
+
code,
|
|
2331
2332
|
pattern,
|
|
2332
2333
|
stripeWebhookUnprotected,
|
|
2333
2334
|
filePath,
|
|
@@ -10077,6 +10078,9 @@ var SKIP_FILENAMES = /(?:package-lock\.json|pnpm-lock\.yaml|yarn\.lock|composer\
|
|
|
10077
10078
|
var SAFE_VAR_NAMES = /(?:description|message|text|label|title|content|template|html|svg|css|style|class(?:Name)?|query|mutation|schema|regex|pattern|format|placeholder|comment|url|path|route|endpoint|href|src|alt|name|type|version|encoding|charset|chars|alphabet|locale|translation|copy|prose|markdown|slug|handle)/i;
|
|
10078
10079
|
var HASH_LIKE_VAR_NAMES = /(?:^|[^a-z])(?:hash|digest|checksum|fingerprint|etag|crc|md5|sha1|sha256|sha512|contenthash|buildid|revision|commit|sri|integrity|cacheKey|fileHash|assetId|versionId)(?:$|[^a-z])/i;
|
|
10079
10080
|
var HASH_PREFIX_RE = /^(?:sha\d+|md5|crc32|base64|bcrypt|argon2|pbkdf2|blake2b?)[:_]/i;
|
|
10081
|
+
var VERIFICATION_BLOCK_RE = /\bverification\s*:\s*\{/;
|
|
10082
|
+
var VERIFICATION_KEY_NAMES = /^(?:google|yandex|yahoo|bing|me|other|["']?(?:google-site-verification|facebook-domain-verification|msvalidate\.01|norton-safeweb-site-verification|ahrefs-site-verification|p:domain_verify|wot-verification)["']?)$/i;
|
|
10083
|
+
var VERIFICATION_META_RE = /<meta[^>]+name\s*=\s*["'][^"']*(?:site-verification|domain-verification|msvalidate|domain_verify)[^"']*["']/i;
|
|
10080
10084
|
var SECRET_VAR_NAMES = /(?:^|[^a-z])(?:key|secret|token|password|passwd|pwd|api[_-]?key|auth|credential|private|signing|bearer|access[_-]?token|refresh[_-]?token|session[_-]?id)(?:$|[^a-z])/i;
|
|
10081
10085
|
function getSnippet2(content, line) {
|
|
10082
10086
|
const lines = content.split("\n");
|
|
@@ -10101,8 +10105,21 @@ function scanEntropy(files) {
|
|
|
10101
10105
|
if (/(?:\.test\.|\.spec\.|__tests__|__mocks__|fixtures?\/)/i.test(filePath)) continue;
|
|
10102
10106
|
const vendored = isVendoredPath(filePath);
|
|
10103
10107
|
const lines = content.split("\n");
|
|
10108
|
+
let verificationDepth = -1;
|
|
10109
|
+
let braceDepth = 0;
|
|
10104
10110
|
for (let i = 0; i < lines.length; i++) {
|
|
10105
10111
|
const line = lines[i];
|
|
10112
|
+
if (VERIFICATION_BLOCK_RE.test(line) && verificationDepth === -1) {
|
|
10113
|
+
verificationDepth = braceDepth;
|
|
10114
|
+
}
|
|
10115
|
+
const opens = (line.match(/\{/g) || []).length;
|
|
10116
|
+
const closes = (line.match(/\}/g) || []).length;
|
|
10117
|
+
const depthBefore = braceDepth;
|
|
10118
|
+
braceDepth += opens - closes;
|
|
10119
|
+
if (verificationDepth !== -1 && braceDepth <= verificationDepth && depthBefore > verificationDepth) {
|
|
10120
|
+
verificationDepth = -1;
|
|
10121
|
+
}
|
|
10122
|
+
const inVerificationBlock = verificationDepth !== -1;
|
|
10106
10123
|
const trimmed = line.trimStart();
|
|
10107
10124
|
if (trimmed.startsWith("//") || trimmed.startsWith("#") || trimmed.startsWith("*") || trimmed.startsWith("/*")) continue;
|
|
10108
10125
|
const stringPattern = /(?:[:=]\s*)(["'`])([^"'`\n]{20,120})\1/g;
|
|
@@ -10124,7 +10141,9 @@ function scanEntropy(files) {
|
|
|
10124
10141
|
if (value.length < 20) continue;
|
|
10125
10142
|
const entropy = shannonEntropy(value);
|
|
10126
10143
|
if (entropy < threshold) continue;
|
|
10127
|
-
const varName = beforeAssign.match(/(
|
|
10144
|
+
const varName = beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
|
|
10145
|
+
if (inVerificationBlock && VERIFICATION_KEY_NAMES.test(varName)) continue;
|
|
10146
|
+
if (VERIFICATION_META_RE.test(line)) continue;
|
|
10128
10147
|
if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
|
|
10129
10148
|
const isLikelySecret = SECRET_VAR_NAMES.test(varName);
|
|
10130
10149
|
if (entropy < 4.5 && !isLikelySecret) continue;
|