@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/index.js CHANGED
@@ -42484,6 +42484,17 @@ var NEVER_REPORT_RANGES = [
42484
42484
  ];
42485
42485
  var CONNECTION_VERIFIED_CATEGORIES = /* @__PURE__ */ new Set(["auth", "web", "pentest"]);
42486
42486
  var CONNECTION_VERIFIED_MODULES = ["honeypot", "honey-pot", "webhoneypot"];
42487
+ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
42488
+ function formSpamIdentity(event) {
42489
+ const raw = event.details?.form_spam;
42490
+ if (!raw || typeof raw !== "object") return void 0;
42491
+ const { username, email } = raw;
42492
+ if (typeof username !== "string" || typeof email !== "string") return void 0;
42493
+ const u = username.trim();
42494
+ const e = email.trim();
42495
+ if (!u || u.length > 255 || !EMAIL_RE.test(e) || e.length > 254) return void 0;
42496
+ return { username: u, email: e };
42497
+ }
42487
42498
  function summarizeEvidence(events) {
42488
42499
  const modules = /* @__PURE__ */ new Set();
42489
42500
  const categories = /* @__PURE__ */ new Set();
@@ -42492,9 +42503,12 @@ function summarizeEvidence(events) {
42492
42503
  let firstSeen = Infinity;
42493
42504
  let lastSeen = 0;
42494
42505
  let total = 0;
42506
+ let formSpam;
42495
42507
  for (const event of events) {
42496
42508
  if (event.module === "firewall-rules") continue;
42497
42509
  total++;
42510
+ const identity = formSpamIdentity(event);
42511
+ if (identity && event.timestamp.getTime() >= lastSeen) formSpam = identity;
42498
42512
  modules.add(event.module);
42499
42513
  categories.add(event.category);
42500
42514
  const ruleId = event.details?.rule_id;
@@ -42513,7 +42527,8 @@ function summarizeEvidence(events) {
42513
42527
  lastSeen,
42514
42528
  total,
42515
42529
  categories: [...categories],
42516
- ruleIds: [...ruleIds]
42530
+ ruleIds: [...ruleIds],
42531
+ ...formSpam ? { formSpam } : {}
42517
42532
  };
42518
42533
  }
42519
42534
  function isReportable(ip, evidence, config, now = Date.now()) {
@@ -42608,22 +42623,28 @@ async function reportToAbuseIPDB(payload, apiKey) {
42608
42623
  }
42609
42624
  }
42610
42625
  async function reportToStopForumSpam(payload, apiKey) {
42626
+ const identity = payload.evidence.formSpam;
42627
+ if (!identity) {
42628
+ return { destination: "stopforumspam", ok: false, detail: "skipped: no form-spam username/email in evidence" };
42629
+ }
42611
42630
  const body = new URLSearchParams({
42612
- api_key: apiKey,
42613
- ip: payload.ip,
42614
- evidence: payload.comment.slice(0, 1e3)
42631
+ username: identity.username,
42632
+ email: identity.email,
42633
+ ip_addr: payload.ip,
42634
+ evidence: payload.comment.slice(0, 1e3),
42635
+ api_key: apiKey
42615
42636
  });
42616
42637
  try {
42617
- const res = await fetch("https://www.stopforumspam.org/add.php", {
42638
+ const res = await fetch("https://www.stopforumspam.com/add.php", {
42618
42639
  method: "POST",
42619
- headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
42640
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
42620
42641
  body,
42621
42642
  signal: AbortSignal.timeout(TIMEOUT_MS)
42622
42643
  });
42623
42644
  const text = await res.text().catch(() => "");
42624
- if (!res.ok) return { destination: "stopforumspam", ok: false, detail: `HTTP ${res.status} ${text.slice(0, 120)}` };
42625
- const ok = /success|"success"\s*:\s*true/i.test(text);
42626
- return { destination: "stopforumspam", ok, detail: ok ? "reported" : text.slice(0, 120) || "refused" };
42645
+ if (res.status === 200) return { destination: "stopforumspam", ok: true, detail: "reported" };
42646
+ const reason = /<p[^>]*>([\s\S]*?)<\/p>/i.exec(text)?.[1]?.replace(/<[^>]+>/g, "").trim();
42647
+ return { destination: "stopforumspam", ok: false, detail: `HTTP ${res.status} ${(reason || text).slice(0, 160)}`.trim() };
42627
42648
  } catch (err) {
42628
42649
  return { destination: "stopforumspam", ok: false, detail: err.message };
42629
42650
  }
@@ -42632,7 +42653,7 @@ async function dispatch(payload, destinations, keys) {
42632
42653
  const jobs = [];
42633
42654
  for (const dest of destinations) {
42634
42655
  if (dest === "abuseipdb" && keys.abuseipdb) jobs.push(reportToAbuseIPDB(payload, keys.abuseipdb));
42635
- else if (dest === "stopforumspam" && keys.stopforumspam) jobs.push(reportToStopForumSpam(payload, keys.stopforumspam));
42656
+ else if (dest === "stopforumspam" && keys.stopforumspam && payload.evidence.formSpam) jobs.push(reportToStopForumSpam(payload, keys.stopforumspam));
42636
42657
  }
42637
42658
  return Promise.all(jobs);
42638
42659
  }
@@ -42758,7 +42779,7 @@ var AbuseReporter = class {
42758
42779
  }
42759
42780
  if (!this.active) {
42760
42781
  this.opts.log(
42761
- "[abuse] reporter on but inert: no destination API key set (ABUSEIPDB_API_KEY or [abuse-reporter] abuseipdb_api_key). Nothing will be reported."
42782
+ "[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."
42762
42783
  );
42763
42784
  return;
42764
42785
  }