@profullstack/threatcrush 0.13.76 → 0.13.77

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
@@ -23788,7 +23788,7 @@ var source_default = chalk;
23788
23788
  var import_readline = __toESM(require("readline"));
23789
23789
  var import_node_child_process29 = require("child_process");
23790
23790
  var import_node_fs75 = require("fs");
23791
- var import_node_path57 = require("path");
23791
+ var import_node_path58 = require("path");
23792
23792
  var import_node_os24 = require("os");
23793
23793
 
23794
23794
  // src/commands/monitor.ts
@@ -43432,14 +43432,14 @@ async function sshConnect(options) {
43432
43432
  // src/commands/daemon.ts
43433
43433
  var import_node_child_process21 = require("child_process");
43434
43434
  var import_node_fs59 = require("fs");
43435
- var import_node_path46 = require("path");
43435
+ var import_node_path47 = require("path");
43436
43436
  var import_node_fs60 = require("fs");
43437
43437
 
43438
43438
  // src/daemon/index.ts
43439
43439
  var import_node_fs58 = require("fs");
43440
43440
  var import_node_child_process20 = require("child_process");
43441
43441
  var import_node_os19 = require("os");
43442
- var import_node_path45 = require("path");
43442
+ var import_node_path46 = require("path");
43443
43443
  var import_node_util4 = require("util");
43444
43444
  init_paths();
43445
43445
 
@@ -43747,13 +43747,15 @@ function admGid(readGroup = () => (0, import_node_fs34.readFileSync)("/etc/group
43747
43747
 
43748
43748
  // src/daemon/module-host.ts
43749
43749
  var import_node_fs40 = require("fs");
43750
- var import_node_path30 = require("path");
43750
+ var import_node_path31 = require("path");
43751
43751
  var import_node_url = require("url");
43752
- var import_toml4 = __toESM(require_toml());
43752
+ var import_toml5 = __toESM(require_toml());
43753
43753
  init_paths();
43754
43754
 
43755
43755
  // src/daemon/watchers/log-watcher.ts
43756
43756
  var import_node_fs35 = require("fs");
43757
+ var import_node_path29 = require("path");
43758
+ var import_toml4 = __toESM(require_toml());
43757
43759
  var DEFAULT_SOURCES = [
43758
43760
  { path: "/var/log/auth.log", module: "ssh-guard", category: "auth" },
43759
43761
  { path: "/var/log/secure", module: "ssh-guard", category: "auth" },
@@ -43761,6 +43763,39 @@ var DEFAULT_SOURCES = [
43761
43763
  { path: "/var/log/caddy/agent.database.pit.world.access.log", module: "log-watcher", category: "web" },
43762
43764
  { path: "/var/log/syslog", module: "log-watcher", category: "system" }
43763
43765
  ];
43766
+ function configuredWebSources(configFile, confD) {
43767
+ const paths = [];
43768
+ const take = (v) => {
43769
+ if (!Array.isArray(v)) return;
43770
+ for (const p of v) if (typeof p === "string" && p.startsWith("/")) paths.push(p);
43771
+ };
43772
+ const read = (file) => {
43773
+ try {
43774
+ return import_toml4.default.parse((0, import_node_fs35.readFileSync)(file, "utf-8"));
43775
+ } catch {
43776
+ return null;
43777
+ }
43778
+ };
43779
+ const main = (0, import_node_fs35.existsSync)(configFile) ? read(configFile) : null;
43780
+ take(main?.modules?.["log-watcher"]?.paths);
43781
+ take(main?.["log-watcher"]?.paths);
43782
+ if ((0, import_node_fs35.existsSync)(confD)) {
43783
+ let files = [];
43784
+ try {
43785
+ files = (0, import_node_fs35.readdirSync)(confD).filter((f) => f.endsWith(".conf")).sort();
43786
+ } catch {
43787
+ }
43788
+ for (const f of files) take(read((0, import_node_path29.join)(confD, f))?.["log-watcher"]?.paths);
43789
+ }
43790
+ const known = new Set(DEFAULT_SOURCES.map((s) => s.path));
43791
+ const out = [];
43792
+ for (const path2 of paths) {
43793
+ if (known.has(path2)) continue;
43794
+ known.add(path2);
43795
+ out.push({ path: path2, module: "log-watcher", category: "web" });
43796
+ }
43797
+ return out;
43798
+ }
43764
43799
  var AGENTDB_API_PATH = /^\/v1\/(?:list_databases|inspect_schema|query_readonly|explain_query|cluster_health|backup_status|audit\/events|backup\/(?:create|verify)|tokens(?:\/revoke)?)$/;
43765
43800
  var AGENTDB_HOST = "agent.database.pit.world";
43766
43801
  var LogWatcher = class {
@@ -44421,7 +44456,7 @@ var import_node_readline3 = require("readline");
44421
44456
 
44422
44457
  // src/core/threat-feeds/index.ts
44423
44458
  var import_node_fs38 = require("fs");
44424
- var import_node_path29 = require("path");
44459
+ var import_node_path30 = require("path");
44425
44460
  var import_node_net7 = require("net");
44426
44461
 
44427
44462
  // src/daemon/firewall/protected.ts
@@ -44808,7 +44843,7 @@ function readFeedCache(path2) {
44808
44843
  }
44809
44844
  }
44810
44845
  function writeFeedCache(path2, set) {
44811
- (0, import_node_fs38.mkdirSync)((0, import_node_path29.dirname)(path2), { recursive: true });
44846
+ (0, import_node_fs38.mkdirSync)((0, import_node_path30.dirname)(path2), { recursive: true });
44812
44847
  const tmp = `${path2}.tmp`;
44813
44848
  (0, import_node_fs38.writeFileSync)(tmp, JSON.stringify(set));
44814
44849
  (0, import_node_fs38.renameSync)(tmp, path2);
@@ -45207,7 +45242,10 @@ var ModuleHost = class {
45207
45242
  async start() {
45208
45243
  this.registerBuiltins();
45209
45244
  await this.discoverAndStartInstalled();
45210
- this.logWatcher = new LogWatcher(this.bus);
45245
+ this.logWatcher = new LogWatcher(this.bus, [
45246
+ ...DEFAULT_SOURCES,
45247
+ ...configuredWebSources(PATHS.configFile, PATHS.confD)
45248
+ ]);
45211
45249
  const watched = this.logWatcher.start();
45212
45250
  for (const modName of this.logWatcher.activeModules()) {
45213
45251
  const mod = this.modules.get(modName);
@@ -45300,10 +45338,10 @@ var ModuleHost = class {
45300
45338
  const entries = (0, import_node_fs40.readdirSync)(PATHS.moduleDir, { withFileTypes: true });
45301
45339
  for (const entry of entries) {
45302
45340
  if (!entry.isDirectory()) continue;
45303
- const manifestPath = (0, import_node_path30.join)(PATHS.moduleDir, entry.name, "mod.toml");
45341
+ const manifestPath = (0, import_node_path31.join)(PATHS.moduleDir, entry.name, "mod.toml");
45304
45342
  if (!(0, import_node_fs40.existsSync)(manifestPath)) continue;
45305
45343
  try {
45306
- const manifest = import_toml4.default.parse((0, import_node_fs40.readFileSync)(manifestPath, "utf-8"));
45344
+ const manifest = import_toml5.default.parse((0, import_node_fs40.readFileSync)(manifestPath, "utf-8"));
45307
45345
  const name = manifest.module?.name || entry.name;
45308
45346
  const defaults = manifest.module?.config?.defaults || {};
45309
45347
  const config = {
@@ -45317,7 +45355,7 @@ var ModuleHost = class {
45317
45355
  source: "installed",
45318
45356
  status: config.enabled === false ? "disabled" : "loaded",
45319
45357
  events: 0,
45320
- path: (0, import_node_path30.join)(PATHS.moduleDir, entry.name),
45358
+ path: (0, import_node_path31.join)(PATHS.moduleDir, entry.name),
45321
45359
  config
45322
45360
  };
45323
45361
  this.modules.set(name, hosted);
@@ -45332,7 +45370,7 @@ var ModuleHost = class {
45332
45370
  status: "error",
45333
45371
  events: 0,
45334
45372
  detail: `manifest load failed: ${String(err.message || err)}`,
45335
- path: (0, import_node_path30.join)(PATHS.moduleDir, entry.name)
45373
+ path: (0, import_node_path31.join)(PATHS.moduleDir, entry.name)
45336
45374
  });
45337
45375
  }
45338
45376
  }
@@ -45371,16 +45409,16 @@ var ModuleHost = class {
45371
45409
  }
45372
45410
  }
45373
45411
  installedEntrypoint(modulePath) {
45374
- const packageJson = (0, import_node_path30.join)(modulePath, "package.json");
45412
+ const packageJson = (0, import_node_path31.join)(modulePath, "package.json");
45375
45413
  const candidates = [];
45376
45414
  if ((0, import_node_fs40.existsSync)(packageJson)) {
45377
45415
  try {
45378
45416
  const pkg = JSON.parse((0, import_node_fs40.readFileSync)(packageJson, "utf-8"));
45379
- if (pkg.main) candidates.push((0, import_node_path30.join)(modulePath, pkg.main));
45417
+ if (pkg.main) candidates.push((0, import_node_path31.join)(modulePath, pkg.main));
45380
45418
  } catch {
45381
45419
  }
45382
45420
  }
45383
- candidates.push((0, import_node_path30.join)(modulePath, "dist", "index.js"), (0, import_node_path30.join)(modulePath, "index.js"));
45421
+ candidates.push((0, import_node_path31.join)(modulePath, "dist", "index.js"), (0, import_node_path31.join)(modulePath, "index.js"));
45384
45422
  return candidates.find((candidate) => (0, import_node_fs40.existsSync)(candidate)) || null;
45385
45423
  }
45386
45424
  isThreatCrushModule(value) {
@@ -45705,7 +45743,7 @@ function slackChannel(webhookUrl) {
45705
45743
  var import_promises7 = require("dns/promises");
45706
45744
  var import_node_fs41 = require("fs");
45707
45745
  var import_node_net9 = require("net");
45708
- var import_node_path31 = require("path");
45746
+ var import_node_path32 = require("path");
45709
45747
  init_cli_config();
45710
45748
 
45711
45749
  // src/core/cloud-events.ts
@@ -45862,18 +45900,18 @@ function scanTargetError(target, roots, real = import_node_fs41.realpathSync) {
45862
45900
  }
45863
45901
  let path2;
45864
45902
  try {
45865
- path2 = real((0, import_node_path31.resolve)(target));
45903
+ path2 = real((0, import_node_path32.resolve)(target));
45866
45904
  } catch {
45867
45905
  return `no such path: ${target}`;
45868
45906
  }
45869
45907
  for (const root of roots) {
45870
45908
  let base;
45871
45909
  try {
45872
- base = real((0, import_node_path31.resolve)(root));
45910
+ base = real((0, import_node_path32.resolve)(root));
45873
45911
  } catch {
45874
45912
  continue;
45875
45913
  }
45876
- if (path2 === base || path2.startsWith(base.endsWith(import_node_path31.sep) ? base : base + import_node_path31.sep)) return null;
45914
+ if (path2 === base || path2.startsWith(base.endsWith(import_node_path32.sep) ? base : base + import_node_path32.sep)) return null;
45877
45915
  }
45878
45916
  return `${target} is outside [cloud] run_scan_paths`;
45879
45917
  }
@@ -46029,14 +46067,14 @@ init_cli_config();
46029
46067
  // src/daemon/workers/cloud-spool.ts
46030
46068
  var import_node_fs42 = require("fs");
46031
46069
  var import_promises8 = require("fs/promises");
46032
- var import_node_path32 = require("path");
46070
+ var import_node_path33 = require("path");
46033
46071
  var DEFAULT_SPOOL_LIMITS = { maxEvents: 1e4, maxBytes: 20 * 1024 * 1024 };
46034
46072
  var CloudSpool = class {
46035
46073
  constructor(path2, limits = DEFAULT_SPOOL_LIMITS) {
46036
46074
  this.path = path2;
46037
46075
  this.limits = limits;
46038
46076
  try {
46039
- (0, import_node_fs42.mkdirSync)((0, import_node_path32.dirname)(path2), { recursive: true });
46077
+ (0, import_node_fs42.mkdirSync)((0, import_node_path33.dirname)(path2), { recursive: true });
46040
46078
  } catch {
46041
46079
  }
46042
46080
  this.load();
@@ -46580,19 +46618,19 @@ function resolveConfig(section) {
46580
46618
 
46581
46619
  // src/core/abuse-report-log.ts
46582
46620
  var import_node_fs43 = require("fs");
46583
- var import_node_path33 = require("path");
46621
+ var import_node_path34 = require("path");
46584
46622
  init_paths();
46585
46623
  var ABUSE_DIRNAME = "abuse-reports";
46586
46624
  var LOG_FILE2 = "reports.jsonl";
46587
46625
  function resolveAbuseDir(dir) {
46588
46626
  if (dir) return dir;
46589
46627
  if (process.env.THREATCRUSH_ABUSE_DIR) return process.env.THREATCRUSH_ABUSE_DIR;
46590
- const system = (0, import_node_path33.join)("/var/lib/threatcrush", ABUSE_DIRNAME);
46628
+ const system = (0, import_node_path34.join)("/var/lib/threatcrush", ABUSE_DIRNAME);
46591
46629
  if ((0, import_node_fs43.existsSync)(system)) return system;
46592
- return (0, import_node_path33.join)(PATHS.stateDir, ABUSE_DIRNAME);
46630
+ return (0, import_node_path34.join)(PATHS.stateDir, ABUSE_DIRNAME);
46593
46631
  }
46594
46632
  function logPath(dir) {
46595
- return (0, import_node_path33.join)(resolveAbuseDir(dir), LOG_FILE2);
46633
+ return (0, import_node_path34.join)(resolveAbuseDir(dir), LOG_FILE2);
46596
46634
  }
46597
46635
  function appendReport(record, dir) {
46598
46636
  const path2 = logPath(dir);
@@ -47031,7 +47069,7 @@ var RemediationConsumer = class {
47031
47069
  // src/daemon/workers/auto-update.ts
47032
47070
  var import_node_child_process11 = require("child_process");
47033
47071
  var import_node_fs44 = require("fs");
47034
- var import_node_path34 = require("path");
47072
+ var import_node_path35 = require("path");
47035
47073
  init_backoff();
47036
47074
  var PKG_NAME = "@profullstack/threatcrush";
47037
47075
  var REGISTRY = `https://registry.npmjs.org/${PKG_NAME}`;
@@ -47075,12 +47113,12 @@ function pickUpdate(doc, current, opts) {
47075
47113
  return { version: null, reason: `${latest} is younger than min_age, and nothing older is newer than ${current}; waiting` };
47076
47114
  }
47077
47115
  function installPlan(opts) {
47078
- const expected = `${import_node_path34.sep}lib${import_node_path34.sep}node_modules${import_node_path34.sep}@profullstack${import_node_path34.sep}threatcrush`;
47116
+ const expected = `${import_node_path35.sep}lib${import_node_path35.sep}node_modules${import_node_path35.sep}@profullstack${import_node_path35.sep}threatcrush`;
47079
47117
  if (!opts.pkgRoot.endsWith(expected)) {
47080
47118
  return { kind: "unsupported", reason: `not an npm global install (${opts.pkgRoot}); run \`threatcrush update\`` };
47081
47119
  }
47082
- const nodeBin = (0, import_node_path34.dirname)(opts.execPath);
47083
- const npm = (0, import_node_path34.join)(nodeBin, "npm");
47120
+ const nodeBin = (0, import_node_path35.dirname)(opts.execPath);
47121
+ const npm = (0, import_node_path35.join)(nodeBin, "npm");
47084
47122
  if (!opts.npmExists(npm)) return { kind: "unsupported", reason: `no npm beside ${opts.execPath}` };
47085
47123
  if (!opts.owner) return { kind: "unsupported", reason: `cannot tell who owns ${opts.pkgRoot}` };
47086
47124
  const npmArgs = [npm, "i", "-g", `${PKG_NAME}@${opts.version}`, "--no-fund", "--no-audit"];
@@ -47279,7 +47317,7 @@ var AutoUpdate = class {
47279
47317
  // src/daemon/workers/threat-feeds.ts
47280
47318
  var import_node_child_process12 = require("child_process");
47281
47319
  var import_node_fs45 = require("fs");
47282
- var import_node_path35 = require("path");
47320
+ var import_node_path36 = require("path");
47283
47321
  var import_node_net13 = require("net");
47284
47322
  init_backoff();
47285
47323
  var EGRESS_TABLE = "threatcrush_egress";
@@ -47451,10 +47489,10 @@ var ThreatFeeds = class {
47451
47489
  */
47452
47490
  writeResolverFiles(set) {
47453
47491
  const domains = this.wantsDomainBlock ? Object.keys(set.domains).sort() : [];
47454
- const dir = this.opts.resolverDir ?? (0, import_node_path35.dirname)(this.opts.cachePath);
47492
+ const dir = this.opts.resolverDir ?? (0, import_node_path36.dirname)(this.opts.cachePath);
47455
47493
  const hooks = this.opts.resolverHooks ?? RESOLVER_HOOKS;
47456
47494
  const write = (name, content) => {
47457
- const path2 = (0, import_node_path35.join)(dir, name);
47495
+ const path2 = (0, import_node_path36.join)(dir, name);
47458
47496
  if (this.resolverWritten.get(name) === content) return false;
47459
47497
  try {
47460
47498
  (0, import_node_fs45.writeFileSync)(`${path2}.tmp`, content);
@@ -47535,7 +47573,7 @@ var ThreatFeeds = class {
47535
47573
 
47536
47574
  // src/daemon/workers/privilege-watch.ts
47537
47575
  var import_node_fs46 = require("fs");
47538
- var import_node_path36 = require("path");
47576
+ var import_node_path37 = require("path");
47539
47577
  var import_node_child_process13 = require("child_process");
47540
47578
 
47541
47579
  // src/core/privileges/index.ts
@@ -47783,7 +47821,7 @@ function readJson(path2) {
47783
47821
  }
47784
47822
  }
47785
47823
  function writeJson(path2, value) {
47786
- (0, import_node_fs46.mkdirSync)((0, import_node_path36.dirname)(path2), { recursive: true });
47824
+ (0, import_node_fs46.mkdirSync)((0, import_node_path37.dirname)(path2), { recursive: true });
47787
47825
  (0, import_node_fs46.writeFileSync)(`${path2}.tmp`, JSON.stringify(value));
47788
47826
  (0, import_node_fs46.renameSync)(`${path2}.tmp`, path2);
47789
47827
  }
@@ -48068,7 +48106,7 @@ var PrivilegeWatch = class {
48068
48106
  // src/daemon/workers/command-history.ts
48069
48107
  var import_node_fs47 = require("fs");
48070
48108
  var import_node_child_process14 = require("child_process");
48071
- var import_node_path37 = require("path");
48109
+ var import_node_path38 = require("path");
48072
48110
  var import_node_zlib2 = require("zlib");
48073
48111
  var import_node_crypto13 = require("crypto");
48074
48112
  var POLL_MS3 = 6e4;
@@ -48104,9 +48142,9 @@ function historyAccounts() {
48104
48142
  const name = fields[0] ?? "";
48105
48143
  const home = fields[5] ?? "";
48106
48144
  const shell = fields[6] ?? "";
48107
- if (!Number.isInteger(uid) || !Number.isInteger(gid) || !(0, import_node_path37.isAbsolute)(home) || home === "/" || home.split("/").includes("..")) return [];
48145
+ if (!Number.isInteger(uid) || !Number.isInteger(gid) || !(0, import_node_path38.isAbsolute)(home) || home === "/" || home.split("/").includes("..")) return [];
48108
48146
  if (root ? uid !== 0 && uid < 1e3 : uid !== process.getuid?.()) return [];
48109
- if (!HISTORY_TARGETS[(0, import_node_path37.basename)(shell)]) return [];
48147
+ if (!HISTORY_TARGETS[(0, import_node_path38.basename)(shell)]) return [];
48110
48148
  return [{ uid, gid, name, home, shell }];
48111
48149
  });
48112
48150
  }
@@ -48117,11 +48155,11 @@ function descriptorPath(directoryFd, name) {
48117
48155
  return `/proc/self/fd/${directoryFd}/${name}`;
48118
48156
  }
48119
48157
  function openDirectoryChain(path2) {
48120
- if (!(0, import_node_path37.isAbsolute)(path2) || path2.split(import_node_path37.sep).includes("..")) throw new Error("directory path is not a safe absolute path");
48158
+ if (!(0, import_node_path38.isAbsolute)(path2) || path2.split(import_node_path38.sep).includes("..")) throw new Error("directory path is not a safe absolute path");
48121
48159
  const flags = import_node_fs47.constants.O_RDONLY | import_node_fs47.constants.O_DIRECTORY | (import_node_fs47.constants.O_NOFOLLOW ?? 0);
48122
48160
  let fd = (0, import_node_fs47.openSync)("/", flags);
48123
48161
  try {
48124
- for (const part of path2.split(import_node_path37.sep).filter((item) => item && item !== ".")) {
48162
+ for (const part of path2.split(import_node_path38.sep).filter((item) => item && item !== ".")) {
48125
48163
  const next = (0, import_node_fs47.openSync)(descriptorPath(fd, part), flags);
48126
48164
  (0, import_node_fs47.closeSync)(fd);
48127
48165
  fd = next;
@@ -48165,9 +48203,9 @@ function safeReadHistory(directoryFd, name, uid) {
48165
48203
  }
48166
48204
  }
48167
48205
  function atomicWrite(path2, data, mode = 384, owner, parentFd) {
48168
- const dirFd = parentFd ?? openDirectoryChain((0, import_node_path37.dirname)(path2));
48206
+ const dirFd = parentFd ?? openDirectoryChain((0, import_node_path38.dirname)(path2));
48169
48207
  const ownsDirFd = parentFd === void 0;
48170
- const name = (0, import_node_path37.basename)(path2);
48208
+ const name = (0, import_node_path38.basename)(path2);
48171
48209
  const temp = descriptorPath(dirFd, `${name}.${(0, import_node_crypto13.randomUUID)()}.tmp`);
48172
48210
  const destination = descriptorPath(dirFd, name);
48173
48211
  const noFollow = import_node_fs47.constants.O_NOFOLLOW ?? 0;
@@ -48203,9 +48241,9 @@ function atomicWrite(path2, data, mode = 384, owner, parentFd) {
48203
48241
  function readCurrentBackup(path2) {
48204
48242
  let fd;
48205
48243
  try {
48206
- const parentFd = openDirectoryChain((0, import_node_path37.dirname)(path2));
48244
+ const parentFd = openDirectoryChain((0, import_node_path38.dirname)(path2));
48207
48245
  try {
48208
- fd = (0, import_node_fs47.openSync)(descriptorPath(parentFd, (0, import_node_path37.basename)(path2)), import_node_fs47.constants.O_RDONLY | (import_node_fs47.constants.O_NOFOLLOW ?? 0));
48246
+ fd = (0, import_node_fs47.openSync)(descriptorPath(parentFd, (0, import_node_path38.basename)(path2)), import_node_fs47.constants.O_RDONLY | (import_node_fs47.constants.O_NOFOLLOW ?? 0));
48209
48247
  } finally {
48210
48248
  (0, import_node_fs47.closeSync)(parentFd);
48211
48249
  }
@@ -48230,7 +48268,7 @@ var CommandHistoryWatcher = class {
48230
48268
  this.pollMs = Math.max(1e4, opts.pollMs ?? POLL_MS3);
48231
48269
  this.now = opts.now ?? (() => /* @__PURE__ */ new Date());
48232
48270
  this.listAccounts = opts.listAccounts ?? historyAccounts;
48233
- this.root = (0, import_node_path37.join)(opts.stateDir, "command-history");
48271
+ this.root = (0, import_node_path38.join)(opts.stateDir, "command-history");
48234
48272
  }
48235
48273
  opts;
48236
48274
  timer = null;
@@ -48271,7 +48309,7 @@ var CommandHistoryWatcher = class {
48271
48309
  try {
48272
48310
  privateDirectory(this.root);
48273
48311
  for (const account of this.listAccounts()) {
48274
- if (!Number.isInteger(account.uid) || account.uid < 0 || !(0, import_node_path37.isAbsolute)(account.home)) continue;
48312
+ if (!Number.isInteger(account.uid) || account.uid < 0 || !(0, import_node_path38.isAbsolute)(account.home)) continue;
48275
48313
  const targets = this.targetsFor(account);
48276
48314
  for (const relative4 of targets) this.scanFile(account, relative4);
48277
48315
  }
@@ -48282,10 +48320,10 @@ var CommandHistoryWatcher = class {
48282
48320
  }
48283
48321
  }
48284
48322
  targetsFor(account) {
48285
- const targets = new Set(HISTORY_TARGETS[(0, import_node_path37.basename)(account.shell)] ?? []);
48323
+ const targets = new Set(HISTORY_TARGETS[(0, import_node_path38.basename)(account.shell)] ?? []);
48286
48324
  for (const relative4 of Object.values(HISTORY_TARGETS).flat()) {
48287
48325
  if (targets.has(relative4)) continue;
48288
- const path2 = (0, import_node_path37.join)(account.home, relative4);
48326
+ const path2 = (0, import_node_path38.join)(account.home, relative4);
48289
48327
  try {
48290
48328
  (0, import_node_fs47.lstatSync)(path2);
48291
48329
  targets.add(relative4);
@@ -48293,25 +48331,25 @@ var CommandHistoryWatcher = class {
48293
48331
  } catch (error2) {
48294
48332
  if (error2.code !== "ENOENT") continue;
48295
48333
  }
48296
- const current = (0, import_node_path37.join)(this.root, String(account.uid), `${(0, import_node_path37.basename)(relative4)}.current.gz`);
48334
+ const current = (0, import_node_path38.join)(this.root, String(account.uid), `${(0, import_node_path38.basename)(relative4)}.current.gz`);
48297
48335
  if (readCurrentBackup(current) !== null) targets.add(relative4);
48298
48336
  }
48299
48337
  return [...targets];
48300
48338
  }
48301
48339
  scanFile(account, relative4) {
48302
- const path2 = (0, import_node_path37.join)(account.home, relative4);
48303
- const store = (0, import_node_path37.join)(this.root, String(account.uid), (0, import_node_path37.basename)(relative4));
48340
+ const path2 = (0, import_node_path38.join)(account.home, relative4);
48341
+ const store = (0, import_node_path38.join)(this.root, String(account.uid), (0, import_node_path38.basename)(relative4));
48304
48342
  const current = `${store}.current.gz`;
48305
48343
  let userParentFd;
48306
48344
  try {
48307
- userParentFd = openDirectoryChain((0, import_node_path37.dirname)(path2));
48345
+ userParentFd = openDirectoryChain((0, import_node_path38.dirname)(path2));
48308
48346
  } catch {
48309
- this.opts.log(`[command-history] skipped uid=${account.uid} ${(0, import_node_path37.basename)(relative4)} because its parent path is missing or not a real directory`);
48347
+ this.opts.log(`[command-history] skipped uid=${account.uid} ${(0, import_node_path38.basename)(relative4)} because its parent path is missing or not a real directory`);
48310
48348
  return;
48311
48349
  }
48312
48350
  try {
48313
- privateDirectory((0, import_node_path37.dirname)(store));
48314
- const userPath = descriptorPath(userParentFd, (0, import_node_path37.basename)(path2));
48351
+ privateDirectory((0, import_node_path38.dirname)(store));
48352
+ const userPath = descriptorPath(userParentFd, (0, import_node_path38.basename)(path2));
48315
48353
  let status;
48316
48354
  try {
48317
48355
  status = (0, import_node_fs47.lstatSync)(userPath);
@@ -48329,7 +48367,7 @@ var CommandHistoryWatcher = class {
48329
48367
  } else if (!status) {
48330
48368
  this.restore(path2, Buffer.alloc(0), account, userParentFd);
48331
48369
  }
48332
- const data = safeReadHistory(userParentFd, (0, import_node_path37.basename)(path2), account.uid);
48370
+ const data = safeReadHistory(userParentFd, (0, import_node_path38.basename)(path2), account.uid);
48333
48371
  if (data === null) return;
48334
48372
  const previous = backup;
48335
48373
  if (previous?.equals(data)) {
@@ -48342,7 +48380,7 @@ var CommandHistoryWatcher = class {
48342
48380
  atomicWrite(current, compressed);
48343
48381
  this.pruneSnapshots(store);
48344
48382
  } catch (error2) {
48345
- this.opts.log(`[command-history] could not snapshot uid=${account.uid} ${(0, import_node_path37.basename)(relative4)}: ${error2.message}`);
48383
+ this.opts.log(`[command-history] could not snapshot uid=${account.uid} ${(0, import_node_path38.basename)(relative4)}: ${error2.message}`);
48346
48384
  } finally {
48347
48385
  (0, import_node_fs47.closeSync)(userParentFd);
48348
48386
  }
@@ -48357,16 +48395,16 @@ var CommandHistoryWatcher = class {
48357
48395
  module: "command-history",
48358
48396
  category: "system",
48359
48397
  severity: "medium",
48360
- message: `Shell history for ${name} (${(0, import_node_path37.basename)(relative4)}) was ${reason}; restored${hadBackup ? " from the latest backup" : " as an empty file"}`,
48361
- details: { uid: account.uid, account: name, history_file: (0, import_node_path37.basename)(relative4), action: "restored", reason, had_backup: hadBackup }
48398
+ message: `Shell history for ${name} (${(0, import_node_path38.basename)(relative4)}) was ${reason}; restored${hadBackup ? " from the latest backup" : " as an empty file"}`,
48399
+ details: { uid: account.uid, account: name, history_file: (0, import_node_path38.basename)(relative4), action: "restored", reason, had_backup: hadBackup }
48362
48400
  };
48363
48401
  this.opts.bus.publish(event);
48364
48402
  this.opts.log(`[command-history] ${event.message}`);
48365
48403
  }
48366
48404
  pruneSnapshots(current) {
48367
- const dir = (0, import_node_path37.dirname)(current);
48368
- const prefix = `${(0, import_node_path37.basename)(current).replace(/\.current\.gz$/, "")}.`;
48369
- const snapshots = (0, import_node_fs47.readdirSync)(dir).filter((name) => name !== (0, import_node_path37.basename)(current) && name.startsWith(prefix) && name.endsWith(".gz")).map((name) => ({ path: (0, import_node_path37.join)(dir, name), name, time: (0, import_node_fs47.lstatSync)((0, import_node_path37.join)(dir, name)).mtimeMs })).sort((a, b) => a.time - b.time);
48405
+ const dir = (0, import_node_path38.dirname)(current);
48406
+ const prefix = `${(0, import_node_path38.basename)(current).replace(/\.current\.gz$/, "")}.`;
48407
+ const snapshots = (0, import_node_fs47.readdirSync)(dir).filter((name) => name !== (0, import_node_path38.basename)(current) && name.startsWith(prefix) && name.endsWith(".gz")).map((name) => ({ path: (0, import_node_path38.join)(dir, name), name, time: (0, import_node_fs47.lstatSync)((0, import_node_path38.join)(dir, name)).mtimeMs })).sort((a, b) => a.time - b.time);
48370
48408
  const cutoff = this.now().getTime() - SNAPSHOT_RETENTION_MS;
48371
48409
  const removeCount = Math.max(0, snapshots.length - MAX_SNAPSHOTS);
48372
48410
  snapshots.forEach((snapshot, index) => {
@@ -48384,7 +48422,7 @@ var CommandHistoryWatcher = class {
48384
48422
  var import_node_fs48 = require("fs");
48385
48423
  var import_promises9 = require("fs/promises");
48386
48424
  var import_node_crypto14 = require("crypto");
48387
- var import_node_path38 = require("path");
48425
+ var import_node_path39 = require("path");
48388
48426
  var DEFAULT_POLL_MS = 15 * 6e4;
48389
48427
  var MAX_FILES = 5e4;
48390
48428
  var MAX_FILE_BYTES = 64 * 1024 * 1024;
@@ -48399,8 +48437,8 @@ var READ_CHUNK_BYTES = 64 * 1024;
48399
48437
  var CANARY_CONTENT = "ThreatCrush file integrity canary v1\n";
48400
48438
  function fileIntegritySettings(section) {
48401
48439
  const safePath = (value) => {
48402
- if (typeof value !== "string" || !(0, import_node_path38.isAbsolute)(value) || value.split(import_node_path38.sep).includes("..")) return null;
48403
- const path2 = (0, import_node_path38.normalize)(value);
48440
+ if (typeof value !== "string" || !(0, import_node_path39.isAbsolute)(value) || value.split(import_node_path39.sep).includes("..")) return null;
48441
+ const path2 = (0, import_node_path39.normalize)(value);
48404
48442
  return path2 === "/" ? null : path2;
48405
48443
  };
48406
48444
  const strings = (values) => Array.isArray(values) ? [...new Set(values.map(safePath).filter((path2) => path2 !== null))] : [];
@@ -48429,7 +48467,7 @@ async function readState(path2) {
48429
48467
  }
48430
48468
  }
48431
48469
  async function writeState(path2, state) {
48432
- await (0, import_promises9.mkdir)((0, import_node_path38.dirname)(path2), { recursive: true, mode: 448 });
48470
+ await (0, import_promises9.mkdir)((0, import_node_path39.dirname)(path2), { recursive: true, mode: 448 });
48433
48471
  const temp = `${path2}.${process.pid}.${(0, import_node_crypto14.randomUUID)()}.tmp`;
48434
48472
  await (0, import_promises9.writeFile)(temp, JSON.stringify(state), { mode: 384 });
48435
48473
  await (0, import_promises9.rename)(temp, path2);
@@ -48459,10 +48497,10 @@ var OPEN_FILE_FLAGS = import_promises9.constants.O_RDONLY | import_promises9.con
48459
48497
  var OPEN_DIR_FLAGS = OPEN_FILE_FLAGS | import_promises9.constants.O_DIRECTORY;
48460
48498
  var CREATE_FILE_FLAGS = import_promises9.constants.O_WRONLY | import_promises9.constants.O_CREAT | import_promises9.constants.O_EXCL | import_promises9.constants.O_NOFOLLOW;
48461
48499
  function autoCanaryPath(directory) {
48462
- return (0, import_node_path38.join)(directory, ".threatcrush-canary");
48500
+ return (0, import_node_path39.join)(directory, ".threatcrush-canary");
48463
48501
  }
48464
48502
  async function openAbsoluteDirectory(path2) {
48465
- const parts = path2.split(import_node_path38.sep).filter((part) => part && part !== ".");
48503
+ const parts = path2.split(import_node_path39.sep).filter((part) => part && part !== ".");
48466
48504
  if (parts.includes("..")) throw new Error("invalid canary directory");
48467
48505
  let directory = await (0, import_promises9.open)("/", OPEN_DIR_FLAGS);
48468
48506
  try {
@@ -48485,9 +48523,9 @@ async function createAutoCanary(path2) {
48485
48523
  } catch (error2) {
48486
48524
  if (error2.code !== "ENOENT") return false;
48487
48525
  }
48488
- const directory = await openAbsoluteDirectory((0, import_node_path38.dirname)(path2));
48526
+ const directory = await openAbsoluteDirectory((0, import_node_path39.dirname)(path2));
48489
48527
  try {
48490
- const file = await (0, import_promises9.open)(`/proc/self/fd/${directory.fd}/${(0, import_node_path38.basename)(path2)}`, CREATE_FILE_FLAGS, 438);
48528
+ const file = await (0, import_promises9.open)(`/proc/self/fd/${directory.fd}/${(0, import_node_path39.basename)(path2)}`, CREATE_FILE_FLAGS, 438);
48491
48529
  try {
48492
48530
  await file.chmod(438);
48493
48531
  await file.writeFile(CANARY_CONTENT);
@@ -48504,7 +48542,7 @@ async function createAutoCanary(path2) {
48504
48542
  }
48505
48543
  }
48506
48544
  async function openAbsoluteTarget(path2) {
48507
- const parts = path2.split(import_node_path38.sep).filter((part) => part && part !== ".");
48545
+ const parts = path2.split(import_node_path39.sep).filter((part) => part && part !== ".");
48508
48546
  if (parts.length === 0 || parts.includes("..")) throw new Error("invalid file integrity path");
48509
48547
  let directory = await (0, import_promises9.open)("/", OPEN_DIR_FLAGS);
48510
48548
  try {
@@ -48539,7 +48577,7 @@ async function scanTargets(targets, canaries) {
48539
48577
  }
48540
48578
  let handle;
48541
48579
  try {
48542
- handle = parent ? await (0, import_promises9.open)(`/proc/self/fd/${parent.fd}/${path2.slice(path2.lastIndexOf(import_node_path38.sep) + 1)}`, OPEN_FILE_FLAGS) : await openAbsoluteTarget(path2);
48580
+ handle = parent ? await (0, import_promises9.open)(`/proc/self/fd/${parent.fd}/${path2.slice(path2.lastIndexOf(import_node_path39.sep) + 1)}`, OPEN_FILE_FLAGS) : await openAbsoluteTarget(path2);
48543
48581
  const stat = await handle.stat();
48544
48582
  if (stat.isDirectory()) {
48545
48583
  directories.push(path2);
@@ -48557,7 +48595,7 @@ async function scanTargets(targets, canaries) {
48557
48595
  return;
48558
48596
  }
48559
48597
  for (const entry of entries) {
48560
- await walk((0, import_node_path38.join)(path2, entry.name), handle);
48598
+ await walk((0, import_node_path39.join)(path2, entry.name), handle);
48561
48599
  if (!complete) return;
48562
48600
  }
48563
48601
  return;
@@ -48767,7 +48805,7 @@ var FileIntegrityWatch = class {
48767
48805
  if (current.complete) {
48768
48806
  const directories = new Set(current.directories);
48769
48807
  for (const path2 of Object.keys(current.files)) {
48770
- if (!directories.has(path2)) directories.add((0, import_node_path38.dirname)(path2));
48808
+ if (!directories.has(path2)) directories.add((0, import_node_path39.dirname)(path2));
48771
48809
  }
48772
48810
  this.refreshWatchers([...directories]);
48773
48811
  }
@@ -48877,7 +48915,7 @@ var FileIntegrityWatch = class {
48877
48915
 
48878
48916
  // src/daemon/workers/edr.ts
48879
48917
  var import_node_fs49 = require("fs");
48880
- var import_node_path39 = require("path");
48918
+ var import_node_path40 = require("path");
48881
48919
  var import_node_child_process15 = require("child_process");
48882
48920
  var DEFAULT_AUDIT_LOG = "/var/log/audit/audit.log";
48883
48921
  var DEFAULT_WEB_USERS = ["www-data", "nginx", "apache", "httpd", "caddy", "node"];
@@ -48895,8 +48933,8 @@ var SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "dash", "zsh", "ksh", "fish"
48895
48933
  var DOWNLOADERS = /* @__PURE__ */ new Set(["curl", "wget"]);
48896
48934
  var MINERS = /* @__PURE__ */ new Set(["xmrig", "minerd", "cpuminer", "cpuminer-multi", "kdevtmpfsi", "kinsing", "cryptonight"]);
48897
48935
  function safeAbsolutePath(value) {
48898
- if (typeof value !== "string" || !(0, import_node_path39.isAbsolute)(value) || value.split(import_node_path39.sep).includes("..")) return null;
48899
- const path2 = (0, import_node_path39.normalize)(value);
48936
+ if (typeof value !== "string" || !(0, import_node_path40.isAbsolute)(value) || value.split(import_node_path40.sep).includes("..")) return null;
48937
+ const path2 = (0, import_node_path40.normalize)(value);
48900
48938
  return path2 === "/" ? null : path2;
48901
48939
  }
48902
48940
  function edrSettings(section) {
@@ -48942,7 +48980,7 @@ function parseAuditRecord(line2) {
48942
48980
  serial: header2[2],
48943
48981
  key: fields.key,
48944
48982
  executable,
48945
- comm: fields.comm ?? (0, import_node_path39.basename)(executable),
48983
+ comm: fields.comm ?? (0, import_node_path40.basename)(executable),
48946
48984
  euid,
48947
48985
  ...Number.isInteger(pid) && pid > 0 ? { pid } : {},
48948
48986
  ...Number.isInteger(ppid) && ppid > 0 ? { ppid } : {}
@@ -48972,7 +49010,7 @@ function pathWithin(path2, root) {
48972
49010
  }
48973
49011
  function executableInWorldWritableDirectory(executable) {
48974
49012
  try {
48975
- return ((0, import_node_fs49.statSync)((0, import_node_path39.dirname)(executable)).mode & 2) !== 0;
49013
+ return ((0, import_node_fs49.statSync)((0, import_node_path40.dirname)(executable)).mode & 2) !== 0;
48976
49014
  } catch {
48977
49015
  return false;
48978
49016
  }
@@ -49058,7 +49096,7 @@ var EdrWatch = class {
49058
49096
  this.opts.bus.publish(event);
49059
49097
  }
49060
49098
  classify(execution) {
49061
- const name = (0, import_node_path39.basename)(execution.executable).toLowerCase();
49099
+ const name = (0, import_node_path40.basename)(execution.executable).toLowerCase();
49062
49100
  const account = this.usersById.get(execution.euid) ?? String(execution.euid);
49063
49101
  let severity;
49064
49102
  let ruleId;
@@ -49180,7 +49218,7 @@ var EdrWatch = class {
49180
49218
  let executable = (0, import_node_fs49.readlinkSync)(`${proc}/exe`);
49181
49219
  executable = executable.replace(/ \(deleted\)$/, "");
49182
49220
  if (!this.opts.settings.tempExecPaths.some((path2) => pathWithin(executable, path2))) continue;
49183
- const name = (0, import_node_path39.basename)(executable).toLowerCase();
49221
+ const name = (0, import_node_path40.basename)(executable).toLowerCase();
49184
49222
  if (MINERS.has(name)) continue;
49185
49223
  const key = `${pid}:${startTicks}`;
49186
49224
  const ticks = userTicks + systemTicks;
@@ -49217,7 +49255,7 @@ var EdrWatch = class {
49217
49255
 
49218
49256
  // src/daemon/workers/ssh-intrusion.ts
49219
49257
  var import_node_fs50 = require("fs");
49220
- var import_node_path40 = require("path");
49258
+ var import_node_path41 = require("path");
49221
49259
  var import_node_child_process16 = require("child_process");
49222
49260
 
49223
49261
  // src/core/asn.ts
@@ -49417,7 +49455,7 @@ function readJson2(path2) {
49417
49455
  }
49418
49456
  }
49419
49457
  function writeJson2(path2, value) {
49420
- (0, import_node_fs50.mkdirSync)((0, import_node_path40.dirname)(path2), { recursive: true });
49458
+ (0, import_node_fs50.mkdirSync)((0, import_node_path41.dirname)(path2), { recursive: true });
49421
49459
  (0, import_node_fs50.writeFileSync)(`${path2}.tmp`, JSON.stringify(value));
49422
49460
  (0, import_node_fs50.renameSync)(`${path2}.tmp`, path2);
49423
49461
  }
@@ -49791,7 +49829,7 @@ var LightningWatch = class {
49791
49829
 
49792
49830
  // src/core/tor-exits.ts
49793
49831
  var import_node_fs53 = require("fs");
49794
- var import_node_path41 = require("path");
49832
+ var import_node_path42 = require("path");
49795
49833
  var import_node_net15 = require("net");
49796
49834
  var TOR_BULK_EXIT_LIST_URL = "https://check.torproject.org/torbulkexitlist";
49797
49835
  function parseTorExitList(text) {
@@ -49894,7 +49932,7 @@ var TorExitList = class _TorExitList {
49894
49932
  const before2 = this.exits.size;
49895
49933
  this.load(parsed);
49896
49934
  try {
49897
- (0, import_node_fs53.mkdirSync)((0, import_node_path41.dirname)(this.opts.cachePath), { recursive: true });
49935
+ (0, import_node_fs53.mkdirSync)((0, import_node_path42.dirname)(this.opts.cachePath), { recursive: true });
49898
49936
  (0, import_node_fs53.writeFileSync)(`${this.opts.cachePath}.tmp`, [...parsed].join("\n") + "\n");
49899
49937
  (0, import_node_fs53.renameSync)(`${this.opts.cachePath}.tmp`, this.opts.cachePath);
49900
49938
  } catch (err) {
@@ -50118,7 +50156,7 @@ var RuleEngine = class {
50118
50156
 
50119
50157
  // src/daemon/rules/loader.ts
50120
50158
  var import_node_fs54 = require("fs");
50121
- var import_node_path42 = require("path");
50159
+ var import_node_path43 = require("path");
50122
50160
 
50123
50161
  // src/daemon/rules/default-rules.ts
50124
50162
  var AT_CRS_THRESHOLD = { field: "severity", operator: "regex", value: "^(high|critical)$" };
@@ -50767,7 +50805,7 @@ function loadAllRules(customDir) {
50767
50805
  const files = (0, import_node_fs54.readdirSync)(dir).filter((f) => f.endsWith(".json"));
50768
50806
  for (const file of files) {
50769
50807
  try {
50770
- const raw = (0, import_node_fs54.readFileSync)((0, import_node_path42.join)(dir, file), "utf-8");
50808
+ const raw = (0, import_node_fs54.readFileSync)((0, import_node_path43.join)(dir, file), "utf-8");
50771
50809
  const parsed = JSON.parse(raw);
50772
50810
  const customRules = Array.isArray(parsed) ? parsed : [parsed];
50773
50811
  for (const rule of customRules) {
@@ -50800,7 +50838,7 @@ function loadAllRules(customDir) {
50800
50838
  // src/daemon/firewall/adapters.ts
50801
50839
  var import_node_child_process17 = require("child_process");
50802
50840
  var import_node_fs55 = require("fs");
50803
- var import_node_path43 = require("path");
50841
+ var import_node_path44 = require("path");
50804
50842
  var import_node_net16 = require("net");
50805
50843
  function assertValidFirewallIp(ip) {
50806
50844
  if ((0, import_node_net16.isIP)(ip) !== 4) {
@@ -50813,7 +50851,7 @@ function assertBannableIp(ip) {
50813
50851
  }
50814
50852
  }
50815
50853
  function writeIfAbsent(path2, contents) {
50816
- (0, import_node_fs55.mkdirSync)((0, import_node_path43.dirname)(path2), { recursive: true });
50854
+ (0, import_node_fs55.mkdirSync)((0, import_node_path44.dirname)(path2), { recursive: true });
50817
50855
  try {
50818
50856
  (0, import_node_fs55.writeFileSync)(path2, contents, { flag: "wx" });
50819
50857
  } catch (err) {
@@ -51716,7 +51754,7 @@ init_backoff();
51716
51754
 
51717
51755
  // src/daemon/watchdog-service.ts
51718
51756
  var import_node_fs57 = require("fs");
51719
- var import_node_path44 = require("path");
51757
+ var import_node_path45 = require("path");
51720
51758
  function defaultShareGid() {
51721
51759
  const isRoot4 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
51722
51760
  if (!isRoot4) return void 0;
@@ -51727,7 +51765,7 @@ function defaultShareGid() {
51727
51765
  }
51728
51766
  }
51729
51767
  function startWatchdog(opts) {
51730
- const dir = opts.config?.dir ?? (0, import_node_path44.join)(opts.stateDir, WATCHDOG_DIRNAME);
51768
+ const dir = opts.config?.dir ?? (0, import_node_path45.join)(opts.stateDir, WATCHDOG_DIRNAME);
51731
51769
  const base = { dir, logged: 0, answered: 0, errored: 0 };
51732
51770
  if (opts.config?.enabled === false) {
51733
51771
  opts.log("[watchdog] off ([watchdog] enabled = false)");
@@ -51842,7 +51880,7 @@ function versionOfNode(path2) {
51842
51880
  // src/daemon/index.ts
51843
51881
  function readVersion2() {
51844
51882
  try {
51845
- const pkg = JSON.parse((0, import_node_fs58.readFileSync)((0, import_node_path45.join)(__dirname, "..", "package.json"), "utf-8"));
51883
+ const pkg = JSON.parse((0, import_node_fs58.readFileSync)((0, import_node_path46.join)(__dirname, "..", "package.json"), "utf-8"));
51846
51884
  return pkg.version || "0.0.0";
51847
51885
  } catch {
51848
51886
  return "0.0.0";
@@ -51851,7 +51889,7 @@ function readVersion2() {
51851
51889
  async function runHardeningChecks() {
51852
51890
  const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process20.execFile)(
51853
51891
  process.execPath,
51854
- [(0, import_node_path45.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
51892
+ [(0, import_node_path46.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
51855
51893
  { timeout: 12e4, maxBuffer: 4 * 1024 * 1024 }
51856
51894
  );
51857
51895
  const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
@@ -51865,7 +51903,7 @@ async function runHardeningChecks() {
51865
51903
  async function runPatchCheck() {
51866
51904
  const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process20.execFile)(
51867
51905
  process.execPath,
51868
- [(0, import_node_path45.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
51906
+ [(0, import_node_path46.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
51869
51907
  { timeout: 3e5, maxBuffer: 16 * 1024 * 1024 }
51870
51908
  );
51871
51909
  const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
@@ -51915,7 +51953,7 @@ async function runDaemon() {
51915
51953
  } catch (err) {
51916
51954
  logLine(`[daemon] state db unavailable: ${err.message}`);
51917
51955
  }
51918
- const loaded = loadDaemonConfig(PATHS.configFile, (0, import_node_path45.join)(PATHS.stateDir, "threatcrushd.conf.last-good"));
51956
+ const loaded = loadDaemonConfig(PATHS.configFile, (0, import_node_path46.join)(PATHS.stateDir, "threatcrushd.conf.last-good"));
51919
51957
  const config = loaded.config;
51920
51958
  if (loaded.error) {
51921
51959
  logLine(`[daemon] CONFIG ERROR: ${loaded.error}; ${loaded.usedLastGood ? "running on the last config that parsed" : "no earlier good copy, running on DEFAULTS (no protected list)"}`);
@@ -51986,7 +52024,7 @@ async function runDaemon() {
51986
52024
  const threatFeeds = new ThreatFeeds({
51987
52025
  settings: { ...feedSettings, allow: [...feedSettings.allow, ...remediation.getAllowlist()] },
51988
52026
  enforcing: !remediationStatus.dry_run && firewallAdapter.enforces !== false,
51989
- cachePath: (0, import_node_path45.join)(PATHS.stateDir, "threat-feeds.json"),
52027
+ cachePath: (0, import_node_path46.join)(PATHS.stateDir, "threat-feeds.json"),
51990
52028
  bus,
51991
52029
  log: logLine
51992
52030
  });
@@ -51994,9 +52032,9 @@ async function runDaemon() {
51994
52032
  const privilegeWatch = new PrivilegeWatch({
51995
52033
  settings: privilegeSettings(config.privileged),
51996
52034
  bus,
51997
- snapshotPath: (0, import_node_path45.join)(PATHS.stateDir, "privileges.json"),
51998
- loginsPath: (0, import_node_path45.join)(PATHS.stateDir, "login-countries.json"),
51999
- cursorPath: (0, import_node_path45.join)(PATHS.stateDir, "sudo-cursor.json"),
52035
+ snapshotPath: (0, import_node_path46.join)(PATHS.stateDir, "privileges.json"),
52036
+ loginsPath: (0, import_node_path46.join)(PATHS.stateDir, "login-countries.json"),
52037
+ cursorPath: (0, import_node_path46.join)(PATHS.stateDir, "sudo-cursor.json"),
52000
52038
  log: logLine
52001
52039
  });
52002
52040
  privilegeWatch.start();
@@ -52010,20 +52048,20 @@ async function runDaemon() {
52010
52048
  const fileIntegrity = new FileIntegrityWatch({
52011
52049
  bus,
52012
52050
  settings: fileIntegritySettings(config.file_integrity),
52013
- baselinePath: (0, import_node_path45.join)(PATHS.stateDir, "file-integrity-baseline.json"),
52014
- observedPath: (0, import_node_path45.join)(PATHS.stateDir, "file-integrity-observed.json"),
52051
+ baselinePath: (0, import_node_path46.join)(PATHS.stateDir, "file-integrity-baseline.json"),
52052
+ observedPath: (0, import_node_path46.join)(PATHS.stateDir, "file-integrity-observed.json"),
52015
52053
  log: logLine
52016
52054
  });
52017
52055
  fileIntegrity.start();
52018
52056
  const edr = new EdrWatch({
52019
52057
  bus,
52020
52058
  settings: edrSettings(config.edr),
52021
- networkBaselinePath: (0, import_node_path45.join)(PATHS.stateDir, "edr-outbound-executables.json"),
52059
+ networkBaselinePath: (0, import_node_path46.join)(PATHS.stateDir, "edr-outbound-executables.json"),
52022
52060
  log: logLine
52023
52061
  });
52024
52062
  edr.start();
52025
52063
  const torExits = new TorExitList({
52026
- cachePath: (0, import_node_path45.join)(PATHS.stateDir, "tor-exits.txt"),
52064
+ cachePath: (0, import_node_path46.join)(PATHS.stateDir, "tor-exits.txt"),
52027
52065
  url: config.remediation?.tor_exit_list_url,
52028
52066
  log: logLine
52029
52067
  });
@@ -52031,7 +52069,7 @@ async function runDaemon() {
52031
52069
  bus,
52032
52070
  manager: remediation,
52033
52071
  tor: torExits,
52034
- historyPath: (0, import_node_path45.join)(PATHS.stateDir, "key-logins.json"),
52072
+ historyPath: (0, import_node_path46.join)(PATHS.stateDir, "key-logins.json"),
52035
52073
  keyLoginWatch: config.privileged?.key_login_watch !== false,
52036
52074
  log: logLine
52037
52075
  });
@@ -52078,7 +52116,7 @@ async function runDaemon() {
52078
52116
  version,
52079
52117
  hostname: (0, import_node_os19.hostname)(),
52080
52118
  minSeverity,
52081
- spoolPath: (0, import_node_path45.join)(PATHS.stateDir, "cloud-spool.jsonl"),
52119
+ spoolPath: (0, import_node_path46.join)(PATHS.stateDir, "cloud-spool.jsonl"),
52082
52120
  log: logLine,
52083
52121
  ruleModules: new Set(ruleEngine.getRules().flatMap((rule) => rule.source_types)),
52084
52122
  runHardening: runHardeningChecks
@@ -52111,8 +52149,8 @@ async function runDaemon() {
52111
52149
  const autoUpdate = autoUpdateRef = new AutoUpdate({
52112
52150
  version,
52113
52151
  settings: updateSettings(config.update),
52114
- pkgRoot: (0, import_node_path45.join)(__dirname, ".."),
52115
- statePath: (0, import_node_path45.join)(PATHS.stateDir, "auto-update.json"),
52152
+ pkgRoot: (0, import_node_path46.join)(__dirname, ".."),
52153
+ statePath: (0, import_node_path46.join)(PATHS.stateDir, "auto-update.json"),
52116
52154
  bus,
52117
52155
  log: logLine,
52118
52156
  restartDaemon
@@ -52222,7 +52260,7 @@ var SYSTEM_SOCKET = "/var/run/threatcrush/threatcrushd.sock";
52222
52260
  function isRoot2() {
52223
52261
  return typeof process.getuid === "function" && process.getuid() === 0;
52224
52262
  }
52225
- var DAEMON_ENTRY = (0, import_node_path46.join)(__dirname, "daemon.js");
52263
+ var DAEMON_ENTRY = (0, import_node_path47.join)(__dirname, "daemon.js");
52226
52264
  async function daemonForeground() {
52227
52265
  await runDaemon();
52228
52266
  }
@@ -52354,12 +52392,12 @@ async function releaseStaleSocket() {
52354
52392
  // src/commands/service.ts
52355
52393
  var import_node_child_process22 = require("child_process");
52356
52394
  var import_node_fs61 = require("fs");
52357
- var import_node_path47 = require("path");
52395
+ var import_node_path48 = require("path");
52358
52396
  var import_node_os20 = require("os");
52359
52397
  var UNIT_PATH = "/etc/systemd/system/threatcrushd.service";
52360
52398
  var DAEMON_UNIT_NAME = "threatcrushd.service";
52361
52399
  function resolveTemplate() {
52362
- const templatePath = (0, import_node_path47.join)(__dirname, "systemd", "threatcrushd.service");
52400
+ const templatePath = (0, import_node_path48.join)(__dirname, "systemd", "threatcrushd.service");
52363
52401
  if (!(0, import_node_fs61.existsSync)(templatePath)) {
52364
52402
  throw new Error(`systemd unit template not found at ${templatePath}`);
52365
52403
  }
@@ -52434,9 +52472,9 @@ function callerHome() {
52434
52472
  function stopUserModeDaemon() {
52435
52473
  const home = callerHome();
52436
52474
  if (!home) return;
52437
- const runDir = (0, import_node_path47.join)(home, ".threatcrush", "run");
52438
- const pidFile = (0, import_node_path47.join)(runDir, "threatcrushd.pid");
52439
- const socket = (0, import_node_path47.join)(runDir, "threatcrushd.sock");
52475
+ const runDir = (0, import_node_path48.join)(home, ".threatcrush", "run");
52476
+ const pidFile = (0, import_node_path48.join)(runDir, "threatcrushd.pid");
52477
+ const socket = (0, import_node_path48.join)(runDir, "threatcrushd.sock");
52440
52478
  if (!(0, import_node_fs61.existsSync)(pidFile) && !(0, import_node_fs61.existsSync)(socket)) return;
52441
52479
  let pid = null;
52442
52480
  try {
@@ -52506,7 +52544,7 @@ async function installServiceCommand() {
52506
52544
  }
52507
52545
  }
52508
52546
  const exec = execStartCommand(binPath, nodePath, isNodeScript);
52509
- const configDir = (0, import_node_path47.join)((0, import_node_os20.homedir)(), ".threatcrush");
52547
+ const configDir = (0, import_node_path48.join)((0, import_node_os20.homedir)(), ".threatcrush");
52510
52548
  const commandHistoryEnabled = commandHistorySettings(loadConfig().command_history).enabled;
52511
52549
  const historyPaths = commandHistoryEnabled ? historyWritableHomes() : [];
52512
52550
  const unit = renderUnit(resolveTemplate(), { exec, binPath, configDir, historyPaths });
@@ -52563,7 +52601,7 @@ function renderLogrotate(logDir = "/var/log/threatcrush") {
52563
52601
  ].join("\n");
52564
52602
  }
52565
52603
  function installLogrotate() {
52566
- if (!(0, import_node_fs61.existsSync)((0, import_node_path47.dirname)(LOGROTATE_PATH))) return;
52604
+ if (!(0, import_node_fs61.existsSync)((0, import_node_path48.dirname)(LOGROTATE_PATH))) return;
52567
52605
  try {
52568
52606
  (0, import_node_fs61.writeFileSync)(LOGROTATE_PATH, renderLogrotate(), { mode: 420 });
52569
52607
  console.log(source_default.green(` \u2713 Log rotation: ${LOGROTATE_PATH} (daily or 200M, keeps 7)`));
@@ -52643,7 +52681,7 @@ async function uninstallServiceCommand() {
52643
52681
 
52644
52682
  // src/commands/save.ts
52645
52683
  var import_node_fs62 = require("fs");
52646
- var import_toml5 = __toESM(require_toml());
52684
+ var import_toml6 = __toESM(require_toml());
52647
52685
  init_cli_config();
52648
52686
  init_paths();
52649
52687
  var SECRET_KEY = /pass(word)?|secret|token|api_?key|private|webhook|dsn|url|routing_key|auth/i;
@@ -52683,7 +52721,7 @@ async function saveCommand(opts = {}) {
52683
52721
  let config = {};
52684
52722
  if ((0, import_node_fs62.existsSync)(path2)) {
52685
52723
  try {
52686
- config = import_toml5.default.parse((0, import_node_fs62.readFileSync)(path2, "utf-8"));
52724
+ config = import_toml6.default.parse((0, import_node_fs62.readFileSync)(path2, "utf-8"));
52687
52725
  } catch (err) {
52688
52726
  console.log(source_default.red(` \u2717 ${path2} is not valid TOML: ${err.message}
52689
52727
  `));
@@ -52797,7 +52835,7 @@ function welcomeCommand() {
52797
52835
 
52798
52836
  // src/commands/properties.ts
52799
52837
  var import_node_fs63 = require("fs");
52800
- var import_node_path48 = require("path");
52838
+ var import_node_path49 = require("path");
52801
52839
  var import_node_readline4 = __toESM(require("readline"));
52802
52840
  init_cli_config();
52803
52841
  var API_URL6 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
@@ -53127,7 +53165,7 @@ async function propertiesRunsCommand(opts) {
53127
53165
  }
53128
53166
  }
53129
53167
  function parseImportFile(path2) {
53130
- const ext = (0, import_node_path48.extname)(path2).toLowerCase();
53168
+ const ext = (0, import_node_path49.extname)(path2).toLowerCase();
53131
53169
  const raw = (0, import_node_fs63.readFileSync)(path2, "utf-8");
53132
53170
  if (ext === ".json") {
53133
53171
  const parsed = JSON.parse(raw);
@@ -54004,7 +54042,7 @@ async function hardenCommand(opts) {
54004
54042
 
54005
54043
  // src/core/patches/index.ts
54006
54044
  var import_node_fs66 = require("fs");
54007
- var import_node_path49 = require("path");
54045
+ var import_node_path50 = require("path");
54008
54046
  var import_node_child_process24 = require("child_process");
54009
54047
  var import_node_util5 = require("util");
54010
54048
 
@@ -54166,7 +54204,7 @@ function newestReleaseMtime(dir) {
54166
54204
  let newest = 0;
54167
54205
  for (const name of (0, import_node_fs66.readdirSync)(dir)) {
54168
54206
  if (!/Release$/.test(name)) continue;
54169
- newest = Math.max(newest, (0, import_node_fs66.statSync)((0, import_node_path49.join)(dir, name)).mtimeMs);
54207
+ newest = Math.max(newest, (0, import_node_fs66.statSync)((0, import_node_path50.join)(dir, name)).mtimeMs);
54170
54208
  }
54171
54209
  return newest > 0 ? new Date(newest) : null;
54172
54210
  } catch {
@@ -54410,13 +54448,13 @@ async function patchesCommand(opts) {
54410
54448
 
54411
54449
  // src/commands/feeds.ts
54412
54450
  var import_node_net18 = require("net");
54413
- var import_node_path51 = require("path");
54451
+ var import_node_path52 = require("path");
54414
54452
  init_paths();
54415
54453
 
54416
54454
  // src/commands/feeds-resolver.ts
54417
54455
  var import_node_child_process25 = require("child_process");
54418
54456
  var import_node_fs67 = require("fs");
54419
- var import_node_path50 = require("path");
54457
+ var import_node_path51 = require("path");
54420
54458
  var realIO = {
54421
54459
  exists: (p) => (0, import_node_fs67.existsSync)(p),
54422
54460
  read: (p) => {
@@ -54437,17 +54475,17 @@ var APPARMOR_LOCAL = "/etc/apparmor.d/local/usr.sbin.unbound";
54437
54475
  var APPARMOR_PROFILE = "/etc/apparmor.d/usr.sbin.unbound";
54438
54476
  function hookContent(resolver, stateDir) {
54439
54477
  const head2 = "# Installed by `threatcrush feeds resolver install`; `threatcrush feeds resolver remove` takes it out.\n";
54440
- return resolver === "dnsmasq" ? `${head2}addn-hosts=${(0, import_node_path50.join)(stateDir, RESOLVER_FILES.hosts)}
54441
- ` : `${head2}include: "${(0, import_node_path50.join)(stateDir, RESOLVER_FILES.unbound)}"
54478
+ return resolver === "dnsmasq" ? `${head2}addn-hosts=${(0, import_node_path51.join)(stateDir, RESOLVER_FILES.hosts)}
54479
+ ` : `${head2}include: "${(0, import_node_path51.join)(stateDir, RESOLVER_FILES.unbound)}"
54442
54480
  `;
54443
54481
  }
54444
54482
  function apparmorRule(stateDir) {
54445
- return ` ${(0, import_node_path50.join)(stateDir, RESOLVER_FILES.unbound)} r, # threatcrush`;
54483
+ return ` ${(0, import_node_path51.join)(stateDir, RESOLVER_FILES.unbound)} r, # threatcrush`;
54446
54484
  }
54447
54485
  function detectResolvers(io = realIO) {
54448
54486
  const found = [];
54449
- if (io.exists((0, import_node_path50.dirname)(RESOLVER_HOOKS.dnsmasq)) && io.run("dnsmasq", ["--version"]).code === 0) found.push("dnsmasq");
54450
- if (io.exists((0, import_node_path50.dirname)(RESOLVER_HOOKS.unbound)) && io.run("unbound-checkconf", ["-h"]).code !== 127) found.push("unbound");
54487
+ if (io.exists((0, import_node_path51.dirname)(RESOLVER_HOOKS.dnsmasq)) && io.run("dnsmasq", ["--version"]).code === 0) found.push("dnsmasq");
54488
+ if (io.exists((0, import_node_path51.dirname)(RESOLVER_HOOKS.unbound)) && io.run("unbound-checkconf", ["-h"]).code !== 127) found.push("unbound");
54451
54489
  return found;
54452
54490
  }
54453
54491
  function check(resolver, io) {
@@ -54460,7 +54498,7 @@ function restartIfActive(resolver, io) {
54460
54498
  }
54461
54499
  function installHook(resolver, stateDir, io = realIO) {
54462
54500
  const hook = RESOLVER_HOOKS[resolver];
54463
- const file = (0, import_node_path50.join)(stateDir, resolver === "dnsmasq" ? RESOLVER_FILES.hosts : RESOLVER_FILES.unbound);
54501
+ const file = (0, import_node_path51.join)(stateDir, resolver === "dnsmasq" ? RESOLVER_FILES.hosts : RESOLVER_FILES.unbound);
54464
54502
  if (!io.exists(file)) io.write(file, resolver === "dnsmasq" ? hostsBlocklist([]) : unboundBlocklist([]));
54465
54503
  io.write(hook, hookContent(resolver, stateDir));
54466
54504
  if (resolver === "unbound" && io.exists(APPARMOR_LOCAL)) {
@@ -54521,8 +54559,8 @@ function resolverCommand(sub, stateDir, io = realIO) {
54521
54559
  }
54522
54560
  return failed ? 1 : 0;
54523
54561
  }
54524
- const hosts = io.read((0, import_node_path50.join)(stateDir, RESOLVER_FILES.hosts));
54525
- const unbound = io.read((0, import_node_path50.join)(stateDir, RESOLVER_FILES.unbound));
54562
+ const hosts = io.read((0, import_node_path51.join)(stateDir, RESOLVER_FILES.hosts));
54563
+ const unbound = io.read((0, import_node_path51.join)(stateDir, RESOLVER_FILES.unbound));
54526
54564
  console.log(` resolvers here: ${found.join(", ") || "none that can block (systemd-resolved only?)"}`);
54527
54565
  for (const r of ["dnsmasq", "unbound"]) {
54528
54566
  console.log(` ${r.padEnd(8)} hook ${io.exists(RESOLVER_HOOKS[r]) ? source_default.green("installed") : source_default.gray("not installed")}`);
@@ -54534,11 +54572,11 @@ function resolverCommand(sub, stateDir, io = realIO) {
54534
54572
  // src/commands/feeds.ts
54535
54573
  async function loadSet() {
54536
54574
  for (const dir of [SYSTEM_PATHS.stateDir, USER_PATHS.stateDir]) {
54537
- const path2 = (0, import_node_path51.join)(dir, "threat-feeds.json");
54575
+ const path2 = (0, import_node_path52.join)(dir, "threat-feeds.json");
54538
54576
  const set = readFeedCache(path2);
54539
54577
  if (set) return { set, from: path2 };
54540
54578
  }
54541
- const settings = threatFeedSettings(loadConfig((0, import_node_path51.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).threat_feeds);
54579
+ const settings = threatFeedSettings(loadConfig((0, import_node_path52.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).threat_feeds);
54542
54580
  return { set: await fetchFeeds(settings), from: "abuse.ch (live; no daemon cache readable)" };
54543
54581
  }
54544
54582
  async function feedsCommand(action, value, opts) {
@@ -54584,14 +54622,14 @@ async function feedsCommand(action, value, opts) {
54584
54622
  // src/commands/tor.ts
54585
54623
  var import_node_fs68 = require("fs");
54586
54624
  var import_node_net19 = require("net");
54587
- var import_node_path52 = require("path");
54625
+ var import_node_path53 = require("path");
54588
54626
  init_paths();
54589
54627
  async function torCommand(action, value, opts) {
54590
54628
  let exits = /* @__PURE__ */ new Set();
54591
54629
  let from = "";
54592
54630
  let updated = null;
54593
54631
  for (const dir of [SYSTEM_PATHS.stateDir, USER_PATHS.stateDir]) {
54594
- const path2 = (0, import_node_path52.join)(dir, "tor-exits.txt");
54632
+ const path2 = (0, import_node_path53.join)(dir, "tor-exits.txt");
54595
54633
  try {
54596
54634
  if (!(0, import_node_fs68.existsSync)(path2)) continue;
54597
54635
  exits = parseTorExitList((0, import_node_fs68.readFileSync)(path2, "utf-8"));
@@ -54612,7 +54650,7 @@ async function torCommand(action, value, opts) {
54612
54650
  } catch {
54613
54651
  }
54614
54652
  }
54615
- const remediation = loadConfig((0, import_node_path52.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).remediation;
54653
+ const remediation = loadConfig((0, import_node_path53.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).remediation;
54616
54654
  const ban = remediation?.block_tor_ssh !== false && remediation?.enabled !== false;
54617
54655
  if (action === "check") {
54618
54656
  if (!value || !(0, import_node_net19.isIP)(value)) {
@@ -54645,9 +54683,9 @@ async function torCommand(action, value, opts) {
54645
54683
  // src/commands/reputation.ts
54646
54684
  var import_node_os22 = require("os");
54647
54685
  var import_node_fs69 = require("fs");
54648
- var import_node_path53 = require("path");
54686
+ var import_node_path54 = require("path");
54649
54687
  var API_URL7 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
54650
- var CONFIG_PATH4 = (0, import_node_path53.join)((0, import_node_os22.homedir)(), ".threatcrush", "config.json");
54688
+ var CONFIG_PATH4 = (0, import_node_path54.join)((0, import_node_os22.homedir)(), ".threatcrush", "config.json");
54651
54689
  function readConfig3() {
54652
54690
  try {
54653
54691
  return JSON.parse((0, import_node_fs69.readFileSync)(CONFIG_PATH4, "utf-8"));
@@ -54906,7 +54944,7 @@ async function privilegedCommand(opts) {
54906
54944
 
54907
54945
  // src/commands/integrity.ts
54908
54946
  var import_node_fs71 = require("fs");
54909
- var import_node_path54 = require("path");
54947
+ var import_node_path55 = require("path");
54910
54948
  init_paths();
54911
54949
  function readState2(path2) {
54912
54950
  try {
@@ -54930,11 +54968,11 @@ function changedCount(baseline, observed) {
54930
54968
  async function integrityCommand(action = "status", opts = {}) {
54931
54969
  const config = loadConfig();
54932
54970
  const settings = fileIntegritySettings(config.file_integrity);
54933
- const systemBaseline = (0, import_node_path54.join)(SYSTEM_PATHS.stateDir, "file-integrity-baseline.json");
54971
+ const systemBaseline = (0, import_node_path55.join)(SYSTEM_PATHS.stateDir, "file-integrity-baseline.json");
54934
54972
  const useSystemState = PATHS.mode === "system" || systemDaemonPresent() || (0, import_node_fs71.existsSync)(systemBaseline);
54935
54973
  const stateDir = useSystemState ? SYSTEM_PATHS.stateDir : PATHS.stateDir;
54936
- const baselinePath = (0, import_node_path54.join)(stateDir, "file-integrity-baseline.json");
54937
- const observedPath = (0, import_node_path54.join)(stateDir, "file-integrity-observed.json");
54974
+ const baselinePath = (0, import_node_path55.join)(stateDir, "file-integrity-baseline.json");
54975
+ const observedPath = (0, import_node_path55.join)(stateDir, "file-integrity-observed.json");
54938
54976
  if (action === "rebaseline") {
54939
54977
  const watch4 = new FileIntegrityWatch({
54940
54978
  bus: { publish: () => void 0 },
@@ -55008,7 +55046,7 @@ init_paths();
55008
55046
  // src/daemon/auditd/rules.ts
55009
55047
  var import_node_fs72 = require("fs");
55010
55048
  var import_node_child_process26 = require("child_process");
55011
- var import_node_path55 = require("path");
55049
+ var import_node_path56 = require("path");
55012
55050
  var WEB_TOOLS = ["sh", "bash", "dash", "zsh", "curl", "wget"];
55013
55051
  var MINER_NAMES = ["xmrig", "minerd", "cpuminer", "cpuminer-multi", "kdevtmpfsi", "kinsing", "cryptonight"];
55014
55052
  var CONNECT_KEY2 = "threatcrush_edr_connect";
@@ -55048,7 +55086,7 @@ function existingExecutables(names) {
55048
55086
  }
55049
55087
  function existingDirectories(paths) {
55050
55088
  return [...new Set(paths)].filter((path2) => {
55051
- if (!(0, import_node_path55.isAbsolute)(path2) || /[\s\r\n]/.test(path2)) return false;
55089
+ if (!(0, import_node_path56.isAbsolute)(path2) || /[\s\r\n]/.test(path2)) return false;
55052
55090
  try {
55053
55091
  return (0, import_node_fs72.statSync)(path2).isDirectory();
55054
55092
  } catch {
@@ -55528,7 +55566,7 @@ function installUserAgent(target = globalThis) {
55528
55566
  // src/core/cloud-upload.ts
55529
55567
  var import_node_child_process28 = require("child_process");
55530
55568
  var import_node_os23 = require("os");
55531
- var import_node_path56 = require("path");
55569
+ var import_node_path57 = require("path");
55532
55570
  init_cli_config();
55533
55571
  function uploadDisabled(upload, env3 = process.env) {
55534
55572
  if (upload === false) return true;
@@ -55547,8 +55585,8 @@ function cleanUrl(raw) {
55547
55585
  return raw.split(/[?#]/)[0];
55548
55586
  }
55549
55587
  }
55550
- function repoTarget(path2, run2 = (args) => (0, import_node_child_process28.execFileSync)("git", args, { cwd: (0, import_node_path56.resolve)(path2), encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5e3 }).trim()) {
55551
- const abs = (0, import_node_path56.resolve)(path2);
55588
+ function repoTarget(path2, run2 = (args) => (0, import_node_child_process28.execFileSync)("git", args, { cwd: (0, import_node_path57.resolve)(path2), encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5e3 }).trim()) {
55589
+ const abs = (0, import_node_path57.resolve)(path2);
55552
55590
  try {
55553
55591
  const root = run2(["rev-parse", "--show-toplevel"]);
55554
55592
  const sub = abs === root ? "." : abs.slice(root.length + 1);
@@ -55920,7 +55958,7 @@ ${source_default.dim(" C R U S H")}
55920
55958
  var API_URL8 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
55921
55959
  var PKG_NAME2 = "@profullstack/threatcrush";
55922
55960
  var DESKTOP_PKG_NAME = "@profullstack/threatcrush-desktop";
55923
- var INSTALL_CONFIG_PATH = (0, import_node_path57.join)((0, import_node_os24.homedir)(), ".threatcrush", "install.json");
55961
+ var INSTALL_CONFIG_PATH = (0, import_node_path58.join)((0, import_node_os24.homedir)(), ".threatcrush", "install.json");
55924
55962
  function detectPackageManager() {
55925
55963
  try {
55926
55964
  const npmGlobal = (0, import_node_child_process29.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
@@ -56550,7 +56588,7 @@ storeCmd.command("search <query>").description("Search for modules in the store"
56550
56588
  });
56551
56589
  storeCmd.command("publish <url>").description("Publish a module from a git URL or web URL").action(async (url) => {
56552
56590
  console.log(LOGO2);
56553
- const configPath = (0, import_node_path57.join)((0, import_node_os24.homedir)(), ".threatcrush", "config.json");
56591
+ const configPath = (0, import_node_path58.join)((0, import_node_os24.homedir)(), ".threatcrush", "config.json");
56554
56592
  let email = "";
56555
56593
  try {
56556
56594
  const config = JSON.parse((0, import_node_fs75.readFileSync)(configPath, "utf-8"));
@@ -56570,7 +56608,7 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
56570
56608
  return;
56571
56609
  }
56572
56610
  try {
56573
- const dir = (0, import_node_path57.join)((0, import_node_os24.homedir)(), ".threatcrush");
56611
+ const dir = (0, import_node_path58.join)((0, import_node_os24.homedir)(), ".threatcrush");
56574
56612
  if (!(0, import_node_fs75.existsSync)(dir)) (0, import_node_fs75.mkdirSync)(dir, { recursive: true });
56575
56613
  (0, import_node_fs75.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
56576
56614
  console.log(source_default.dim(` Saved email to ${configPath}`));