@profullstack/threatcrush 0.12.6 → 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 CHANGED
@@ -5063,6 +5063,7 @@ var GENERIC_GUARD = (
5063
5063
  );
5064
5064
  var XXE_GUARD = /FEATURE_SECURE_PROCESSING|setExpandEntityReferences|disallow-doctype-decl|external-general-entities|external-parameter-entities|setXIncludeAware\s*\(\s*false/;
5065
5065
  var XML_PARSING_FILE = /\b(?:javax\.xml|org\.xml\.sax|org\.w3c\.dom|org\.jdom2?|org\.dom4j|XmlPullParser|DocumentBuilderFactory|DocumentBuilder|SAXParserFactory|SAXParser|XMLInputFactory|XMLReaderFactory|XMLReader|SAXBuilder|SAXReader)\b/;
5066
+ var PY_XPATH_FILE = /\b(?:lxml|xml\.etree|ElementTree|etree|defusedxml|xpath)\b/i;
5066
5067
  var CODE_SINK = /\bglobalThis\s*\[|\bconstructor\b|\beval\b|\bFunction\b|\brun\s*\(|\bvm\s*\.\s*run/;
5067
5068
  var EXFIL_SINK = /\bconsole\s*\.\s*(?:log|debug|info|warn|error)\s*\(|\bfetch\s*\(|\baxios\b|\brequest\s*\(|\.\s*send\s*\(/;
5068
5069
  var SQL_KEYWORDS = "SELECT\\b(?=[^`'\"\\n]*\\bFROM\\b)|INSERT\\s+INTO|UPDATE\\b(?=[^`'\"\\n]*\\bSET\\b)|DELETE\\s+FROM|DROP\\s+(?:TABLE|DATABASE|INDEX|VIEW|SCHEMA)|TRUNCATE\\s+TABLE|UNION\\s+SELECT";
@@ -5358,7 +5359,8 @@ var CODE_RULES = [
5358
5359
  severity: "high",
5359
5360
  languages: ["python"],
5360
5361
  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*[,)]/,
5361
- needsContext: true
5362
+ needsContext: true,
5363
+ constantRequestHostGuard: true
5362
5364
  },
5363
5365
  {
5364
5366
  id: "go-ssrf-outbound-request",
@@ -6023,8 +6025,11 @@ var CODE_RULES = [
6023
6025
  severity: "high",
6024
6026
  languages: ["python"],
6025
6027
  // Per-quote, so an inner `'` in a `"`-delimited f-string (`text()='{x}'`)
6026
- // does not truncate the match before the interpolation.
6027
- pattern: /\bf"[^"\n]*(?:\/\/|\/\w+\[)[^"\n]*\{[^}\n]+\}|\bf'[^'\n]*(?:\/\/|\/\w+\[)[^'\n]*\{[^}\n]+\}/
6028
+ // does not truncate the match before the interpolation. `(?<!:)` keeps the
6029
+ // `//` of a URL scheme out of it: `f"https://{host}/v1"` is a URL, not a
6030
+ // descendant-or-self step, and it was by far the commonest match here.
6031
+ pattern: /\bf"[^"\n]*(?:(?<!:)\/\/|\/\w+\[)[^"\n]*\{[^}\n]+\}|\bf'[^'\n]*(?:(?<!:)\/\/|\/\w+\[)[^'\n]*\{[^}\n]+\}/,
6032
+ fileRequires: PY_XPATH_FILE
6028
6033
  },
6029
6034
  {
6030
6035
  id: "py-fast-password-hash",
@@ -6270,6 +6275,21 @@ function identifierAfter(text, start) {
6270
6275
  while (isIdentifierPart(text[index])) index += 1;
6271
6276
  return text.slice(from, index);
6272
6277
  }
6278
+ function urlAuthority(text) {
6279
+ const found = /['"]\s*https?:\/\/([^'"/?#\s]*)/.exec(text);
6280
+ return found ? found[1] : null;
6281
+ }
6282
+ function requestHostIsConstant(line, fileText) {
6283
+ const call = /(?:urlopen|requests\.(?:get|request|head)|httpx\.get)\s*\(\s*([A-Za-z_]\w*)\s*[,)]/.exec(line);
6284
+ if (!call) return false;
6285
+ const assignment = new RegExp(String.raw`^[ \t]*${call[1]}[ \t]*=[ \t]*(.+)$`, "gm");
6286
+ const values = [...fileText.matchAll(assignment)].map((m) => m[1]);
6287
+ if (!values.length) return false;
6288
+ return values.every((value) => {
6289
+ const authority = urlAuthority(value);
6290
+ return authority !== null && /^[A-Za-z0-9.-]+(?::\d+)?$/.test(authority);
6291
+ });
6292
+ }
6273
6293
  function hasSafeRedirectValue(line, fileText) {
6274
6294
  const location = line.indexOf("window.location");
6275
6295
  const redirect = line.indexOf(".redirect");
@@ -6379,6 +6399,9 @@ function evaluateRule(rule, ctx) {
6379
6399
  if (rule.safeRedirectGuard && hasSafeRedirectValue(line, fileTextOf(ctx.lines))) {
6380
6400
  return null;
6381
6401
  }
6402
+ if (rule.constantRequestHostGuard && requestHostIsConstant(line, fileTextOf(ctx.lines))) {
6403
+ return null;
6404
+ }
6382
6405
  if (rule.filledBeforeUseGuard && bufferFilledBeforeUse(ctx)) return null;
6383
6406
  const guard = rule.guard === void 0 ? GENERIC_GUARD : rule.guard;
6384
6407
  if (guard && (guard.test(line) || guard.test(context))) return null;
@@ -7004,7 +7027,7 @@ var SECRET_RULES = [
7004
7027
  keywordShaped: true
7005
7028
  }
7006
7029
  ];
7007
- var INTERPOLATION = String.raw`(?:\{\{[^}]*\}\}|\$\{[^}]*\}|\$[A-Za-z_]\w*|%[sdv])`;
7030
+ var INTERPOLATION = String.raw`(?:\{\{[^}]*\}\}|\$\{[^}]*\}|\$[A-Za-z_]\w*|%[sdv]|\{[^{}\s'"@/]+\}|<[A-Za-z_][\w.-]*>)`;
7008
7031
  var KNOWN_PLACEHOLDERS = [
7009
7032
  // Deliberately NOT here: AWS's published documentation key/secret pair
7010
7033
  // (`AKIAIOSFODNN7EXAMPLE`, `wJalrXUtnFEMI/…`). GitHub allow-lists them, and