@profullstack/threatcrush 0.13.59 → 0.13.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/daemon.js CHANGED
@@ -1643,20 +1643,20 @@ var require_parse_async = __commonJS({
1643
1643
  const index = 0;
1644
1644
  const blocksize = opts.blocksize || 40960;
1645
1645
  const parser = new TOMLParser();
1646
- return new Promise((resolve3, reject) => {
1647
- setImmediate(parseAsyncNext, index, blocksize, resolve3, reject);
1646
+ return new Promise((resolve4, reject) => {
1647
+ setImmediate(parseAsyncNext, index, blocksize, resolve4, reject);
1648
1648
  });
1649
- function parseAsyncNext(index2, blocksize2, resolve3, reject) {
1649
+ function parseAsyncNext(index2, blocksize2, resolve4, reject) {
1650
1650
  if (index2 >= str3.length) {
1651
1651
  try {
1652
- return resolve3(parser.finish());
1652
+ return resolve4(parser.finish());
1653
1653
  } catch (err) {
1654
1654
  return reject(prettyError(err, str3));
1655
1655
  }
1656
1656
  }
1657
1657
  try {
1658
1658
  parser.parse(str3.slice(index2, index2 + blocksize2));
1659
- setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve3, reject);
1659
+ setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve4, reject);
1660
1660
  } catch (err) {
1661
1661
  reject(prettyError(err, str3));
1662
1662
  }
@@ -1682,7 +1682,7 @@ var require_parse_stream = __commonJS({
1682
1682
  function parseReadable(stm) {
1683
1683
  const parser = new TOMLParser();
1684
1684
  stm.setEncoding("utf8");
1685
- return new Promise((resolve3, reject) => {
1685
+ return new Promise((resolve4, reject) => {
1686
1686
  let readable;
1687
1687
  let ended = false;
1688
1688
  let errored = false;
@@ -1690,7 +1690,7 @@ var require_parse_stream = __commonJS({
1690
1690
  ended = true;
1691
1691
  if (readable) return;
1692
1692
  try {
1693
- resolve3(parser.finish());
1693
+ resolve4(parser.finish());
1694
1694
  } catch (err) {
1695
1695
  reject(err);
1696
1696
  }
@@ -2026,10 +2026,10 @@ var require_toml = __commonJS({
2026
2026
  });
2027
2027
 
2028
2028
  // src/daemon/index.ts
2029
- var import_node_fs30 = require("fs");
2029
+ var import_node_fs31 = require("fs");
2030
2030
  var import_node_child_process11 = require("child_process");
2031
2031
  var import_node_os5 = require("os");
2032
- var import_node_path23 = require("path");
2032
+ var import_node_path24 = require("path");
2033
2033
  var import_node_util = require("util");
2034
2034
 
2035
2035
  // src/daemon/paths.ts
@@ -2451,7 +2451,7 @@ var IpcServer = class {
2451
2451
  } catch {
2452
2452
  }
2453
2453
  }
2454
- return new Promise((resolve3, reject) => {
2454
+ return new Promise((resolve4, reject) => {
2455
2455
  this.server = (0, import_node_net.createServer)((sock) => this.handleClient(sock));
2456
2456
  this.server.on("error", reject);
2457
2457
  this.server.listen(PATHS.socket, () => {
@@ -2470,7 +2470,7 @@ var IpcServer = class {
2470
2470
  }
2471
2471
  }
2472
2472
  }
2473
- resolve3();
2473
+ resolve4();
2474
2474
  });
2475
2475
  });
2476
2476
  }
@@ -2482,20 +2482,20 @@ var IpcServer = class {
2482
2482
  }
2483
2483
  }
2484
2484
  this.clients.clear();
2485
- return new Promise((resolve3) => {
2485
+ return new Promise((resolve4) => {
2486
2486
  if (!this.server) {
2487
2487
  try {
2488
2488
  if ((0, import_node_fs4.existsSync)(PATHS.socket)) (0, import_node_fs4.unlinkSync)(PATHS.socket);
2489
2489
  } catch {
2490
2490
  }
2491
- return resolve3();
2491
+ return resolve4();
2492
2492
  }
2493
2493
  this.server.close(() => {
2494
2494
  try {
2495
2495
  if ((0, import_node_fs4.existsSync)(PATHS.socket)) (0, import_node_fs4.unlinkSync)(PATHS.socket);
2496
2496
  } catch {
2497
2497
  }
2498
- resolve3();
2498
+ resolve4();
2499
2499
  });
2500
2500
  });
2501
2501
  }
@@ -11553,6 +11553,12 @@ function slackChannel(webhookUrl) {
11553
11553
  };
11554
11554
  }
11555
11555
 
11556
+ // src/daemon/workers/runs-worker.ts
11557
+ var import_promises = require("dns/promises");
11558
+ var import_node_fs20 = require("fs");
11559
+ var import_node_net5 = require("net");
11560
+ var import_node_path14 = require("path");
11561
+
11556
11562
  // src/core/cli-config.ts
11557
11563
  var import_node_fs15 = require("fs");
11558
11564
  var import_node_path8 = require("path");
@@ -11648,6 +11654,116 @@ async function cloudFetch(path, init = {}) {
11648
11654
  return send();
11649
11655
  }
11650
11656
 
11657
+ // src/core/cloud-events.ts
11658
+ var import_node_crypto3 = require("crypto");
11659
+ var import_node_net4 = require("net");
11660
+ function currentLink() {
11661
+ if (!hasSession()) return null;
11662
+ const cfg = readCliConfig();
11663
+ if (!cfg.server_id || !cfg.server_org_id) return null;
11664
+ return { serverId: cfg.server_id, orgId: cfg.server_org_id };
11665
+ }
11666
+ var SEVERITY_RANK4 = {
11667
+ info: 0,
11668
+ low: 1,
11669
+ medium: 2,
11670
+ high: 3,
11671
+ critical: 4
11672
+ };
11673
+ var MAX_TITLE_CHARS = 300;
11674
+ var MAX_METADATA_BYTES = 16 * 1024;
11675
+ var MAX_STRING_CHARS = 1024;
11676
+ function jsonBytes(value) {
11677
+ try {
11678
+ return Buffer.byteLength(JSON.stringify(value) ?? "");
11679
+ } catch {
11680
+ return Infinity;
11681
+ }
11682
+ }
11683
+ function trimMetadata(meta) {
11684
+ const entries = [];
11685
+ for (const [key, value] of Object.entries(meta)) {
11686
+ if (value === void 0 || typeof value === "function") continue;
11687
+ const cut = typeof value === "string" && value.length > MAX_STRING_CHARS ? `${value.slice(0, MAX_STRING_CHARS)}\u2026` : value;
11688
+ if (jsonBytes(cut) === Infinity) continue;
11689
+ entries.push([key, cut]);
11690
+ }
11691
+ let out = Object.fromEntries(entries);
11692
+ let truncated = entries.length !== Object.keys(meta).length;
11693
+ if (jsonBytes(out) > MAX_METADATA_BYTES) {
11694
+ truncated = true;
11695
+ const work = new Map(entries);
11696
+ const shrunk = /* @__PURE__ */ new Set();
11697
+ const size = () => jsonBytes({ ...Object.fromEntries(work), _truncated: true });
11698
+ while (work.size > 0 && size() > MAX_METADATA_BYTES) {
11699
+ const [key] = [...work.entries()].filter(([k]) => k !== "evidence" || !shrunk.has(k)).sort((a, b) => jsonBytes(b[1]) - jsonBytes(a[1]))[0] ?? [];
11700
+ if (key === void 0) break;
11701
+ if (!shrunk.has(key)) {
11702
+ const text = typeof work.get(key) === "string" ? work.get(key) : JSON.stringify(work.get(key));
11703
+ work.set(key, text.length > MAX_STRING_CHARS ? `${text.slice(0, MAX_STRING_CHARS)}\u2026` : text);
11704
+ shrunk.add(key);
11705
+ } else if (key !== "evidence") {
11706
+ work.delete(key);
11707
+ } else break;
11708
+ }
11709
+ out = Object.fromEntries(work);
11710
+ }
11711
+ return truncated ? { ...out, _truncated: true } : out;
11712
+ }
11713
+ function str(value) {
11714
+ return typeof value === "string" && value ? value : void 0;
11715
+ }
11716
+ function detectionEvent(serverId, event) {
11717
+ const { rule_id, username, user, description, ...rest } = event.details ?? {};
11718
+ const title = event.module === "rule-engine" ? event.message.replace(/^\[DETECTION\]\s*/, "") : event.message;
11719
+ return {
11720
+ type: "detection",
11721
+ server_id: serverId,
11722
+ severity: event.severity,
11723
+ title: title.slice(0, MAX_TITLE_CHARS) || event.module,
11724
+ rule_id: str(rule_id) ?? event.module,
11725
+ description: str(description),
11726
+ source_ip: event.source_ip && (0, import_node_net4.isIP)(event.source_ip) ? event.source_ip : void 0,
11727
+ username: str(username) ?? str(user),
11728
+ raw_metadata: trimMetadata({ module: event.module, category: event.category, ...rest }),
11729
+ detected_at: event.timestamp.toISOString()
11730
+ };
11731
+ }
11732
+ function remediationEvent(serverId, event) {
11733
+ const d = event.details ?? {};
11734
+ if (d.action !== "block" && d.action !== "unblock") return null;
11735
+ if (d.origin === "cloud" || !event.source_ip) return null;
11736
+ const at = event.timestamp;
11737
+ const ttl = typeof d.ttl_seconds === "number" ? d.ttl_seconds : null;
11738
+ return {
11739
+ type: "remediation",
11740
+ server_id: serverId,
11741
+ event_id: (0, import_node_crypto3.randomUUID)(),
11742
+ action_type: d.action,
11743
+ target_value: event.source_ip,
11744
+ status: d.failed === true ? "failed" : "executed",
11745
+ rule_id: str(d.rule_id),
11746
+ reason: str(d.reason),
11747
+ error: str(d.error),
11748
+ dry_run: d.dry_run === true,
11749
+ executed_at: at.toISOString(),
11750
+ expires_at: d.action === "block" && ttl !== null && d.failed !== true ? new Date(at.getTime() + ttl * 1e3).toISOString() : null
11751
+ };
11752
+ }
11753
+ function findingEvents(serverId, results, observedAt = /* @__PURE__ */ new Date()) {
11754
+ return results.map((r) => ({
11755
+ type: "hardening_finding",
11756
+ server_id: serverId,
11757
+ finding_key: r.key,
11758
+ status: r.status,
11759
+ severity: r.severity,
11760
+ title: r.title.slice(0, MAX_TITLE_CHARS),
11761
+ recommendation: r.recommendation,
11762
+ observed_at: observedAt.toISOString(),
11763
+ ...r.details ? { details: trimMetadata(r.details) } : {}
11764
+ }));
11765
+ }
11766
+
11651
11767
  // src/commands/scan.ts
11652
11768
  var import_node_fs19 = require("fs");
11653
11769
  var import_node_path13 = require("path");
@@ -15725,7 +15841,7 @@ async function queryOsv(name, version, ecosystem) {
15725
15841
  }
15726
15842
 
15727
15843
  // ../../packages/scan/src/node/sarif.ts
15728
- var import_node_crypto3 = require("crypto");
15844
+ var import_node_crypto4 = require("crypto");
15729
15845
  var import_node_path12 = require("path");
15730
15846
 
15731
15847
  // src/commands/scan.ts
@@ -15949,16 +16065,77 @@ async function collectPentestResults(targetUrl) {
15949
16065
  // src/daemon/workers/runs-worker.ts
15950
16066
  var POLL_INTERVAL_MS = 3e4;
15951
16067
  var SCHEDULE_INTERVAL_MS = 12e4;
16068
+ var NOT_PUBLIC = [
16069
+ ...DEFAULT_PROTECTED,
16070
+ "0.0.0.0/8",
16071
+ "100.64.0.0/10",
16072
+ "192.0.0.0/24",
16073
+ "198.18.0.0/15",
16074
+ "224.0.0.0/3",
16075
+ "::/128",
16076
+ "::ffff:0:0/96",
16077
+ "64:ff9b::/96",
16078
+ "ff00::/8"
16079
+ ];
16080
+ function isPublicTarget(ip) {
16081
+ return (0, import_node_net5.isIP)(ip) !== 0 && !isProtected(ip, NOT_PUBLIC);
16082
+ }
16083
+ async function pentestTargetError(rawUrl, resolveHost = async (h) => (await (0, import_promises.lookup)(h, { all: true })).map((a) => a.address)) {
16084
+ let url;
16085
+ try {
16086
+ url = new URL(rawUrl.startsWith("http") ? rawUrl : `https://${rawUrl}`);
16087
+ } catch {
16088
+ return `not a URL: ${rawUrl}`;
16089
+ }
16090
+ if (url.protocol !== "http:" && url.protocol !== "https:") return `not an http(s) URL: ${rawUrl}`;
16091
+ const host = url.hostname.replace(/^\[|\]$/g, "");
16092
+ let addresses;
16093
+ try {
16094
+ addresses = (0, import_node_net5.isIP)(host) ? [host] : await resolveHost(host);
16095
+ } catch (err) {
16096
+ return `cannot resolve ${host}: ${err.message}`;
16097
+ }
16098
+ if (addresses.length === 0) return `cannot resolve ${host}`;
16099
+ const inside = addresses.find((a) => !isPublicTarget(a));
16100
+ return inside ? `${host} resolves to ${inside}, which is not a public address; dashboard runs never reach inside this network` : null;
16101
+ }
16102
+ function scanTargetError(target, roots, real = import_node_fs20.realpathSync) {
16103
+ if (roots.length === 0) {
16104
+ return "dashboard scans of this machine are off; list the directories they may read in [cloud] run_scan_paths";
16105
+ }
16106
+ let path;
16107
+ try {
16108
+ path = real((0, import_node_path14.resolve)(target));
16109
+ } catch {
16110
+ return `no such path: ${target}`;
16111
+ }
16112
+ for (const root of roots) {
16113
+ let base;
16114
+ try {
16115
+ base = real((0, import_node_path14.resolve)(root));
16116
+ } catch {
16117
+ continue;
16118
+ }
16119
+ if (path === base || path.startsWith(base.endsWith(import_node_path14.sep) ? base : base + import_node_path14.sep)) return null;
16120
+ }
16121
+ return `${target} is outside [cloud] run_scan_paths`;
16122
+ }
15952
16123
  var RunsWorker = class {
15953
- constructor(bus2) {
16124
+ constructor(bus2, opts = { enabled: false, scanRoots: [] }) {
15954
16125
  this.bus = bus2;
16126
+ this.opts = opts;
15955
16127
  }
15956
16128
  bus;
16129
+ opts;
15957
16130
  pollTimer = null;
15958
16131
  scheduleTimer = null;
15959
16132
  running = false;
15960
16133
  orgIds = [];
15961
16134
  async start() {
16135
+ if (!this.opts.enabled) {
16136
+ this.opts.log?.("[runs] dashboard property runs off (set [cloud] runs = true to run them on this machine)");
16137
+ return;
16138
+ }
15962
16139
  if (!hasSession()) return;
15963
16140
  try {
15964
16141
  await this.refreshOrgs();
@@ -15980,7 +16157,7 @@ var RunsWorker = class {
15980
16157
  async scheduleTick() {
15981
16158
  if (!hasSession()) return;
15982
16159
  try {
15983
- if (this.orgIds.length === 0) await this.refreshOrgs();
16160
+ await this.refreshOrgs();
15984
16161
  for (const orgId of this.orgIds) {
15985
16162
  try {
15986
16163
  await cloudFetch(`/api/orgs/${orgId}/schedules/tick`, { method: "POST" });
@@ -15995,7 +16172,7 @@ var RunsWorker = class {
15995
16172
  if (!hasSession()) return;
15996
16173
  this.running = true;
15997
16174
  try {
15998
- if (this.orgIds.length === 0) await this.refreshOrgs();
16175
+ await this.refreshOrgs();
15999
16176
  for (const orgId of this.orgIds) {
16000
16177
  const claimed = await this.claimOne(orgId);
16001
16178
  if (!claimed) continue;
@@ -16007,11 +16184,10 @@ var RunsWorker = class {
16007
16184
  this.running = false;
16008
16185
  }
16009
16186
  }
16187
+ /** Only the org this server is linked to: never every org its user is in. */
16010
16188
  async refreshOrgs() {
16011
- const res = await cloudFetch("/api/orgs");
16012
- if (!res.ok) return;
16013
- const data = await res.json();
16014
- this.orgIds = (data.organizations || []).map((o) => o.id);
16189
+ const link = currentLink();
16190
+ this.orgIds = link ? [link.orgId] : [];
16015
16191
  }
16016
16192
  async claimOne(orgId) {
16017
16193
  try {
@@ -16038,6 +16214,18 @@ var RunsWorker = class {
16038
16214
  error: "property target missing"
16039
16215
  };
16040
16216
  }
16217
+ const refused = run.type === "scan" ? scanTargetError(target, this.opts.scanRoots) : await pentestTargetError(target);
16218
+ if (refused) {
16219
+ this.opts.log?.(`[runs] refused ${run.type} ${target}: ${refused}`);
16220
+ return {
16221
+ type: run.type,
16222
+ target,
16223
+ findings: [],
16224
+ severity_summary: { critical: 0, high: 0, medium: 0, low: 0, info: 0 },
16225
+ summary: `refused: ${refused}`,
16226
+ error: refused
16227
+ };
16228
+ }
16041
16229
  this.bus.announceModule("runs-worker", "running", `${run.type} ${run.property?.name || target}`);
16042
16230
  try {
16043
16231
  if (run.type === "scan") return await runScan(target);
@@ -16078,117 +16266,17 @@ var RunsWorker = class {
16078
16266
  }
16079
16267
  };
16080
16268
 
16081
- // src/core/cloud-events.ts
16082
- var import_node_crypto4 = require("crypto");
16083
- var import_node_net4 = require("net");
16084
- function currentLink() {
16085
- if (!hasSession()) return null;
16086
- const cfg = readCliConfig();
16087
- if (!cfg.server_id || !cfg.server_org_id) return null;
16088
- return { serverId: cfg.server_id, orgId: cfg.server_org_id };
16089
- }
16090
- var SEVERITY_RANK4 = {
16091
- info: 0,
16092
- low: 1,
16093
- medium: 2,
16094
- high: 3,
16095
- critical: 4
16096
- };
16097
- var MAX_TITLE_CHARS = 300;
16098
- var MAX_METADATA_BYTES = 16 * 1024;
16099
- var MAX_STRING_CHARS = 1024;
16100
- function jsonBytes(value) {
16101
- try {
16102
- return Buffer.byteLength(JSON.stringify(value) ?? "");
16103
- } catch {
16104
- return Infinity;
16105
- }
16106
- }
16107
- function trimMetadata(meta) {
16108
- const entries = [];
16109
- for (const [key, value] of Object.entries(meta)) {
16110
- if (value === void 0 || typeof value === "function") continue;
16111
- const cut = typeof value === "string" && value.length > MAX_STRING_CHARS ? `${value.slice(0, MAX_STRING_CHARS)}\u2026` : value;
16112
- if (jsonBytes(cut) === Infinity) continue;
16113
- entries.push([key, cut]);
16114
- }
16115
- let out = Object.fromEntries(entries);
16116
- let truncated = entries.length !== Object.keys(meta).length;
16117
- if (jsonBytes(out) > MAX_METADATA_BYTES) {
16118
- truncated = true;
16119
- const bySize = [...entries].sort((a, b) => jsonBytes(a[1]) - jsonBytes(b[1]));
16120
- while (bySize.length > 0 && jsonBytes({ ...Object.fromEntries(bySize), _truncated: true }) > MAX_METADATA_BYTES) {
16121
- bySize.pop();
16122
- }
16123
- out = Object.fromEntries(bySize);
16124
- }
16125
- return truncated ? { ...out, _truncated: true } : out;
16126
- }
16127
- function str(value) {
16128
- return typeof value === "string" && value ? value : void 0;
16129
- }
16130
- function detectionEvent(serverId, event) {
16131
- const { rule_id, username, user, description, ...rest } = event.details ?? {};
16132
- const title = event.module === "rule-engine" ? event.message.replace(/^\[DETECTION\]\s*/, "") : event.message;
16133
- return {
16134
- type: "detection",
16135
- server_id: serverId,
16136
- severity: event.severity,
16137
- title: title.slice(0, MAX_TITLE_CHARS) || event.module,
16138
- rule_id: str(rule_id) ?? event.module,
16139
- description: str(description),
16140
- source_ip: event.source_ip && (0, import_node_net4.isIP)(event.source_ip) ? event.source_ip : void 0,
16141
- username: str(username) ?? str(user),
16142
- raw_metadata: trimMetadata({ module: event.module, category: event.category, ...rest }),
16143
- detected_at: event.timestamp.toISOString()
16144
- };
16145
- }
16146
- function remediationEvent(serverId, event) {
16147
- const d = event.details ?? {};
16148
- if (d.action !== "block" && d.action !== "unblock") return null;
16149
- if (d.origin === "cloud" || !event.source_ip) return null;
16150
- const at = event.timestamp;
16151
- const ttl = typeof d.ttl_seconds === "number" ? d.ttl_seconds : null;
16152
- return {
16153
- type: "remediation",
16154
- server_id: serverId,
16155
- event_id: (0, import_node_crypto4.randomUUID)(),
16156
- action_type: d.action,
16157
- target_value: event.source_ip,
16158
- status: d.failed === true ? "failed" : "executed",
16159
- rule_id: str(d.rule_id),
16160
- reason: str(d.reason),
16161
- error: str(d.error),
16162
- dry_run: d.dry_run === true,
16163
- executed_at: at.toISOString(),
16164
- expires_at: d.action === "block" && ttl !== null && d.failed !== true ? new Date(at.getTime() + ttl * 1e3).toISOString() : null
16165
- };
16166
- }
16167
- function findingEvents(serverId, results, observedAt = /* @__PURE__ */ new Date()) {
16168
- return results.map((r) => ({
16169
- type: "hardening_finding",
16170
- server_id: serverId,
16171
- finding_key: r.key,
16172
- status: r.status,
16173
- severity: r.severity,
16174
- title: r.title.slice(0, MAX_TITLE_CHARS),
16175
- recommendation: r.recommendation,
16176
- observed_at: observedAt.toISOString(),
16177
- ...r.details ? { details: trimMetadata(r.details) } : {}
16178
- }));
16179
- }
16180
-
16181
16269
  // src/daemon/workers/cloud-spool.ts
16182
- var import_node_fs20 = require("fs");
16183
- var import_promises = require("fs/promises");
16184
- var import_node_path14 = require("path");
16270
+ var import_node_fs21 = require("fs");
16271
+ var import_promises2 = require("fs/promises");
16272
+ var import_node_path15 = require("path");
16185
16273
  var DEFAULT_SPOOL_LIMITS = { maxEvents: 1e4, maxBytes: 20 * 1024 * 1024 };
16186
16274
  var CloudSpool = class {
16187
16275
  constructor(path, limits = DEFAULT_SPOOL_LIMITS) {
16188
16276
  this.path = path;
16189
16277
  this.limits = limits;
16190
16278
  try {
16191
- (0, import_node_fs20.mkdirSync)((0, import_node_path14.dirname)(path), { recursive: true });
16279
+ (0, import_node_fs21.mkdirSync)((0, import_node_path15.dirname)(path), { recursive: true });
16192
16280
  } catch {
16193
16281
  }
16194
16282
  this.load();
@@ -16257,7 +16345,7 @@ var CloudSpool = class {
16257
16345
  load() {
16258
16346
  let raw;
16259
16347
  try {
16260
- raw = (0, import_node_fs20.readFileSync)(this.path, "utf-8");
16348
+ raw = (0, import_node_fs21.readFileSync)(this.path, "utf-8");
16261
16349
  } catch {
16262
16350
  return;
16263
16351
  }
@@ -16288,13 +16376,13 @@ var CloudSpool = class {
16288
16376
  const body = this.lines.length > 0 ? `${this.lines.join("\n")}
16289
16377
  ` : "";
16290
16378
  const tmp = `${this.path}.tmp`;
16291
- await (0, import_promises.writeFile)(tmp, body, { mode: 384 });
16292
- await (0, import_promises.rename)(tmp, this.path);
16379
+ await (0, import_promises2.writeFile)(tmp, body, { mode: 384 });
16380
+ await (0, import_promises2.rename)(tmp, this.path);
16293
16381
  } else if (this.pendingAppend.length > 0) {
16294
16382
  const chunk = `${this.pendingAppend.join("\n")}
16295
16383
  `;
16296
16384
  this.pendingAppend = [];
16297
- await (0, import_promises.appendFile)(this.path, chunk, { mode: 384 });
16385
+ await (0, import_promises2.appendFile)(this.path, chunk, { mode: 384 });
16298
16386
  }
16299
16387
  }).catch(() => {
16300
16388
  this.needsRewrite = true;
@@ -16498,7 +16586,7 @@ var CloudSync = class {
16498
16586
  var import_node_crypto5 = require("crypto");
16499
16587
 
16500
16588
  // src/daemon/workers/abuse-evidence.ts
16501
- var import_node_net5 = require("net");
16589
+ var import_node_net6 = require("net");
16502
16590
  var NEVER_REPORT_RANGES = [
16503
16591
  ...DEFAULT_PROTECTED,
16504
16592
  "100.64.0.0/10",
@@ -16574,7 +16662,7 @@ function summarizeEvidence(events) {
16574
16662
  };
16575
16663
  }
16576
16664
  function isReportable(ip, evidence, config, now = Date.now()) {
16577
- if ((0, import_node_net5.isIP)(ip) === 0) return { reportable: false, reason: "not an IP address" };
16665
+ if ((0, import_node_net6.isIP)(ip) === 0) return { reportable: false, reason: "not an IP address" };
16578
16666
  if (isProtected(ip, config.neverReport)) {
16579
16667
  return { reportable: false, reason: "address is in a never-report range (private/CGNAT/reserved/allowlisted)" };
16580
16668
  }
@@ -16723,31 +16811,31 @@ function resolveConfig(section) {
16723
16811
  }
16724
16812
 
16725
16813
  // src/core/abuse-report-log.ts
16726
- var import_node_fs21 = require("fs");
16727
- var import_node_path15 = require("path");
16814
+ var import_node_fs22 = require("fs");
16815
+ var import_node_path16 = require("path");
16728
16816
  var ABUSE_DIRNAME = "abuse-reports";
16729
16817
  var LOG_FILE = "reports.jsonl";
16730
16818
  function resolveAbuseDir(dir) {
16731
16819
  if (dir) return dir;
16732
16820
  if (process.env.THREATCRUSH_ABUSE_DIR) return process.env.THREATCRUSH_ABUSE_DIR;
16733
- const system = (0, import_node_path15.join)("/var/lib/threatcrush", ABUSE_DIRNAME);
16734
- if ((0, import_node_fs21.existsSync)(system)) return system;
16735
- return (0, import_node_path15.join)(PATHS.stateDir, ABUSE_DIRNAME);
16821
+ const system = (0, import_node_path16.join)("/var/lib/threatcrush", ABUSE_DIRNAME);
16822
+ if ((0, import_node_fs22.existsSync)(system)) return system;
16823
+ return (0, import_node_path16.join)(PATHS.stateDir, ABUSE_DIRNAME);
16736
16824
  }
16737
16825
  function logPath(dir) {
16738
- return (0, import_node_path15.join)(resolveAbuseDir(dir), LOG_FILE);
16826
+ return (0, import_node_path16.join)(resolveAbuseDir(dir), LOG_FILE);
16739
16827
  }
16740
16828
  function appendReport(record, dir) {
16741
16829
  const path = logPath(dir);
16742
- (0, import_node_fs21.mkdirSync)(resolveAbuseDir(dir), { recursive: true, mode: 493 });
16743
- (0, import_node_fs21.appendFileSync)(path, `${JSON.stringify(record)}
16830
+ (0, import_node_fs22.mkdirSync)(resolveAbuseDir(dir), { recursive: true, mode: 493 });
16831
+ (0, import_node_fs22.appendFileSync)(path, `${JSON.stringify(record)}
16744
16832
  `, { mode: 420 });
16745
16833
  }
16746
16834
  function readReports(dir) {
16747
16835
  const path = logPath(dir);
16748
16836
  let raw;
16749
16837
  try {
16750
- raw = (0, import_node_fs21.readFileSync)(path, "utf-8");
16838
+ raw = (0, import_node_fs22.readFileSync)(path, "utf-8");
16751
16839
  } catch {
16752
16840
  return [];
16753
16841
  }
@@ -16905,18 +16993,25 @@ var AbuseReporter = class {
16905
16993
  };
16906
16994
 
16907
16995
  // src/daemon/workers/remediation-consumer.ts
16908
- var import_node_net7 = require("net");
16996
+ var import_node_net8 = require("net");
16909
16997
 
16910
16998
  // src/daemon/workers/allowlist-sync.ts
16911
- var import_node_net6 = require("net");
16999
+ var import_node_net7 = require("net");
16912
17000
  function isAddressOrCidr(value) {
16913
17001
  const [network, prefix, extra] = value.split("/");
16914
- const family = (0, import_node_net6.isIP)(network);
17002
+ const family = (0, import_node_net7.isIP)(network);
16915
17003
  if (family === 0 || extra !== void 0) return false;
16916
17004
  if (prefix === void 0) return true;
16917
17005
  if (!/^\d{1,3}$/.test(prefix)) return false;
16918
17006
  return Number(prefix) <= (family === 4 ? 32 : 128);
16919
17007
  }
17008
+ var CLOUD_MIN_PREFIX = { 4: 8, 6: 16 };
17009
+ function isCloudAllowEntry(value) {
17010
+ if (!isAddressOrCidr(value)) return false;
17011
+ const [network, prefix] = value.split("/");
17012
+ if (prefix === void 0) return true;
17013
+ return Number(prefix) >= CLOUD_MIN_PREFIX[(0, import_node_net7.isIP)(network)];
17014
+ }
16920
17015
  var AllowlistSync = class {
16921
17016
  constructor(manager, opts) {
16922
17017
  this.manager = manager;
@@ -16952,7 +17047,8 @@ var AllowlistSync = class {
16952
17047
  for (const entry of entries) {
16953
17048
  if (entry.type !== "ip" && entry.type !== "cidr") continue;
16954
17049
  const value = String(entry.value ?? "").trim();
16955
- if (isAddressOrCidr(value)) wanted.add(value);
17050
+ if (isCloudAllowEntry(value)) wanted.add(value);
17051
+ else if (isAddressOrCidr(value)) this.opts.log(`[cloud] org allowlist: ignoring ${value} (wider than /${CLOUD_MIN_PREFIX[(0, import_node_net7.isIP)(value.split("/")[0])]})`);
16956
17052
  }
16957
17053
  const added2 = [];
16958
17054
  const protectedNow = new Set(this.manager.getProtected());
@@ -17060,7 +17156,7 @@ var RemediationConsumer = class {
17060
17156
  try {
17061
17157
  switch (action.action_type) {
17062
17158
  case "block": {
17063
- if ((0, import_node_net7.isIP)(target) === 0) return failed(`not an IP address: ${target}`);
17159
+ if ((0, import_node_net8.isIP)(target) === 0) return failed(`not an IP address: ${target}`);
17064
17160
  let ttlSeconds = this.manager.status().max_ban_seconds;
17065
17161
  if (action.expires_at) {
17066
17162
  const until = Date.parse(action.expires_at);
@@ -17079,7 +17175,7 @@ var RemediationConsumer = class {
17079
17175
  return { status: "executed", dry_run: result.entry?.dry_run === true, executed_at };
17080
17176
  }
17081
17177
  case "unblock": {
17082
- if ((0, import_node_net7.isIP)(target) === 0) return failed(`not an IP address: ${target}`);
17178
+ if ((0, import_node_net8.isIP)(target) === 0) return failed(`not an IP address: ${target}`);
17083
17179
  const wasBanned = this.manager.getBlocklist().some((b) => b.ip === target);
17084
17180
  const result = await this.manager.unban(target, {
17085
17181
  forget: true,
@@ -17092,13 +17188,16 @@ var RemediationConsumer = class {
17092
17188
  return { status: "executed", dry_run: this.manager.status().dry_run, executed_at };
17093
17189
  }
17094
17190
  case "allowlist_add":
17095
- if (!isAddressOrCidr(target)) return failed(`not an IP address or CIDR: ${target}`);
17191
+ if (!isCloudAllowEntry(target)) return failed(`not an IP address or CIDR the dashboard may protect: ${target}`);
17096
17192
  this.manager.addToAllowlist(target);
17097
17193
  return { status: "executed", executed_at };
17098
17194
  case "allowlist_remove":
17099
17195
  if (DEFAULT_PROTECTED.includes(target)) {
17100
17196
  return failed(`${target} is a built-in protected range and cannot be removed`);
17101
17197
  }
17198
+ if (this.manager.isPinned(target)) {
17199
+ return failed(`${target} is protected by this server's own configuration and cannot be removed from the dashboard`);
17200
+ }
17102
17201
  this.manager.removeFromAllowlist(target);
17103
17202
  return { status: "executed", executed_at };
17104
17203
  case "restart": {
@@ -17131,8 +17230,8 @@ var RemediationConsumer = class {
17131
17230
 
17132
17231
  // src/daemon/workers/auto-update.ts
17133
17232
  var import_node_child_process5 = require("child_process");
17134
- var import_node_fs22 = require("fs");
17135
- var import_node_path16 = require("path");
17233
+ var import_node_fs23 = require("fs");
17234
+ var import_node_path17 = require("path");
17136
17235
  var PKG_NAME = "@profullstack/threatcrush";
17137
17236
  var REGISTRY = `https://registry.npmjs.org/${PKG_NAME}`;
17138
17237
  var DEFAULT_INTERVAL_MS = 6 * 36e5;
@@ -17175,12 +17274,12 @@ function pickUpdate(doc, current, opts) {
17175
17274
  return { version: null, reason: `${latest} is younger than min_age, and nothing older is newer than ${current}; waiting` };
17176
17275
  }
17177
17276
  function installPlan(opts) {
17178
- const expected = `${import_node_path16.sep}lib${import_node_path16.sep}node_modules${import_node_path16.sep}@profullstack${import_node_path16.sep}threatcrush`;
17277
+ const expected = `${import_node_path17.sep}lib${import_node_path17.sep}node_modules${import_node_path17.sep}@profullstack${import_node_path17.sep}threatcrush`;
17179
17278
  if (!opts.pkgRoot.endsWith(expected)) {
17180
17279
  return { kind: "unsupported", reason: `not an npm global install (${opts.pkgRoot}); run \`threatcrush update\`` };
17181
17280
  }
17182
- const nodeBin = (0, import_node_path16.dirname)(opts.execPath);
17183
- const npm = (0, import_node_path16.join)(nodeBin, "npm");
17281
+ const nodeBin = (0, import_node_path17.dirname)(opts.execPath);
17282
+ const npm = (0, import_node_path17.join)(nodeBin, "npm");
17184
17283
  if (!opts.npmExists(npm)) return { kind: "unsupported", reason: `no npm beside ${opts.execPath}` };
17185
17284
  if (!opts.owner) return { kind: "unsupported", reason: `cannot tell who owns ${opts.pkgRoot}` };
17186
17285
  const npmArgs = [npm, "i", "-g", `${PKG_NAME}@${opts.version}`, "--no-fund", "--no-audit"];
@@ -17212,10 +17311,10 @@ function installPlan(opts) {
17212
17311
  }
17213
17312
  function ownerOf(path, passwd = "/etc/passwd") {
17214
17313
  try {
17215
- const st = (0, import_node_fs22.statSync)(path);
17314
+ const st = (0, import_node_fs23.statSync)(path);
17216
17315
  let home = st.uid === 0 ? "/root" : "";
17217
17316
  try {
17218
- for (const line of (0, import_node_fs22.readFileSync)(passwd, "utf8").split("\n")) {
17317
+ for (const line of (0, import_node_fs23.readFileSync)(passwd, "utf8").split("\n")) {
17219
17318
  const f = line.split(":");
17220
17319
  if (Number(f[2]) === st.uid && f[5]) home = f[5];
17221
17320
  }
@@ -17237,7 +17336,7 @@ function updateSettings(section, env2 = process.env) {
17237
17336
  };
17238
17337
  }
17239
17338
  function defaultRun(argv, env2) {
17240
- return new Promise((resolve3) => {
17339
+ return new Promise((resolve4) => {
17241
17340
  const child = (0, import_node_child_process5.spawn)(argv[0], argv.slice(1), {
17242
17341
  env: { ...process.env, ...env2 },
17243
17342
  stdio: ["ignore", "pipe", "pipe"]
@@ -17248,8 +17347,8 @@ function defaultRun(argv, env2) {
17248
17347
  };
17249
17348
  child.stdout?.on("data", keep);
17250
17349
  child.stderr?.on("data", keep);
17251
- child.on("error", (err) => resolve3({ code: -1, output: err.message }));
17252
- child.on("close", (code) => resolve3({ code: code ?? -1, output }));
17350
+ child.on("error", (err) => resolve4({ code: -1, output: err.message }));
17351
+ child.on("close", (code) => resolve4({ code: code ?? -1, output }));
17253
17352
  });
17254
17353
  }
17255
17354
  var AutoUpdate = class {
@@ -17325,7 +17424,7 @@ var AutoUpdate = class {
17325
17424
  uid: process.getuid?.() ?? -1,
17326
17425
  owner: ownerOf(this.opts.pkgRoot),
17327
17426
  underSystemd: this.opts.underSystemd ?? Boolean(process.env.INVOCATION_ID),
17328
- npmExists: import_node_fs22.existsSync
17427
+ npmExists: import_node_fs23.existsSync
17329
17428
  });
17330
17429
  if (plan.kind === "unsupported") return this.note(`${target} is available but cannot self-install: ${plan.reason}`);
17331
17430
  this.recordAttempt(target);
@@ -17361,7 +17460,7 @@ var AutoUpdate = class {
17361
17460
  }
17362
17461
  lastAttempt() {
17363
17462
  try {
17364
- const v = JSON.parse((0, import_node_fs22.readFileSync)(this.opts.statePath, "utf8"));
17463
+ const v = JSON.parse((0, import_node_fs23.readFileSync)(this.opts.statePath, "utf8"));
17365
17464
  return v.version && typeof v.at === "number" ? { version: v.version, at: v.at } : null;
17366
17465
  } catch {
17367
17466
  return null;
@@ -17369,7 +17468,7 @@ var AutoUpdate = class {
17369
17468
  }
17370
17469
  recordAttempt(version) {
17371
17470
  try {
17372
- (0, import_node_fs22.writeFileSync)(this.opts.statePath, JSON.stringify({ version, at: this.now() }));
17471
+ (0, import_node_fs23.writeFileSync)(this.opts.statePath, JSON.stringify({ version, at: this.now() }));
17373
17472
  } catch (err) {
17374
17473
  this.opts.log(`[update] could not record attempt: ${err.message}`);
17375
17474
  }
@@ -17378,9 +17477,9 @@ var AutoUpdate = class {
17378
17477
 
17379
17478
  // src/daemon/workers/threat-feeds.ts
17380
17479
  var import_node_child_process6 = require("child_process");
17381
- var import_node_fs23 = require("fs");
17382
- var import_node_path17 = require("path");
17383
- var import_node_net8 = require("net");
17480
+ var import_node_fs24 = require("fs");
17481
+ var import_node_path18 = require("path");
17482
+ var import_node_net9 = require("net");
17384
17483
  var EGRESS_TABLE = "threatcrush_egress";
17385
17484
  var DEFAULT_REFRESH_MS = 36e5;
17386
17485
  var POLL_MS = 15e3;
@@ -17398,8 +17497,8 @@ function threatFeedSettings(section) {
17398
17497
  };
17399
17498
  }
17400
17499
  function egressRuleset(ips) {
17401
- const v4 = ips.filter((ip) => (0, import_node_net8.isIP)(ip) === 4);
17402
- const v6 = ips.filter((ip) => (0, import_node_net8.isIP)(ip) === 6);
17500
+ const v4 = ips.filter((ip) => (0, import_node_net9.isIP)(ip) === 4);
17501
+ const v6 = ips.filter((ip) => (0, import_node_net9.isIP)(ip) === 6);
17403
17502
  const set = (name, type, items) => ` set ${name} { type ${type};${items.length ? ` elements = { ${items.join(", ")} }` : ""} }`;
17404
17503
  const chain = (name, hook) => [
17405
17504
  ` chain ${name} {`,
@@ -17424,7 +17523,7 @@ function splitAddr(addr) {
17424
17523
  const m = /^\[?(.+?)\]?:(\d+|\*)$/.exec(addr);
17425
17524
  if (!m) return null;
17426
17525
  const ip = m[1].replace(/%.*$/, "").replace(/^::ffff:/i, "");
17427
- return (0, import_node_net8.isIP)(ip) ? { ip, port: m[2] === "*" ? 0 : Number(m[2]) } : null;
17526
+ return (0, import_node_net9.isIP)(ip) ? { ip, port: m[2] === "*" ? 0 : Number(m[2]) } : null;
17428
17527
  }
17429
17528
  function parseSs(text) {
17430
17529
  const out = [];
@@ -17550,14 +17649,14 @@ var ThreatFeeds = class {
17550
17649
  */
17551
17650
  writeResolverFiles(set) {
17552
17651
  const domains = this.wantsDomainBlock ? Object.keys(set.domains).sort() : [];
17553
- const dir = this.opts.resolverDir ?? (0, import_node_path17.dirname)(this.opts.cachePath);
17652
+ const dir = this.opts.resolverDir ?? (0, import_node_path18.dirname)(this.opts.cachePath);
17554
17653
  const hooks = this.opts.resolverHooks ?? RESOLVER_HOOKS;
17555
17654
  const write = (name, content) => {
17556
- const path = (0, import_node_path17.join)(dir, name);
17655
+ const path = (0, import_node_path18.join)(dir, name);
17557
17656
  if (this.resolverWritten.get(name) === content) return false;
17558
17657
  try {
17559
- (0, import_node_fs23.writeFileSync)(`${path}.tmp`, content);
17560
- (0, import_node_fs23.renameSync)(`${path}.tmp`, path);
17658
+ (0, import_node_fs24.writeFileSync)(`${path}.tmp`, content);
17659
+ (0, import_node_fs24.renameSync)(`${path}.tmp`, path);
17561
17660
  this.resolverWritten.set(name, content);
17562
17661
  return true;
17563
17662
  } catch (err) {
@@ -17568,11 +17667,11 @@ var ThreatFeeds = class {
17568
17667
  const hostsChanged = write(RESOLVER_FILES.hosts, hostsBlocklist(domains));
17569
17668
  const unboundChanged = write(RESOLVER_FILES.unbound, unboundBlocklist(domains));
17570
17669
  const via = [];
17571
- if ((0, import_node_fs23.existsSync)(hooks.dnsmasq)) {
17670
+ if ((0, import_node_fs24.existsSync)(hooks.dnsmasq)) {
17572
17671
  via.push("dnsmasq");
17573
17672
  if (hostsChanged) this.run("systemctl", ["kill", "-s", "HUP", "dnsmasq.service"]);
17574
17673
  }
17575
- if ((0, import_node_fs23.existsSync)(hooks.unbound)) {
17674
+ if ((0, import_node_fs24.existsSync)(hooks.unbound)) {
17576
17675
  via.push("unbound");
17577
17676
  if (unboundChanged && this.run("unbound-control", ["reload"]) === null) {
17578
17677
  this.run("systemctl", ["reload", "unbound.service"]);
@@ -17633,8 +17732,8 @@ var ThreatFeeds = class {
17633
17732
  };
17634
17733
 
17635
17734
  // src/daemon/workers/privilege-watch.ts
17636
- var import_node_fs24 = require("fs");
17637
- var import_node_path18 = require("path");
17735
+ var import_node_fs25 = require("fs");
17736
+ var import_node_path19 = require("path");
17638
17737
  var import_node_child_process7 = require("child_process");
17639
17738
 
17640
17739
  // src/core/privileges/index.ts
@@ -17825,31 +17924,31 @@ function countryName(code) {
17825
17924
  var fsIO = {
17826
17925
  readFile: (p) => {
17827
17926
  try {
17828
- return (0, import_node_fs24.readFileSync)(p, "utf-8");
17927
+ return (0, import_node_fs25.readFileSync)(p, "utf-8");
17829
17928
  } catch {
17830
17929
  return null;
17831
17930
  }
17832
17931
  },
17833
17932
  readDir: (p) => {
17834
17933
  try {
17835
- return (0, import_node_fs24.readdirSync)(p);
17934
+ return (0, import_node_fs25.readdirSync)(p);
17836
17935
  } catch {
17837
17936
  return null;
17838
17937
  }
17839
17938
  },
17840
- exists: (p) => (0, import_node_fs24.existsSync)(p)
17939
+ exists: (p) => (0, import_node_fs25.existsSync)(p)
17841
17940
  };
17842
17941
  function readJson(path) {
17843
17942
  try {
17844
- return JSON.parse((0, import_node_fs24.readFileSync)(path, "utf-8"));
17943
+ return JSON.parse((0, import_node_fs25.readFileSync)(path, "utf-8"));
17845
17944
  } catch {
17846
17945
  return null;
17847
17946
  }
17848
17947
  }
17849
17948
  function writeJson(path, value) {
17850
- (0, import_node_fs24.mkdirSync)((0, import_node_path18.dirname)(path), { recursive: true });
17851
- (0, import_node_fs24.writeFileSync)(`${path}.tmp`, JSON.stringify(value));
17852
- (0, import_node_fs24.renameSync)(`${path}.tmp`, path);
17949
+ (0, import_node_fs25.mkdirSync)((0, import_node_path19.dirname)(path), { recursive: true });
17950
+ (0, import_node_fs25.writeFileSync)(`${path}.tmp`, JSON.stringify(value));
17951
+ (0, import_node_fs25.renameSync)(`${path}.tmp`, path);
17853
17952
  }
17854
17953
  function defaultRun3(cmd, args) {
17855
17954
  const res = (0, import_node_child_process7.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 2e4, maxBuffer: 16 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
@@ -18005,7 +18104,7 @@ var PrivilegeWatch = class {
18005
18104
  * raised a "new country" alert on its first run; on dev2 it did, at once.
18006
18105
  */
18007
18106
  async backfillLogins() {
18008
- if ((0, import_node_fs24.existsSync)(this.opts.loginsPath)) return;
18107
+ if ((0, import_node_fs25.existsSync)(this.opts.loginsPath)) return;
18009
18108
  const out = this.run("journalctl", ["_COMM=sshd", "_COMM=sshd-session", "--since=-30d", "-o", "cat", "--no-pager"]);
18010
18109
  const byUser = parseAcceptedLogins(out ?? "");
18011
18110
  const ips = [...new Set([...byUser.values()].flatMap((s) => [...s]))];
@@ -18018,7 +18117,7 @@ var PrivilegeWatch = class {
18018
18117
  return;
18019
18118
  }
18020
18119
  }
18021
- if ((0, import_node_fs24.existsSync)(this.opts.loginsPath)) return;
18120
+ if ((0, import_node_fs25.existsSync)(this.opts.loginsPath)) return;
18022
18121
  const at = this.now().toISOString();
18023
18122
  const history = {};
18024
18123
  for (const [user, userIps] of byUser) {
@@ -18083,6 +18182,23 @@ function expire(window, now) {
18083
18182
  window.head = 0;
18084
18183
  }
18085
18184
  }
18185
+ var EVIDENCE_MESSAGE_CHARS = 500;
18186
+ var EVIDENCE_FIELD_CHARS = 200;
18187
+ var EVIDENCE_FIELDS = ["unit", "identifier", "process", "comm", "pid", "user", "path", "method", "status", "host", "priority"];
18188
+ function evidenceOf(event) {
18189
+ const details = event.details ?? {};
18190
+ const out = {
18191
+ at: event.timestamp instanceof Date ? event.timestamp.toISOString() : String(event.timestamp ?? ""),
18192
+ module: event.module,
18193
+ message: String(event.message ?? "").slice(0, EVIDENCE_MESSAGE_CHARS)
18194
+ };
18195
+ if (event.source_ip) out.source_ip = event.source_ip;
18196
+ for (const k of EVIDENCE_FIELDS) {
18197
+ const v = details[k];
18198
+ if (typeof v === "string" || typeof v === "number") out[k] = String(v).slice(0, EVIDENCE_FIELD_CHARS);
18199
+ }
18200
+ return out;
18201
+ }
18086
18202
  var RuleEngine = class {
18087
18203
  constructor(onDetection) {
18088
18204
  this.onDetection = onDetection;
@@ -18151,6 +18267,9 @@ var RuleEngine = class {
18151
18267
  tags: rule.tags,
18152
18268
  category: rule.category,
18153
18269
  remediation: rule.remediation,
18270
+ // What actually happened: without this every alert, page and incident
18271
+ // could only repeat the rule's description ("a critical log message").
18272
+ evidence: evidenceOf(event),
18154
18273
  ...aggregate ? { group_by: groupBy, group: groupValue, distinct_ips: distinctIps, hits } : {}
18155
18274
  }
18156
18275
  });
@@ -18230,8 +18349,8 @@ var RuleEngine = class {
18230
18349
  };
18231
18350
 
18232
18351
  // src/daemon/rules/loader.ts
18233
- var import_node_fs25 = require("fs");
18234
- var import_node_path19 = require("path");
18352
+ var import_node_fs26 = require("fs");
18353
+ var import_node_path20 = require("path");
18235
18354
 
18236
18355
  // src/daemon/rules/default-rules.ts
18237
18356
  var AT_CRS_THRESHOLD = { field: "severity", operator: "regex", value: "^(high|critical)$" };
@@ -18701,11 +18820,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
18701
18820
  function loadAllRules(customDir) {
18702
18821
  const rules = [...DEFAULT_RULES];
18703
18822
  const dir = customDir || RULES_DIR;
18704
- if ((0, import_node_fs25.existsSync)(dir)) {
18705
- const files = (0, import_node_fs25.readdirSync)(dir).filter((f) => f.endsWith(".json"));
18823
+ if ((0, import_node_fs26.existsSync)(dir)) {
18824
+ const files = (0, import_node_fs26.readdirSync)(dir).filter((f) => f.endsWith(".json"));
18706
18825
  for (const file of files) {
18707
18826
  try {
18708
- const raw = (0, import_node_fs25.readFileSync)((0, import_node_path19.join)(dir, file), "utf-8");
18827
+ const raw = (0, import_node_fs26.readFileSync)((0, import_node_path20.join)(dir, file), "utf-8");
18709
18828
  const parsed = JSON.parse(raw);
18710
18829
  const customRules = Array.isArray(parsed) ? parsed : [parsed];
18711
18830
  for (const rule of customRules) {
@@ -18737,23 +18856,23 @@ function loadAllRules(customDir) {
18737
18856
 
18738
18857
  // src/daemon/firewall/adapters.ts
18739
18858
  var import_node_child_process8 = require("child_process");
18740
- var import_node_fs26 = require("fs");
18741
- var import_node_path20 = require("path");
18742
- var import_node_net9 = require("net");
18859
+ var import_node_fs27 = require("fs");
18860
+ var import_node_path21 = require("path");
18861
+ var import_node_net10 = require("net");
18743
18862
  function assertValidFirewallIp(ip) {
18744
- if ((0, import_node_net9.isIP)(ip) !== 4) {
18863
+ if ((0, import_node_net10.isIP)(ip) !== 4) {
18745
18864
  throw new Error(`Invalid IPv4 address: ${ip}`);
18746
18865
  }
18747
18866
  }
18748
18867
  function assertBannableIp(ip) {
18749
- if ((0, import_node_net9.isIP)(ip) === 0) {
18868
+ if ((0, import_node_net10.isIP)(ip) === 0) {
18750
18869
  throw new Error(`Invalid IP address: ${ip}`);
18751
18870
  }
18752
18871
  }
18753
18872
  function writeIfAbsent(path, contents) {
18754
- (0, import_node_fs26.mkdirSync)((0, import_node_path20.dirname)(path), { recursive: true });
18873
+ (0, import_node_fs27.mkdirSync)((0, import_node_path21.dirname)(path), { recursive: true });
18755
18874
  try {
18756
- (0, import_node_fs26.writeFileSync)(path, contents, { flag: "wx" });
18875
+ (0, import_node_fs27.writeFileSync)(path, contents, { flag: "wx" });
18757
18876
  } catch (err) {
18758
18877
  if (err.code !== "EEXIST") throw err;
18759
18878
  }
@@ -18852,7 +18971,7 @@ var Fail2banAdapter = class {
18852
18971
  const status = this.client(["status", this.jail]);
18853
18972
  const line = status.split("\n").find((l) => /Banned IP list:/i.test(l));
18854
18973
  if (!line) return [];
18855
- return line.split(":").slice(1).join(":").trim().split(/\s+/).filter((s) => (0, import_node_net9.isIP)(s) !== 0);
18974
+ return line.split(":").slice(1).join(":").trim().split(/\s+/).filter((s) => (0, import_node_net10.isIP)(s) !== 0);
18856
18975
  } catch {
18857
18976
  return [];
18858
18977
  }
@@ -18862,10 +18981,10 @@ var Fail2banAdapter = class {
18862
18981
  function parseBannedList(output) {
18863
18982
  const found = [];
18864
18983
  for (const match of output.matchAll(/['"]([^'"]+)['"]/g)) {
18865
- if ((0, import_node_net9.isIP)(match[1]) !== 0) found.push(match[1]);
18984
+ if ((0, import_node_net10.isIP)(match[1]) !== 0) found.push(match[1]);
18866
18985
  }
18867
18986
  if (found.length > 0) return found;
18868
- return output.replace(/[[\],]/g, " ").split(/\s+/).filter((s) => (0, import_node_net9.isIP)(s) !== 0);
18987
+ return output.replace(/[[\],]/g, " ").split(/\s+/).filter((s) => (0, import_node_net10.isIP)(s) !== 0);
18869
18988
  }
18870
18989
  var NftablesAdapter = class {
18871
18990
  name = "nftables";
@@ -19012,9 +19131,9 @@ function detectFirewallAdapter(backend = "auto") {
19012
19131
  }
19013
19132
 
19014
19133
  // src/daemon/firewall/remediation.ts
19015
- var import_node_fs27 = require("fs");
19134
+ var import_node_fs28 = require("fs");
19016
19135
  var import_node_child_process9 = require("child_process");
19017
- var import_node_net10 = require("net");
19136
+ var import_node_net11 = require("net");
19018
19137
 
19019
19138
  // src/daemon/firewall/crawlers.ts
19020
19139
  var import_node_dns = require("dns");
@@ -19081,19 +19200,19 @@ var defaultDiscovery = {
19081
19200
  const snapshot = takeSnapshot({
19082
19201
  readFile: (p) => {
19083
19202
  try {
19084
- return (0, import_node_fs27.readFileSync)(p, "utf-8");
19203
+ return (0, import_node_fs28.readFileSync)(p, "utf-8");
19085
19204
  } catch {
19086
19205
  return null;
19087
19206
  }
19088
19207
  },
19089
19208
  readDir: (p) => {
19090
19209
  try {
19091
- return (0, import_node_fs27.readdirSync)(p);
19210
+ return (0, import_node_fs28.readdirSync)(p);
19092
19211
  } catch {
19093
19212
  return null;
19094
19213
  }
19095
19214
  },
19096
- exists: (p) => (0, import_node_fs27.existsSync)(p)
19215
+ exists: (p) => (0, import_node_fs28.existsSync)(p)
19097
19216
  });
19098
19217
  const out = /* @__PURE__ */ new Set();
19099
19218
  for (const keys of Object.values(snapshot.keys)) {
@@ -19101,12 +19220,12 @@ var defaultDiscovery = {
19101
19220
  }
19102
19221
  return out;
19103
19222
  },
19104
- keyLoginJournal: (sinceSeconds) => new Promise((resolve3) => {
19223
+ keyLoginJournal: (sinceSeconds) => new Promise((resolve4) => {
19105
19224
  (0, import_node_child_process9.execFile)(
19106
19225
  "journalctl",
19107
19226
  ["_COMM=sshd", "_COMM=sshd-session", `--since=-${Math.ceil(sinceSeconds / 86400)}d`, "-o", "short-unix", "--no-pager", "--grep", "Accepted publickey"],
19108
19227
  { maxBuffer: 32 * 1024 * 1024, timeout: 6e4 },
19109
- (_err, stdout) => resolve3(stdout ?? "")
19228
+ (_err, stdout) => resolve4(stdout ?? "")
19110
19229
  );
19111
19230
  })
19112
19231
  };
@@ -19141,6 +19260,7 @@ var RemediationManager = class {
19141
19260
  this.config.allowlist = [...this.config.allowlist];
19142
19261
  this.protectedList = [...DEFAULT_PROTECTED, ...SHARED_INFRASTRUCTURE, ...this.config.allowlist];
19143
19262
  for (const gateway of defaultGateways()) this.protectedList.push(gateway);
19263
+ this.pinned = new Set(this.protectedList);
19144
19264
  if (this.adapter.enforces === false) this.config.dry_run = true;
19145
19265
  this.loadState();
19146
19266
  this.refreshSshProtection();
@@ -19156,6 +19276,12 @@ var RemediationManager = class {
19156
19276
  blocklist = [];
19157
19277
  strikes = {};
19158
19278
  protectedList = [];
19279
+ /**
19280
+ * What was protected at start: built-ins, shared infrastructure, the
19281
+ * operator's `[remediation] allowlist`, default gateways. The dashboard may
19282
+ * add to the protected set but never take these out of it.
19283
+ */
19284
+ pinned = /* @__PURE__ */ new Set();
19159
19285
  /** Operator address → last time seen (ms), persisted. */
19160
19286
  operators = {};
19161
19287
  expiryTimer = null;
@@ -19228,7 +19354,7 @@ var RemediationManager = class {
19228
19354
  if (remediation?.action !== "block") return;
19229
19355
  }
19230
19356
  const ip = event.source_ip;
19231
- if (!ip || (0, import_node_net10.isIP)(ip) === 0) return;
19357
+ if (!ip || (0, import_node_net11.isIP)(ip) === 0) return;
19232
19358
  if (this.isAllowlisted(ip)) return;
19233
19359
  if (this.blocklist.some((b) => b.ip === ip)) return;
19234
19360
  if (this.config.spare_verified_crawlers) {
@@ -19247,7 +19373,7 @@ var RemediationManager = class {
19247
19373
  * 4th offence and so on, clamped to `max_ban_seconds`.
19248
19374
  */
19249
19375
  async ban(ip, reason, opts = {}) {
19250
- if ((0, import_node_net10.isIP)(ip) === 0) return { ok: false, error: `not an IP address: ${ip}` };
19376
+ if ((0, import_node_net11.isIP)(ip) === 0) return { ok: false, error: `not an IP address: ${ip}` };
19251
19377
  if (this.isAllowlisted(ip)) {
19252
19378
  return { ok: false, error: `${ip} is protected and can never be blocked` };
19253
19379
  }
@@ -19404,6 +19530,10 @@ var RemediationManager = class {
19404
19530
  if (!this.protectedList.includes(ip)) this.protectedList.push(ip);
19405
19531
  if (!this.config.allowlist.includes(ip)) this.config.allowlist.push(ip);
19406
19532
  }
19533
+ /** Protected since start (built-in, shared infrastructure, operator config, gateway): not removable from the cloud. */
19534
+ isPinned(ip) {
19535
+ return this.pinned.has(ip);
19536
+ }
19407
19537
  removeFromAllowlist(ip) {
19408
19538
  if (DEFAULT_PROTECTED.includes(ip)) return;
19409
19539
  this.protectedList = this.protectedList.filter((a) => a !== ip);
@@ -19510,7 +19640,7 @@ var RemediationManager = class {
19510
19640
  if (saved && typeof saved === "object" && this.config.protect_recent_operators) {
19511
19641
  const cutoff = Date.now() - this.config.operator_memory_seconds * 1e3;
19512
19642
  for (const [ip, at] of Object.entries(saved)) {
19513
- if (typeof at !== "number" || at < cutoff || !(0, import_node_net10.isIP)(ip)) continue;
19643
+ if (typeof at !== "number" || at < cutoff || !(0, import_node_net11.isIP)(ip)) continue;
19514
19644
  this.operators[ip] = at;
19515
19645
  if (!this.protectedList.includes(ip)) this.protectedList.push(ip);
19516
19646
  }
@@ -19534,7 +19664,7 @@ var RemediationManager = class {
19534
19664
  }
19535
19665
  logLine(line) {
19536
19666
  try {
19537
- (0, import_node_fs27.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
19667
+ (0, import_node_fs28.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
19538
19668
  `);
19539
19669
  } catch {
19540
19670
  }
@@ -19573,13 +19703,13 @@ function remediationSettings(section) {
19573
19703
  }
19574
19704
 
19575
19705
  // src/daemon/watchdog-service.ts
19576
- var import_node_fs29 = require("fs");
19577
- var import_node_path22 = require("path");
19706
+ var import_node_fs30 = require("fs");
19707
+ var import_node_path23 = require("path");
19578
19708
 
19579
19709
  // src/core/watchdog.ts
19580
- var import_node_fs28 = require("fs");
19710
+ var import_node_fs29 = require("fs");
19581
19711
  var import_node_crypto7 = require("crypto");
19582
- var import_node_path21 = require("path");
19712
+ var import_node_path22 = require("path");
19583
19713
  var WATCHDOG_DIRNAME = "watchdog";
19584
19714
  var LOG_FILE2 = "attacks.jsonl";
19585
19715
  var ROTATED_FILE = "attacks.1.jsonl";
@@ -19668,12 +19798,12 @@ var WatchdogLog = class {
19668
19798
  stats = { logged: 0, answered: 0, errored: 0 };
19669
19799
  constructor(dir, options = {}) {
19670
19800
  this.dir = dir;
19671
- this.file = (0, import_node_path21.join)(dir, LOG_FILE2);
19801
+ this.file = (0, import_node_path22.join)(dir, LOG_FILE2);
19672
19802
  this.shareGid = options.shareGid;
19673
- (0, import_node_fs28.mkdirSync)(dir, { recursive: true, mode: this.shareGid === void 0 ? 448 : 1528 });
19803
+ (0, import_node_fs29.mkdirSync)(dir, { recursive: true, mode: this.shareGid === void 0 ? 448 : 1528 });
19674
19804
  if (this.shareGid !== void 0) {
19675
- (0, import_node_fs28.chownSync)(dir, process.getuid?.() ?? 0, this.shareGid);
19676
- (0, import_node_fs28.chmodSync)(dir, 1528);
19805
+ (0, import_node_fs29.chownSync)(dir, process.getuid?.() ?? 0, this.shareGid);
19806
+ (0, import_node_fs29.chmodSync)(dir, 1528);
19677
19807
  }
19678
19808
  for (const r of readTail(this.file, 512 * 1024)) this.remember(dedupeKey(r));
19679
19809
  }
@@ -19702,16 +19832,16 @@ var WatchdogLog = class {
19702
19832
  const chunk = this.buffer.join("\n") + "\n";
19703
19833
  this.buffer = [];
19704
19834
  try {
19705
- if ((0, import_node_fs28.statSync)(this.file).size > ROTATE_BYTES) {
19706
- (0, import_node_fs28.renameSync)(this.file, (0, import_node_path21.join)(this.dir, ROTATED_FILE));
19835
+ if ((0, import_node_fs29.statSync)(this.file).size > ROTATE_BYTES) {
19836
+ (0, import_node_fs29.renameSync)(this.file, (0, import_node_path22.join)(this.dir, ROTATED_FILE));
19707
19837
  }
19708
19838
  } catch {
19709
19839
  }
19710
- (0, import_node_fs28.appendFileSync)(this.file, chunk, { mode: this.shareGid === void 0 ? 384 : 432 });
19840
+ (0, import_node_fs29.appendFileSync)(this.file, chunk, { mode: this.shareGid === void 0 ? 384 : 432 });
19711
19841
  if (this.shareGid !== void 0) {
19712
19842
  try {
19713
- (0, import_node_fs28.chownSync)(this.file, process.getuid?.() ?? 0, this.shareGid);
19714
- (0, import_node_fs28.chmodSync)(this.file, 432);
19843
+ (0, import_node_fs29.chownSync)(this.file, process.getuid?.() ?? 0, this.shareGid);
19844
+ (0, import_node_fs29.chmodSync)(this.file, 432);
19715
19845
  } catch {
19716
19846
  }
19717
19847
  }
@@ -19732,21 +19862,21 @@ function parseLines(text) {
19732
19862
  function readTail(file, bytes) {
19733
19863
  let fd;
19734
19864
  try {
19735
- fd = (0, import_node_fs28.openSync)(file, "r");
19865
+ fd = (0, import_node_fs29.openSync)(file, "r");
19736
19866
  } catch (err) {
19737
19867
  if (err.code === "ENOENT") return [];
19738
19868
  throw err;
19739
19869
  }
19740
19870
  try {
19741
- const size = (0, import_node_fs28.fstatSync)(fd).size;
19871
+ const size = (0, import_node_fs29.fstatSync)(fd).size;
19742
19872
  const start = Math.max(0, size - bytes);
19743
19873
  const buf = Buffer.alloc(size - start);
19744
- (0, import_node_fs28.readSync)(fd, buf, 0, buf.length, start);
19874
+ (0, import_node_fs29.readSync)(fd, buf, 0, buf.length, start);
19745
19875
  let text = buf.toString("utf8");
19746
19876
  if (start > 0) text = text.slice(text.indexOf("\n") + 1);
19747
19877
  return parseLines(text);
19748
19878
  } finally {
19749
- (0, import_node_fs28.closeSync)(fd);
19879
+ (0, import_node_fs29.closeSync)(fd);
19750
19880
  }
19751
19881
  }
19752
19882
 
@@ -19755,13 +19885,13 @@ function defaultShareGid() {
19755
19885
  const isRoot2 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
19756
19886
  if (!isRoot2) return void 0;
19757
19887
  try {
19758
- return (0, import_node_fs29.statSync)("/var/log/auth.log").gid;
19888
+ return (0, import_node_fs30.statSync)("/var/log/auth.log").gid;
19759
19889
  } catch {
19760
19890
  return void 0;
19761
19891
  }
19762
19892
  }
19763
19893
  function startWatchdog(opts) {
19764
- const dir = opts.config?.dir ?? (0, import_node_path22.join)(opts.stateDir, WATCHDOG_DIRNAME);
19894
+ const dir = opts.config?.dir ?? (0, import_node_path23.join)(opts.stateDir, WATCHDOG_DIRNAME);
19765
19895
  const base = { dir, logged: 0, answered: 0, errored: 0 };
19766
19896
  if (opts.config?.enabled === false) {
19767
19897
  opts.log("[watchdog] off ([watchdog] enabled = false)");
@@ -19868,7 +19998,7 @@ function daemonNodeProblem(version) {
19868
19998
  // src/daemon/index.ts
19869
19999
  function readVersion2() {
19870
20000
  try {
19871
- const pkg = JSON.parse((0, import_node_fs30.readFileSync)((0, import_node_path23.join)(__dirname, "..", "package.json"), "utf-8"));
20001
+ const pkg = JSON.parse((0, import_node_fs31.readFileSync)((0, import_node_path24.join)(__dirname, "..", "package.json"), "utf-8"));
19872
20002
  return pkg.version || "0.0.0";
19873
20003
  } catch {
19874
20004
  return "0.0.0";
@@ -19877,7 +20007,7 @@ function readVersion2() {
19877
20007
  async function runHardeningChecks() {
19878
20008
  const { stdout } = await (0, import_node_util.promisify)(import_node_child_process11.execFile)(
19879
20009
  process.execPath,
19880
- [(0, import_node_path23.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
20010
+ [(0, import_node_path24.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
19881
20011
  { timeout: 12e4, maxBuffer: 4 * 1024 * 1024 }
19882
20012
  );
19883
20013
  const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
@@ -19891,7 +20021,7 @@ async function runHardeningChecks() {
19891
20021
  async function runPatchCheck() {
19892
20022
  const { stdout } = await (0, import_node_util.promisify)(import_node_child_process11.execFile)(
19893
20023
  process.execPath,
19894
- [(0, import_node_path23.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
20024
+ [(0, import_node_path24.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
19895
20025
  { timeout: 3e5, maxBuffer: 16 * 1024 * 1024 }
19896
20026
  );
19897
20027
  const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
@@ -19899,7 +20029,7 @@ async function runPatchCheck() {
19899
20029
  }
19900
20030
  function logLine(line) {
19901
20031
  try {
19902
- (0, import_node_fs30.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
20032
+ (0, import_node_fs31.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
19903
20033
  `);
19904
20034
  } catch {
19905
20035
  }
@@ -19941,7 +20071,7 @@ async function runDaemon() {
19941
20071
  } catch (err) {
19942
20072
  logLine(`[daemon] state db unavailable: ${err.message}`);
19943
20073
  }
19944
- const config = loadConfig((0, import_node_fs30.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
20074
+ const config = loadConfig((0, import_node_fs31.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
19945
20075
  configureAttackDetection(config.detection);
19946
20076
  const retentionSeconds = parseDuration(config.storage?.event_retention) ?? DEFAULT_EVENT_RETENTION_SECONDS;
19947
20077
  const maxEvents = config.storage?.max_events ?? DEFAULT_MAX_EVENTS;
@@ -20005,7 +20135,7 @@ async function runDaemon() {
20005
20135
  const threatFeeds = new ThreatFeeds({
20006
20136
  settings: { ...feedSettings, allow: [...feedSettings.allow, ...remediation.getAllowlist()] },
20007
20137
  enforcing: !remediationStatus.dry_run && firewallAdapter.enforces !== false,
20008
- cachePath: (0, import_node_path23.join)(PATHS.stateDir, "threat-feeds.json"),
20138
+ cachePath: (0, import_node_path24.join)(PATHS.stateDir, "threat-feeds.json"),
20009
20139
  bus,
20010
20140
  log: logLine
20011
20141
  });
@@ -20013,14 +20143,18 @@ async function runDaemon() {
20013
20143
  const privilegeWatch = new PrivilegeWatch({
20014
20144
  settings: privilegeSettings(config.privileged),
20015
20145
  bus,
20016
- snapshotPath: (0, import_node_path23.join)(PATHS.stateDir, "privileges.json"),
20017
- loginsPath: (0, import_node_path23.join)(PATHS.stateDir, "login-countries.json"),
20018
- cursorPath: (0, import_node_path23.join)(PATHS.stateDir, "sudo-cursor.json"),
20146
+ snapshotPath: (0, import_node_path24.join)(PATHS.stateDir, "privileges.json"),
20147
+ loginsPath: (0, import_node_path24.join)(PATHS.stateDir, "login-countries.json"),
20148
+ cursorPath: (0, import_node_path24.join)(PATHS.stateDir, "sudo-cursor.json"),
20019
20149
  log: logLine
20020
20150
  });
20021
20151
  privilegeWatch.start();
20022
20152
  new AlertDispatcher(bus, config);
20023
- const runsWorker = new RunsWorker(bus);
20153
+ const runsWorker = new RunsWorker(bus, {
20154
+ enabled: config.cloud?.enabled !== false && config.cloud?.runs === true,
20155
+ scanRoots: Array.isArray(config.cloud?.run_scan_paths) ? config.cloud.run_scan_paths.filter((p) => typeof p === "string") : [],
20156
+ log: logLine
20157
+ });
20024
20158
  try {
20025
20159
  await runsWorker.start();
20026
20160
  } catch (err) {
@@ -20039,7 +20173,7 @@ async function runDaemon() {
20039
20173
  version,
20040
20174
  hostname: (0, import_node_os5.hostname)(),
20041
20175
  minSeverity,
20042
- spoolPath: (0, import_node_path23.join)(PATHS.stateDir, "cloud-spool.jsonl"),
20176
+ spoolPath: (0, import_node_path24.join)(PATHS.stateDir, "cloud-spool.jsonl"),
20043
20177
  log: logLine,
20044
20178
  ruleModules: new Set(ruleEngine.getRules().flatMap((rule) => rule.source_types)),
20045
20179
  runHardening: runHardeningChecks
@@ -20063,8 +20197,8 @@ async function runDaemon() {
20063
20197
  const autoUpdate = autoUpdateRef = new AutoUpdate({
20064
20198
  version,
20065
20199
  settings: updateSettings(config.update),
20066
- pkgRoot: (0, import_node_path23.join)(__dirname, ".."),
20067
- statePath: (0, import_node_path23.join)(PATHS.stateDir, "auto-update.json"),
20200
+ pkgRoot: (0, import_node_path24.join)(__dirname, ".."),
20201
+ statePath: (0, import_node_path24.join)(PATHS.stateDir, "auto-update.json"),
20068
20202
  bus,
20069
20203
  log: logLine,
20070
20204
  restartDaemon