@profullstack/threatcrush 0.13.43 → 0.13.44

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
@@ -16312,6 +16312,17 @@ var NEVER_REPORT_RANGES = [
16312
16312
  ];
16313
16313
  var CONNECTION_VERIFIED_CATEGORIES = /* @__PURE__ */ new Set(["auth", "web", "pentest"]);
16314
16314
  var CONNECTION_VERIFIED_MODULES = ["honeypot", "honey-pot", "webhoneypot"];
16315
+ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
16316
+ function formSpamIdentity(event) {
16317
+ const raw = event.details?.form_spam;
16318
+ if (!raw || typeof raw !== "object") return void 0;
16319
+ const { username, email } = raw;
16320
+ if (typeof username !== "string" || typeof email !== "string") return void 0;
16321
+ const u = username.trim();
16322
+ const e = email.trim();
16323
+ if (!u || u.length > 255 || !EMAIL_RE.test(e) || e.length > 254) return void 0;
16324
+ return { username: u, email: e };
16325
+ }
16315
16326
  function summarizeEvidence(events) {
16316
16327
  const modules = /* @__PURE__ */ new Set();
16317
16328
  const categories = /* @__PURE__ */ new Set();
@@ -16320,9 +16331,12 @@ function summarizeEvidence(events) {
16320
16331
  let firstSeen = Infinity;
16321
16332
  let lastSeen = 0;
16322
16333
  let total = 0;
16334
+ let formSpam;
16323
16335
  for (const event of events) {
16324
16336
  if (event.module === "firewall-rules") continue;
16325
16337
  total++;
16338
+ const identity = formSpamIdentity(event);
16339
+ if (identity && event.timestamp.getTime() >= lastSeen) formSpam = identity;
16326
16340
  modules.add(event.module);
16327
16341
  categories.add(event.category);
16328
16342
  const ruleId = event.details?.rule_id;
@@ -16341,7 +16355,8 @@ function summarizeEvidence(events) {
16341
16355
  lastSeen,
16342
16356
  total,
16343
16357
  categories: [...categories],
16344
- ruleIds: [...ruleIds]
16358
+ ruleIds: [...ruleIds],
16359
+ ...formSpam ? { formSpam } : {}
16345
16360
  };
16346
16361
  }
16347
16362
  function isReportable(ip, evidence, config, now = Date.now()) {
@@ -16436,22 +16451,28 @@ async function reportToAbuseIPDB(payload, apiKey) {
16436
16451
  }
16437
16452
  }
16438
16453
  async function reportToStopForumSpam(payload, apiKey) {
16454
+ const identity = payload.evidence.formSpam;
16455
+ if (!identity) {
16456
+ return { destination: "stopforumspam", ok: false, detail: "skipped: no form-spam username/email in evidence" };
16457
+ }
16439
16458
  const body = new URLSearchParams({
16440
- api_key: apiKey,
16441
- ip: payload.ip,
16442
- evidence: payload.comment.slice(0, 1e3)
16459
+ username: identity.username,
16460
+ email: identity.email,
16461
+ ip_addr: payload.ip,
16462
+ evidence: payload.comment.slice(0, 1e3),
16463
+ api_key: apiKey
16443
16464
  });
16444
16465
  try {
16445
- const res = await fetch("https://www.stopforumspam.org/add.php", {
16466
+ const res = await fetch("https://www.stopforumspam.com/add.php", {
16446
16467
  method: "POST",
16447
- headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
16468
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
16448
16469
  body,
16449
16470
  signal: AbortSignal.timeout(TIMEOUT_MS)
16450
16471
  });
16451
16472
  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" };
16473
+ if (res.status === 200) return { destination: "stopforumspam", ok: true, detail: "reported" };
16474
+ const reason = /<p[^>]*>([\s\S]*?)<\/p>/i.exec(text)?.[1]?.replace(/<[^>]+>/g, "").trim();
16475
+ return { destination: "stopforumspam", ok: false, detail: `HTTP ${res.status} ${(reason || text).slice(0, 160)}`.trim() };
16455
16476
  } catch (err) {
16456
16477
  return { destination: "stopforumspam", ok: false, detail: err.message };
16457
16478
  }
@@ -16460,7 +16481,7 @@ async function dispatch(payload, destinations, keys) {
16460
16481
  const jobs = [];
16461
16482
  for (const dest of destinations) {
16462
16483
  if (dest === "abuseipdb" && keys.abuseipdb) jobs.push(reportToAbuseIPDB(payload, keys.abuseipdb));
16463
- else if (dest === "stopforumspam" && keys.stopforumspam) jobs.push(reportToStopForumSpam(payload, keys.stopforumspam));
16484
+ else if (dest === "stopforumspam" && keys.stopforumspam && payload.evidence.formSpam) jobs.push(reportToStopForumSpam(payload, keys.stopforumspam));
16464
16485
  }
16465
16486
  return Promise.all(jobs);
16466
16487
  }
@@ -16566,7 +16587,7 @@ var AbuseReporter = class {
16566
16587
  }
16567
16588
  if (!this.active) {
16568
16589
  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."
16590
+ "[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
16591
  );
16571
16592
  return;
16572
16593
  }