xploitscan-shared-rules 2.4.18 → 2.4.19
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 +217 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +217 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -162,7 +162,7 @@ __export(index_exports, {
|
|
|
162
162
|
module.exports = __toCommonJS(index_exports);
|
|
163
163
|
|
|
164
164
|
// src/version.ts
|
|
165
|
-
var SCANNER_VERSION = "2.4.
|
|
165
|
+
var SCANNER_VERSION = "2.4.19";
|
|
166
166
|
|
|
167
167
|
// src/snippet.ts
|
|
168
168
|
var cacheContent = null;
|
|
@@ -5256,7 +5256,219 @@ var HASH_LIKE_VAR_NAMES = /(?:^|[^a-z])(?:hash|digest|checksum|fingerprint|etag|
|
|
|
5256
5256
|
var HASH_PREFIX_RE = /^(?:sha\d+|md5|crc32|base64|bcrypt|argon2|pbkdf2|blake2b?)[:_]/i;
|
|
5257
5257
|
var VERIFICATION_BLOCK_RE = /\bverification\s*:\s*\{/;
|
|
5258
5258
|
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;
|
|
5259
|
-
|
|
5259
|
+
function isWsCode(code) {
|
|
5260
|
+
if (code <= 32) return code === 9 || code === 10 || code === 11 || code === 12 || code === 13 || code === 32;
|
|
5261
|
+
if (code < 160) return false;
|
|
5262
|
+
if (code === 160 || code === 5760 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279) return true;
|
|
5263
|
+
return code >= 8192 && code <= 8202;
|
|
5264
|
+
}
|
|
5265
|
+
function isWordCode(code) {
|
|
5266
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95;
|
|
5267
|
+
}
|
|
5268
|
+
function isWs(c) {
|
|
5269
|
+
return c !== void 0 && isWsCode(c.charCodeAt(0));
|
|
5270
|
+
}
|
|
5271
|
+
function isLineTerminator2(c) {
|
|
5272
|
+
return c === "\n" || c === "\r" || c === "\u2028" || c === "\u2029";
|
|
5273
|
+
}
|
|
5274
|
+
function isAsciiLetter(c) {
|
|
5275
|
+
if (c === void 0) return false;
|
|
5276
|
+
const a = c.charCodeAt(0);
|
|
5277
|
+
return a >= 65 && a <= 90 || a >= 97 && a <= 122;
|
|
5278
|
+
}
|
|
5279
|
+
function isKeyChar(c) {
|
|
5280
|
+
if (c === void 0) return false;
|
|
5281
|
+
const a = c.charCodeAt(0);
|
|
5282
|
+
return a >= 48 && a <= 57 || a >= 65 && a <= 90 || a >= 97 && a <= 122 || a === 95 || a === 46 || a === 45;
|
|
5283
|
+
}
|
|
5284
|
+
function ciAt(line, p, word) {
|
|
5285
|
+
if (p < 0 || p + word.length > line.length) return false;
|
|
5286
|
+
for (let k = 0; k < word.length; k++) {
|
|
5287
|
+
const a = line.charCodeAt(p + k);
|
|
5288
|
+
const b = word.charCodeAt(k);
|
|
5289
|
+
if (a !== b && !(a >= 65 && a <= 90 && a + 32 === b)) return false;
|
|
5290
|
+
}
|
|
5291
|
+
return true;
|
|
5292
|
+
}
|
|
5293
|
+
function matchConfigAssign(line) {
|
|
5294
|
+
const n = line.length;
|
|
5295
|
+
let i = 0;
|
|
5296
|
+
while (i < n && isWs(line[i])) i++;
|
|
5297
|
+
if (!isAsciiLetter(line[i])) return null;
|
|
5298
|
+
const keyStart = i;
|
|
5299
|
+
i++;
|
|
5300
|
+
let extra = 0;
|
|
5301
|
+
while (i < n && extra < 120 && isKeyChar(line[i])) {
|
|
5302
|
+
i++;
|
|
5303
|
+
extra++;
|
|
5304
|
+
}
|
|
5305
|
+
if (extra < 1) return null;
|
|
5306
|
+
if (isKeyChar(line[i])) return null;
|
|
5307
|
+
while (i < n && isWs(line[i])) i++;
|
|
5308
|
+
if (line[i] !== ":" && line[i] !== "=") return null;
|
|
5309
|
+
const valueFrom = i + 1;
|
|
5310
|
+
let j = valueFrom;
|
|
5311
|
+
while (j < n && isWs(line[j])) j++;
|
|
5312
|
+
let end = n;
|
|
5313
|
+
while (end > j && isWs(line[end - 1])) end--;
|
|
5314
|
+
let vs;
|
|
5315
|
+
let ve;
|
|
5316
|
+
if (end > j) {
|
|
5317
|
+
for (let k = j; k < end; k++) if (isLineTerminator2(line[k])) return null;
|
|
5318
|
+
vs = j;
|
|
5319
|
+
ve = end;
|
|
5320
|
+
} else {
|
|
5321
|
+
let k = n - 1;
|
|
5322
|
+
while (k >= valueFrom && isLineTerminator2(line[k])) k--;
|
|
5323
|
+
if (k < valueFrom) return null;
|
|
5324
|
+
vs = k;
|
|
5325
|
+
ve = k + 1;
|
|
5326
|
+
}
|
|
5327
|
+
const out = [line, line.slice(keyStart, keyStart + 1 + extra), line.slice(vs, ve)];
|
|
5328
|
+
out.index = 0;
|
|
5329
|
+
return out;
|
|
5330
|
+
}
|
|
5331
|
+
function isQuote(c) {
|
|
5332
|
+
return c === '"' || c === "'";
|
|
5333
|
+
}
|
|
5334
|
+
function eqQuote(line, p) {
|
|
5335
|
+
const n = line.length;
|
|
5336
|
+
while (p < n && isWs(line[p])) p++;
|
|
5337
|
+
if (line[p] !== "=") return -1;
|
|
5338
|
+
p++;
|
|
5339
|
+
while (p < n && isWs(line[p])) p++;
|
|
5340
|
+
if (!isQuote(line[p])) return -1;
|
|
5341
|
+
return p + 1;
|
|
5342
|
+
}
|
|
5343
|
+
function litAt(line, p, min, max) {
|
|
5344
|
+
let k = p;
|
|
5345
|
+
const lim = Math.min(line.length, p + max + 1);
|
|
5346
|
+
while (k < lim && !isQuote(line[k])) k++;
|
|
5347
|
+
if (k >= line.length || !isQuote(line[k])) return -1;
|
|
5348
|
+
const len = k - p;
|
|
5349
|
+
if (len < min || len > max) return -1;
|
|
5350
|
+
return k;
|
|
5351
|
+
}
|
|
5352
|
+
function rightmostIn(arr, lo, hi) {
|
|
5353
|
+
let a = 0;
|
|
5354
|
+
let b = arr.length - 1;
|
|
5355
|
+
let best = null;
|
|
5356
|
+
while (a <= b) {
|
|
5357
|
+
const mid = a + b >> 1;
|
|
5358
|
+
if (arr[mid][0] <= hi) {
|
|
5359
|
+
if (arr[mid][0] >= lo) best = arr[mid];
|
|
5360
|
+
a = mid + 1;
|
|
5361
|
+
} else b = mid - 1;
|
|
5362
|
+
}
|
|
5363
|
+
return best;
|
|
5364
|
+
}
|
|
5365
|
+
function gtOffsets(line) {
|
|
5366
|
+
const out = [];
|
|
5367
|
+
let from = 0;
|
|
5368
|
+
while (from < line.length) {
|
|
5369
|
+
const g = line.indexOf(">", from);
|
|
5370
|
+
if (g < 0) break;
|
|
5371
|
+
out.push(g);
|
|
5372
|
+
from = g + 1;
|
|
5373
|
+
}
|
|
5374
|
+
return out;
|
|
5375
|
+
}
|
|
5376
|
+
function firstGtAt(offsets, lineLength, from) {
|
|
5377
|
+
let lo = 0;
|
|
5378
|
+
let hi = offsets.length;
|
|
5379
|
+
while (lo < hi) {
|
|
5380
|
+
const mid = lo + hi >> 1;
|
|
5381
|
+
if (offsets[mid] < from) lo = mid + 1;
|
|
5382
|
+
else hi = mid;
|
|
5383
|
+
}
|
|
5384
|
+
return lo < offsets.length ? offsets[lo] : lineLength;
|
|
5385
|
+
}
|
|
5386
|
+
function attrStart(kind, code) {
|
|
5387
|
+
if (kind === "key") return code === 75 || code === 107 || code === 78 || code === 110;
|
|
5388
|
+
return code === 86 || code === 118;
|
|
5389
|
+
}
|
|
5390
|
+
function matchInto(line, p, kind, buf) {
|
|
5391
|
+
if (p > 0 && isWordCode(line.charCodeAt(p - 1))) return false;
|
|
5392
|
+
let w = 0;
|
|
5393
|
+
if (kind === "key") {
|
|
5394
|
+
w = ciAt(line, p, "key") ? 3 : ciAt(line, p, "name") ? 4 : 0;
|
|
5395
|
+
} else if (ciAt(line, p, "value")) {
|
|
5396
|
+
w = 5;
|
|
5397
|
+
}
|
|
5398
|
+
if (!w) return false;
|
|
5399
|
+
const q = eqQuote(line, p + w);
|
|
5400
|
+
if (q < 0) return false;
|
|
5401
|
+
const e = litAt(line, q, kind === "key" ? 1 : 20, kind === "key" ? Number.POSITIVE_INFINITY : 256);
|
|
5402
|
+
if (e < 0) return false;
|
|
5403
|
+
buf[0] = p;
|
|
5404
|
+
buf[1] = q;
|
|
5405
|
+
buf[2] = e;
|
|
5406
|
+
buf[3] = e + 1;
|
|
5407
|
+
return true;
|
|
5408
|
+
}
|
|
5409
|
+
function collectAttr(line, kind) {
|
|
5410
|
+
const buf = [0, 0, 0, 0];
|
|
5411
|
+
const out = [];
|
|
5412
|
+
for (let p = 0; p < line.length; p++) {
|
|
5413
|
+
if (!attrStart(kind, line.charCodeAt(p))) continue;
|
|
5414
|
+
if (!matchInto(line, p, kind, buf)) continue;
|
|
5415
|
+
out.push([buf[0], buf[1], buf[2], buf[3]]);
|
|
5416
|
+
}
|
|
5417
|
+
return out;
|
|
5418
|
+
}
|
|
5419
|
+
function pairScan(line, first, second) {
|
|
5420
|
+
const seconds = collectAttr(line, second);
|
|
5421
|
+
if (seconds.length === 0) return null;
|
|
5422
|
+
const gts = gtOffsets(line);
|
|
5423
|
+
const buf = [0, 0, 0, 0];
|
|
5424
|
+
const n = line.length;
|
|
5425
|
+
for (let p = 0; p < n; p++) {
|
|
5426
|
+
if (!attrStart(first, line.charCodeAt(p))) continue;
|
|
5427
|
+
if (!matchInto(line, p, first, buf)) continue;
|
|
5428
|
+
const s2 = rightmostIn(seconds, buf[3], firstGtAt(gts, n, buf[3]));
|
|
5429
|
+
if (!s2) continue;
|
|
5430
|
+
const out = [line.slice(buf[0], s2[3]), line.slice(buf[1], buf[2]), line.slice(s2[1], s2[2])];
|
|
5431
|
+
out.index = buf[0];
|
|
5432
|
+
return out;
|
|
5433
|
+
}
|
|
5434
|
+
return null;
|
|
5435
|
+
}
|
|
5436
|
+
function matchXmlAttr(line) {
|
|
5437
|
+
return pairScan(line, "key", "value");
|
|
5438
|
+
}
|
|
5439
|
+
function matchXmlElement(line) {
|
|
5440
|
+
return pairScan(line, "value", "key");
|
|
5441
|
+
}
|
|
5442
|
+
var VERIFICATION_META_KEYWORDS = ["site-verification", "domain-verification", "msvalidate", "domain_verify"];
|
|
5443
|
+
function ciIncludes(hay, word) {
|
|
5444
|
+
for (let p = 0; p + word.length <= hay.length; p++) if (ciAt(hay, p, word)) return true;
|
|
5445
|
+
return false;
|
|
5446
|
+
}
|
|
5447
|
+
function matchVerificationMeta(line) {
|
|
5448
|
+
const good = [];
|
|
5449
|
+
for (let p = 0; p < line.length; p++) {
|
|
5450
|
+
if (!ciAt(line, p, "name")) continue;
|
|
5451
|
+
const q = eqQuote(line, p + 4);
|
|
5452
|
+
if (q < 0) continue;
|
|
5453
|
+
const e = litAt(line, q, 0, Number.POSITIVE_INFINITY);
|
|
5454
|
+
if (e < 0) continue;
|
|
5455
|
+
const lit = line.slice(q, e);
|
|
5456
|
+
if (VERIFICATION_META_KEYWORDS.some((w) => ciIncludes(lit, w))) good.push([p]);
|
|
5457
|
+
}
|
|
5458
|
+
if (good.length === 0) return false;
|
|
5459
|
+
const gts = gtOffsets(line);
|
|
5460
|
+
for (let s = 0; s < line.length; s++) {
|
|
5461
|
+
if (!ciAt(line, s, "<meta")) continue;
|
|
5462
|
+
if (rightmostIn(good, s + 6, firstGtAt(gts, line.length, s + 5))) return true;
|
|
5463
|
+
}
|
|
5464
|
+
return false;
|
|
5465
|
+
}
|
|
5466
|
+
var entropyLineMatchers = {
|
|
5467
|
+
configAssign: matchConfigAssign,
|
|
5468
|
+
xmlAttr: matchXmlAttr,
|
|
5469
|
+
xmlElement: matchXmlElement,
|
|
5470
|
+
verificationMeta: matchVerificationMeta
|
|
5471
|
+
};
|
|
5260
5472
|
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;
|
|
5261
5473
|
var CAMEL_SECRET_VAR_NAMES = /(?:Key|Secret|Token|Password|Passwd|Credential|Private|Signing|Bearer|Auth)$/;
|
|
5262
5474
|
var HUMAN_READABLE_ENV_REFERENCE_RE = /^(?:[a-z][a-z'-]*\s+){1,6}[A-Z][A-Z0-9_]{2,}$/;
|
|
@@ -5347,7 +5559,7 @@ function scanEntropyFiles(files, collect) {
|
|
|
5347
5559
|
}
|
|
5348
5560
|
} else {
|
|
5349
5561
|
if (KEY_VALUE_CONFIG_RE.test(filePath)) {
|
|
5350
|
-
const configAssign =
|
|
5562
|
+
const configAssign = entropyLineMatchers.configAssign(line);
|
|
5351
5563
|
if (configAssign && isSecretVariableName(configAssign[1])) {
|
|
5352
5564
|
const value = dotenvValue(configAssign[2]);
|
|
5353
5565
|
if (value.length >= 20 && value.length <= MAX_DOTENV_VALUE) {
|
|
@@ -5360,7 +5572,7 @@ function scanEntropyFiles(files, collect) {
|
|
|
5360
5572
|
}
|
|
5361
5573
|
}
|
|
5362
5574
|
if (XML_CONFIG_RE.test(filePath)) {
|
|
5363
|
-
const xmlPair =
|
|
5575
|
+
const xmlPair = entropyLineMatchers.xmlAttr(line) || entropyLineMatchers.xmlElement(line);
|
|
5364
5576
|
if (xmlPair) {
|
|
5365
5577
|
const valueFirst = /^\s*<[^>]*\bvalue\s*=/i.test(line);
|
|
5366
5578
|
const variableName = valueFirst ? xmlPair[2] : xmlPair[1];
|
|
@@ -5452,7 +5664,7 @@ function scanEntropyFiles(files, collect) {
|
|
|
5452
5664
|
continue;
|
|
5453
5665
|
}
|
|
5454
5666
|
if (inVerificationBlock && VERIFICATION_KEY_NAMES.test(varName)) continue;
|
|
5455
|
-
if (verificationMeta === void 0) verificationMeta =
|
|
5667
|
+
if (verificationMeta === void 0) verificationMeta = entropyLineMatchers.verificationMeta(line);
|
|
5456
5668
|
if (verificationMeta) continue;
|
|
5457
5669
|
if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
|
|
5458
5670
|
if (JWT_RE.test(value) && !isSecretVariableName(varName)) continue;
|