@profullstack/threatcrush 0.11.6 → 0.11.8

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
@@ -7316,27 +7316,27 @@ function isRoot() {
7316
7316
  return process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
7317
7317
  }
7318
7318
  function resolveClientSocket() {
7319
- if ((0, import_node_fs.existsSync)(PATHS.socket)) return PATHS.socket;
7319
+ if ((0, import_node_fs2.existsSync)(PATHS.socket)) return PATHS.socket;
7320
7320
  const other = PATHS.mode === "system" ? USER_PATHS.socket : SYSTEM_PATHS.socket;
7321
- if ((0, import_node_fs.existsSync)(other)) return other;
7321
+ if ((0, import_node_fs2.existsSync)(other)) return other;
7322
7322
  return PATHS.socket;
7323
7323
  }
7324
7324
  function ensureRuntimeDirs() {
7325
7325
  for (const dir of [PATHS.configDir, PATHS.confD, PATHS.moduleDir, PATHS.logDir, PATHS.stateDir, PATHS.runDir]) {
7326
7326
  try {
7327
- (0, import_node_fs.mkdirSync)(dir, { recursive: true });
7327
+ (0, import_node_fs2.mkdirSync)(dir, { recursive: true });
7328
7328
  } catch {
7329
7329
  }
7330
7330
  }
7331
7331
  }
7332
- var import_node_fs, import_node_os2, import_node_path, userBase, SYSTEM_PATHS, USER_PATHS, PATHS;
7332
+ var import_node_fs2, import_node_os2, import_node_path2, userBase, SYSTEM_PATHS, USER_PATHS, PATHS;
7333
7333
  var init_paths = __esm({
7334
7334
  "src/daemon/paths.ts"() {
7335
7335
  "use strict";
7336
- import_node_fs = require("fs");
7336
+ import_node_fs2 = require("fs");
7337
7337
  import_node_os2 = require("os");
7338
- import_node_path = require("path");
7339
- userBase = (0, import_node_path.join)((0, import_node_os2.homedir)(), ".threatcrush");
7338
+ import_node_path2 = require("path");
7339
+ userBase = (0, import_node_path2.join)((0, import_node_os2.homedir)(), ".threatcrush");
7340
7340
  SYSTEM_PATHS = {
7341
7341
  mode: "system",
7342
7342
  configDir: "/etc/threatcrush",
@@ -7354,16 +7354,16 @@ var init_paths = __esm({
7354
7354
  USER_PATHS = {
7355
7355
  mode: "user",
7356
7356
  configDir: userBase,
7357
- configFile: (0, import_node_path.join)(userBase, "threatcrushd.conf"),
7358
- confD: (0, import_node_path.join)(userBase, "threatcrushd.conf.d"),
7359
- moduleDir: (0, import_node_path.join)(userBase, "modules"),
7360
- logDir: (0, import_node_path.join)(userBase, "logs"),
7361
- logFile: (0, import_node_path.join)(userBase, "logs", "threatcrushd.log"),
7362
- stateDir: (0, import_node_path.join)(userBase, "state"),
7363
- stateDb: (0, import_node_path.join)(userBase, "state", "state.db"),
7364
- runDir: (0, import_node_path.join)(userBase, "run"),
7365
- pidFile: (0, import_node_path.join)(userBase, "run", "threatcrushd.pid"),
7366
- socket: (0, import_node_path.join)(userBase, "run", "threatcrushd.sock")
7357
+ configFile: (0, import_node_path2.join)(userBase, "threatcrushd.conf"),
7358
+ confD: (0, import_node_path2.join)(userBase, "threatcrushd.conf.d"),
7359
+ moduleDir: (0, import_node_path2.join)(userBase, "modules"),
7360
+ logDir: (0, import_node_path2.join)(userBase, "logs"),
7361
+ logFile: (0, import_node_path2.join)(userBase, "logs", "threatcrushd.log"),
7362
+ stateDir: (0, import_node_path2.join)(userBase, "state"),
7363
+ stateDb: (0, import_node_path2.join)(userBase, "state", "state.db"),
7364
+ runDir: (0, import_node_path2.join)(userBase, "run"),
7365
+ pidFile: (0, import_node_path2.join)(userBase, "run", "threatcrushd.pid"),
7366
+ socket: (0, import_node_path2.join)(userBase, "run", "threatcrushd.sock")
7367
7367
  };
7368
7368
  PATHS = isRoot() ? SYSTEM_PATHS : USER_PATHS;
7369
7369
  }
@@ -7372,17 +7372,17 @@ var init_paths = __esm({
7372
7372
  // src/daemon/control-token.ts
7373
7373
  function issueControlToken() {
7374
7374
  const token = (0, import_node_crypto.randomBytes)(32).toString("hex");
7375
- (0, import_node_fs2.writeFileSync)(CONTROL_TOKEN_FILE, token, { mode: 384 });
7375
+ (0, import_node_fs3.writeFileSync)(CONTROL_TOKEN_FILE, token, { mode: 384 });
7376
7376
  try {
7377
- (0, import_node_fs2.chmodSync)(CONTROL_TOKEN_FILE, 384);
7377
+ (0, import_node_fs3.chmodSync)(CONTROL_TOKEN_FILE, 384);
7378
7378
  } catch {
7379
7379
  }
7380
7380
  return token;
7381
7381
  }
7382
7382
  function readControlToken() {
7383
- if (!(0, import_node_fs2.existsSync)(CONTROL_TOKEN_FILE)) return null;
7383
+ if (!(0, import_node_fs3.existsSync)(CONTROL_TOKEN_FILE)) return null;
7384
7384
  try {
7385
- const token = (0, import_node_fs2.readFileSync)(CONTROL_TOKEN_FILE, "utf-8").trim();
7385
+ const token = (0, import_node_fs3.readFileSync)(CONTROL_TOKEN_FILE, "utf-8").trim();
7386
7386
  return token || null;
7387
7387
  } catch {
7388
7388
  return null;
@@ -7394,25 +7394,25 @@ function tokensMatch(expected, provided) {
7394
7394
  const b = Buffer.from(provided);
7395
7395
  return a.length === b.length && (0, import_node_crypto.timingSafeEqual)(a, b);
7396
7396
  }
7397
- var import_node_crypto, import_node_fs2, import_node_path2, CONTROL_TOKEN_FILE;
7397
+ var import_node_crypto, import_node_fs3, import_node_path3, CONTROL_TOKEN_FILE;
7398
7398
  var init_control_token = __esm({
7399
7399
  "src/daemon/control-token.ts"() {
7400
7400
  "use strict";
7401
7401
  import_node_crypto = require("crypto");
7402
- import_node_fs2 = require("fs");
7403
- import_node_path2 = require("path");
7402
+ import_node_fs3 = require("fs");
7403
+ import_node_path3 = require("path");
7404
7404
  init_paths();
7405
- CONTROL_TOKEN_FILE = (0, import_node_path2.join)(PATHS.runDir, "control.token");
7405
+ CONTROL_TOKEN_FILE = (0, import_node_path3.join)(PATHS.runDir, "control.token");
7406
7406
  }
7407
7407
  });
7408
7408
 
7409
7409
  // src/core/ipc-client.ts
7410
- var import_node_net, import_node_fs3, IpcClient;
7410
+ var import_node_net, import_node_fs4, IpcClient;
7411
7411
  var init_ipc_client = __esm({
7412
7412
  "src/core/ipc-client.ts"() {
7413
7413
  "use strict";
7414
7414
  import_node_net = require("net");
7415
- import_node_fs3 = require("fs");
7415
+ import_node_fs4 = require("fs");
7416
7416
  init_paths();
7417
7417
  init_control_token();
7418
7418
  IpcClient = class {
@@ -7427,10 +7427,10 @@ var init_ipc_client = __esm({
7427
7427
  pending = /* @__PURE__ */ new Map();
7428
7428
  socketPath;
7429
7429
  static isDaemonRunning(socketPath = resolveClientSocket()) {
7430
- return (0, import_node_fs3.existsSync)(socketPath);
7430
+ return (0, import_node_fs4.existsSync)(socketPath);
7431
7431
  }
7432
7432
  async connect(timeoutMs = 2e3) {
7433
- if (!(0, import_node_fs3.existsSync)(this.socketPath)) {
7433
+ if (!(0, import_node_fs4.existsSync)(this.socketPath)) {
7434
7434
  throw new Error(`threatcrushd socket not found at ${this.socketPath}`);
7435
7435
  }
7436
7436
  return new Promise((resolve5, reject) => {
@@ -12338,14 +12338,30 @@ var source_default = chalk;
12338
12338
  // src/index.ts
12339
12339
  var import_readline = __toESM(require("readline"));
12340
12340
  var import_node_child_process11 = require("child_process");
12341
- var import_node_fs31 = require("fs");
12342
- var import_node_path21 = require("path");
12341
+ var import_node_fs32 = require("fs");
12342
+ var import_node_path22 = require("path");
12343
12343
  var import_node_os8 = require("os");
12344
12344
 
12345
12345
  // src/commands/monitor.ts
12346
- var import_node_fs4 = require("fs");
12346
+ var import_node_fs5 = require("fs");
12347
12347
  var import_node_readline = require("readline");
12348
12348
 
12349
+ // src/core/version.ts
12350
+ var import_node_fs = require("fs");
12351
+ var import_node_path = require("path");
12352
+ var FALLBACK_VERSION = "0.0.0";
12353
+ function readPackageVersion() {
12354
+ try {
12355
+ const pkg = JSON.parse(
12356
+ (0, import_node_fs.readFileSync)((0, import_node_path.join)(__dirname, "..", "package.json"), "utf-8")
12357
+ );
12358
+ return pkg.version || FALLBACK_VERSION;
12359
+ } catch {
12360
+ return FALLBACK_VERSION;
12361
+ }
12362
+ }
12363
+ var PKG_VERSION = readPackageVersion();
12364
+
12349
12365
  // src/core/logger.ts
12350
12366
  var SEVERITY_COLORS = {
12351
12367
  info: source_default.green,
@@ -12393,7 +12409,8 @@ function banner() {
12393
12409
  \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551
12394
12410
  \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
12395
12411
  `));
12396
- console.log(source_default.gray(" All-in-one security agent daemon \u2014 v0.1.0\n"));
12412
+ console.log(source_default.gray(` All-in-one security agent daemon \u2014 v${PKG_VERSION}
12413
+ `));
12397
12414
  }
12398
12415
 
12399
12416
  // src/core/log-parser.ts
@@ -12705,9 +12722,9 @@ async function monitorCommand(options) {
12705
12722
  const unreadable = [];
12706
12723
  for (const s of LOG_SOURCES) {
12707
12724
  if (moduleFilter && !moduleFilter.includes(s.name)) continue;
12708
- if (!(0, import_node_fs4.existsSync)(s.path)) continue;
12725
+ if (!(0, import_node_fs5.existsSync)(s.path)) continue;
12709
12726
  try {
12710
- (0, import_node_fs4.accessSync)(s.path, import_node_fs4.constants.R_OK);
12727
+ (0, import_node_fs5.accessSync)(s.path, import_node_fs5.constants.R_OK);
12711
12728
  availableSources.push(s);
12712
12729
  } catch {
12713
12730
  unreadable.push(s);
@@ -12724,11 +12741,11 @@ async function monitorCommand(options) {
12724
12741
  logger.warn("No readable log files found to monitor.");
12725
12742
  logger.info("Available log paths checked:");
12726
12743
  for (const s of LOG_SOURCES) {
12727
- const exists = (0, import_node_fs4.existsSync)(s.path);
12744
+ const exists = (0, import_node_fs5.existsSync)(s.path);
12728
12745
  let readable = false;
12729
12746
  if (exists) {
12730
12747
  try {
12731
- (0, import_node_fs4.accessSync)(s.path, import_node_fs4.constants.R_OK);
12748
+ (0, import_node_fs5.accessSync)(s.path, import_node_fs5.constants.R_OK);
12732
12749
  readable = true;
12733
12750
  } catch {
12734
12751
  readable = false;
@@ -12760,16 +12777,16 @@ async function monitorCommand(options) {
12760
12777
  }
12761
12778
  function tailLog(source) {
12762
12779
  const { path, name, category } = source;
12763
- const stat = (0, import_node_fs4.statSync)(path);
12780
+ const stat = (0, import_node_fs5.statSync)(path);
12764
12781
  let position = stat.size;
12765
12782
  const checkForNewData = () => {
12766
12783
  try {
12767
- const currentStat = (0, import_node_fs4.statSync)(path);
12784
+ const currentStat = (0, import_node_fs5.statSync)(path);
12768
12785
  if (currentStat.size <= position) {
12769
12786
  if (currentStat.size < position) position = 0;
12770
12787
  return;
12771
12788
  }
12772
- const stream = (0, import_node_fs4.createReadStream)(path, { start: position, encoding: "utf-8" });
12789
+ const stream = (0, import_node_fs5.createReadStream)(path, { start: position, encoding: "utf-8" });
12773
12790
  stream.on("error", (err) => {
12774
12791
  logger.warn(`stopped tailing ${path}: ${err.code || err.message}`);
12775
12792
  position = currentStat.size;
@@ -12871,8 +12888,8 @@ async function runDemoMode() {
12871
12888
  }
12872
12889
 
12873
12890
  // src/commands/scan.ts
12874
- var import_node_fs7 = require("fs");
12875
- var import_node_path6 = require("path");
12891
+ var import_node_fs8 = require("fs");
12892
+ var import_node_path7 = require("path");
12876
12893
 
12877
12894
  // ../../node_modules/.pnpm/ora@8.2.0/node_modules/ora/index.js
12878
12895
  var import_node_process7 = __toESM(require("process"), 1);
@@ -16580,8 +16597,8 @@ function meetsFailThreshold(findings, threshold) {
16580
16597
  }
16581
16598
 
16582
16599
  // ../../packages/scan/src/node/walk.ts
16583
- var import_node_fs5 = require("fs");
16584
- var import_node_path3 = require("path");
16600
+ var import_node_fs6 = require("fs");
16601
+ var import_node_path4 = require("path");
16585
16602
  function compileExcludes(patterns) {
16586
16603
  const matchers = patterns.map((p) => p.trim()).filter((p) => p.length > 0 && !p.startsWith("#")).map(compilePattern);
16587
16604
  if (matchers.length === 0) return () => false;
@@ -16652,7 +16669,7 @@ function matchPrefix(parts, segs) {
16652
16669
  }
16653
16670
  function readIgnoreFile(root) {
16654
16671
  try {
16655
- return (0, import_node_fs5.readFileSync)((0, import_node_path3.join)(root, ".threatcrushignore"), "utf-8").split("\n");
16672
+ return (0, import_node_fs6.readFileSync)((0, import_node_path4.join)(root, ".threatcrushignore"), "utf-8").split("\n");
16656
16673
  } catch {
16657
16674
  return [];
16658
16675
  }
@@ -16668,16 +16685,16 @@ function scanPath(targetPath, options = {}) {
16668
16685
  let excluded = 0;
16669
16686
  const rootIsDirectory = (() => {
16670
16687
  try {
16671
- return (0, import_node_fs5.statSync)(targetPath).isDirectory();
16688
+ return (0, import_node_fs6.statSync)(targetPath).isDirectory();
16672
16689
  } catch {
16673
16690
  return true;
16674
16691
  }
16675
16692
  })();
16676
- const walkRoot = rootIsDirectory ? targetPath : (0, import_node_path3.dirname)(targetPath);
16693
+ const walkRoot = rootIsDirectory ? targetPath : (0, import_node_path4.dirname)(targetPath);
16677
16694
  const isExcluded = compileExcludes([...options.exclude ?? [], ...readIgnoreFile(walkRoot)]);
16678
16695
  const scanFile = (fullPath, filename) => {
16679
16696
  const relativePath = toRelative(walkRoot, fullPath);
16680
- const extension = (0, import_node_path3.extname)(filename).toLowerCase();
16697
+ const extension = (0, import_node_path4.extname)(filename).toLowerCase();
16681
16698
  const isManifest = filename === "package.json" || filename === "requirements.txt";
16682
16699
  const scannable = SCAN_EXTENSIONS.has(extension) || filename.startsWith(".env");
16683
16700
  const mayDeclareInterpreter = !scannable && !isManifest && extension === "";
@@ -16689,26 +16706,26 @@ function scanPath(targetPath, options = {}) {
16689
16706
  let handle;
16690
16707
  let declared = null;
16691
16708
  try {
16692
- handle = (0, import_node_fs5.openSync)(fullPath, "r");
16709
+ handle = (0, import_node_fs6.openSync)(fullPath, "r");
16693
16710
  } catch {
16694
16711
  unreadable.push(relativePath);
16695
16712
  return;
16696
16713
  }
16697
16714
  try {
16698
- if ((0, import_node_fs5.fstatSync)(handle).size > maxFileBytes) return;
16715
+ if ((0, import_node_fs6.fstatSync)(handle).size > maxFileBytes) return;
16699
16716
  if (mayDeclareInterpreter) {
16700
16717
  const prefix = Buffer.alloc(128);
16701
- const read = (0, import_node_fs5.readSync)(handle, prefix, 0, prefix.length, 0);
16718
+ const read = (0, import_node_fs6.readSync)(handle, prefix, 0, prefix.length, 0);
16702
16719
  declared = languageOfShebang(prefix.subarray(0, read).toString("utf-8").split("\n", 1)[0] ?? "");
16703
16720
  if (!declared) return;
16704
16721
  }
16705
- text = (0, import_node_fs5.readFileSync)(handle, "utf-8");
16722
+ text = (0, import_node_fs6.readFileSync)(handle, "utf-8");
16706
16723
  } catch {
16707
16724
  unreadable.push(relativePath);
16708
16725
  return;
16709
16726
  } finally {
16710
16727
  try {
16711
- (0, import_node_fs5.closeSync)(handle);
16728
+ (0, import_node_fs6.closeSync)(handle);
16712
16729
  } catch {
16713
16730
  }
16714
16731
  }
@@ -16726,13 +16743,13 @@ function scanPath(targetPath, options = {}) {
16726
16743
  const walk = (currentPath) => {
16727
16744
  let entries;
16728
16745
  try {
16729
- entries = (0, import_node_fs5.readdirSync)(currentPath, { withFileTypes: true });
16746
+ entries = (0, import_node_fs6.readdirSync)(currentPath, { withFileTypes: true });
16730
16747
  } catch {
16731
16748
  unreadable.push(toRelative(walkRoot, currentPath));
16732
16749
  return;
16733
16750
  }
16734
16751
  for (const entry of entries) {
16735
- const fullPath = (0, import_node_path3.join)(currentPath, entry.name);
16752
+ const fullPath = (0, import_node_path4.join)(currentPath, entry.name);
16736
16753
  const relativePath = toRelative(walkRoot, fullPath);
16737
16754
  if (entry.isDirectory()) {
16738
16755
  if (SKIP_DIRS.has(entry.name)) continue;
@@ -16756,7 +16773,7 @@ function scanPath(targetPath, options = {}) {
16756
16773
  } else if (isExcluded(toRelative(walkRoot, targetPath))) {
16757
16774
  excluded += 1;
16758
16775
  } else {
16759
- scanFile(targetPath, (0, import_node_path3.basename)(targetPath));
16776
+ scanFile(targetPath, (0, import_node_path4.basename)(targetPath));
16760
16777
  }
16761
16778
  if (options.missingControls) findings.push(...controls.findings());
16762
16779
  const filtered = allowed ? findings.filter((f) => allowed.has(f.category)) : findings;
@@ -16788,22 +16805,22 @@ function recordSensitiveFile(filename, relativePath, sink, fileFindings) {
16788
16805
  }
16789
16806
  }
16790
16807
  function toRelative(base, target) {
16791
- const rel = (0, import_node_path3.relative)(base, target);
16792
- return (rel === "" ? target : rel).split(import_node_path3.sep).join("/");
16808
+ const rel = (0, import_node_path4.relative)(base, target);
16809
+ return (rel === "" ? target : rel).split(import_node_path4.sep).join("/");
16793
16810
  }
16794
16811
 
16795
16812
  // ../../packages/scan/src/node/dependencies.ts
16796
- var import_node_fs6 = require("fs");
16797
- var import_node_path4 = require("path");
16813
+ var import_node_fs7 = require("fs");
16814
+ var import_node_path5 = require("path");
16798
16815
  var MAX_DEPS_PER_LOCKFILE = 50;
16799
16816
  async function scanDependencies(targetPath) {
16800
16817
  const findings = [];
16801
16818
  for (const { file, ecosystem, parse: parse2 } of LOCKFILES) {
16802
- const lockPath = (0, import_node_path4.join)(targetPath, file);
16803
- if (!(0, import_node_fs6.existsSync)(lockPath)) continue;
16819
+ const lockPath = (0, import_node_path5.join)(targetPath, file);
16820
+ if (!(0, import_node_fs7.existsSync)(lockPath)) continue;
16804
16821
  let deps;
16805
16822
  try {
16806
- deps = dedupe(parse2((0, import_node_fs6.readFileSync)(lockPath, "utf-8")));
16823
+ deps = dedupe(parse2((0, import_node_fs7.readFileSync)(lockPath, "utf-8")));
16807
16824
  } catch {
16808
16825
  continue;
16809
16826
  }
@@ -17018,7 +17035,7 @@ async function queryOsv(name, version, ecosystem) {
17018
17035
 
17019
17036
  // ../../packages/scan/src/node/sarif.ts
17020
17037
  var import_node_crypto2 = require("crypto");
17021
- var import_node_path5 = require("path");
17038
+ var import_node_path6 = require("path");
17022
17039
  var FINGERPRINT_KEY = "threatcrush/contentHash/v1";
17023
17040
  function fingerprintOf(finding) {
17024
17041
  const content = finding.excerpt.replace(/\s+/g, " ").trim();
@@ -17056,11 +17073,11 @@ function securitySeverity(severity) {
17056
17073
  }
17057
17074
  }
17058
17075
  function toArtifactUri(filePath, base, prefix = "", root = base) {
17059
- const absolute = (0, import_node_path5.isAbsolute)(filePath) ? filePath : (0, import_node_path5.resolve)(root, filePath);
17060
- const relativePath = (0, import_node_path5.relative)(base, absolute);
17076
+ const absolute = (0, import_node_path6.isAbsolute)(filePath) ? filePath : (0, import_node_path6.resolve)(root, filePath);
17077
+ const relativePath = (0, import_node_path6.relative)(base, absolute);
17061
17078
  const escapedOut = relativePath.startsWith("..") || relativePath === "";
17062
17079
  const chosen = escapedOut ? absolute : relativePath;
17063
- const posix = chosen.split(import_node_path5.sep).join("/").replace(/^\.\//, "");
17080
+ const posix = chosen.split(import_node_path6.sep).join("/").replace(/^\.\//, "");
17064
17081
  if (!prefix || escapedOut) return posix;
17065
17082
  const trimmed = prefix.replace(/^\/+|\/+$/g, "");
17066
17083
  return trimmed ? `${trimmed}/${posix}` : posix;
@@ -17150,17 +17167,17 @@ ${finding.consequence}` : `**${finding.title}**`
17150
17167
  // src/commands/scan.ts
17151
17168
  function readVersion() {
17152
17169
  for (const candidate of [
17153
- (0, import_node_path6.join)(__dirname, "..", "package.json"),
17154
- (0, import_node_path6.join)(__dirname, "..", "..", "package.json")
17170
+ (0, import_node_path7.join)(__dirname, "..", "package.json"),
17171
+ (0, import_node_path7.join)(__dirname, "..", "..", "package.json")
17155
17172
  ]) {
17156
17173
  try {
17157
- return JSON.parse((0, import_node_fs7.readFileSync)(candidate, "utf-8")).version ?? "0.0.0";
17174
+ return JSON.parse((0, import_node_fs8.readFileSync)(candidate, "utf-8")).version ?? "0.0.0";
17158
17175
  } catch {
17159
17176
  }
17160
17177
  }
17161
17178
  return "0.0.0";
17162
17179
  }
17163
- var PKG_VERSION = readVersion();
17180
+ var PKG_VERSION2 = readVersion();
17164
17181
  function parseFailOn(raw) {
17165
17182
  if (!raw) return [];
17166
17183
  const requested = raw.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean);
@@ -17221,7 +17238,7 @@ async function scanCommand(targetPath, options = {}) {
17221
17238
  const say = machineReadable ? (line) => process.stderr.write(`${line}
17222
17239
  `) : (line) => process.stdout.write(`${line}
17223
17240
  `);
17224
- if (!(0, import_node_fs7.existsSync)(targetPath)) {
17241
+ if (!(0, import_node_fs8.existsSync)(targetPath)) {
17225
17242
  say(source_default.red(`Scan target does not exist: ${targetPath}`));
17226
17243
  process.exitCode = 2;
17227
17244
  return failedResult(targetPath, `no such path: ${targetPath}`);
@@ -17306,7 +17323,7 @@ async function scanCommand(targetPath, options = {}) {
17306
17323
  }
17307
17324
  function emitMachineReadable(format, outcome, targetPath, options, say) {
17308
17325
  const payload = format === "sarif" ? buildSarif(outcome.findings, {
17309
- toolVersion: PKG_VERSION,
17326
+ toolVersion: PKG_VERSION2,
17310
17327
  pathPrefix: options.pathPrefix,
17311
17328
  // Relative to the working directory, NOT the scan root. `threatcrush
17312
17329
  // scan vulns` from a repo root must emit `vulns/secrets/x.env`, not
@@ -17317,10 +17334,10 @@ function emitMachineReadable(format, outcome, targetPath, options, say) {
17317
17334
  // and it fails silently. `--path-prefix` covers the remaining case:
17318
17335
  // a scan run from inside the subdirectory it is scanning.
17319
17336
  base: process.cwd(),
17320
- root: (0, import_node_path6.resolve)(outcome.root)
17337
+ root: (0, import_node_path7.resolve)(outcome.root)
17321
17338
  }) : {
17322
17339
  tool: "threatcrush",
17323
- version: PKG_VERSION,
17340
+ version: PKG_VERSION2,
17324
17341
  target: targetPath,
17325
17342
  filesScanned: outcome.filesScanned,
17326
17343
  unreadable: outcome.unreadable,
@@ -17331,8 +17348,8 @@ function emitMachineReadable(format, outcome, targetPath, options, say) {
17331
17348
  const serialized = `${JSON.stringify(payload, null, 2)}
17332
17349
  `;
17333
17350
  if (options.output) {
17334
- (0, import_node_fs7.mkdirSync)((0, import_node_path6.dirname)((0, import_node_path6.resolve)(options.output)), { recursive: true });
17335
- (0, import_node_fs7.writeFileSync)(options.output, serialized, "utf-8");
17351
+ (0, import_node_fs8.mkdirSync)((0, import_node_path7.dirname)((0, import_node_path7.resolve)(options.output)), { recursive: true });
17352
+ (0, import_node_fs8.writeFileSync)(options.output, serialized, "utf-8");
17336
17353
  say(
17337
17354
  source_default.gray(
17338
17355
  ` ${format.toUpperCase()} written to ${options.output} (${outcome.findings.length} finding(s))`
@@ -17384,13 +17401,13 @@ function printHuman(outcome) {
17384
17401
  }
17385
17402
 
17386
17403
  // src/commands/init.ts
17387
- var import_node_fs10 = require("fs");
17404
+ var import_node_fs11 = require("fs");
17388
17405
  var import_node_child_process = require("child_process");
17389
17406
  var import_node_readline3 = __toESM(require("readline"));
17390
17407
 
17391
17408
  // src/core/config.ts
17392
- var import_node_fs8 = require("fs");
17393
- var import_node_path7 = require("path");
17409
+ var import_node_fs9 = require("fs");
17410
+ var import_node_path8 = require("path");
17394
17411
  var import_toml = __toESM(require_toml());
17395
17412
  var DEFAULT_CONFIG_PATH = "/etc/threatcrush/threatcrushd.conf";
17396
17413
  var DEFAULT_CONFDIR = "/etc/threatcrush/threatcrushd.conf.d";
@@ -17416,11 +17433,11 @@ var DEFAULT_CONFIG = {
17416
17433
  };
17417
17434
  function loadConfig(configPath) {
17418
17435
  const path = configPath || DEFAULT_CONFIG_PATH;
17419
- if (!(0, import_node_fs8.existsSync)(path)) {
17436
+ if (!(0, import_node_fs9.existsSync)(path)) {
17420
17437
  return { ...DEFAULT_CONFIG };
17421
17438
  }
17422
17439
  try {
17423
- const raw = (0, import_node_fs8.readFileSync)(path, "utf-8");
17440
+ const raw = (0, import_node_fs9.readFileSync)(path, "utf-8");
17424
17441
  const parsed = import_toml.default.parse(raw);
17425
17442
  return {
17426
17443
  daemon: { ...DEFAULT_CONFIG.daemon, ...parsed.daemon },
@@ -17436,13 +17453,13 @@ function loadConfig(configPath) {
17436
17453
  function loadModuleConfigs(confDir) {
17437
17454
  const dir = confDir || DEFAULT_CONFDIR;
17438
17455
  const configs = /* @__PURE__ */ new Map();
17439
- if (!(0, import_node_fs8.existsSync)(dir)) {
17456
+ if (!(0, import_node_fs9.existsSync)(dir)) {
17440
17457
  return configs;
17441
17458
  }
17442
- const files = (0, import_node_fs8.readdirSync)(dir).filter((f) => f.endsWith(".conf"));
17459
+ const files = (0, import_node_fs9.readdirSync)(dir).filter((f) => f.endsWith(".conf"));
17443
17460
  for (const file of files) {
17444
17461
  try {
17445
- const raw = (0, import_node_fs8.readFileSync)((0, import_node_path7.join)(dir, file), "utf-8");
17462
+ const raw = (0, import_node_fs9.readFileSync)((0, import_node_path8.join)(dir, file), "utf-8");
17446
17463
  const parsed = import_toml.default.parse(raw);
17447
17464
  for (const [name, config] of Object.entries(parsed)) {
17448
17465
  configs.set(name, config);
@@ -17471,23 +17488,23 @@ function generateModuleConfig(moduleName, defaults = {}) {
17471
17488
  }
17472
17489
 
17473
17490
  // src/core/cli-config.ts
17474
- var import_node_fs9 = require("fs");
17475
- var import_node_path8 = require("path");
17491
+ var import_node_fs10 = require("fs");
17492
+ var import_node_path9 = require("path");
17476
17493
  var import_node_os4 = require("os");
17477
- var CLI_CONFIG_DIR = (0, import_node_path8.join)((0, import_node_os4.homedir)(), ".threatcrush");
17478
- var CLI_CONFIG_PATH = (0, import_node_path8.join)(CLI_CONFIG_DIR, "config.json");
17494
+ var CLI_CONFIG_DIR = (0, import_node_path9.join)((0, import_node_os4.homedir)(), ".threatcrush");
17495
+ var CLI_CONFIG_PATH = (0, import_node_path9.join)(CLI_CONFIG_DIR, "config.json");
17479
17496
  function readCliConfig() {
17480
17497
  try {
17481
- return JSON.parse((0, import_node_fs9.readFileSync)(CLI_CONFIG_PATH, "utf-8"));
17498
+ return JSON.parse((0, import_node_fs10.readFileSync)(CLI_CONFIG_PATH, "utf-8"));
17482
17499
  } catch {
17483
17500
  return {};
17484
17501
  }
17485
17502
  }
17486
17503
  function writeCliConfig(config) {
17487
- if (!(0, import_node_fs9.existsSync)(CLI_CONFIG_DIR)) (0, import_node_fs9.mkdirSync)(CLI_CONFIG_DIR, { recursive: true });
17488
- (0, import_node_fs9.writeFileSync)(CLI_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
17504
+ if (!(0, import_node_fs10.existsSync)(CLI_CONFIG_DIR)) (0, import_node_fs10.mkdirSync)(CLI_CONFIG_DIR, { recursive: true });
17505
+ (0, import_node_fs10.writeFileSync)(CLI_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
17489
17506
  try {
17490
- (0, import_node_fs9.chmodSync)(CLI_CONFIG_PATH, 384);
17507
+ (0, import_node_fs10.chmodSync)(CLI_CONFIG_PATH, 384);
17491
17508
  } catch {
17492
17509
  }
17493
17510
  }
@@ -17732,7 +17749,7 @@ function binaryExists(name) {
17732
17749
  }
17733
17750
  }
17734
17751
  function findLogPath(paths) {
17735
- return paths.find((p) => (0, import_node_fs10.existsSync)(p));
17752
+ return paths.find((p) => (0, import_node_fs11.existsSync)(p));
17736
17753
  }
17737
17754
  async function promptYesNo(question, fallback2) {
17738
17755
  const rl = import_node_readline3.default.createInterface({ input: process.stdin, output: process.stdout });
@@ -17848,11 +17865,11 @@ async function initCommand() {
17848
17865
  }
17849
17866
  } else {
17850
17867
  const spinner2 = ora({ text: "Writing configuration files...", color: "green" }).start();
17851
- (0, import_node_fs10.mkdirSync)(confDDir, { recursive: true });
17852
- (0, import_node_fs10.mkdirSync)("/var/log/threatcrush", { recursive: true });
17853
- (0, import_node_fs10.mkdirSync)("/var/lib/threatcrush", { recursive: true });
17868
+ (0, import_node_fs11.mkdirSync)(confDDir, { recursive: true });
17869
+ (0, import_node_fs11.mkdirSync)("/var/log/threatcrush", { recursive: true });
17870
+ (0, import_node_fs11.mkdirSync)("/var/lib/threatcrush", { recursive: true });
17854
17871
  const mainConfig = generateDefaultConfig(detected.map((d) => d.name));
17855
- (0, import_node_fs10.writeFileSync)(`${configDir}/threatcrushd.conf`, mainConfig);
17872
+ (0, import_node_fs11.writeFileSync)(`${configDir}/threatcrushd.conf`, mainConfig);
17856
17873
  for (const svc of detected) {
17857
17874
  const svcDef = SERVICES_TO_DETECT.find((s) => s.name === svc.name);
17858
17875
  if (!svcDef) continue;
@@ -17861,7 +17878,7 @@ async function initCommand() {
17861
17878
  ...svcDef.moduleConfig,
17862
17879
  log_path: svc.logPath || svcDef.logPaths[0]
17863
17880
  });
17864
- (0, import_node_fs10.writeFileSync)(`${confDDir}/${modName}.conf`, modConfig);
17881
+ (0, import_node_fs11.writeFileSync)(`${confDDir}/${modName}.conf`, modConfig);
17865
17882
  }
17866
17883
  spinner2.succeed("Configuration written successfully");
17867
17884
  console.log();
@@ -17879,8 +17896,8 @@ async function initCommand() {
17879
17896
  }
17880
17897
  function checkWriteAccess(dir) {
17881
17898
  try {
17882
- if (!(0, import_node_fs10.existsSync)(dir)) {
17883
- (0, import_node_fs10.mkdirSync)(dir, { recursive: true });
17899
+ if (!(0, import_node_fs11.existsSync)(dir)) {
17900
+ (0, import_node_fs11.mkdirSync)(dir, { recursive: true });
17884
17901
  }
17885
17902
  return true;
17886
17903
  } catch {
@@ -17889,8 +17906,8 @@ function checkWriteAccess(dir) {
17889
17906
  }
17890
17907
 
17891
17908
  // src/core/module-loader.ts
17892
- var import_node_fs11 = require("fs");
17893
- var import_node_path9 = require("path");
17909
+ var import_node_fs12 = require("fs");
17910
+ var import_node_path10 = require("path");
17894
17911
  var import_toml2 = __toESM(require_toml());
17895
17912
  init_paths();
17896
17913
  function discoverModules(moduleDir, confDir) {
@@ -17898,22 +17915,22 @@ function discoverModules(moduleDir, confDir) {
17898
17915
  const configs = loadModuleConfigs(confDir || PATHS.confD);
17899
17916
  const searchPaths = [
17900
17917
  moduleDir || PATHS.moduleDir,
17901
- (0, import_node_path9.resolve)(process.cwd(), "modules")
17918
+ (0, import_node_path10.resolve)(process.cwd(), "modules")
17902
17919
  ];
17903
- const builtinDir = (0, import_node_path9.resolve)(__dirname || ".", "..", "modules");
17904
- if ((0, import_node_fs11.existsSync)(builtinDir)) {
17920
+ const builtinDir = (0, import_node_path10.resolve)(__dirname || ".", "..", "modules");
17921
+ if ((0, import_node_fs12.existsSync)(builtinDir)) {
17905
17922
  searchPaths.push(builtinDir);
17906
17923
  }
17907
17924
  for (const basePath of searchPaths) {
17908
- if (!(0, import_node_fs11.existsSync)(basePath)) continue;
17909
- const entries = (0, import_node_fs11.readdirSync)(basePath, { withFileTypes: true });
17925
+ if (!(0, import_node_fs12.existsSync)(basePath)) continue;
17926
+ const entries = (0, import_node_fs12.readdirSync)(basePath, { withFileTypes: true });
17910
17927
  for (const entry of entries) {
17911
17928
  if (!entry.isDirectory()) continue;
17912
- const modPath = (0, import_node_path9.join)(basePath, entry.name);
17913
- const manifestPath = (0, import_node_path9.join)(modPath, "mod.toml");
17914
- if (!(0, import_node_fs11.existsSync)(manifestPath)) continue;
17929
+ const modPath = (0, import_node_path10.join)(basePath, entry.name);
17930
+ const manifestPath = (0, import_node_path10.join)(modPath, "mod.toml");
17931
+ if (!(0, import_node_fs12.existsSync)(manifestPath)) continue;
17915
17932
  try {
17916
- const raw = (0, import_node_fs11.readFileSync)(manifestPath, "utf-8");
17933
+ const raw = (0, import_node_fs12.readFileSync)(manifestPath, "utf-8");
17917
17934
  const manifest = import_toml2.default.parse(raw);
17918
17935
  const config = configs.get(manifest.module.name) || { enabled: true };
17919
17936
  modules.push({
@@ -17939,21 +17956,21 @@ function discoverModules(moduleDir, confDir) {
17939
17956
  init_ipc_client();
17940
17957
 
17941
17958
  // src/daemon/pidfile.ts
17942
- var import_node_fs12 = require("fs");
17959
+ var import_node_fs13 = require("fs");
17943
17960
  init_paths();
17944
17961
  function writePidFile() {
17945
17962
  ensureRuntimeDirs();
17946
- (0, import_node_fs12.writeFileSync)(PATHS.pidFile, String(process.pid), "utf-8");
17963
+ (0, import_node_fs13.writeFileSync)(PATHS.pidFile, String(process.pid), "utf-8");
17947
17964
  }
17948
17965
  function readPidFile() {
17949
- if (!(0, import_node_fs12.existsSync)(PATHS.pidFile)) return null;
17950
- const raw = (0, import_node_fs12.readFileSync)(PATHS.pidFile, "utf-8").trim();
17966
+ if (!(0, import_node_fs13.existsSync)(PATHS.pidFile)) return null;
17967
+ const raw = (0, import_node_fs13.readFileSync)(PATHS.pidFile, "utf-8").trim();
17951
17968
  const pid = parseInt(raw, 10);
17952
17969
  return Number.isFinite(pid) ? pid : null;
17953
17970
  }
17954
17971
  function removePidFile() {
17955
17972
  try {
17956
- if ((0, import_node_fs12.existsSync)(PATHS.pidFile)) (0, import_node_fs12.unlinkSync)(PATHS.pidFile);
17973
+ if ((0, import_node_fs13.existsSync)(PATHS.pidFile)) (0, import_node_fs13.unlinkSync)(PATHS.pidFile);
17957
17974
  } catch {
17958
17975
  }
17959
17976
  }
@@ -18067,24 +18084,24 @@ function formatUptime2(seconds) {
18067
18084
 
18068
18085
  // src/commands/modules.ts
18069
18086
  var import_node_child_process2 = require("child_process");
18070
- var import_node_fs14 = require("fs");
18071
- var import_node_path11 = require("path");
18087
+ var import_node_fs15 = require("fs");
18088
+ var import_node_path12 = require("path");
18072
18089
  var import_toml3 = __toESM(require_toml());
18073
18090
  init_paths();
18074
18091
 
18075
18092
  // src/daemon/module-trust.ts
18076
18093
  var import_node_crypto3 = require("crypto");
18077
- var import_node_fs13 = require("fs");
18078
- var import_node_path10 = require("path");
18094
+ var import_node_fs14 = require("fs");
18095
+ var import_node_path11 = require("path");
18079
18096
  init_paths();
18080
- var TRUST_FILE = (0, import_node_path10.join)(PATHS.configDir, "trusted-modules.json");
18081
- var PUBLISHER_KEYS_FILE = (0, import_node_path10.join)(PATHS.configDir, "publisher-keys.json");
18097
+ var TRUST_FILE = (0, import_node_path11.join)(PATHS.configDir, "trusted-modules.json");
18098
+ var PUBLISHER_KEYS_FILE = (0, import_node_path11.join)(PATHS.configDir, "publisher-keys.json");
18082
18099
  var DIGEST_EXCLUDED_DIRS = /* @__PURE__ */ new Set([".git"]);
18083
18100
  function collectFiles(root, dir = root, out = []) {
18084
- for (const entry of (0, import_node_fs13.readdirSync)(dir, { withFileTypes: true }).sort(
18101
+ for (const entry of (0, import_node_fs14.readdirSync)(dir, { withFileTypes: true }).sort(
18085
18102
  (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0
18086
18103
  )) {
18087
- const full = (0, import_node_path10.join)(dir, entry.name);
18104
+ const full = (0, import_node_path11.join)(dir, entry.name);
18088
18105
  if (entry.isSymbolicLink()) {
18089
18106
  out.push({ path: full, isSymlink: true });
18090
18107
  } else if (entry.isDirectory()) {
@@ -18099,24 +18116,24 @@ function collectFiles(root, dir = root, out = []) {
18099
18116
  function computeModuleDigest(modulePath) {
18100
18117
  const hash = (0, import_node_crypto3.createHash)("sha256");
18101
18118
  for (const entry of collectFiles(modulePath)) {
18102
- const relPath = (0, import_node_path10.relative)(modulePath, entry.path).split(import_node_path10.sep).join("/");
18119
+ const relPath = (0, import_node_path11.relative)(modulePath, entry.path).split(import_node_path11.sep).join("/");
18103
18120
  hash.update(relPath);
18104
18121
  hash.update("\0");
18105
18122
  if (entry.isSymlink) {
18106
18123
  hash.update("symlink:");
18107
- hash.update((0, import_node_fs13.readlinkSync)(entry.path));
18124
+ hash.update((0, import_node_fs14.readlinkSync)(entry.path));
18108
18125
  } else {
18109
18126
  hash.update("file:");
18110
- hash.update((0, import_node_fs13.readFileSync)(entry.path));
18127
+ hash.update((0, import_node_fs14.readFileSync)(entry.path));
18111
18128
  }
18112
18129
  hash.update("\0");
18113
18130
  }
18114
18131
  return hash.digest("hex");
18115
18132
  }
18116
18133
  function readTrustFile() {
18117
- if (!(0, import_node_fs13.existsSync)(TRUST_FILE)) return { version: 1, modules: {} };
18134
+ if (!(0, import_node_fs14.existsSync)(TRUST_FILE)) return { version: 1, modules: {} };
18118
18135
  try {
18119
- const parsed = JSON.parse((0, import_node_fs13.readFileSync)(TRUST_FILE, "utf-8"));
18136
+ const parsed = JSON.parse((0, import_node_fs14.readFileSync)(TRUST_FILE, "utf-8"));
18120
18137
  if (parsed.version !== 1 || typeof parsed.modules !== "object" || !parsed.modules) {
18121
18138
  return { version: 1, modules: {} };
18122
18139
  }
@@ -18126,9 +18143,9 @@ function readTrustFile() {
18126
18143
  }
18127
18144
  }
18128
18145
  function writeTrustFile(file) {
18129
- (0, import_node_fs13.writeFileSync)(TRUST_FILE, JSON.stringify(file, null, 2) + "\n", { mode: 384 });
18146
+ (0, import_node_fs14.writeFileSync)(TRUST_FILE, JSON.stringify(file, null, 2) + "\n", { mode: 384 });
18130
18147
  try {
18131
- (0, import_node_fs13.chmodSync)(TRUST_FILE, 384);
18148
+ (0, import_node_fs14.chmodSync)(TRUST_FILE, 384);
18132
18149
  } catch {
18133
18150
  }
18134
18151
  }
@@ -18154,9 +18171,9 @@ function listTrustedModules() {
18154
18171
  return readTrustFile().modules;
18155
18172
  }
18156
18173
  function readPublisherKeys() {
18157
- if (!(0, import_node_fs13.existsSync)(PUBLISHER_KEYS_FILE)) return {};
18174
+ if (!(0, import_node_fs14.existsSync)(PUBLISHER_KEYS_FILE)) return {};
18158
18175
  try {
18159
- const parsed = JSON.parse((0, import_node_fs13.readFileSync)(PUBLISHER_KEYS_FILE, "utf-8"));
18176
+ const parsed = JSON.parse((0, import_node_fs14.readFileSync)(PUBLISHER_KEYS_FILE, "utf-8"));
18160
18177
  return parsed && typeof parsed === "object" ? parsed : {};
18161
18178
  } catch {
18162
18179
  return {};
@@ -18165,16 +18182,16 @@ function readPublisherKeys() {
18165
18182
  function verifyModuleSignature(modulePath, digest) {
18166
18183
  const keys = readPublisherKeys();
18167
18184
  const pinnedKeyIds = Object.keys(keys);
18168
- const sigPath = (0, import_node_path10.join)(modulePath, "mod.sig");
18185
+ const sigPath = (0, import_node_path11.join)(modulePath, "mod.sig");
18169
18186
  if (pinnedKeyIds.length === 0) {
18170
18187
  return { ok: true };
18171
18188
  }
18172
- if (!(0, import_node_fs13.existsSync)(sigPath)) {
18189
+ if (!(0, import_node_fs14.existsSync)(sigPath)) {
18173
18190
  return { ok: false, reason: "publisher keys are pinned but the module ships no mod.sig" };
18174
18191
  }
18175
18192
  let parsed;
18176
18193
  try {
18177
- parsed = JSON.parse((0, import_node_fs13.readFileSync)(sigPath, "utf-8"));
18194
+ parsed = JSON.parse((0, import_node_fs14.readFileSync)(sigPath, "utf-8"));
18178
18195
  } catch {
18179
18196
  return { ok: false, reason: "mod.sig is not valid JSON" };
18180
18197
  }
@@ -18235,7 +18252,7 @@ function safeModuleDirName(name, label = "module name") {
18235
18252
  return name;
18236
18253
  }
18237
18254
  function moduleDestination(dir, name, label) {
18238
- return (0, import_node_path11.join)(dir, safeModuleDirName(name, label));
18255
+ return (0, import_node_path12.join)(dir, safeModuleDirName(name, label));
18239
18256
  }
18240
18257
  function assertSafeTarballEntries(tarPath) {
18241
18258
  const listing = (0, import_node_child_process2.execFileSync)("tar", ["-tzf", tarPath], { encoding: "utf-8" });
@@ -18248,12 +18265,12 @@ function assertSafeTarballEntries(tarPath) {
18248
18265
  }
18249
18266
  }
18250
18267
  function validateManifest(modPath) {
18251
- const manifestPath = (0, import_node_path11.join)(modPath, "mod.toml");
18252
- if (!(0, import_node_fs14.existsSync)(manifestPath)) {
18268
+ const manifestPath = (0, import_node_path12.join)(modPath, "mod.toml");
18269
+ if (!(0, import_node_fs15.existsSync)(manifestPath)) {
18253
18270
  return { ok: false, error: `mod.toml not found at ${manifestPath}` };
18254
18271
  }
18255
18272
  try {
18256
- const raw = (0, import_node_fs14.readFileSync)(manifestPath, "utf-8");
18273
+ const raw = (0, import_node_fs15.readFileSync)(manifestPath, "utf-8");
18257
18274
  const parsed = import_toml3.default.parse(raw);
18258
18275
  const name = parsed.module?.name;
18259
18276
  const version = parsed.module?.version;
@@ -18313,8 +18330,8 @@ async function modulesInstallCommand(source) {
18313
18330
  console.log();
18314
18331
  const dir = modulesDir();
18315
18332
  if (source.startsWith("./") || source.startsWith("/") || source.startsWith("~")) {
18316
- const absPath = (0, import_node_path11.resolve)(source.startsWith("~") ? source.replace("~", process.env.HOME || "") : source);
18317
- if (!(0, import_node_fs14.existsSync)(absPath)) {
18333
+ const absPath = (0, import_node_path12.resolve)(source.startsWith("~") ? source.replace("~", process.env.HOME || "") : source);
18334
+ if (!(0, import_node_fs15.existsSync)(absPath)) {
18318
18335
  console.log(source_default.red(` \u2717 Path not found: ${absPath}
18319
18336
  `));
18320
18337
  return;
@@ -18333,7 +18350,7 @@ async function modulesInstallCommand(source) {
18333
18350
  `));
18334
18351
  return;
18335
18352
  }
18336
- if ((0, import_node_fs14.existsSync)(dest2)) {
18353
+ if ((0, import_node_fs15.existsSync)(dest2)) {
18337
18354
  console.log(source_default.yellow(` ! ${check.name} is already installed at ${dest2}`));
18338
18355
  console.log(source_default.dim(` Run ${source_default.white(`threatcrush modules remove ${check.name}`)} first.
18339
18356
  `));
@@ -18341,7 +18358,7 @@ async function modulesInstallCommand(source) {
18341
18358
  }
18342
18359
  const spinner2 = ora({ text: `Copying module files...`, color: "green" }).start();
18343
18360
  try {
18344
- (0, import_node_fs14.cpSync)(absPath, dest2, { recursive: true, dereference: true });
18361
+ (0, import_node_fs15.cpSync)(absPath, dest2, { recursive: true, dereference: true });
18345
18362
  spinner2.succeed(`Installed ${source_default.white(check.name)} v${check.version} \u2192 ${dest2}`);
18346
18363
  } catch (err) {
18347
18364
  spinner2.fail(`Copy failed: ${err.message}`);
@@ -18357,14 +18374,14 @@ async function modulesInstallCommand(source) {
18357
18374
  let name;
18358
18375
  let dest2;
18359
18376
  try {
18360
- name = safeModuleDirName((0, import_node_path11.basename)(gitUrl.replace(/\.git$/, "")), "repository name");
18377
+ name = safeModuleDirName((0, import_node_path12.basename)(gitUrl.replace(/\.git$/, "")), "repository name");
18361
18378
  dest2 = moduleDestination(dir, name);
18362
18379
  } catch (err) {
18363
18380
  console.log(source_default.red(` x ${err.message}
18364
18381
  `));
18365
18382
  return;
18366
18383
  }
18367
- if ((0, import_node_fs14.existsSync)(dest2)) {
18384
+ if ((0, import_node_fs15.existsSync)(dest2)) {
18368
18385
  console.log(source_default.yellow(` ! ${name} is already installed at ${dest2}`));
18369
18386
  console.log(source_default.dim(` Run ${source_default.white(`threatcrush modules remove ${name}`)} first.
18370
18387
  `));
@@ -18381,7 +18398,7 @@ async function modulesInstallCommand(source) {
18381
18398
  if (!check.ok) {
18382
18399
  spinner2.fail(check.error);
18383
18400
  try {
18384
- (0, import_node_fs14.rmSync)(dest2, { recursive: true, force: true });
18401
+ (0, import_node_fs15.rmSync)(dest2, { recursive: true, force: true });
18385
18402
  } catch {
18386
18403
  }
18387
18404
  return;
@@ -18427,7 +18444,7 @@ async function modulesInstallCommand(source) {
18427
18444
  `));
18428
18445
  return;
18429
18446
  }
18430
- if ((0, import_node_fs14.existsSync)(dest)) {
18447
+ if ((0, import_node_fs15.existsSync)(dest)) {
18431
18448
  console.log(source_default.yellow(` ! ${mod.slug} is already installed at ${dest}
18432
18449
  `));
18433
18450
  return;
@@ -18453,7 +18470,7 @@ async function modulesInstallCommand(source) {
18453
18470
  if (!check.ok) {
18454
18471
  cloneSpinner.fail(check.error);
18455
18472
  try {
18456
- (0, import_node_fs14.rmSync)(dest, { recursive: true, force: true });
18473
+ (0, import_node_fs15.rmSync)(dest, { recursive: true, force: true });
18457
18474
  } catch {
18458
18475
  }
18459
18476
  return;
@@ -18467,11 +18484,11 @@ async function modulesInstallCommand(source) {
18467
18484
  dlSpinner.fail(`HTTP ${res.status}`);
18468
18485
  return;
18469
18486
  }
18470
- const tar = (0, import_node_path11.join)(dir, `${mod.slug}.tar.gz`);
18471
- (0, import_node_fs14.writeFileSync)(tar, Buffer.from(await res.arrayBuffer()));
18487
+ const tar = (0, import_node_path12.join)(dir, `${mod.slug}.tar.gz`);
18488
+ (0, import_node_fs15.writeFileSync)(tar, Buffer.from(await res.arrayBuffer()));
18472
18489
  assertSafeTarballEntries(tar);
18473
18490
  (0, import_node_child_process2.execFileSync)("tar", ["-xzf", tar, "-C", dir], { stdio: "pipe" });
18474
- (0, import_node_fs14.rmSync)(tar, { force: true });
18491
+ (0, import_node_fs15.rmSync)(tar, { force: true });
18475
18492
  const check = validateManifest(dest);
18476
18493
  if (!check.ok) {
18477
18494
  dlSpinner.fail(check.error);
@@ -18503,7 +18520,7 @@ async function modulesRemoveCommand(name) {
18503
18520
  `));
18504
18521
  return;
18505
18522
  }
18506
- if (!(0, import_node_fs14.existsSync)(target)) {
18523
+ if (!(0, import_node_fs15.existsSync)(target)) {
18507
18524
  console.log(source_default.yellow(` ! No module named "${name}" in ${dir}
18508
18525
  `));
18509
18526
  return;
@@ -18513,7 +18530,7 @@ async function modulesRemoveCommand(name) {
18513
18530
  console.log(source_default.yellow(` ! Directory name "${name}" does not match manifest name "${check.name}"`));
18514
18531
  }
18515
18532
  try {
18516
- (0, import_node_fs14.rmSync)(target, { recursive: true, force: true });
18533
+ (0, import_node_fs15.rmSync)(target, { recursive: true, force: true });
18517
18534
  untrustModule(name);
18518
18535
  console.log(source_default.green(` \u2713 Removed ${name} from ${dir}
18519
18536
  `));
@@ -18538,7 +18555,7 @@ async function modulesTrustCommand(name) {
18538
18555
  `));
18539
18556
  return;
18540
18557
  }
18541
- if (!(0, import_node_fs14.existsSync)(target)) {
18558
+ if (!(0, import_node_fs15.existsSync)(target)) {
18542
18559
  console.log(source_default.yellow(` ! No module named "${name}" in ${dir}
18543
18560
  `));
18544
18561
  return;
@@ -18974,21 +18991,21 @@ async function pentestCommand(targetUrl) {
18974
18991
 
18975
18992
  // src/commands/orgs.ts
18976
18993
  var import_node_os5 = require("os");
18977
- var import_node_fs15 = require("fs");
18978
- var import_node_path12 = require("path");
18994
+ var import_node_fs16 = require("fs");
18995
+ var import_node_path13 = require("path");
18979
18996
  var API_URL3 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
18980
- var CONFIG_PATH = (0, import_node_path12.join)((0, import_node_os5.homedir)(), ".threatcrush", "config.json");
18997
+ var CONFIG_PATH = (0, import_node_path13.join)((0, import_node_os5.homedir)(), ".threatcrush", "config.json");
18981
18998
  function readConfig() {
18982
18999
  try {
18983
- return JSON.parse((0, import_node_fs15.readFileSync)(CONFIG_PATH, "utf-8"));
19000
+ return JSON.parse((0, import_node_fs16.readFileSync)(CONFIG_PATH, "utf-8"));
18984
19001
  } catch {
18985
19002
  return {};
18986
19003
  }
18987
19004
  }
18988
19005
  function writeConfig(config) {
18989
- const dir = (0, import_node_path12.join)((0, import_node_os5.homedir)(), ".threatcrush");
18990
- if (!(0, import_node_fs15.existsSync)(dir)) (0, import_node_fs15.mkdirSync)(dir, { recursive: true });
18991
- (0, import_node_fs15.writeFileSync)(CONFIG_PATH, JSON.stringify(config, null, 2));
19006
+ const dir = (0, import_node_path13.join)((0, import_node_os5.homedir)(), ".threatcrush");
19007
+ if (!(0, import_node_fs16.existsSync)(dir)) (0, import_node_fs16.mkdirSync)(dir, { recursive: true });
19008
+ (0, import_node_fs16.writeFileSync)(CONFIG_PATH, JSON.stringify(config, null, 2));
18992
19009
  }
18993
19010
  function getAuthHeaders() {
18994
19011
  const config = readConfig();
@@ -19124,13 +19141,13 @@ async function useOrganization(slug) {
19124
19141
 
19125
19142
  // src/commands/servers.ts
19126
19143
  var import_node_os6 = require("os");
19127
- var import_node_fs16 = require("fs");
19128
- var import_node_path13 = require("path");
19144
+ var import_node_fs17 = require("fs");
19145
+ var import_node_path14 = require("path");
19129
19146
  var API_URL4 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
19130
- var CONFIG_PATH2 = (0, import_node_path13.join)((0, import_node_os6.homedir)(), ".threatcrush", "config.json");
19147
+ var CONFIG_PATH2 = (0, import_node_path14.join)((0, import_node_os6.homedir)(), ".threatcrush", "config.json");
19131
19148
  function readConfig2() {
19132
19149
  try {
19133
- return JSON.parse((0, import_node_fs16.readFileSync)(CONFIG_PATH2, "utf-8"));
19150
+ return JSON.parse((0, import_node_fs17.readFileSync)(CONFIG_PATH2, "utf-8"));
19134
19151
  } catch {
19135
19152
  return {};
19136
19153
  }
@@ -19233,14 +19250,14 @@ function timeAgo(dateStr) {
19233
19250
 
19234
19251
  // src/commands/connect.ts
19235
19252
  var import_node_os7 = require("os");
19236
- var import_node_fs17 = require("fs");
19237
- var import_node_path14 = require("path");
19253
+ var import_node_fs18 = require("fs");
19254
+ var import_node_path15 = require("path");
19238
19255
  var import_node_child_process3 = require("child_process");
19239
19256
  var API_URL5 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
19240
- var CONFIG_PATH3 = (0, import_node_path14.join)((0, import_node_os7.homedir)(), ".threatcrush", "config.json");
19257
+ var CONFIG_PATH3 = (0, import_node_path15.join)((0, import_node_os7.homedir)(), ".threatcrush", "config.json");
19241
19258
  function readConfig3() {
19242
19259
  try {
19243
- return JSON.parse((0, import_node_fs17.readFileSync)(CONFIG_PATH3, "utf-8"));
19260
+ return JSON.parse((0, import_node_fs18.readFileSync)(CONFIG_PATH3, "utf-8"));
19244
19261
  } catch {
19245
19262
  return {};
19246
19263
  }
@@ -19395,18 +19412,18 @@ async function sshConnect(options) {
19395
19412
 
19396
19413
  // src/commands/daemon.ts
19397
19414
  var import_node_child_process7 = require("child_process");
19398
- var import_node_fs26 = require("fs");
19399
- var import_node_path18 = require("path");
19400
19415
  var import_node_fs27 = require("fs");
19416
+ var import_node_path19 = require("path");
19417
+ var import_node_fs28 = require("fs");
19401
19418
 
19402
19419
  // src/daemon/index.ts
19403
- var import_node_fs25 = require("fs");
19404
- var import_node_path17 = require("path");
19420
+ var import_node_fs26 = require("fs");
19421
+ var import_node_path18 = require("path");
19405
19422
  init_paths();
19406
19423
 
19407
19424
  // src/daemon/ipc-server.ts
19408
19425
  var import_node_net2 = require("net");
19409
- var import_node_fs18 = require("fs");
19426
+ var import_node_fs19 = require("fs");
19410
19427
  init_paths();
19411
19428
  init_control_token();
19412
19429
 
@@ -19455,9 +19472,9 @@ var IpcServer = class {
19455
19472
  controlToken = "";
19456
19473
  async start() {
19457
19474
  this.controlToken = issueControlToken();
19458
- if ((0, import_node_fs18.existsSync)(PATHS.socket)) {
19475
+ if ((0, import_node_fs19.existsSync)(PATHS.socket)) {
19459
19476
  try {
19460
- (0, import_node_fs18.unlinkSync)(PATHS.socket);
19477
+ (0, import_node_fs19.unlinkSync)(PATHS.socket);
19461
19478
  } catch {
19462
19479
  }
19463
19480
  }
@@ -19493,14 +19510,14 @@ var IpcServer = class {
19493
19510
  return new Promise((resolve5) => {
19494
19511
  if (!this.server) {
19495
19512
  try {
19496
- if ((0, import_node_fs18.existsSync)(PATHS.socket)) (0, import_node_fs18.unlinkSync)(PATHS.socket);
19513
+ if ((0, import_node_fs19.existsSync)(PATHS.socket)) (0, import_node_fs19.unlinkSync)(PATHS.socket);
19497
19514
  } catch {
19498
19515
  }
19499
19516
  return resolve5();
19500
19517
  }
19501
19518
  this.server.close(() => {
19502
19519
  try {
19503
- if ((0, import_node_fs18.existsSync)(PATHS.socket)) (0, import_node_fs18.unlinkSync)(PATHS.socket);
19520
+ if ((0, import_node_fs19.existsSync)(PATHS.socket)) (0, import_node_fs19.unlinkSync)(PATHS.socket);
19504
19521
  } catch {
19505
19522
  }
19506
19523
  resolve5();
@@ -19614,14 +19631,14 @@ var IpcServer = class {
19614
19631
  };
19615
19632
 
19616
19633
  // src/daemon/module-host.ts
19617
- var import_node_fs22 = require("fs");
19618
- var import_node_path15 = require("path");
19634
+ var import_node_fs23 = require("fs");
19635
+ var import_node_path16 = require("path");
19619
19636
  var import_node_url = require("url");
19620
19637
  var import_toml4 = __toESM(require_toml());
19621
19638
  init_paths();
19622
19639
 
19623
19640
  // src/daemon/watchers/log-watcher.ts
19624
- var import_node_fs19 = require("fs");
19641
+ var import_node_fs20 = require("fs");
19625
19642
  var import_node_readline4 = require("readline");
19626
19643
  var DEFAULT_SOURCES = [
19627
19644
  { path: "/var/log/auth.log", module: "ssh-guard", category: "auth" },
@@ -19642,9 +19659,9 @@ var LogWatcher = class {
19642
19659
  start() {
19643
19660
  const started = [];
19644
19661
  for (const src of this.sources) {
19645
- if (!(0, import_node_fs19.existsSync)(src.path)) continue;
19662
+ if (!(0, import_node_fs20.existsSync)(src.path)) continue;
19646
19663
  try {
19647
- (0, import_node_fs19.accessSync)(src.path, import_node_fs19.constants.R_OK);
19664
+ (0, import_node_fs20.accessSync)(src.path, import_node_fs20.constants.R_OK);
19648
19665
  } catch {
19649
19666
  continue;
19650
19667
  }
@@ -19664,7 +19681,7 @@ var LogWatcher = class {
19664
19681
  }
19665
19682
  tail(src) {
19666
19683
  try {
19667
- this.positions.set(src.path, (0, import_node_fs19.statSync)(src.path).size);
19684
+ this.positions.set(src.path, (0, import_node_fs20.statSync)(src.path).size);
19668
19685
  } catch {
19669
19686
  this.positions.set(src.path, 0);
19670
19687
  }
@@ -19675,7 +19692,7 @@ var LogWatcher = class {
19675
19692
  poll(src) {
19676
19693
  let stat;
19677
19694
  try {
19678
- stat = (0, import_node_fs19.statSync)(src.path);
19695
+ stat = (0, import_node_fs20.statSync)(src.path);
19679
19696
  } catch {
19680
19697
  return;
19681
19698
  }
@@ -19685,7 +19702,7 @@ var LogWatcher = class {
19685
19702
  return;
19686
19703
  }
19687
19704
  if (stat.size === prev) return;
19688
- const stream = (0, import_node_fs19.createReadStream)(src.path, { start: prev, encoding: "utf-8" });
19705
+ const stream = (0, import_node_fs20.createReadStream)(src.path, { start: prev, encoding: "utf-8" });
19689
19706
  stream.on("error", () => this.positions.set(src.path, stat.size));
19690
19707
  const rl = (0, import_node_readline4.createInterface)({ input: stream });
19691
19708
  rl.on("error", () => {
@@ -19877,7 +19894,7 @@ function realtimeToDate(rt) {
19877
19894
 
19878
19895
  // src/modules/network-monitor/index.ts
19879
19896
  var import_node_child_process5 = require("child_process");
19880
- var import_node_fs20 = require("fs");
19897
+ var import_node_fs21 = require("fs");
19881
19898
  var NetworkMonitor = class {
19882
19899
  constructor(bus2) {
19883
19900
  this.bus = bus2;
@@ -19915,7 +19932,7 @@ var NetworkMonitor = class {
19915
19932
  hasConntrackOrSs() {
19916
19933
  const ss = (0, import_node_child_process5.spawnSync)("ss", ["--version"], { stdio: "pipe" });
19917
19934
  if (ss.status === 0) return true;
19918
- return (0, import_node_fs20.existsSync)("/proc/net/tcp");
19935
+ return (0, import_node_fs21.existsSync)("/proc/net/tcp");
19919
19936
  }
19920
19937
  poll() {
19921
19938
  try {
@@ -20054,7 +20071,7 @@ var NetworkMonitor = class {
20054
20071
  };
20055
20072
 
20056
20073
  // src/modules/dns-monitor/index.ts
20057
- var import_node_fs21 = require("fs");
20074
+ var import_node_fs22 = require("fs");
20058
20075
  var import_node_readline5 = require("readline");
20059
20076
  var DNS_LOG_SOURCES = [
20060
20077
  "/var/log/syslog",
@@ -20088,9 +20105,9 @@ var DnsMonitor = class {
20088
20105
  entropyThreshold = 3.5;
20089
20106
  start() {
20090
20107
  const sources = DNS_LOG_SOURCES.filter((p) => {
20091
- if (!(0, import_node_fs21.existsSync)(p)) return false;
20108
+ if (!(0, import_node_fs22.existsSync)(p)) return false;
20092
20109
  try {
20093
- (0, import_node_fs21.accessSync)(p, import_node_fs21.constants.R_OK);
20110
+ (0, import_node_fs22.accessSync)(p, import_node_fs22.constants.R_OK);
20094
20111
  return true;
20095
20112
  } catch {
20096
20113
  return false;
@@ -20114,7 +20131,7 @@ var DnsMonitor = class {
20114
20131
  }
20115
20132
  tailLog(path) {
20116
20133
  try {
20117
- this.positions.set(path, (0, import_node_fs21.statSync)(path).size);
20134
+ this.positions.set(path, (0, import_node_fs22.statSync)(path).size);
20118
20135
  } catch {
20119
20136
  this.positions.set(path, 0);
20120
20137
  }
@@ -20124,7 +20141,7 @@ var DnsMonitor = class {
20124
20141
  pollLog(path) {
20125
20142
  let stat;
20126
20143
  try {
20127
- stat = (0, import_node_fs21.statSync)(path);
20144
+ stat = (0, import_node_fs22.statSync)(path);
20128
20145
  } catch {
20129
20146
  return;
20130
20147
  }
@@ -20134,7 +20151,7 @@ var DnsMonitor = class {
20134
20151
  return;
20135
20152
  }
20136
20153
  if (stat.size === prev) return;
20137
- const stream = (0, import_node_fs21.createReadStream)(path, { start: prev, encoding: "utf-8" });
20154
+ const stream = (0, import_node_fs22.createReadStream)(path, { start: prev, encoding: "utf-8" });
20138
20155
  stream.on("error", () => this.positions.set(path, stat.size));
20139
20156
  const rl = (0, import_node_readline5.createInterface)({ input: stream });
20140
20157
  rl.on("line", (line) => this.parseDnsLine(line));
@@ -20365,15 +20382,15 @@ var ModuleHost = class {
20365
20382
  for (const m of builtins) this.modules.set(m.name, m);
20366
20383
  }
20367
20384
  async discoverAndStartInstalled() {
20368
- if (!(0, import_node_fs22.existsSync)(PATHS.moduleDir)) return;
20385
+ if (!(0, import_node_fs23.existsSync)(PATHS.moduleDir)) return;
20369
20386
  const configs = loadModuleConfigs(PATHS.confD);
20370
- const entries = (0, import_node_fs22.readdirSync)(PATHS.moduleDir, { withFileTypes: true });
20387
+ const entries = (0, import_node_fs23.readdirSync)(PATHS.moduleDir, { withFileTypes: true });
20371
20388
  for (const entry of entries) {
20372
20389
  if (!entry.isDirectory()) continue;
20373
- const manifestPath = (0, import_node_path15.join)(PATHS.moduleDir, entry.name, "mod.toml");
20374
- if (!(0, import_node_fs22.existsSync)(manifestPath)) continue;
20390
+ const manifestPath = (0, import_node_path16.join)(PATHS.moduleDir, entry.name, "mod.toml");
20391
+ if (!(0, import_node_fs23.existsSync)(manifestPath)) continue;
20375
20392
  try {
20376
- const manifest = import_toml4.default.parse((0, import_node_fs22.readFileSync)(manifestPath, "utf-8"));
20393
+ const manifest = import_toml4.default.parse((0, import_node_fs23.readFileSync)(manifestPath, "utf-8"));
20377
20394
  const name = manifest.module?.name || entry.name;
20378
20395
  const defaults = manifest.module?.config?.defaults || {};
20379
20396
  const config = {
@@ -20387,7 +20404,7 @@ var ModuleHost = class {
20387
20404
  source: "installed",
20388
20405
  status: config.enabled === false ? "disabled" : "loaded",
20389
20406
  events: 0,
20390
- path: (0, import_node_path15.join)(PATHS.moduleDir, entry.name),
20407
+ path: (0, import_node_path16.join)(PATHS.moduleDir, entry.name),
20391
20408
  config
20392
20409
  };
20393
20410
  this.modules.set(name, hosted);
@@ -20402,7 +20419,7 @@ var ModuleHost = class {
20402
20419
  status: "error",
20403
20420
  events: 0,
20404
20421
  detail: `manifest load failed: ${String(err.message || err)}`,
20405
- path: (0, import_node_path15.join)(PATHS.moduleDir, entry.name)
20422
+ path: (0, import_node_path16.join)(PATHS.moduleDir, entry.name)
20406
20423
  });
20407
20424
  }
20408
20425
  }
@@ -20441,17 +20458,17 @@ var ModuleHost = class {
20441
20458
  }
20442
20459
  }
20443
20460
  installedEntrypoint(modulePath) {
20444
- const packageJson = (0, import_node_path15.join)(modulePath, "package.json");
20461
+ const packageJson = (0, import_node_path16.join)(modulePath, "package.json");
20445
20462
  const candidates = [];
20446
- if ((0, import_node_fs22.existsSync)(packageJson)) {
20463
+ if ((0, import_node_fs23.existsSync)(packageJson)) {
20447
20464
  try {
20448
- const pkg = JSON.parse((0, import_node_fs22.readFileSync)(packageJson, "utf-8"));
20449
- if (pkg.main) candidates.push((0, import_node_path15.join)(modulePath, pkg.main));
20465
+ const pkg = JSON.parse((0, import_node_fs23.readFileSync)(packageJson, "utf-8"));
20466
+ if (pkg.main) candidates.push((0, import_node_path16.join)(modulePath, pkg.main));
20450
20467
  } catch {
20451
20468
  }
20452
20469
  }
20453
- candidates.push((0, import_node_path15.join)(modulePath, "dist", "index.js"), (0, import_node_path15.join)(modulePath, "index.js"));
20454
- return candidates.find((candidate) => (0, import_node_fs22.existsSync)(candidate)) || null;
20470
+ candidates.push((0, import_node_path16.join)(modulePath, "dist", "index.js"), (0, import_node_path16.join)(modulePath, "index.js"));
20471
+ return candidates.find((candidate) => (0, import_node_fs23.existsSync)(candidate)) || null;
20455
20472
  }
20456
20473
  isThreatCrushModule(value) {
20457
20474
  return Boolean(
@@ -20972,8 +20989,8 @@ var RuleEngine = class {
20972
20989
  };
20973
20990
 
20974
20991
  // src/daemon/rules/loader.ts
20975
- var import_node_fs23 = require("fs");
20976
- var import_node_path16 = require("path");
20992
+ var import_node_fs24 = require("fs");
20993
+ var import_node_path17 = require("path");
20977
20994
 
20978
20995
  // src/daemon/rules/default-rules.ts
20979
20996
  var DEFAULT_RULES = [
@@ -21257,11 +21274,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
21257
21274
  function loadAllRules(customDir) {
21258
21275
  const rules = [...DEFAULT_RULES];
21259
21276
  const dir = customDir || RULES_DIR;
21260
- if ((0, import_node_fs23.existsSync)(dir)) {
21261
- const files = (0, import_node_fs23.readdirSync)(dir).filter((f) => f.endsWith(".json"));
21277
+ if ((0, import_node_fs24.existsSync)(dir)) {
21278
+ const files = (0, import_node_fs24.readdirSync)(dir).filter((f) => f.endsWith(".json"));
21262
21279
  for (const file of files) {
21263
21280
  try {
21264
- const raw = (0, import_node_fs23.readFileSync)((0, import_node_path16.join)(dir, file), "utf-8");
21281
+ const raw = (0, import_node_fs24.readFileSync)((0, import_node_path17.join)(dir, file), "utf-8");
21265
21282
  const parsed = JSON.parse(raw);
21266
21283
  const customRules = Array.isArray(parsed) ? parsed : [parsed];
21267
21284
  for (const rule of customRules) {
@@ -21424,7 +21441,7 @@ function detectFirewallAdapter() {
21424
21441
  }
21425
21442
 
21426
21443
  // src/daemon/firewall/remediation.ts
21427
- var import_node_fs24 = require("fs");
21444
+ var import_node_fs25 = require("fs");
21428
21445
  init_paths();
21429
21446
  var DEFAULT_CONFIG2 = {
21430
21447
  enabled: true,
@@ -21580,7 +21597,7 @@ var RemediationManager = class {
21580
21597
  }
21581
21598
  logLine(line) {
21582
21599
  try {
21583
- (0, import_node_fs24.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
21600
+ (0, import_node_fs25.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
21584
21601
  `);
21585
21602
  } catch {
21586
21603
  }
@@ -21636,7 +21653,7 @@ async function flushTelemetry(timeoutMs = 2e3) {
21636
21653
  // src/daemon/index.ts
21637
21654
  function readVersion2() {
21638
21655
  try {
21639
- const pkg = JSON.parse((0, import_node_fs25.readFileSync)((0, import_node_path17.join)(__dirname, "..", "package.json"), "utf-8"));
21656
+ const pkg = JSON.parse((0, import_node_fs26.readFileSync)((0, import_node_path18.join)(__dirname, "..", "package.json"), "utf-8"));
21640
21657
  return pkg.version || "0.0.0";
21641
21658
  } catch {
21642
21659
  return "0.0.0";
@@ -21644,7 +21661,7 @@ function readVersion2() {
21644
21661
  }
21645
21662
  function logLine(line) {
21646
21663
  try {
21647
- (0, import_node_fs25.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
21664
+ (0, import_node_fs26.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
21648
21665
  `);
21649
21666
  } catch {
21650
21667
  }
@@ -21672,7 +21689,7 @@ async function runDaemon() {
21672
21689
  } catch (err) {
21673
21690
  logLine(`[daemon] state db unavailable: ${err.message}`);
21674
21691
  }
21675
- const config = loadConfig((0, import_node_fs25.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
21692
+ const config = loadConfig((0, import_node_fs26.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
21676
21693
  bus.on("event", (event) => {
21677
21694
  logLine(`[event] ${event.severity} ${event.module} ${event.message}`);
21678
21695
  });
@@ -21763,7 +21780,7 @@ async function runDaemon() {
21763
21780
  // src/commands/daemon.ts
21764
21781
  init_paths();
21765
21782
  init_ipc_client();
21766
- var DAEMON_ENTRY = (0, import_node_path18.join)(__dirname, "daemon.js");
21783
+ var DAEMON_ENTRY = (0, import_node_path19.join)(__dirname, "daemon.js");
21767
21784
  async function daemonForeground() {
21768
21785
  await runDaemon();
21769
21786
  }
@@ -21774,7 +21791,7 @@ async function daemonStart() {
21774
21791
  return;
21775
21792
  }
21776
21793
  ensureRuntimeDirs();
21777
- if (!(0, import_node_fs26.existsSync)(DAEMON_ENTRY)) {
21794
+ if (!(0, import_node_fs27.existsSync)(DAEMON_ENTRY)) {
21778
21795
  console.log(source_default.red(` Daemon entry not found at ${DAEMON_ENTRY}.`));
21779
21796
  console.log(source_default.dim(" Reinstall with `threatcrush update` or `pnpm run build` in the cli package."));
21780
21797
  return;
@@ -21782,8 +21799,8 @@ async function daemonStart() {
21782
21799
  let out;
21783
21800
  let err;
21784
21801
  try {
21785
- out = (0, import_node_fs27.openSync)(PATHS.logFile, "a");
21786
- err = (0, import_node_fs27.openSync)(PATHS.logFile, "a");
21802
+ out = (0, import_node_fs28.openSync)(PATHS.logFile, "a");
21803
+ err = (0, import_node_fs28.openSync)(PATHS.logFile, "a");
21787
21804
  } catch (e) {
21788
21805
  const code = e.code;
21789
21806
  console.log(source_default.red(` \u2717 Cannot write daemon log at ${PATHS.logFile} (${code ?? "error"}).`));
@@ -21869,12 +21886,12 @@ async function waitForExit(pid, timeoutMs) {
21869
21886
  }
21870
21887
  async function releaseStaleSocket() {
21871
21888
  const deadline = Date.now() + 2e3;
21872
- while ((0, import_node_fs26.existsSync)(PATHS.socket) && Date.now() < deadline) {
21889
+ while ((0, import_node_fs27.existsSync)(PATHS.socket) && Date.now() < deadline) {
21873
21890
  await new Promise((r) => setTimeout(r, 50));
21874
21891
  }
21875
- if ((0, import_node_fs26.existsSync)(PATHS.socket)) {
21892
+ if ((0, import_node_fs27.existsSync)(PATHS.socket)) {
21876
21893
  try {
21877
- (0, import_node_fs26.unlinkSync)(PATHS.socket);
21894
+ (0, import_node_fs27.unlinkSync)(PATHS.socket);
21878
21895
  } catch {
21879
21896
  }
21880
21897
  }
@@ -21882,19 +21899,24 @@ async function releaseStaleSocket() {
21882
21899
 
21883
21900
  // src/commands/service.ts
21884
21901
  var import_node_child_process8 = require("child_process");
21885
- var import_node_fs28 = require("fs");
21886
- var import_node_path19 = require("path");
21902
+ var import_node_fs29 = require("fs");
21903
+ var import_node_path20 = require("path");
21887
21904
  var UNIT_PATH = "/etc/systemd/system/threatcrushd.service";
21888
21905
  function resolveTemplate() {
21889
- const templatePath = (0, import_node_path19.join)(__dirname, "systemd", "threatcrushd.service");
21890
- if (!(0, import_node_fs28.existsSync)(templatePath)) {
21906
+ const templatePath = (0, import_node_path20.join)(__dirname, "systemd", "threatcrushd.service");
21907
+ if (!(0, import_node_fs29.existsSync)(templatePath)) {
21891
21908
  throw new Error(`systemd unit template not found at ${templatePath}`);
21892
21909
  }
21893
- return (0, import_node_fs28.readFileSync)(templatePath, "utf-8");
21910
+ return (0, import_node_fs29.readFileSync)(templatePath, "utf-8");
21911
+ }
21912
+ function stableBinPath(binPath) {
21913
+ const stable = binPath.replace(/\/\.pnpm\/[^/]+\/node_modules\//, "/node_modules/");
21914
+ if (stable === binPath) return binPath;
21915
+ return (0, import_node_fs29.existsSync)(stable) ? stable : binPath;
21894
21916
  }
21895
21917
  function resolveBinPath() {
21896
21918
  const arg = process.argv[1];
21897
- if (arg && (0, import_node_fs28.existsSync)(arg)) return arg;
21919
+ if (arg && (0, import_node_fs29.existsSync)(arg)) return stableBinPath(arg);
21898
21920
  try {
21899
21921
  return (0, import_node_child_process8.execSync)("command -v threatcrush", { encoding: "utf-8" }).trim();
21900
21922
  } catch {
@@ -21915,7 +21937,7 @@ async function installServiceCommand() {
21915
21937
  return;
21916
21938
  }
21917
21939
  const unit = resolveTemplate().replace("{{BIN_PATH}}", resolveBinPath());
21918
- (0, import_node_fs28.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
21940
+ (0, import_node_fs29.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
21919
21941
  console.log(source_default.green(` \u2713 Installed unit file: ${UNIT_PATH}`));
21920
21942
  ensureSystemDirs();
21921
21943
  try {
@@ -21934,25 +21956,27 @@ function ensureSystemDirs() {
21934
21956
  { path: "/etc/threatcrush/modules", groupWritable: true, sticky: true },
21935
21957
  { path: "/etc/threatcrush/threatcrushd.conf.d", groupWritable: true },
21936
21958
  { path: "/var/log/threatcrush", groupWritable: false },
21937
- { path: "/var/lib/threatcrush", groupWritable: false },
21938
- { path: "/var/run/threatcrush", groupWritable: false }
21959
+ { path: "/var/lib/threatcrush", groupWritable: false }
21960
+ // /run/threatcrush is deliberately absent: it lives on a tmpfs, so creating
21961
+ // it here only lasts until the next reboot. The unit's RuntimeDirectory=
21962
+ // recreates it on every start instead.
21939
21963
  ];
21940
21964
  let admGid = null;
21941
21965
  try {
21942
- admGid = (0, import_node_fs28.statSync)("/var/log/auth.log").gid;
21966
+ admGid = (0, import_node_fs29.statSync)("/var/log/auth.log").gid;
21943
21967
  } catch {
21944
21968
  }
21945
21969
  for (const { path, groupWritable, sticky } of dirs) {
21946
21970
  try {
21947
- (0, import_node_fs28.mkdirSync)(path, { recursive: true });
21971
+ (0, import_node_fs29.mkdirSync)(path, { recursive: true });
21948
21972
  } catch {
21949
21973
  }
21950
21974
  try {
21951
21975
  if (groupWritable && admGid !== null) {
21952
- (0, import_node_fs28.chmodSync)(path, sticky ? 1533 : 509);
21976
+ (0, import_node_fs29.chmodSync)(path, sticky ? 1533 : 509);
21953
21977
  (0, import_node_child_process8.execSync)(`chgrp adm ${path}`, { stdio: "ignore" });
21954
21978
  } else {
21955
- (0, import_node_fs28.chmodSync)(path, 493);
21979
+ (0, import_node_fs29.chmodSync)(path, 493);
21956
21980
  }
21957
21981
  } catch {
21958
21982
  }
@@ -21978,7 +22002,7 @@ async function uninstallServiceCommand() {
21978
22002
  } catch {
21979
22003
  }
21980
22004
  try {
21981
- if ((0, import_node_fs28.existsSync)(UNIT_PATH)) {
22005
+ if ((0, import_node_fs29.existsSync)(UNIT_PATH)) {
21982
22006
  (0, import_node_child_process8.execSync)(`rm -f ${UNIT_PATH}`);
21983
22007
  console.log(source_default.green(` \u2713 Removed unit file: ${UNIT_PATH}`));
21984
22008
  }
@@ -22076,8 +22100,8 @@ function welcomeCommand() {
22076
22100
  }
22077
22101
 
22078
22102
  // src/commands/properties.ts
22079
- var import_node_fs29 = require("fs");
22080
- var import_node_path20 = require("path");
22103
+ var import_node_fs30 = require("fs");
22104
+ var import_node_path21 = require("path");
22081
22105
  var import_node_readline6 = __toESM(require("readline"));
22082
22106
  var API_URL7 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
22083
22107
  var KINDS = ["url", "api", "domain", "ip", "repo"];
@@ -22406,8 +22430,8 @@ async function propertiesRunsCommand(opts) {
22406
22430
  }
22407
22431
  }
22408
22432
  function parseImportFile(path) {
22409
- const ext = (0, import_node_path20.extname)(path).toLowerCase();
22410
- const raw = (0, import_node_fs29.readFileSync)(path, "utf-8");
22433
+ const ext = (0, import_node_path21.extname)(path).toLowerCase();
22434
+ const raw = (0, import_node_fs30.readFileSync)(path, "utf-8");
22411
22435
  if (ext === ".json") {
22412
22436
  const parsed = JSON.parse(raw);
22413
22437
  if (!Array.isArray(parsed)) throw new Error("JSON must be an array of objects");
@@ -22597,7 +22621,7 @@ async function rulesCommand(opts) {
22597
22621
  }
22598
22622
 
22599
22623
  // src/commands/harden.ts
22600
- var import_node_fs30 = require("fs");
22624
+ var import_node_fs31 = require("fs");
22601
22625
  var import_node_child_process9 = require("child_process");
22602
22626
  function tryExec(cmd) {
22603
22627
  try {
@@ -22608,7 +22632,7 @@ function tryExec(cmd) {
22608
22632
  }
22609
22633
  function tryRead(path) {
22610
22634
  try {
22611
- return (0, import_node_fs30.readFileSync)(path, "utf-8");
22635
+ return (0, import_node_fs31.readFileSync)(path, "utf-8");
22612
22636
  } catch {
22613
22637
  return null;
22614
22638
  }
@@ -22712,8 +22736,8 @@ function checkSshWeakConfig() {
22712
22736
  };
22713
22737
  }
22714
22738
  function checkAutoUpdates() {
22715
- const unattended = (0, import_node_fs30.existsSync)("/etc/apt/apt.conf.d/20auto-upgrades") || (0, import_node_fs30.existsSync)("/etc/apt/apt.conf.d/50unattended-upgrades");
22716
- const dnfAuto = (0, import_node_fs30.existsSync)("/etc/dnf/automatic.conf");
22739
+ const unattended = (0, import_node_fs31.existsSync)("/etc/apt/apt.conf.d/20auto-upgrades") || (0, import_node_fs31.existsSync)("/etc/apt/apt.conf.d/50unattended-upgrades");
22740
+ const dnfAuto = (0, import_node_fs31.existsSync)("/etc/dnf/automatic.conf");
22717
22741
  if (unattended || dnfAuto) {
22718
22742
  return {
22719
22743
  key: "auto-updates",
@@ -22839,7 +22863,7 @@ function checkFail2ban() {
22839
22863
  explanation: "fail2ban is installed and running."
22840
22864
  };
22841
22865
  }
22842
- if ((0, import_node_fs30.existsSync)("/etc/fail2ban/fail2ban.conf")) {
22866
+ if ((0, import_node_fs31.existsSync)("/etc/fail2ban/fail2ban.conf")) {
22843
22867
  return {
22844
22868
  key: checkKey,
22845
22869
  status: "warn",
@@ -23137,6 +23161,30 @@ async function latestPublishedVersion(pkgName, timeoutMs = 8e3) {
23137
23161
  return null;
23138
23162
  }
23139
23163
  }
23164
+ var DAEMON_UNIT = "threatcrushd.service";
23165
+ function systemdOwnsDaemon(mainPidOutput, daemonPid) {
23166
+ if (!mainPidOutput || !daemonPid) return false;
23167
+ const mainPid = Number.parseInt(mainPidOutput.trim(), 10);
23168
+ return Number.isFinite(mainPid) && mainPid > 0 && mainPid === daemonPid;
23169
+ }
23170
+ function daemonRefreshPlan(opts) {
23171
+ if (!opts.daemonRunning) return { action: "none" };
23172
+ if (opts.systemdManaged) {
23173
+ return { action: "manual", command: `sudo systemctl restart ${opts.unit ?? DAEMON_UNIT}` };
23174
+ }
23175
+ return { action: "restart" };
23176
+ }
23177
+ function staleDaemonWarning(cliVersion, daemonVersion, restartCommand = "threatcrush restart") {
23178
+ if (!cliVersion || !daemonVersion || cliVersion === daemonVersion) return null;
23179
+ return [
23180
+ "\u26A0 The CLI was updated, but the running daemon is still on the old build.",
23181
+ ` CLI: ${cliVersion}`,
23182
+ ` Daemon: ${daemonVersion}`,
23183
+ "",
23184
+ " A running daemon keeps executing the bundle it started from. Restart it:",
23185
+ ` ${restartCommand}`
23186
+ ];
23187
+ }
23140
23188
  function shadowedUpdateWarning(latest, active, activePath) {
23141
23189
  if (!latest || !active || latest === active) return null;
23142
23190
  return [
@@ -23152,12 +23200,7 @@ function shadowedUpdateWarning(latest, active, activePath) {
23152
23200
  }
23153
23201
 
23154
23202
  // src/index.ts
23155
- var PKG_VERSION2 = "0.1.8";
23156
- try {
23157
- const pkg = JSON.parse((0, import_node_fs31.readFileSync)((0, import_node_path21.join)(__dirname, "..", "package.json"), "utf-8"));
23158
- PKG_VERSION2 = pkg.version;
23159
- } catch {
23160
- }
23203
+ init_ipc_client();
23161
23204
  var LOGO2 = `
23162
23205
  ${source_default.green(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557")}
23163
23206
  ${source_default.green(" \u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D")}
@@ -23170,7 +23213,7 @@ ${source_default.dim(" C R U S H")}
23170
23213
  var API_URL8 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
23171
23214
  var PKG_NAME = "@profullstack/threatcrush";
23172
23215
  var DESKTOP_PKG_NAME = "@profullstack/threatcrush-desktop";
23173
- var INSTALL_CONFIG_PATH = (0, import_node_path21.join)((0, import_node_os8.homedir)(), ".threatcrush", "install.json");
23216
+ var INSTALL_CONFIG_PATH = (0, import_node_path22.join)((0, import_node_os8.homedir)(), ".threatcrush", "install.json");
23174
23217
  function detectPackageManager() {
23175
23218
  try {
23176
23219
  const npmGlobal = (0, import_node_child_process11.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
@@ -23196,7 +23239,7 @@ function detectPackageManager() {
23196
23239
  }
23197
23240
  function readInstallConfig() {
23198
23241
  try {
23199
- return JSON.parse((0, import_node_fs31.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
23242
+ return JSON.parse((0, import_node_fs32.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
23200
23243
  } catch {
23201
23244
  return {};
23202
23245
  }
@@ -23230,6 +23273,55 @@ async function reportIfStillStale() {
23230
23273
  }
23231
23274
  console.log();
23232
23275
  }
23276
+ async function liveDaemon() {
23277
+ const pid = findRunningDaemon();
23278
+ if (!pid) return { pid: null, version: null };
23279
+ const client = new IpcClient();
23280
+ try {
23281
+ await client.connect();
23282
+ const live = await client.status();
23283
+ return { pid, version: live.version ?? null };
23284
+ } catch {
23285
+ return { pid, version: null };
23286
+ } finally {
23287
+ client.close();
23288
+ }
23289
+ }
23290
+ async function refreshDaemonAfterUpgrade() {
23291
+ const before = await liveDaemon();
23292
+ const plan = daemonRefreshPlan({
23293
+ daemonRunning: before.pid !== null,
23294
+ systemdManaged: systemdOwnsDaemon(
23295
+ execQuiet(`systemctl show ${DAEMON_UNIT} -p MainPID --value`),
23296
+ before.pid
23297
+ )
23298
+ });
23299
+ if (plan.action === "none") return;
23300
+ if (plan.action === "manual") {
23301
+ console.log(source_default.yellow(" ! The daemon is managed by systemd and is still on the old build."));
23302
+ console.log(source_default.dim(` Restart it with: ${plan.command}
23303
+ `));
23304
+ return;
23305
+ }
23306
+ console.log(source_default.dim(" Restarting threatcrushd onto the new build...\n"));
23307
+ await daemonRestart();
23308
+ const after = await liveDaemon();
23309
+ const warning = staleDaemonWarning(PKG_VERSION, after.version);
23310
+ if (warning) {
23311
+ console.log(source_default.yellow(` ${warning[0]}`));
23312
+ for (const line of warning.slice(1)) {
23313
+ console.log(source_default.dim(` ${line}`));
23314
+ }
23315
+ console.log();
23316
+ }
23317
+ }
23318
+ function execQuiet(cmd) {
23319
+ try {
23320
+ return (0, import_node_child_process11.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
23321
+ } catch {
23322
+ return null;
23323
+ }
23324
+ }
23233
23325
  var program2 = new Command();
23234
23326
  program2.name("threatcrush").description(
23235
23327
  `${source_default.green("\u26A1 ThreatCrush")} \u2014 All-in-one security agent
@@ -23250,7 +23342,7 @@ ${source_default.dim("Examples:")}
23250
23342
  ${source_default.green("$")} threatcrush modules install ${source_default.dim("# Install a module")}
23251
23343
  ${source_default.green("$")} threatcrush update ${source_default.dim("# Update to latest")}
23252
23344
  ${source_default.green("$")} threatcrush remove ${source_default.dim("# Uninstall completely")}`
23253
- ).version(PKG_VERSION2, "-v, --version", "Show version number").helpOption("-h, --help", "Show this help").addHelpText("after", `
23345
+ ).version(PKG_VERSION, "-v, --version", "Show version number").helpOption("-h, --help", "Show this help").addHelpText("after", `
23254
23346
  ${source_default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}
23255
23347
  ${source_default.dim("Modules:")}
23256
23348
  ThreatCrush uses pluggable security modules. Core modules included:
@@ -23373,7 +23465,7 @@ program2.command("uninstall-service").description("Remove the threatcrushd syste
23373
23465
  program2.command("logs").description("Tail daemon logs").action(async () => {
23374
23466
  console.log(LOGO2);
23375
23467
  const logPath = PATHS.logFile;
23376
- if (!(0, import_node_fs31.existsSync)(logPath)) {
23468
+ if (!(0, import_node_fs32.existsSync)(logPath)) {
23377
23469
  console.log(source_default.yellow(` No log file found at ${logPath}`));
23378
23470
  console.log(source_default.dim(" Start the daemon first with `threatcrush start`\n"));
23379
23471
  return;
@@ -23446,7 +23538,7 @@ program2.command("update").description("Update ThreatCrush CLI and installed bun
23446
23538
  const installMode = opts.cli ? "server" : opts.desktop ? "desktop" : installConfig.installMode || "server";
23447
23539
  console.log(source_default.dim(` Detected package manager: ${holders.join(", ") || detectPackageManager()}`));
23448
23540
  console.log(source_default.dim(` Install mode: ${installMode}`));
23449
- console.log(source_default.dim(` Current version: ${PKG_VERSION2}
23541
+ console.log(source_default.dim(` Current version: ${PKG_VERSION}
23450
23542
  `));
23451
23543
  const commands = upgradeCommands(PKG_NAME);
23452
23544
  try {
@@ -23462,6 +23554,8 @@ program2.command("update").description("Update ThreatCrush CLI and installed bun
23462
23554
  console.log(source_default.dim(" Updated bundle: CLI only\n"));
23463
23555
  }
23464
23556
  await reportIfStillStale();
23557
+ await refreshDaemonAfterUpgrade();
23558
+ console.log(source_default.dim(" If a `threatcrush monitor --tui` is open, quit and relaunch it.\n"));
23465
23559
  } catch (err) {
23466
23560
  console.log(source_default.red("\n \u2717 Update failed. Try manually:\n"));
23467
23561
  for (const cmd of commands) {
@@ -23578,10 +23672,10 @@ storeCmd.command("search <query>").description("Search for modules in the store"
23578
23672
  });
23579
23673
  storeCmd.command("publish <url>").description("Publish a module from a git URL or web URL").action(async (url) => {
23580
23674
  console.log(LOGO2);
23581
- const configPath = (0, import_node_path21.join)((0, import_node_os8.homedir)(), ".threatcrush", "config.json");
23675
+ const configPath = (0, import_node_path22.join)((0, import_node_os8.homedir)(), ".threatcrush", "config.json");
23582
23676
  let email = "";
23583
23677
  try {
23584
- const config = JSON.parse((0, import_node_fs31.readFileSync)(configPath, "utf-8"));
23678
+ const config = JSON.parse((0, import_node_fs32.readFileSync)(configPath, "utf-8"));
23585
23679
  email = config.email || "";
23586
23680
  } catch {
23587
23681
  }
@@ -23598,9 +23692,9 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
23598
23692
  return;
23599
23693
  }
23600
23694
  try {
23601
- const dir = (0, import_node_path21.join)((0, import_node_os8.homedir)(), ".threatcrush");
23602
- if (!(0, import_node_fs31.existsSync)(dir)) (0, import_node_fs31.mkdirSync)(dir, { recursive: true });
23603
- (0, import_node_fs31.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
23695
+ const dir = (0, import_node_path22.join)((0, import_node_os8.homedir)(), ".threatcrush");
23696
+ if (!(0, import_node_fs32.existsSync)(dir)) (0, import_node_fs32.mkdirSync)(dir, { recursive: true });
23697
+ (0, import_node_fs32.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
23604
23698
  console.log(source_default.dim(` Saved email to ${configPath}`));
23605
23699
  } catch {
23606
23700
  }