@profullstack/threatcrush 0.12.7 → 0.12.8
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 +20 -1
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18032,7 +18032,8 @@ var CODE_RULES = [
|
|
|
18032
18032
|
severity: "high",
|
|
18033
18033
|
languages: ["python"],
|
|
18034
18034
|
pattern: /\brequests\.(?:get|request|head)\s*\(\s*[a-zA-Z_]\w*\s*[,)]|\burlopen\s*\(\s*[a-zA-Z_]\w*\s*[,)]|\bhttpx\.get\s*\(\s*[a-zA-Z_]\w*\s*[,)]/,
|
|
18035
|
-
needsContext: true
|
|
18035
|
+
needsContext: true,
|
|
18036
|
+
constantRequestHostGuard: true
|
|
18036
18037
|
},
|
|
18037
18038
|
{
|
|
18038
18039
|
id: "go-ssrf-outbound-request",
|
|
@@ -18947,6 +18948,21 @@ function identifierAfter(text, start) {
|
|
|
18947
18948
|
while (isIdentifierPart(text[index])) index += 1;
|
|
18948
18949
|
return text.slice(from, index);
|
|
18949
18950
|
}
|
|
18951
|
+
function urlAuthority(text) {
|
|
18952
|
+
const found = /['"]\s*https?:\/\/([^'"/?#\s]*)/.exec(text);
|
|
18953
|
+
return found ? found[1] : null;
|
|
18954
|
+
}
|
|
18955
|
+
function requestHostIsConstant(line, fileText) {
|
|
18956
|
+
const call = /(?:urlopen|requests\.(?:get|request|head)|httpx\.get)\s*\(\s*([A-Za-z_]\w*)\s*[,)]/.exec(line);
|
|
18957
|
+
if (!call) return false;
|
|
18958
|
+
const assignment = new RegExp(String.raw`^[ \t]*${call[1]}[ \t]*=[ \t]*(.+)$`, "gm");
|
|
18959
|
+
const values = [...fileText.matchAll(assignment)].map((m) => m[1]);
|
|
18960
|
+
if (!values.length) return false;
|
|
18961
|
+
return values.every((value) => {
|
|
18962
|
+
const authority = urlAuthority(value);
|
|
18963
|
+
return authority !== null && /^[A-Za-z0-9.-]+(?::\d+)?$/.test(authority);
|
|
18964
|
+
});
|
|
18965
|
+
}
|
|
18950
18966
|
function hasSafeRedirectValue(line, fileText) {
|
|
18951
18967
|
const location = line.indexOf("window.location");
|
|
18952
18968
|
const redirect = line.indexOf(".redirect");
|
|
@@ -19056,6 +19072,9 @@ function evaluateRule(rule, ctx) {
|
|
|
19056
19072
|
if (rule.safeRedirectGuard && hasSafeRedirectValue(line, fileTextOf(ctx.lines))) {
|
|
19057
19073
|
return null;
|
|
19058
19074
|
}
|
|
19075
|
+
if (rule.constantRequestHostGuard && requestHostIsConstant(line, fileTextOf(ctx.lines))) {
|
|
19076
|
+
return null;
|
|
19077
|
+
}
|
|
19059
19078
|
if (rule.filledBeforeUseGuard && bufferFilledBeforeUse(ctx)) return null;
|
|
19060
19079
|
const guard = rule.guard === void 0 ? GENERIC_GUARD : rule.guard;
|
|
19061
19080
|
if (guard && (guard.test(line) || guard.test(context))) return null;
|