@profullstack/threatcrush 0.13.43 → 0.13.45

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
@@ -9110,6 +9110,11 @@ var DEFAULT_EXCLUDED_RULE_IDS = [941130];
9110
9110
  var ARGUMENT_EXCLUSIONS = [
9111
9111
  { ruleIds: [942100], path: /^\/rest\/v1\//, arg: "select", value: /^[A-Za-z0-9_*,.:!()>-]+$/ }
9112
9112
  ];
9113
+ var COMMAND_WORD_RULE_IDS = /* @__PURE__ */ new Set([932260, 932340, 932370, 932380]);
9114
+ var PLAIN_WORDS = /^[\p{L}\p{N}][\p{L}\p{N} .,_+/-]*(?: & [\p{L}\p{N}][\p{L}\p{N} .,_+/-]*)*$/u;
9115
+ function isPlainWords(value) {
9116
+ return value.length <= 200 && PLAIN_WORDS.test(value);
9117
+ }
9113
9118
  var ATTACK_TYPES = {
9114
9119
  "attack-sqli": "sqli",
9115
9120
  "attack-xss": "xss",
@@ -9262,6 +9267,7 @@ var RequestContext = class {
9262
9267
  const exclusions = ARGUMENT_EXCLUSIONS.filter((e) => e.path.test(path));
9263
9268
  return parseArguments(query).map(({ name, value }) => {
9264
9269
  const ids = exclusions.filter((e) => e.arg === name && e.value.test(value)).flatMap((e) => e.ruleIds);
9270
+ if (isPlainWords(value)) ids.push(...COMMAND_WORD_RULE_IDS);
9265
9271
  return { value, cache: /* @__PURE__ */ new Map(), ...ids.length ? { excluded: new Set(ids) } : {} };
9266
9272
  });
9267
9273
  }
@@ -10182,6 +10188,38 @@ var DEFAULT_PROTECTED = [
10182
10188
  "fc00::/7",
10183
10189
  "fe80::/10"
10184
10190
  ];
10191
+ var SHARED_INFRASTRUCTURE = [
10192
+ "173.245.48.0/20",
10193
+ "103.21.244.0/22",
10194
+ "103.22.200.0/22",
10195
+ "103.31.4.0/22",
10196
+ "141.101.64.0/18",
10197
+ "108.162.192.0/18",
10198
+ "190.93.240.0/20",
10199
+ "188.114.96.0/20",
10200
+ "197.234.240.0/22",
10201
+ "198.41.128.0/17",
10202
+ "162.158.0.0/15",
10203
+ "104.16.0.0/13",
10204
+ "104.24.0.0/14",
10205
+ "172.64.0.0/13",
10206
+ "131.0.72.0/22",
10207
+ "2400:cb00::/32",
10208
+ "2606:4700::/32",
10209
+ "2803:f800::/32",
10210
+ "2405:b500::/32",
10211
+ "2405:8100::/32",
10212
+ "2a06:98c0::/29",
10213
+ "2c0f:f248::/32",
10214
+ "1.1.1.1/32",
10215
+ "1.0.0.1/32",
10216
+ "8.8.8.8/32",
10217
+ "8.8.4.4/32",
10218
+ "9.9.9.9/32",
10219
+ "149.112.112.112/32",
10220
+ "208.67.222.222/32",
10221
+ "208.67.220.220/32"
10222
+ ];
10185
10223
  function ipToBytes(ip) {
10186
10224
  const version = (0, import_node_net2.isIP)(ip);
10187
10225
  if (version === 4) return v4ToBytes(ip);
@@ -16312,6 +16350,17 @@ var NEVER_REPORT_RANGES = [
16312
16350
  ];
16313
16351
  var CONNECTION_VERIFIED_CATEGORIES = /* @__PURE__ */ new Set(["auth", "web", "pentest"]);
16314
16352
  var CONNECTION_VERIFIED_MODULES = ["honeypot", "honey-pot", "webhoneypot"];
16353
+ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
16354
+ function formSpamIdentity(event) {
16355
+ const raw = event.details?.form_spam;
16356
+ if (!raw || typeof raw !== "object") return void 0;
16357
+ const { username, email } = raw;
16358
+ if (typeof username !== "string" || typeof email !== "string") return void 0;
16359
+ const u = username.trim();
16360
+ const e = email.trim();
16361
+ if (!u || u.length > 255 || !EMAIL_RE.test(e) || e.length > 254) return void 0;
16362
+ return { username: u, email: e };
16363
+ }
16315
16364
  function summarizeEvidence(events) {
16316
16365
  const modules = /* @__PURE__ */ new Set();
16317
16366
  const categories = /* @__PURE__ */ new Set();
@@ -16320,9 +16369,12 @@ function summarizeEvidence(events) {
16320
16369
  let firstSeen = Infinity;
16321
16370
  let lastSeen = 0;
16322
16371
  let total = 0;
16372
+ let formSpam;
16323
16373
  for (const event of events) {
16324
16374
  if (event.module === "firewall-rules") continue;
16325
16375
  total++;
16376
+ const identity = formSpamIdentity(event);
16377
+ if (identity && event.timestamp.getTime() >= lastSeen) formSpam = identity;
16326
16378
  modules.add(event.module);
16327
16379
  categories.add(event.category);
16328
16380
  const ruleId = event.details?.rule_id;
@@ -16341,7 +16393,8 @@ function summarizeEvidence(events) {
16341
16393
  lastSeen,
16342
16394
  total,
16343
16395
  categories: [...categories],
16344
- ruleIds: [...ruleIds]
16396
+ ruleIds: [...ruleIds],
16397
+ ...formSpam ? { formSpam } : {}
16345
16398
  };
16346
16399
  }
16347
16400
  function isReportable(ip, evidence, config, now = Date.now()) {
@@ -16436,22 +16489,28 @@ async function reportToAbuseIPDB(payload, apiKey) {
16436
16489
  }
16437
16490
  }
16438
16491
  async function reportToStopForumSpam(payload, apiKey) {
16492
+ const identity = payload.evidence.formSpam;
16493
+ if (!identity) {
16494
+ return { destination: "stopforumspam", ok: false, detail: "skipped: no form-spam username/email in evidence" };
16495
+ }
16439
16496
  const body = new URLSearchParams({
16440
- api_key: apiKey,
16441
- ip: payload.ip,
16442
- evidence: payload.comment.slice(0, 1e3)
16497
+ username: identity.username,
16498
+ email: identity.email,
16499
+ ip_addr: payload.ip,
16500
+ evidence: payload.comment.slice(0, 1e3),
16501
+ api_key: apiKey
16443
16502
  });
16444
16503
  try {
16445
- const res = await fetch("https://www.stopforumspam.org/add.php", {
16504
+ const res = await fetch("https://www.stopforumspam.com/add.php", {
16446
16505
  method: "POST",
16447
- headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
16506
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
16448
16507
  body,
16449
16508
  signal: AbortSignal.timeout(TIMEOUT_MS)
16450
16509
  });
16451
16510
  const text = await res.text().catch(() => "");
16452
- if (!res.ok) return { destination: "stopforumspam", ok: false, detail: `HTTP ${res.status} ${text.slice(0, 120)}` };
16453
- const ok = /success|"success"\s*:\s*true/i.test(text);
16454
- return { destination: "stopforumspam", ok, detail: ok ? "reported" : text.slice(0, 120) || "refused" };
16511
+ if (res.status === 200) return { destination: "stopforumspam", ok: true, detail: "reported" };
16512
+ const reason = /<p[^>]*>([\s\S]*?)<\/p>/i.exec(text)?.[1]?.replace(/<[^>]+>/g, "").trim();
16513
+ return { destination: "stopforumspam", ok: false, detail: `HTTP ${res.status} ${(reason || text).slice(0, 160)}`.trim() };
16455
16514
  } catch (err) {
16456
16515
  return { destination: "stopforumspam", ok: false, detail: err.message };
16457
16516
  }
@@ -16460,7 +16519,7 @@ async function dispatch(payload, destinations, keys) {
16460
16519
  const jobs = [];
16461
16520
  for (const dest of destinations) {
16462
16521
  if (dest === "abuseipdb" && keys.abuseipdb) jobs.push(reportToAbuseIPDB(payload, keys.abuseipdb));
16463
- else if (dest === "stopforumspam" && keys.stopforumspam) jobs.push(reportToStopForumSpam(payload, keys.stopforumspam));
16522
+ else if (dest === "stopforumspam" && keys.stopforumspam && payload.evidence.formSpam) jobs.push(reportToStopForumSpam(payload, keys.stopforumspam));
16464
16523
  }
16465
16524
  return Promise.all(jobs);
16466
16525
  }
@@ -16566,7 +16625,7 @@ var AbuseReporter = class {
16566
16625
  }
16567
16626
  if (!this.active) {
16568
16627
  this.opts.log(
16569
- "[abuse] reporter on but inert: no destination API key set (ABUSEIPDB_API_KEY or [abuse-reporter] abuseipdb_api_key). Nothing will be reported."
16628
+ "[abuse] reporter on but inert: no destination API key set (ABUSEIPDB_API_KEY / STOPFORUMSPAM_API_KEY or [abuse-reporter] *_api_key). Nothing will be reported."
16570
16629
  );
16571
16630
  return;
16572
16631
  }
@@ -18822,7 +18881,7 @@ var RemediationManager = class {
18822
18881
  this.discovery = discovery;
18823
18882
  this.config = { ...DEFAULT_CONFIG2, ...config };
18824
18883
  this.config.allowlist = [...this.config.allowlist];
18825
- this.protectedList = [...DEFAULT_PROTECTED, ...this.config.allowlist];
18884
+ this.protectedList = [...DEFAULT_PROTECTED, ...SHARED_INFRASTRUCTURE, ...this.config.allowlist];
18826
18885
  for (const gateway of defaultGateways()) this.protectedList.push(gateway);
18827
18886
  if (this.adapter.enforces === false) this.config.dry_run = true;
18828
18887
  this.loadState();