@profullstack/threatcrush 0.13.11 → 0.13.13

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
@@ -12916,20 +12916,13 @@ var init_state = __esm({
12916
12916
  });
12917
12917
 
12918
12918
  // src/daemon/firewall/backoff.ts
12919
- function fibonacciMinutes(strike) {
12919
+ function backoffFactor(strike) {
12920
12920
  const n = Math.max(1, Math.floor(strike));
12921
- let prev = 1;
12922
- let curr = 1;
12923
- for (let i = 1; i < n; i++) {
12924
- const next = prev + curr;
12925
- prev = curr;
12926
- curr = next;
12927
- }
12928
- return curr;
12921
+ return 2 ** Math.min(n - 1, 52);
12929
12922
  }
12930
- function banSeconds(strike, maxSeconds) {
12931
- const seconds = fibonacciMinutes(strike) * 60;
12932
- return Math.min(seconds, Math.max(60, maxSeconds));
12923
+ function banSeconds(strike, maxSeconds, firstSeconds = DEFAULT_FIRST_BAN_SECONDS) {
12924
+ const first = Math.max(60, firstSeconds);
12925
+ return Math.min(first * backoffFactor(strike), Math.max(first, maxSeconds));
12933
12926
  }
12934
12927
  function recordStrike(strikes, ip, now, memorySeconds) {
12935
12928
  const existing = strikes[ip];
@@ -12964,9 +12957,11 @@ function formatDuration(seconds) {
12964
12957
  if (m > 0) return s > 0 && m < 10 ? `${m}m ${s}s` : `${m}m`;
12965
12958
  return `${s}s`;
12966
12959
  }
12960
+ var DEFAULT_FIRST_BAN_SECONDS;
12967
12961
  var init_backoff = __esm({
12968
12962
  "src/daemon/firewall/backoff.ts"() {
12969
12963
  "use strict";
12964
+ DEFAULT_FIRST_BAN_SECONDS = 5 * 60;
12970
12965
  }
12971
12966
  });
12972
12967
 
@@ -15911,7 +15906,7 @@ var source_default = chalk;
15911
15906
 
15912
15907
  // src/index.ts
15913
15908
  var import_readline = __toESM(require("readline"));
15914
- var import_node_child_process14 = require("child_process");
15909
+ var import_node_child_process15 = require("child_process");
15915
15910
  var import_node_fs35 = require("fs");
15916
15911
  var import_node_path24 = require("path");
15917
15912
  var import_node_os9 = require("os");
@@ -30310,14 +30305,14 @@ async function sshConnect(options) {
30310
30305
  }
30311
30306
 
30312
30307
  // src/commands/daemon.ts
30313
- var import_node_child_process10 = require("child_process");
30308
+ var import_node_child_process11 = require("child_process");
30314
30309
  var import_node_fs30 = require("fs");
30315
30310
  var import_node_path21 = require("path");
30316
30311
  var import_node_fs31 = require("fs");
30317
30312
 
30318
30313
  // src/daemon/index.ts
30319
30314
  var import_node_fs29 = require("fs");
30320
- var import_node_child_process9 = require("child_process");
30315
+ var import_node_child_process10 = require("child_process");
30321
30316
  var import_node_os8 = require("os");
30322
30317
  var import_node_path20 = require("path");
30323
30318
  var import_node_util = require("util");
@@ -31119,9 +31114,9 @@ var NetworkMonitor = class {
31119
31114
  );
31120
31115
  this.scanTrackers.delete(key);
31121
31116
  } else if (
31122
- // A smaller spread across our listening ports is worth surfacing, but
31123
- // at `medium` so it is logged and never banned (auto-defence bans at
31124
- // `high`). These are inbound-to-listening only, so the ephemeral
31117
+ // A smaller spread across our listening ports. The event itself is
31118
+ // `medium`, but the `port-scan-indicator` rule matches it and bans on
31119
+ // first sight. These are inbound-to-listening only, so the ephemeral
31125
31120
  // outbound-port bug that once banned our upstreams cannot recur here.
31126
31121
  tracker.ports.size >= this.portScanNoticeThreshold && withinWindow && !this.noticed.has(key)
31127
31122
  ) {
@@ -33192,12 +33187,15 @@ var DEFAULT_RULES = [
33192
33187
  enabled: true
33193
33188
  },
33194
33189
  {
33190
+ // A rule that declares `block` must be at the severity auto-defence bans
33191
+ // at, or it fires and is ignored: this one was `medium`, and on dev1 it
33192
+ // detected scanners 25 times and banned none of them.
33195
33193
  id: "web-scanner-detection",
33196
33194
  title: "Web Vulnerability Scanner Detected",
33197
33195
  description: "High volume of 4xx errors suggesting automated scanning",
33198
33196
  version: "1.0.0",
33199
33197
  category: "web",
33200
- severity: "medium",
33198
+ severity: "high",
33201
33199
  source_types: ["log-watcher", "web"],
33202
33200
  match: {
33203
33201
  field: "message",
@@ -33221,7 +33219,7 @@ var DEFAULT_RULES = [
33221
33219
  // and keeps walking URLs: GoogleOther did ~40/min per IP against r4ck's
33222
33220
  // /api/v1/search on dev2, 2026-09-25. `web-scanner-detection` saw it too,
33223
33221
  // but it is `medium`, and auto-defence bans at `high` and above, so it fired
33224
- // every minute and never banned. This one is `high` on purpose.
33222
+ // every minute and never banned (it is `high` now too). This one is `high` on purpose.
33225
33223
  //
33226
33224
  // It cannot see a proxy swarm that asks once per address; nothing per-IP can.
33227
33225
  id: "paywall-hammering",
@@ -33281,12 +33279,16 @@ var DEFAULT_RULES = [
33281
33279
  enabled: true
33282
33280
  },
33283
33281
  {
33282
+ // `high` for the same reason as web-scanner-detection: as `medium` it fired
33283
+ // 21 times on dev1 without a single ban. It also matches network-monitor's
33284
+ // "Possible port scan" notice (5+ of our LISTENING ports from one address),
33285
+ // so that is now banned on first sight as well.
33284
33286
  id: "port-scan-indicator",
33285
33287
  title: "Port Scan Indicators",
33286
33288
  description: "Connection attempts to many ports from a single source",
33287
33289
  version: "1.0.0",
33288
33290
  category: "network",
33289
- severity: "medium",
33291
+ severity: "high",
33290
33292
  source_types: ["network-monitor", "network"],
33291
33293
  match: {
33292
33294
  field: "message",
@@ -33714,8 +33716,11 @@ var DEFAULT_CONFIG2 = {
33714
33716
  enabled: true,
33715
33717
  dry_run: false,
33716
33718
  min_severity: "high",
33717
- max_ban_seconds: 86400,
33718
- strike_memory_seconds: 86400,
33719
+ first_ban_seconds: DEFAULT_FIRST_BAN_SECONDS,
33720
+ max_ban_seconds: 7 * 86400,
33721
+ // Longer than the ceiling, or an address that reaches it is forgotten while
33722
+ // banned and comes back at the first rung.
33723
+ strike_memory_seconds: 30 * 86400,
33719
33724
  allowlist: [],
33720
33725
  protect_current_ssh_client: true,
33721
33726
  spare_verified_crawlers: true
@@ -33807,9 +33812,9 @@ var RemediationManager = class {
33807
33812
  await this.ban(ip, event.message, { ruleId, source: "auto" });
33808
33813
  }
33809
33814
  /**
33810
- * Ban `ip`. With no explicit TTL the length comes from the Fibonacci ladder:
33811
- * 1m, 2m, 3m, 5m, 8m, 13m … for the 1st, 2nd, 3rd offence and so on, clamped
33812
- * to `max_ban_seconds`.
33815
+ * Ban `ip`. With no explicit TTL the length comes from the doubling ladder:
33816
+ * `first_ban_seconds` (5m by default), then 10m, 20m, 40m … for the 2nd, 3rd,
33817
+ * 4th offence and so on, clamped to `max_ban_seconds`.
33813
33818
  */
33814
33819
  async ban(ip, reason, opts = {}) {
33815
33820
  if ((0, import_node_net8.isIP)(ip) === 0) return { ok: false, error: `not an IP address: ${ip}` };
@@ -33847,7 +33852,7 @@ var RemediationManager = class {
33847
33852
  }
33848
33853
  }
33849
33854
  const strike = recordStrike(this.strikes, ip, now, this.config.strike_memory_seconds);
33850
- const ttl = opts.ttlSeconds ?? banSeconds(strike, this.config.max_ban_seconds);
33855
+ const ttl = opts.ttlSeconds ?? banSeconds(strike, this.config.max_ban_seconds, this.config.first_ban_seconds);
33851
33856
  const entry = {
33852
33857
  ip,
33853
33858
  reason,
@@ -33947,6 +33952,7 @@ var RemediationManager = class {
33947
33952
  backend: this.adapter.name,
33948
33953
  min_severity: this.config.min_severity,
33949
33954
  banned: this.blocklist.length,
33955
+ first_ban_seconds: this.config.first_ban_seconds,
33950
33956
  max_ban_seconds: this.config.max_ban_seconds,
33951
33957
  warning: this.privilegeWarning()
33952
33958
  };
@@ -34085,6 +34091,8 @@ function remediationSettings(section) {
34085
34091
  else if (section.mode === "enforce") settings.dry_run = false;
34086
34092
  else if (typeof section.dry_run === "boolean") settings.dry_run = section.dry_run;
34087
34093
  if (section.min_severity) settings.min_severity = section.min_severity;
34094
+ const firstBan = parseDuration(section.first_ban);
34095
+ if (firstBan) settings.first_ban_seconds = firstBan;
34088
34096
  const maxBan = parseDuration(section.max_ban);
34089
34097
  if (maxBan) settings.max_ban_seconds = maxBan;
34090
34098
  const memory = parseDuration(section.strike_memory);
@@ -34100,6 +34108,9 @@ function remediationSettings(section) {
34100
34108
  return settings;
34101
34109
  }
34102
34110
 
34111
+ // src/daemon/index.ts
34112
+ init_backoff();
34113
+
34103
34114
  // src/core/telemetry.ts
34104
34115
  var ready = false;
34105
34116
  var sentry = null;
@@ -34146,6 +34157,25 @@ async function flushTelemetry(timeoutMs = 2e3) {
34146
34157
  }
34147
34158
  }
34148
34159
 
34160
+ // src/core/node-runtime.ts
34161
+ var import_node_child_process9 = require("child_process");
34162
+ var MIN_DAEMON_NODE_MAJOR = 22;
34163
+ function nodeMajor(version) {
34164
+ const m = String(version ?? "").trim().replace(/^v/, "").match(/^(\d+)\./);
34165
+ return m ? Number(m[1]) : null;
34166
+ }
34167
+ function daemonNodeProblem(version) {
34168
+ const major = nodeMajor(version);
34169
+ if (major === null) return `cannot tell which Node version this is (${version ?? "unknown"})`;
34170
+ if (major >= MIN_DAEMON_NODE_MAJOR) return null;
34171
+ return `Node ${version} is too old for threatcrushd (needs ${MIN_DAEMON_NODE_MAJOR}+): its SQLite driver crashes the process with SIGSEGV. Install threatcrush with Node ${MIN_DAEMON_NODE_MAJOR} or newer and re-run threatcrush install-service.`;
34172
+ }
34173
+ function versionOfNode(path) {
34174
+ if (path === process.execPath) return process.versions.node;
34175
+ const res = (0, import_node_child_process9.spawnSync)(path, ["-p", "process.versions.node"], { encoding: "utf-8", timeout: 5e3 });
34176
+ return res.status === 0 ? res.stdout.trim() : null;
34177
+ }
34178
+
34149
34179
  // src/daemon/index.ts
34150
34180
  function readVersion2() {
34151
34181
  try {
@@ -34156,7 +34186,7 @@ function readVersion2() {
34156
34186
  }
34157
34187
  }
34158
34188
  async function runHardeningChecks() {
34159
- const { stdout } = await (0, import_node_util.promisify)(import_node_child_process9.execFile)(
34189
+ const { stdout } = await (0, import_node_util.promisify)(import_node_child_process10.execFile)(
34160
34190
  process.execPath,
34161
34191
  [(0, import_node_path20.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
34162
34192
  { timeout: 12e4, maxBuffer: 4 * 1024 * 1024 }
@@ -34189,6 +34219,12 @@ async function runDaemon() {
34189
34219
  });
34190
34220
  const version = readVersion2();
34191
34221
  logLine(`[daemon] starting threatcrushd v${version} mode=${PATHS.mode}`);
34222
+ const nodeProblem = daemonNodeProblem(process.versions.node);
34223
+ if (nodeProblem) {
34224
+ logLine(`[daemon] ${nodeProblem}`);
34225
+ console.error(nodeProblem);
34226
+ process.exit(1);
34227
+ }
34192
34228
  try {
34193
34229
  initStateDB(PATHS.stateDb);
34194
34230
  } catch (err) {
@@ -34234,7 +34270,7 @@ async function runDaemon() {
34234
34270
  });
34235
34271
  const remediationStatus = remediation.status();
34236
34272
  logLine(
34237
- `[daemon] auto-defence ${remediationStatus.enabled ? "ON" : "OFF"} (backend=${remediationStatus.backend}, mode=${remediationStatus.dry_run ? "dry_run" : "enforce"}, min_severity=${remediationStatus.min_severity}, bans escalate 1m\u21922m\u21923m\u21925m\u21928m\u2026)`
34273
+ `[daemon] auto-defence ${remediationStatus.enabled ? "ON" : "OFF"} (backend=${remediationStatus.backend}, mode=${remediationStatus.dry_run ? "dry_run" : "enforce"}, min_severity=${remediationStatus.min_severity}, bans double from ${formatDuration(remediationStatus.first_ban_seconds)} up to ${formatDuration(remediationStatus.max_ban_seconds)})`
34238
34274
  );
34239
34275
  if (remediationStatus.dry_run && firewallAdapter.enforces !== false) {
34240
34276
  logLine("[daemon] dry_run is set in [remediation] \u2014 detections will be logged, not blocked");
@@ -34381,7 +34417,7 @@ async function daemonStart() {
34381
34417
  }
34382
34418
  return;
34383
34419
  }
34384
- const child = (0, import_node_child_process10.spawn)(process.execPath, [DAEMON_ENTRY], {
34420
+ const child = (0, import_node_child_process11.spawn)(process.execPath, [DAEMON_ENTRY], {
34385
34421
  detached: true,
34386
34422
  stdio: ["ignore", out, err],
34387
34423
  env: { ...process.env, THREATCRUSH_DAEMON: "1" }
@@ -34468,7 +34504,7 @@ async function releaseStaleSocket() {
34468
34504
  }
34469
34505
 
34470
34506
  // src/commands/service.ts
34471
- var import_node_child_process11 = require("child_process");
34507
+ var import_node_child_process12 = require("child_process");
34472
34508
  var import_node_fs32 = require("fs");
34473
34509
  var import_node_path22 = require("path");
34474
34510
  var UNIT_PATH = "/etc/systemd/system/threatcrushd.service";
@@ -34489,7 +34525,7 @@ function resolveBinPath() {
34489
34525
  const arg = process.argv[1];
34490
34526
  if (arg && (0, import_node_fs32.existsSync)(arg)) return stableBinPath(arg);
34491
34527
  try {
34492
- return (0, import_node_child_process11.execSync)("command -v threatcrush", { encoding: "utf-8" }).trim();
34528
+ return (0, import_node_child_process12.execSync)("command -v threatcrush", { encoding: "utf-8" }).trim();
34493
34529
  } catch {
34494
34530
  return "threatcrush";
34495
34531
  }
@@ -34525,18 +34561,18 @@ function isRoot3() {
34525
34561
  return typeof process.getuid === "function" && process.getuid() === 0;
34526
34562
  }
34527
34563
  function reexecWithSudo(args) {
34528
- if ((0, import_node_child_process11.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
34564
+ if ((0, import_node_child_process12.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
34529
34565
  console.log(source_default.dim(" This needs root \u2014 sudo will ask for your password.\n"));
34530
34566
  const bin = resolveBinPath();
34531
34567
  const argv = looksLikeNodeScript(bin) ? [stableNodePath(process.execPath), bin, ...args] : [bin, ...args];
34532
- const result = (0, import_node_child_process11.spawnSync)("sudo", argv, { stdio: "inherit" });
34568
+ const result = (0, import_node_child_process12.spawnSync)("sudo", argv, { stdio: "inherit" });
34533
34569
  return result.status === 0;
34534
34570
  }
34535
34571
  function callerHome() {
34536
34572
  const user = process.env.SUDO_USER;
34537
34573
  if (!user) return null;
34538
34574
  try {
34539
- const line = (0, import_node_child_process11.execSync)(`getent passwd ${user}`, { encoding: "utf-8" }).trim();
34575
+ const line = (0, import_node_child_process12.execSync)(`getent passwd ${user}`, { encoding: "utf-8" }).trim();
34540
34576
  const home = line.split(":")[5];
34541
34577
  return home && (0, import_node_fs32.existsSync)(home) ? home : null;
34542
34578
  } catch {
@@ -34571,7 +34607,7 @@ function stopUserModeDaemon() {
34571
34607
  }
34572
34608
  }
34573
34609
  function unitIsActive() {
34574
- const result = (0, import_node_child_process11.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT_NAME], { stdio: "pipe" });
34610
+ const result = (0, import_node_child_process12.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT_NAME], { stdio: "pipe" });
34575
34611
  return result.status === 0;
34576
34612
  }
34577
34613
  async function installServiceCommand() {
@@ -34582,7 +34618,7 @@ async function installServiceCommand() {
34582
34618
  return;
34583
34619
  }
34584
34620
  const noSystemd = systemdUnavailableReason({
34585
- hasSystemctl: (0, import_node_child_process11.spawnSync)("sh", ["-c", "command -v systemctl"], { stdio: "ignore" }).status === 0,
34621
+ hasSystemctl: (0, import_node_child_process12.spawnSync)("sh", ["-c", "command -v systemctl"], { stdio: "ignore" }).status === 0,
34586
34622
  booted: (0, import_node_fs32.existsSync)("/run/systemd/system")
34587
34623
  });
34588
34624
  if (noSystemd) {
@@ -34608,6 +34644,15 @@ async function installServiceCommand() {
34608
34644
  binPath = (0, import_node_fs32.realpathSync)(binPath);
34609
34645
  nodePath = process.execPath;
34610
34646
  }
34647
+ if (isNodeScript) {
34648
+ const problem = daemonNodeProblem(versionOfNode(nodePath));
34649
+ if (problem) {
34650
+ console.log(source_default.red(` \u2717 ${problem}`));
34651
+ console.log(source_default.dim(" Nothing was installed."));
34652
+ process.exitCode = 1;
34653
+ return;
34654
+ }
34655
+ }
34611
34656
  const exec = execStartCommand(binPath, nodePath, isNodeScript);
34612
34657
  const unit = resolveTemplate().replace("{{BIN_PATH}} daemon", exec).replace("{{BIN_PATH}}", binPath);
34613
34658
  (0, import_node_fs32.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
@@ -34624,8 +34669,8 @@ async function installServiceCommand() {
34624
34669
  ensureSystemDirs();
34625
34670
  stopUserModeDaemon();
34626
34671
  try {
34627
- (0, import_node_child_process11.execSync)("systemctl daemon-reload", { stdio: "inherit" });
34628
- (0, import_node_child_process11.execSync)(`systemctl enable --now ${DAEMON_UNIT_NAME}`, { stdio: "inherit" });
34672
+ (0, import_node_child_process12.execSync)("systemctl daemon-reload", { stdio: "inherit" });
34673
+ (0, import_node_child_process12.execSync)(`systemctl enable --now ${DAEMON_UNIT_NAME}`, { stdio: "inherit" });
34629
34674
  } catch (err) {
34630
34675
  console.log(source_default.yellow(` ! systemctl error: ${err.message}`));
34631
34676
  console.log(source_default.dim(` Logs: journalctl -u ${DAEMON_UNIT_NAME} -n 50`));
@@ -34667,7 +34712,7 @@ function ensureSystemDirs() {
34667
34712
  try {
34668
34713
  if (groupWritable && admGid !== null) {
34669
34714
  (0, import_node_fs32.chmodSync)(path, sticky ? 1533 : 509);
34670
- (0, import_node_child_process11.execSync)(`chgrp adm ${path}`, { stdio: "ignore" });
34715
+ (0, import_node_child_process12.execSync)(`chgrp adm ${path}`, { stdio: "ignore" });
34671
34716
  } else {
34672
34717
  (0, import_node_fs32.chmodSync)(path, 493);
34673
34718
  }
@@ -34689,22 +34734,22 @@ async function uninstallServiceCommand() {
34689
34734
  return;
34690
34735
  }
34691
34736
  try {
34692
- (0, import_node_child_process11.execSync)("systemctl stop threatcrushd.service", { stdio: "inherit" });
34737
+ (0, import_node_child_process12.execSync)("systemctl stop threatcrushd.service", { stdio: "inherit" });
34693
34738
  } catch {
34694
34739
  }
34695
34740
  try {
34696
- (0, import_node_child_process11.execSync)("systemctl disable threatcrushd.service", { stdio: "inherit" });
34741
+ (0, import_node_child_process12.execSync)("systemctl disable threatcrushd.service", { stdio: "inherit" });
34697
34742
  } catch {
34698
34743
  }
34699
34744
  try {
34700
34745
  if ((0, import_node_fs32.existsSync)(UNIT_PATH)) {
34701
- (0, import_node_child_process11.execSync)(`rm -f ${UNIT_PATH}`);
34746
+ (0, import_node_child_process12.execSync)(`rm -f ${UNIT_PATH}`);
34702
34747
  console.log(source_default.green(` \u2713 Removed unit file: ${UNIT_PATH}`));
34703
34748
  }
34704
34749
  } catch {
34705
34750
  }
34706
34751
  try {
34707
- (0, import_node_child_process11.execSync)("systemctl daemon-reload", { stdio: "inherit" });
34752
+ (0, import_node_child_process12.execSync)("systemctl daemon-reload", { stdio: "inherit" });
34708
34753
  } catch {
34709
34754
  }
34710
34755
  console.log(source_default.green(" \u2713 threatcrushd service removed."));
@@ -35285,7 +35330,7 @@ async function rulesShowCommand(ruleId) {
35285
35330
  if (rule.remediation) {
35286
35331
  console.log(` Remediation: ${source_default.gray(rule.remediation.description || rule.remediation.action || "none")}`);
35287
35332
  if (rule.remediation.action === "block") {
35288
- console.log(` Ban length: ${source_default.gray("escalation ladder, 1m \u2192 2m \u2192 3m \u2192 5m \u2192 8m \u2026 up to max_ban")}`);
35333
+ console.log(` Ban length: ${source_default.gray("escalation ladder, doubling from first_ban: 5m \u2192 10m \u2192 20m \u2192 40m \u2026 up to max_ban")}`);
35289
35334
  }
35290
35335
  }
35291
35336
  console.log();
@@ -35322,10 +35367,10 @@ async function rulesCommand(opts) {
35322
35367
 
35323
35368
  // src/commands/harden.ts
35324
35369
  var import_node_fs34 = require("fs");
35325
- var import_node_child_process12 = require("child_process");
35370
+ var import_node_child_process13 = require("child_process");
35326
35371
  function tryExec(cmd) {
35327
35372
  try {
35328
- return (0, import_node_child_process12.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
35373
+ return (0, import_node_child_process13.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
35329
35374
  } catch {
35330
35375
  return null;
35331
35376
  }
@@ -35892,11 +35937,11 @@ async function allowlistCommand(opts) {
35892
35937
  init_paths();
35893
35938
 
35894
35939
  // src/upgrade.ts
35895
- var import_node_child_process13 = require("child_process");
35940
+ var import_node_child_process14 = require("child_process");
35896
35941
  var PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
35897
35942
  var defaultRunner = (cmd) => {
35898
35943
  try {
35899
- return (0, import_node_child_process13.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
35944
+ return (0, import_node_child_process14.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
35900
35945
  } catch {
35901
35946
  return null;
35902
35947
  }
@@ -36014,22 +36059,22 @@ var DESKTOP_PKG_NAME = "@profullstack/threatcrush-desktop";
36014
36059
  var INSTALL_CONFIG_PATH = (0, import_node_path24.join)((0, import_node_os9.homedir)(), ".threatcrush", "install.json");
36015
36060
  function detectPackageManager() {
36016
36061
  try {
36017
- const npmGlobal = (0, import_node_child_process14.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
36062
+ const npmGlobal = (0, import_node_child_process15.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
36018
36063
  if (npmGlobal.includes(PKG_NAME)) return "npm";
36019
36064
  } catch {
36020
36065
  }
36021
36066
  try {
36022
- (0, import_node_child_process14.execSync)("pnpm --version", { stdio: "pipe" });
36067
+ (0, import_node_child_process15.execSync)("pnpm --version", { stdio: "pipe" });
36023
36068
  return "pnpm";
36024
36069
  } catch {
36025
36070
  }
36026
36071
  try {
36027
- (0, import_node_child_process14.execSync)("yarn --version", { stdio: "pipe" });
36072
+ (0, import_node_child_process15.execSync)("yarn --version", { stdio: "pipe" });
36028
36073
  return "yarn";
36029
36074
  } catch {
36030
36075
  }
36031
36076
  try {
36032
- (0, import_node_child_process14.execSync)("bun --version", { stdio: "pipe" });
36077
+ (0, import_node_child_process15.execSync)("bun --version", { stdio: "pipe" });
36033
36078
  return "bun";
36034
36079
  } catch {
36035
36080
  }
@@ -36044,7 +36089,7 @@ function readInstallConfig() {
36044
36089
  }
36045
36090
  function packageLooksInstalled(pm, pkgName) {
36046
36091
  try {
36047
- const output = (0, import_node_child_process14.execSync)(globalListCommand(pm, pkgName), {
36092
+ const output = (0, import_node_child_process15.execSync)(globalListCommand(pm, pkgName), {
36048
36093
  encoding: "utf-8",
36049
36094
  stdio: ["pipe", "pipe", "pipe"]
36050
36095
  });
@@ -36147,14 +36192,14 @@ async function promoteUnprivilegedDaemon() {
36147
36192
  function restartSystemdDaemon() {
36148
36193
  const asRoot = typeof process.getuid === "function" && process.getuid() === 0;
36149
36194
  const argv = asRoot ? ["systemctl", "restart", DAEMON_UNIT] : ["sudo", "systemctl", "restart", DAEMON_UNIT];
36150
- if (!asRoot && (0, import_node_child_process14.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
36195
+ if (!asRoot && (0, import_node_child_process15.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
36151
36196
  const [cmd, ...args] = argv;
36152
- if ((0, import_node_child_process14.spawnSync)(cmd, args, { stdio: "inherit" }).status !== 0) return false;
36153
- return (0, import_node_child_process14.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT], { stdio: "pipe" }).status === 0;
36197
+ if ((0, import_node_child_process15.spawnSync)(cmd, args, { stdio: "inherit" }).status !== 0) return false;
36198
+ return (0, import_node_child_process15.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT], { stdio: "pipe" }).status === 0;
36154
36199
  }
36155
36200
  function execQuiet(cmd) {
36156
36201
  try {
36157
- return (0, import_node_child_process14.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
36202
+ return (0, import_node_child_process15.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
36158
36203
  } catch {
36159
36204
  return null;
36160
36205
  }
@@ -36316,7 +36361,7 @@ program2.command("logs").description("Tail daemon logs").action(async () => {
36316
36361
  console.log(source_default.green(` Tailing ${logPath}...
36317
36362
  `));
36318
36363
  console.log(source_default.gray(" Press Ctrl+C to stop\n"));
36319
- (0, import_node_child_process14.execSync)(`tail -f ${logPath}`, { stdio: "inherit" });
36364
+ (0, import_node_child_process15.execSync)(`tail -f ${logPath}`, { stdio: "inherit" });
36320
36365
  });
36321
36366
  program2.command("update").description("Update ThreatCrush CLI and installed bundle").option("--cli", "Update CLI only").option("--modules", "Update modules only").option("--desktop", "Update desktop app too").action(async (opts) => {
36322
36367
  console.log(LOGO2);
@@ -36328,7 +36373,7 @@ program2.command("update").description("Update ThreatCrush CLI and installed bun
36328
36373
  for (const cmd of commands2) {
36329
36374
  console.log(source_default.green(` \u2192 ${cmd}
36330
36375
  `));
36331
- (0, import_node_child_process14.execSync)(cmd, { stdio: "inherit" });
36376
+ (0, import_node_child_process15.execSync)(cmd, { stdio: "inherit" });
36332
36377
  }
36333
36378
  console.log(source_default.green("\n \u2713 Modules updated successfully!\n"));
36334
36379
  await reportIfStillStale();
@@ -36353,7 +36398,7 @@ program2.command("update").description("Update ThreatCrush CLI and installed bun
36353
36398
  for (const cmd of commands) {
36354
36399
  console.log(source_default.green(` \u2192 ${cmd}
36355
36400
  `));
36356
- (0, import_node_child_process14.execSync)(cmd, { stdio: "inherit" });
36401
+ (0, import_node_child_process15.execSync)(cmd, { stdio: "inherit" });
36357
36402
  }
36358
36403
  console.log(source_default.green("\n \u2713 ThreatCrush updated successfully!\n"));
36359
36404
  if (installMode === "desktop") {
@@ -36404,7 +36449,7 @@ program2.command("remove").description("Uninstall ThreatCrush and the installed
36404
36449
  for (const cmd of commands) {
36405
36450
  console.log(source_default.green(` \u2192 ${cmd}
36406
36451
  `));
36407
- (0, import_node_child_process14.execSync)(cmd, { stdio: "inherit" });
36452
+ (0, import_node_child_process15.execSync)(cmd, { stdio: "inherit" });
36408
36453
  }
36409
36454
  console.log(source_default.green("\n \u2713 ThreatCrush has been uninstalled.\n"));
36410
36455
  console.log(source_default.dim(" We're sorry to see you go! \u{1F44B}\n"));