@profullstack/threatcrush 0.13.73 → 0.13.74
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/daemon.js +18 -10
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +18 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -14956,7 +14956,8 @@ var SECRET_RULES = [
|
|
|
14956
14956
|
pattern: /-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY(?: BLOCK)?-----/,
|
|
14957
14957
|
severity: "critical",
|
|
14958
14958
|
cwe: "CWE-798",
|
|
14959
|
-
consequence: "Key material, committed. Rotation is the only remediation."
|
|
14959
|
+
consequence: "Key material, committed. Rotation is the only remediation.",
|
|
14960
|
+
confirm: (lines, index, match) => hasPemBody(lines, index, match)
|
|
14960
14961
|
},
|
|
14961
14962
|
{
|
|
14962
14963
|
id: "secret-slack-token",
|
|
@@ -15105,6 +15106,18 @@ var KNOWN_PLACEHOLDERS = [
|
|
|
15105
15106
|
function isKnownPlaceholder(text) {
|
|
15106
15107
|
return KNOWN_PLACEHOLDERS.some((pattern) => pattern.test(text));
|
|
15107
15108
|
}
|
|
15109
|
+
var PEM_BODY_LOOKAHEAD = 6;
|
|
15110
|
+
var PEM_BODY_RUN = /[A-Za-z0-9+/]{40,}/;
|
|
15111
|
+
var PEM_BODY_LINE = /^[\s'"`+(]*(?:\\n)?[A-Za-z0-9+/]{40,}={0,2}(?:\\n)?['"`,;+)\s]*$/;
|
|
15112
|
+
function hasPemBody(lines, index, match) {
|
|
15113
|
+
const rest = (lines[index] ?? "").slice(match.index + match[0].length).replace(/\\[nr]/g, " ");
|
|
15114
|
+
if (PEM_BODY_RUN.test(rest)) return true;
|
|
15115
|
+
const last = Math.min(lines.length - 1, index + PEM_BODY_LOOKAHEAD);
|
|
15116
|
+
for (let i = index + 1; i <= last; i++) {
|
|
15117
|
+
if (PEM_BODY_LINE.test(lines[i])) return true;
|
|
15118
|
+
}
|
|
15119
|
+
return false;
|
|
15120
|
+
}
|
|
15108
15121
|
function isPlaceholderAttribute(line, value) {
|
|
15109
15122
|
const at = line.lastIndexOf(value);
|
|
15110
15123
|
if (at === -1) return false;
|
|
@@ -15364,14 +15377,6 @@ function isSuppressed(suppressions, index, ruleId) {
|
|
|
15364
15377
|
if (!rules) return false;
|
|
15365
15378
|
return rules.has("*") || rules.has(ruleId);
|
|
15366
15379
|
}
|
|
15367
|
-
function pemPlaceholder(lines, index) {
|
|
15368
|
-
const first = lines[index] ?? "";
|
|
15369
|
-
const header = /-----BEGIN ((?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY(?: BLOCK)?)-----/.exec(first);
|
|
15370
|
-
if (!header) return false;
|
|
15371
|
-
const tail = [first.slice(header.index + header[0].length), ...lines.slice(index + 1, index + 21)].join("\n").replace(/\\n/g, "\n");
|
|
15372
|
-
const end = tail.indexOf(`-----END ${header[1]}-----`);
|
|
15373
|
-
return end >= 0 && ["your-pem-body-here", "your-private-key-here", "your-private-key-body-here"].includes(tail.slice(0, end).trim().toLowerCase());
|
|
15374
|
-
}
|
|
15375
15380
|
function isTestPath(relativePath) {
|
|
15376
15381
|
const p = relativePath.replace(/\\/g, "/");
|
|
15377
15382
|
return /(?:^|\/)(?:tests?|__tests__|__mocks__|spec|specs|fixtures?|mocks?|e2e|testdata|testutils?|harness)\//i.test(p) || /(?:^|\/)(?:test|conftest)_[^/]+$/i.test(p) || /[._-](?:test|spec)\.[a-z]+$/i.test(p) || /_test\.[a-z]+$/i.test(p);
|
|
@@ -15559,6 +15564,7 @@ function scanText(relativePath, text, language = languageOf(relativePath)) {
|
|
|
15559
15564
|
const match = rule.pattern.exec(line);
|
|
15560
15565
|
if (!match) continue;
|
|
15561
15566
|
if (isKnownPlaceholder(match[0])) continue;
|
|
15567
|
+
if (rule.confirm && !rule.confirm(lines, index, match)) continue;
|
|
15562
15568
|
if (isSuppressed(suppressions, index, rule.id)) continue;
|
|
15563
15569
|
const value = match[1] ?? match[0];
|
|
15564
15570
|
if (isVariableReference(value)) continue;
|
|
@@ -15567,7 +15573,9 @@ function scanText(relativePath, text, language = languageOf(relativePath)) {
|
|
|
15567
15573
|
test: inTests,
|
|
15568
15574
|
"test-block": inlineTests.has(index),
|
|
15569
15575
|
suppressed: foreignSecurityMark(line),
|
|
15570
|
-
|
|
15576
|
+
// A dummy PEM body (`your-pem-body-here`) never reaches here: it is not a
|
|
15577
|
+
// base64 body, so `hasPemBody` already dropped it.
|
|
15578
|
+
placeholder: isPlaceholderAttribute(line, value),
|
|
15571
15579
|
"self-describing": rule.keywordShaped === true && describesItsOwnKey(line, value)
|
|
15572
15580
|
});
|
|
15573
15581
|
findings.push({
|