@profullstack/threatcrush 0.13.66 → 0.13.68

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
@@ -42,9 +42,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
42
42
  mod
43
43
  ));
44
44
 
45
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js
45
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js
46
46
  var require_parser = __commonJS({
47
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js"(exports2, module2) {
47
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js"(exports2, module2) {
48
48
  "use strict";
49
49
  var ParserEND = 1114112;
50
50
  var ParserError = class _ParserError extends Error {
@@ -167,9 +167,9 @@ var require_parser = __commonJS({
167
167
  }
168
168
  });
169
169
 
170
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js
170
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js
171
171
  var require_create_datetime = __commonJS({
172
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js"(exports2, module2) {
172
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js"(exports2, module2) {
173
173
  "use strict";
174
174
  module2.exports = (value) => {
175
175
  const date = new Date(value);
@@ -182,9 +182,9 @@ var require_create_datetime = __commonJS({
182
182
  }
183
183
  });
184
184
 
185
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js
185
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js
186
186
  var require_format_num = __commonJS({
187
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js"(exports2, module2) {
187
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js"(exports2, module2) {
188
188
  "use strict";
189
189
  module2.exports = (d, num) => {
190
190
  num = String(num);
@@ -194,9 +194,9 @@ var require_format_num = __commonJS({
194
194
  }
195
195
  });
196
196
 
197
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js
197
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js
198
198
  var require_create_datetime_float = __commonJS({
199
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js"(exports2, module2) {
199
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js"(exports2, module2) {
200
200
  "use strict";
201
201
  var f = require_format_num();
202
202
  var FloatingDateTime = class extends Date {
@@ -206,8 +206,8 @@ var require_create_datetime_float = __commonJS({
206
206
  }
207
207
  toISOString() {
208
208
  const date = `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`;
209
- const time = `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`;
210
- return `${date}T${time}`;
209
+ const time2 = `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`;
210
+ return `${date}T${time2}`;
211
211
  }
212
212
  };
213
213
  module2.exports = (value) => {
@@ -221,9 +221,9 @@ var require_create_datetime_float = __commonJS({
221
221
  }
222
222
  });
223
223
 
224
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js
224
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js
225
225
  var require_create_date = __commonJS({
226
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js"(exports2, module2) {
226
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js"(exports2, module2) {
227
227
  "use strict";
228
228
  var f = require_format_num();
229
229
  var DateTime = global.Date;
@@ -247,9 +247,9 @@ var require_create_date = __commonJS({
247
247
  }
248
248
  });
249
249
 
250
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js
250
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js
251
251
  var require_create_time = __commonJS({
252
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js"(exports2, module2) {
252
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js"(exports2, module2) {
253
253
  "use strict";
254
254
  var f = require_format_num();
255
255
  var Time = class extends Date {
@@ -272,9 +272,9 @@ var require_create_time = __commonJS({
272
272
  }
273
273
  });
274
274
 
275
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js
275
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js
276
276
  var require_toml_parser = __commonJS({
277
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js"(exports, module) {
277
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js"(exports, module) {
278
278
  "use strict";
279
279
  module.exports = makeParserClass(require_parser());
280
280
  module.exports.makeParserClass = makeParserClass;
@@ -1585,9 +1585,9 @@ var require_toml_parser = __commonJS({
1585
1585
  }
1586
1586
  });
1587
1587
 
1588
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js
1588
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js
1589
1589
  var require_parse_pretty_error = __commonJS({
1590
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js"(exports2, module2) {
1590
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js"(exports2, module2) {
1591
1591
  "use strict";
1592
1592
  module2.exports = prettyError;
1593
1593
  function prettyError(err, buf) {
@@ -1621,9 +1621,9 @@ var require_parse_pretty_error = __commonJS({
1621
1621
  }
1622
1622
  });
1623
1623
 
1624
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js
1624
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js
1625
1625
  var require_parse_string = __commonJS({
1626
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js"(exports2, module2) {
1626
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js"(exports2, module2) {
1627
1627
  "use strict";
1628
1628
  module2.exports = parseString;
1629
1629
  var TOMLParser = require_toml_parser();
@@ -1643,9 +1643,9 @@ var require_parse_string = __commonJS({
1643
1643
  }
1644
1644
  });
1645
1645
 
1646
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js
1646
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js
1647
1647
  var require_parse_async = __commonJS({
1648
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js"(exports2, module2) {
1648
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js"(exports2, module2) {
1649
1649
  "use strict";
1650
1650
  module2.exports = parseAsync;
1651
1651
  var TOMLParser = require_toml_parser();
@@ -1677,9 +1677,9 @@ var require_parse_async = __commonJS({
1677
1677
  }
1678
1678
  });
1679
1679
 
1680
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js
1680
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js
1681
1681
  var require_parse_stream = __commonJS({
1682
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js"(exports2, module2) {
1682
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js"(exports2, module2) {
1683
1683
  "use strict";
1684
1684
  module2.exports = parseStream;
1685
1685
  var stream = require("stream");
@@ -1756,9 +1756,9 @@ var require_parse_stream = __commonJS({
1756
1756
  }
1757
1757
  });
1758
1758
 
1759
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js
1759
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js
1760
1760
  var require_parse = __commonJS({
1761
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js"(exports2, module2) {
1761
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js"(exports2, module2) {
1762
1762
  "use strict";
1763
1763
  module2.exports = require_parse_string();
1764
1764
  module2.exports.async = require_parse_async();
@@ -1767,9 +1767,9 @@ var require_parse = __commonJS({
1767
1767
  }
1768
1768
  });
1769
1769
 
1770
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js
1770
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js
1771
1771
  var require_stringify = __commonJS({
1772
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js"(exports2, module2) {
1772
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js"(exports2, module2) {
1773
1773
  "use strict";
1774
1774
  module2.exports = stringify;
1775
1775
  module2.exports.value = stringifyInline;
@@ -2028,16 +2028,16 @@ var require_stringify = __commonJS({
2028
2028
  }
2029
2029
  });
2030
2030
 
2031
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js
2031
+ // ../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js
2032
2032
  var require_toml = __commonJS({
2033
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js"(exports2) {
2033
+ "../../../../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js"(exports2) {
2034
2034
  "use strict";
2035
2035
  exports2.parse = require_parse();
2036
2036
  exports2.stringify = require_stringify();
2037
2037
  }
2038
2038
  });
2039
2039
 
2040
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/color.js
2040
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/color.js
2041
2041
  function rgb(r, g, b) {
2042
2042
  return RGB_FLAG | (r & 255) << 16 | (g & 255) << 8 | b & 255;
2043
2043
  }
@@ -2151,7 +2151,7 @@ function grayscale(c) {
2151
2151
  }
2152
2152
  var DEFAULT_COLOR, RGB_FLAG, IDX_FLAG, CUBE, BASE16;
2153
2153
  var init_color = __esm({
2154
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/color.js"() {
2154
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/color.js"() {
2155
2155
  "use strict";
2156
2156
  DEFAULT_COLOR = 0;
2157
2157
  RGB_FLAG = 16777216;
@@ -2178,7 +2178,7 @@ var init_color = __esm({
2178
2178
  }
2179
2179
  });
2180
2180
 
2181
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/unicode.js
2181
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/unicode.js
2182
2182
  function isLoneSurrogate(cp) {
2183
2183
  return cp >= 55296 && cp <= 57343;
2184
2184
  }
@@ -2429,7 +2429,7 @@ function wrap(text, width) {
2429
2429
  }
2430
2430
  var CLUSTER_BASE, CONTINUATION, clusters, clusterIds, REPLACEMENT, UNSAFE, MAX_CLUSTER_CODEPOINTS, MAX_CLUSTERS, ZERO_WIDTH, WIDE, PICTOGRAPHIC, isRegional, isToneModifier, isTag, isKeycapBase, ZWJ;
2431
2431
  var init_unicode = __esm({
2432
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/unicode.js"() {
2432
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/unicode.js"() {
2433
2433
  "use strict";
2434
2434
  CLUSTER_BASE = 1114112;
2435
2435
  CONTINUATION = 4294967295;
@@ -2582,10 +2582,10 @@ var init_unicode = __esm({
2582
2582
  }
2583
2583
  });
2584
2584
 
2585
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/buffer.js
2585
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/buffer.js
2586
2586
  var Attr, FrameBuffer;
2587
2587
  var init_buffer = __esm({
2588
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/buffer.js"() {
2588
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/buffer.js"() {
2589
2589
  "use strict";
2590
2590
  init_color();
2591
2591
  init_unicode();
@@ -2774,7 +2774,7 @@ var init_buffer = __esm({
2774
2774
  }
2775
2775
  });
2776
2776
 
2777
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/ansi.js
2777
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/ansi.js
2778
2778
  function moveTo(x, y) {
2779
2779
  return `${CSI}${y + 1};${x + 1}H`;
2780
2780
  }
@@ -2825,7 +2825,7 @@ function stripAnsi(text) {
2825
2825
  }
2826
2826
  var ESC, CSI, ansi, fgDefault, bgDefault, TEXT_UNSAFE;
2827
2827
  var init_ansi = __esm({
2828
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/ansi.js"() {
2828
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/ansi.js"() {
2829
2829
  "use strict";
2830
2830
  init_unicode();
2831
2831
  ESC = "\x1B";
@@ -2861,7 +2861,7 @@ var init_ansi = __esm({
2861
2861
  }
2862
2862
  });
2863
2863
 
2864
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/diff.js
2864
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/diff.js
2865
2865
  function encodeRows(buffer, options = {}) {
2866
2866
  const encoder = new Encoder({ ...options, origin: { x: 0, y: 0 }, relative: false });
2867
2867
  const width = buffer.width;
@@ -2882,7 +2882,7 @@ function encodeRows(buffer, options = {}) {
2882
2882
  }
2883
2883
  var GAP_MERGE, Encoder;
2884
2884
  var init_diff = __esm({
2885
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/diff.js"() {
2885
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/diff.js"() {
2886
2886
  "use strict";
2887
2887
  init_buffer();
2888
2888
  init_buffer();
@@ -3057,17 +3057,17 @@ var init_diff = __esm({
3057
3057
  while (start > 0 && nc[rowStart + start] === CONTINUATION)
3058
3058
  start--;
3059
3059
  let end = start;
3060
- let clean = 0;
3060
+ let clean2 = 0;
3061
3061
  let probe = start;
3062
3062
  while (probe < w) {
3063
3063
  const j = rowStart + probe;
3064
3064
  const d = repaint || nc[j] !== pc[j] || nf[j] !== pf[j] || nb[j] !== pb[j] || na[j] !== pa[j];
3065
3065
  if (d) {
3066
3066
  end = probe;
3067
- clean = 0;
3067
+ clean2 = 0;
3068
3068
  } else {
3069
- clean++;
3070
- if (clean > GAP_MERGE)
3069
+ clean2++;
3070
+ if (clean2 > GAP_MERGE)
3071
3071
  break;
3072
3072
  }
3073
3073
  probe++;
@@ -3099,7 +3099,7 @@ var init_diff = __esm({
3099
3099
  }
3100
3100
  });
3101
3101
 
3102
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/capabilities.js
3102
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/capabilities.js
3103
3103
  function detectProgram(env3) {
3104
3104
  if (env3.TERM_PROGRAM === "hqterm")
3105
3105
  return "hqterm";
@@ -3198,12 +3198,12 @@ function detectCapabilities(overrides = {}, env3 = process.env, stream = process
3198
3198
  };
3199
3199
  }
3200
3200
  var init_capabilities = __esm({
3201
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/capabilities.js"() {
3201
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/capabilities.js"() {
3202
3202
  "use strict";
3203
3203
  }
3204
3204
  });
3205
3205
 
3206
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/input.js
3206
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/input.js
3207
3207
  function decodeModifiers(param) {
3208
3208
  const bits2 = Math.max(0, param - 1);
3209
3209
  return { shift: (bits2 & 1) !== 0, alt: (bits2 & 2) !== 0, ctrl: (bits2 & 4) !== 0 };
@@ -3239,7 +3239,7 @@ function matchKey(event, binding) {
3239
3239
  }
3240
3240
  var SPECIAL, PASTE_END, InputParser, SPECIAL_KEYS_SORTED;
3241
3241
  var init_input = __esm({
3242
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/input.js"() {
3242
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/input.js"() {
3243
3243
  "use strict";
3244
3244
  SPECIAL = {
3245
3245
  "[A": "up",
@@ -3482,7 +3482,7 @@ var init_input = __esm({
3482
3482
  }
3483
3483
  });
3484
3484
 
3485
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/terminal.js
3485
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/terminal.js
3486
3486
  function anchor() {
3487
3487
  return ansi.reset + ansi.cursorSave;
3488
3488
  }
@@ -3491,7 +3491,7 @@ function toAnchor() {
3491
3491
  }
3492
3492
  var Terminal;
3493
3493
  var init_terminal = __esm({
3494
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/terminal.js"() {
3494
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/terminal.js"() {
3495
3495
  "use strict";
3496
3496
  init_ansi();
3497
3497
  init_capabilities();
@@ -3777,7 +3777,7 @@ var init_terminal = __esm({
3777
3777
  }
3778
3778
  });
3779
3779
 
3780
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/theme.js
3780
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/theme.js
3781
3781
  function variant(base, overrides) {
3782
3782
  return { ...base, ...overrides };
3783
3783
  }
@@ -3806,7 +3806,7 @@ function seriesColor(theme, index) {
3806
3806
  }
3807
3807
  var DARK, DRACULA, NORD, TOKYO_NIGHT, GRUVBOX, MATRIX, MONOCHROME, HIGH_CONTRAST, LIGHT, themes, themeList;
3808
3808
  var init_theme = __esm({
3809
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/theme.js"() {
3809
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/theme.js"() {
3810
3810
  "use strict";
3811
3811
  init_color();
3812
3812
  DARK = {
@@ -4017,7 +4017,7 @@ var init_theme = __esm({
4017
4017
  }
4018
4018
  });
4019
4019
 
4020
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/layout.js
4020
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/layout.js
4021
4021
  function parse(c, total) {
4022
4022
  const min = c.min ?? 0;
4023
4023
  const max = c.max ?? Infinity;
@@ -4191,12 +4191,12 @@ function isEmpty(rect) {
4191
4191
  return rect.width <= 0 || rect.height <= 0;
4192
4192
  }
4193
4193
  var init_layout = __esm({
4194
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/layout.js"() {
4194
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/layout.js"() {
4195
4195
  "use strict";
4196
4196
  }
4197
4197
  });
4198
4198
 
4199
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/richtext.js
4199
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/richtext.js
4200
4200
  function isRich(value) {
4201
4201
  return typeof value !== "string";
4202
4202
  }
@@ -4401,14 +4401,14 @@ function wrapRich(value, width) {
4401
4401
  return out;
4402
4402
  }
4403
4403
  var init_richtext = __esm({
4404
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/richtext.js"() {
4404
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/richtext.js"() {
4405
4405
  "use strict";
4406
4406
  init_buffer();
4407
4407
  init_unicode();
4408
4408
  }
4409
4409
  });
4410
4410
 
4411
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/surface.js
4411
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/surface.js
4412
4412
  function borderGlyph(style, bits2) {
4413
4413
  const chars = BORDERS[style];
4414
4414
  for (const [part, value] of Object.entries(PART_BITS)) {
@@ -4447,7 +4447,7 @@ function createSurface(buffer, theme, rect) {
4447
4447
  }
4448
4448
  var BORDERS, EDGE_UP, EDGE_RIGHT, EDGE_DOWN, EDGE_LEFT, PART_BITS, BITS_BY_CODEPOINT, Surface;
4449
4449
  var init_surface = __esm({
4450
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/surface.js"() {
4450
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/surface.js"() {
4451
4451
  "use strict";
4452
4452
  init_layout();
4453
4453
  init_unicode();
@@ -4758,13 +4758,13 @@ var init_surface = __esm({
4758
4758
  }
4759
4759
  });
4760
4760
 
4761
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/braille.js
4761
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/braille.js
4762
4762
  function snap(v) {
4763
4763
  return Math.round(v + (v >= 0 ? 1e-9 : -1e-9));
4764
4764
  }
4765
4765
  var BRAILLE_BASE, DOT_BITS, BrailleCanvas;
4766
4766
  var init_braille = __esm({
4767
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/braille.js"() {
4767
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/braille.js"() {
4768
4768
  "use strict";
4769
4769
  BRAILLE_BASE = 10240;
4770
4770
  DOT_BITS = [
@@ -5018,7 +5018,7 @@ var init_braille = __esm({
5018
5018
  }
5019
5019
  });
5020
5020
 
5021
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/blocks.js
5021
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/blocks.js
5022
5022
  function verticalGlyph(ratio2, mode = "block") {
5023
5023
  const r = ratio2 <= 0 ? 0 : ratio2 >= 1 ? 1 : ratio2;
5024
5024
  if (mode === "ascii")
@@ -5037,14 +5037,14 @@ function horizontalGlyph(ratio2, mode = "block") {
5037
5037
  }
5038
5038
  var HORIZONTAL_EIGHTHS, VERTICAL_EIGHTHS;
5039
5039
  var init_blocks = __esm({
5040
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/blocks.js"() {
5040
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/blocks.js"() {
5041
5041
  "use strict";
5042
5042
  HORIZONTAL_EIGHTHS = ["", "\u258F", "\u258E", "\u258D", "\u258C", "\u258B", "\u258A", "\u2589", "\u2588"];
5043
5043
  VERTICAL_EIGHTHS = ["", "\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
5044
5044
  }
5045
5045
  });
5046
5046
 
5047
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/plot.js
5047
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/plot.js
5048
5048
  function bound(value) {
5049
5049
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
5050
5050
  }
@@ -5333,7 +5333,7 @@ function donut(surface, options) {
5333
5333
  blit(surface, canvas, (col, row) => colorFor.get(`${col},${row}`) ?? theme.muted, options.background);
5334
5334
  }
5335
5335
  var init_plot = __esm({
5336
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/plot.js"() {
5336
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/plot.js"() {
5337
5337
  "use strict";
5338
5338
  init_color();
5339
5339
  init_braille();
@@ -5342,7 +5342,7 @@ var init_plot = __esm({
5342
5342
  }
5343
5343
  });
5344
5344
 
5345
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/canvas.js
5345
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/canvas.js
5346
5346
  function span(bounds) {
5347
5347
  if (!bounds)
5348
5348
  return UNIT;
@@ -5438,7 +5438,7 @@ function drawCanvas(surface, options) {
5438
5438
  }
5439
5439
  var UNIT;
5440
5440
  var init_canvas = __esm({
5441
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/canvas.js"() {
5441
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/canvas.js"() {
5442
5442
  "use strict";
5443
5443
  init_color();
5444
5444
  init_braille();
@@ -5447,7 +5447,7 @@ var init_canvas = __esm({
5447
5447
  }
5448
5448
  });
5449
5449
 
5450
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/text.js
5450
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/text.js
5451
5451
  function attrsOf(o) {
5452
5452
  let a = o.attrs ?? 0;
5453
5453
  if (o.bold)
@@ -5576,7 +5576,7 @@ function drawStatusBar(surface, options) {
5576
5576
  return spans;
5577
5577
  }
5578
5578
  var init_text = __esm({
5579
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/text.js"() {
5579
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/text.js"() {
5580
5580
  "use strict";
5581
5581
  init_buffer();
5582
5582
  init_color();
@@ -5586,7 +5586,7 @@ var init_text = __esm({
5586
5586
  }
5587
5587
  });
5588
5588
 
5589
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/calendar.js
5589
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/calendar.js
5590
5590
  function daysInMonth(year, month) {
5591
5591
  if (month === 2)
5592
5592
  return isLeapYear(year) ? 29 : 28;
@@ -5666,7 +5666,7 @@ function calendarHeight(options) {
5666
5666
  }
5667
5667
  var MONTH_NAMES, WEEKDAY_NAMES, DAY_WIDTH, GRID_WIDTH;
5668
5668
  var init_calendar = __esm({
5669
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/calendar.js"() {
5669
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/calendar.js"() {
5670
5670
  "use strict";
5671
5671
  init_buffer();
5672
5672
  init_unicode();
@@ -5690,7 +5690,7 @@ var init_calendar = __esm({
5690
5690
  }
5691
5691
  });
5692
5692
 
5693
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/chart.js
5693
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/chart.js
5694
5694
  function bound2(value) {
5695
5695
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
5696
5696
  }
@@ -5890,7 +5890,7 @@ function plotCells(surface, series, o) {
5890
5890
  });
5891
5891
  }
5892
5892
  var init_chart = __esm({
5893
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/chart.js"() {
5893
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/chart.js"() {
5894
5894
  "use strict";
5895
5895
  init_color();
5896
5896
  init_braille();
@@ -5900,7 +5900,7 @@ var init_chart = __esm({
5900
5900
  }
5901
5901
  });
5902
5902
 
5903
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/chart.js
5903
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/chart.js
5904
5904
  function niceLabel(value) {
5905
5905
  if (!Number.isFinite(value))
5906
5906
  return "";
@@ -5962,7 +5962,7 @@ function drawChart(surface, options) {
5962
5962
  }
5963
5963
  }
5964
5964
  var init_chart2 = __esm({
5965
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/chart.js"() {
5965
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/chart.js"() {
5966
5966
  "use strict";
5967
5967
  init_unicode();
5968
5968
  init_theme();
@@ -5970,14 +5970,14 @@ var init_chart2 = __esm({
5970
5970
  }
5971
5971
  });
5972
5972
 
5973
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/shadow.js
5973
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/shadow.js
5974
5974
  var init_shadow = __esm({
5975
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/shadow.js"() {
5975
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/shadow.js"() {
5976
5976
  "use strict";
5977
5977
  }
5978
5978
  });
5979
5979
 
5980
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/surface.js
5980
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/surface.js
5981
5981
  function drawClear(surface, options = {}) {
5982
5982
  if (surface.empty)
5983
5983
  return;
@@ -6001,16 +6001,16 @@ function drawFill(surface, options = {}) {
6001
6001
  }
6002
6002
  }
6003
6003
  var init_surface2 = __esm({
6004
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/surface.js"() {
6004
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/surface.js"() {
6005
6005
  "use strict";
6006
6006
  init_unicode();
6007
6007
  }
6008
6008
  });
6009
6009
 
6010
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/world-data.js
6010
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/world-data.js
6011
6011
  var WORLD_COUNTRIES;
6012
6012
  var init_world_data = __esm({
6013
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/world-data.js"() {
6013
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/world-data.js"() {
6014
6014
  "use strict";
6015
6015
  WORLD_COUNTRIES = [
6016
6016
  {
@@ -7301,7 +7301,7 @@ var init_world_data = __esm({
7301
7301
  }
7302
7302
  });
7303
7303
 
7304
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/world.js
7304
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/world.js
7305
7305
  function matches(country, keys) {
7306
7306
  for (const key of keys) {
7307
7307
  if (key.length === 0)
@@ -7366,7 +7366,7 @@ function degreesAt(column, row, width, height, x = WORLD_X, y = WORLD_Y) {
7366
7366
  }
7367
7367
  var WORLD_X, WORLD_Y;
7368
7368
  var init_world = __esm({
7369
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/world.js"() {
7369
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/graphics/world.js"() {
7370
7370
  "use strict";
7371
7371
  init_world_data();
7372
7372
  WORLD_X = { min: -180, max: 180 };
@@ -7374,7 +7374,7 @@ var init_world = __esm({
7374
7374
  }
7375
7375
  });
7376
7376
 
7377
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/world.js
7377
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/world.js
7378
7378
  function drawWorldMap(surface, options = {}) {
7379
7379
  if (surface.empty)
7380
7380
  return;
@@ -7398,14 +7398,14 @@ function countryAtCell(column, row, width, height, options = {}) {
7398
7398
  return countryAt(at.lon, at.lat);
7399
7399
  }
7400
7400
  var init_world2 = __esm({
7401
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/world.js"() {
7401
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/world.js"() {
7402
7402
  "use strict";
7403
7403
  init_canvas();
7404
7404
  init_world();
7405
7405
  }
7406
7406
  });
7407
7407
 
7408
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/scrollbar.js
7408
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/scrollbar.js
7409
7409
  function isVertical(orientation) {
7410
7410
  return orientation === "right" || orientation === "left";
7411
7411
  }
@@ -7461,13 +7461,13 @@ function offsetForPosition(position, track, total, viewport) {
7461
7461
  return Math.round(at / usable2 * (total - visible));
7462
7462
  }
7463
7463
  var init_scrollbar = __esm({
7464
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/scrollbar.js"() {
7464
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/scrollbar.js"() {
7465
7465
  "use strict";
7466
7466
  init_color();
7467
7467
  }
7468
7468
  });
7469
7469
 
7470
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/table.js
7470
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/table.js
7471
7471
  function cellValue(row, column, index) {
7472
7472
  if (column.render)
7473
7473
  return column.render(row, index);
@@ -7698,7 +7698,7 @@ function drawLog(surface, options) {
7698
7698
  }
7699
7699
  }
7700
7700
  var init_table = __esm({
7701
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/table.js"() {
7701
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/table.js"() {
7702
7702
  "use strict";
7703
7703
  init_buffer();
7704
7704
  init_color();
@@ -7709,7 +7709,7 @@ var init_table = __esm({
7709
7709
  }
7710
7710
  });
7711
7711
 
7712
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/meters.js
7712
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/meters.js
7713
7713
  function clampRatio(value) {
7714
7714
  return value > 1 ? 1 : value > 0 ? value : 0;
7715
7715
  }
@@ -7902,7 +7902,7 @@ function drawColumns(surface, options) {
7902
7902
  }
7903
7903
  }
7904
7904
  var init_meters = __esm({
7905
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/meters.js"() {
7905
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/meters.js"() {
7906
7906
  "use strict";
7907
7907
  init_buffer();
7908
7908
  init_color();
@@ -7913,7 +7913,7 @@ var init_meters = __esm({
7913
7913
  }
7914
7914
  });
7915
7915
 
7916
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/controls.js
7916
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/controls.js
7917
7917
  function variantColor(surface, options) {
7918
7918
  const t = surface.theme;
7919
7919
  if (options.color)
@@ -8137,7 +8137,7 @@ function drawTooltip(root, options) {
8137
8137
  inner.text(0, 0, truncate(options.text, inner.width), { fg: theme.foreground });
8138
8138
  }
8139
8139
  var init_controls = __esm({
8140
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/controls.js"() {
8140
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/controls.js"() {
8141
8141
  "use strict";
8142
8142
  init_buffer();
8143
8143
  init_color();
@@ -8146,7 +8146,7 @@ var init_controls = __esm({
8146
8146
  }
8147
8147
  });
8148
8148
 
8149
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/spinner.js
8149
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/spinner.js
8150
8150
  function spinnerFrame(elapsed, frames, interval = 80) {
8151
8151
  if (frames.length === 0)
8152
8152
  return "";
@@ -8188,7 +8188,7 @@ function drawSpinner(surface, options) {
8188
8188
  }
8189
8189
  var SPINNER_FRAMES;
8190
8190
  var init_spinner = __esm({
8191
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/spinner.js"() {
8191
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/spinner.js"() {
8192
8192
  "use strict";
8193
8193
  init_buffer();
8194
8194
  init_unicode();
@@ -8201,10 +8201,10 @@ var init_spinner = __esm({
8201
8201
  }
8202
8202
  });
8203
8203
 
8204
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/emoji-data.js
8204
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/emoji-data.js
8205
8205
  var OPENEMOJI_GROUPS, OPENEMOJI_ROWS, OPENEMOJI_ORDER, OPENEMOJI_TONED, OPENEMOJI_ALIASES, OPENEMOJI_EMOTICONS;
8206
8206
  var init_emoji_data = __esm({
8207
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/emoji-data.js"() {
8207
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/emoji-data.js"() {
8208
8208
  "use strict";
8209
8209
  OPENEMOJI_GROUPS = ["Smileys & Emotion", "People & Body", "Animals & Nature", "Food & Drink", "Travel & Places", "Activities", "Objects", "Symbols", "Flags"];
8210
8210
  OPENEMOJI_ROWS = [
@@ -14530,7 +14530,7 @@ var init_emoji_data = __esm({
14530
14530
  }
14531
14531
  });
14532
14532
 
14533
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/emoji.js
14533
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/emoji.js
14534
14534
  function load() {
14535
14535
  if (table)
14536
14536
  return table;
@@ -14624,7 +14624,7 @@ function emojiByGroup(group) {
14624
14624
  }
14625
14625
  var TONES, TONE_NAMES, slugOf, charOf, table, emoticons;
14626
14626
  var init_emoji = __esm({
14627
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/emoji.js"() {
14627
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/emoji.js"() {
14628
14628
  "use strict";
14629
14629
  init_emoji_data();
14630
14630
  TONES = ["1f3fb", "1f3fc", "1f3fd", "1f3fe", "1f3ff"];
@@ -14635,10 +14635,10 @@ var init_emoji = __esm({
14635
14635
  }
14636
14636
  });
14637
14637
 
14638
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/icons-data.js
14638
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/icons-data.js
14639
14639
  var OPENICON_VERSION, OPENICON_GLYPHS, OPENICON_ALIASES;
14640
14640
  var init_icons_data = __esm({
14641
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/icons-data.js"() {
14641
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/icons-data.js"() {
14642
14642
  "use strict";
14643
14643
  OPENICON_VERSION = "2026-09-24";
14644
14644
  OPENICON_GLYPHS = [
@@ -15176,7 +15176,7 @@ var init_icons_data = __esm({
15176
15176
  }
15177
15177
  });
15178
15178
 
15179
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/icons.js
15179
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/icons.js
15180
15180
  function iconMode(env3 = process.env) {
15181
15181
  if (chosen)
15182
15182
  return chosen;
@@ -15201,7 +15201,7 @@ function icon(name, options = {}) {
15201
15201
  }
15202
15202
  var openIcon, pack, chosen, detected, isMode;
15203
15203
  var init_icons = __esm({
15204
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/icons.js"() {
15204
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/icons.js"() {
15205
15205
  "use strict";
15206
15206
  init_capabilities();
15207
15207
  init_icons_data();
@@ -15216,7 +15216,7 @@ var init_icons = __esm({
15216
15216
  }
15217
15217
  });
15218
15218
 
15219
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/emoji-picker.js
15219
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/emoji-picker.js
15220
15220
  function emojiPickerItems(state, recent = []) {
15221
15221
  if (state.query.trim())
15222
15222
  return emojiSearch(state.query, 400).filter((e) => !TONED.test(e.key));
@@ -15381,7 +15381,7 @@ function emojiPickerIndexAt(state, layout, x, y) {
15381
15381
  }
15382
15382
  var EMOJI_RECENT, TONED, GROUP_ICONS;
15383
15383
  var init_emoji_picker = __esm({
15384
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/emoji-picker.js"() {
15384
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/emoji-picker.js"() {
15385
15385
  "use strict";
15386
15386
  init_buffer();
15387
15387
  init_color();
@@ -15395,7 +15395,7 @@ var init_emoji_picker = __esm({
15395
15395
  }
15396
15396
  });
15397
15397
 
15398
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/data-grid.js
15398
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/data-grid.js
15399
15399
  function dataGridWidths(columns, rows2, options = {}) {
15400
15400
  const cap = options.maxColumnWidth ?? 40;
15401
15401
  const sample = options.sample ?? 1e3;
@@ -15542,7 +15542,7 @@ function drawDataGrid(surface, options) {
15542
15542
  }
15543
15543
  var SEPARATOR, widthCache, firstLine;
15544
15544
  var init_data_grid = __esm({
15545
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/data-grid.js"() {
15545
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/data-grid.js"() {
15546
15546
  "use strict";
15547
15547
  init_buffer();
15548
15548
  init_color();
@@ -15559,9 +15559,9 @@ var init_data_grid = __esm({
15559
15559
  }
15560
15560
  });
15561
15561
 
15562
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/index.js
15562
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/index.js
15563
15563
  var init_widgets = __esm({
15564
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/index.js"() {
15564
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/widgets/index.js"() {
15565
15565
  "use strict";
15566
15566
  init_text();
15567
15567
  init_calendar();
@@ -15579,7 +15579,7 @@ var init_widgets = __esm({
15579
15579
  }
15580
15580
  });
15581
15581
 
15582
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/markdown.js
15582
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/markdown.js
15583
15583
  function markdownText(value) {
15584
15584
  return stripAnsi(value).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, "").replace(/([\\`*_{}\[\]<>#|!])/g, "\\$1");
15585
15585
  }
@@ -15592,7 +15592,7 @@ function clipboardSequence(text, tmux = false) {
15592
15592
  }
15593
15593
  var MarkdownSummary;
15594
15594
  var init_markdown = __esm({
15595
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/markdown.js"() {
15595
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/markdown.js"() {
15596
15596
  "use strict";
15597
15597
  init_ansi();
15598
15598
  init_richtext();
@@ -15643,7 +15643,7 @@ var init_markdown = __esm({
15643
15643
  }
15644
15644
  });
15645
15645
 
15646
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/ui.js
15646
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/ui.js
15647
15647
  function dispatchHit(regions, event) {
15648
15648
  for (let i = regions.length - 1; i >= 0; i--) {
15649
15649
  const hit = regions[i];
@@ -15673,7 +15673,7 @@ function countClicks(previous, press) {
15673
15673
  }
15674
15674
  var DOUBLE_CLICK_MS, Container, GridContainer;
15675
15675
  var init_ui = __esm({
15676
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/ui.js"() {
15676
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/ui.js"() {
15677
15677
  "use strict";
15678
15678
  init_layout();
15679
15679
  init_unicode();
@@ -15693,8 +15693,8 @@ var init_ui = __esm({
15693
15693
  gap;
15694
15694
  justify;
15695
15695
  inner;
15696
- constructor(surface, ctx, direction = "column", options = {}, summary) {
15697
- this.summary = summary;
15696
+ constructor(surface, ctx, direction = "column", options = {}, summary2) {
15697
+ this.summary = summary2;
15698
15698
  this.surface = surface;
15699
15699
  this.ctx = ctx;
15700
15700
  this.direction = direction;
@@ -15772,18 +15772,18 @@ var init_ui = __esm({
15772
15772
  // ---------------------------------------------------------------- layout
15773
15773
  /** A horizontal container. Children default to equal shares. */
15774
15774
  row(options = {}, build) {
15775
- const summary = this.summary?.child();
15775
+ const summary2 = this.summary?.child();
15776
15776
  return this.add((surface) => {
15777
- const container = new _Container(surface, this.ctx, "row", options, summary);
15777
+ const container = new _Container(surface, this.ctx, "row", options, summary2);
15778
15778
  build?.(container);
15779
15779
  container.flush();
15780
15780
  }, this.sizeOf(options, "fill"), options.bordered ?? false);
15781
15781
  }
15782
15782
  /** A vertical container. */
15783
15783
  column(options = {}, build) {
15784
- const summary = this.summary?.child();
15784
+ const summary2 = this.summary?.child();
15785
15785
  return this.add((surface) => {
15786
- const container = new _Container(surface, this.ctx, "column", options, summary);
15786
+ const container = new _Container(surface, this.ctx, "column", options, summary2);
15787
15787
  build?.(container);
15788
15788
  container.flush();
15789
15789
  }, this.sizeOf(options, "fill"), options.bordered ?? false);
@@ -15797,9 +15797,9 @@ var init_ui = __esm({
15797
15797
  * });
15798
15798
  */
15799
15799
  grid(options = {}, build) {
15800
- const summary = this.summary?.child();
15800
+ const summary2 = this.summary?.child();
15801
15801
  return this.add((surface) => {
15802
- const container = new GridContainer(surface, this.ctx, options, summary);
15802
+ const container = new GridContainer(surface, this.ctx, options, summary2);
15803
15803
  build?.(container);
15804
15804
  container.flush();
15805
15805
  }, this.sizeOf(options, "fill"), options.bordered ?? false);
@@ -15808,9 +15808,9 @@ var init_ui = __esm({
15808
15808
  panel(options = {}, build) {
15809
15809
  const focus = options.focusable ? this.ctx.registerFocus() : void 0;
15810
15810
  const copy = options.copyMarkdown ?? this.ctx.copyMarkdown ?? false;
15811
- const summary = options.copyMarkdown !== false && (copy || this.summary) ? new MarkdownSummary() : void 0;
15812
- if (summary)
15813
- this.summary?.add(() => summary.body() ? summary.document(options.title, options.subtitle, void 0, options.footer) : "");
15811
+ const summary2 = options.copyMarkdown !== false && (copy || this.summary) ? new MarkdownSummary() : void 0;
15812
+ if (summary2)
15813
+ this.summary?.add(() => summary2.body() ? summary2.document(options.title, options.subtitle, void 0, options.footer) : "");
15814
15814
  return this.add((surface) => {
15815
15815
  if (options.onClick) {
15816
15816
  const onClick = options.onClick;
@@ -15837,11 +15837,11 @@ var init_ui = __esm({
15837
15837
  const container = new _Container(interior, this.ctx, "column", {
15838
15838
  gap: options.gap,
15839
15839
  padding: options.padding ?? [0, 1]
15840
- }, summary);
15840
+ }, summary2);
15841
15841
  build?.(container);
15842
15842
  container.flush();
15843
- if (canCopy && (copy !== true || summary?.body())) {
15844
- const action = () => this.ctx.copyText?.(() => typeof copy === "function" ? copy() : typeof copy === "string" ? copy : summary.document(options.title, options.subtitle, this.ctx.markdownContext, options.footer));
15843
+ if (canCopy && (copy !== true || summary2?.body())) {
15844
+ const action = () => this.ctx.copyText?.(() => typeof copy === "function" ? copy() : typeof copy === "string" ? copy : summary2.document(options.title, options.subtitle, this.ctx.markdownContext, options.footer));
15845
15845
  const copyFocus = this.ctx.registerFocus(action, true);
15846
15846
  const target = surface.sub(surface.width - copyWidth - 2, 0, copyWidth, 1);
15847
15847
  const glyph = this.ctx.capabilities.unicode ? "\u29C9" : "C";
@@ -16203,9 +16203,9 @@ var init_ui = __esm({
16203
16203
  modal(options, build) {
16204
16204
  this.ctx.overlay((root) => {
16205
16205
  const copy = options.copyMarkdown ?? this.ctx.copyMarkdown ?? false;
16206
- const summary = new MarkdownSummary();
16206
+ const summary2 = new MarkdownSummary();
16207
16207
  if (options.message)
16208
- summary.text(options.message);
16208
+ summary2.text(options.message);
16209
16209
  const canCopy = copy !== false && !!this.ctx.copyText && Math.min(options.width ?? 60, root.width - 4) >= 18;
16210
16210
  const buttons = options.buttons?.map((button) => {
16211
16211
  if (!button.onPress)
@@ -16232,12 +16232,12 @@ var init_ui = __esm({
16232
16232
  });
16233
16233
  }
16234
16234
  if (build) {
16235
- const container = new _Container(inner, this.ctx, "column", { padding: [1, 1] }, summary);
16235
+ const container = new _Container(inner, this.ctx, "column", { padding: [1, 1] }, summary2);
16236
16236
  build(container);
16237
16237
  container.flush();
16238
16238
  }
16239
- if (canCopy && (copy !== true || summary.body())) {
16240
- const action = () => this.ctx.copyText?.(() => typeof copy === "function" ? copy() : typeof copy === "string" ? copy : summary.document(options.title, void 0, this.ctx.markdownContext));
16239
+ if (canCopy && (copy !== true || summary2.body())) {
16240
+ const action = () => this.ctx.copyText?.(() => typeof copy === "function" ? copy() : typeof copy === "string" ? copy : summary2.document(options.title, void 0, this.ctx.markdownContext));
16241
16241
  const focus = this.ctx.registerFocus(action, true);
16242
16242
  const target = root.region({ x: interior.x + interior.width - 7, y: interior.y - 1, width: 6, height: 1 });
16243
16243
  drawButton(target, { label: this.ctx.capabilities.unicode ? "\u29C9 MD" : "C MD", variant: "ghost", focused: focus.focused });
@@ -16381,8 +16381,8 @@ var init_ui = __esm({
16381
16381
  ctx;
16382
16382
  options;
16383
16383
  cells = [];
16384
- constructor(surface, ctx, options, summary) {
16385
- this.summary = summary;
16384
+ constructor(surface, ctx, options, summary2) {
16385
+ this.summary = summary2;
16386
16386
  this.surface = options.padding ? surface.inset(options.padding) : surface;
16387
16387
  this.ctx = ctx;
16388
16388
  this.options = options;
@@ -16415,25 +16415,25 @@ var init_ui = __esm({
16415
16415
  }
16416
16416
  /** A panel occupying the next free cell (or several, with colSpan/rowSpan). */
16417
16417
  panel(options = {}, build) {
16418
- const summary = this.summary?.child();
16418
+ const summary2 = this.summary?.child();
16419
16419
  return this.push(options, (surface) => {
16420
- const container = new Container(surface, this.ctx, "column", {}, summary);
16420
+ const container = new Container(surface, this.ctx, "column", {}, summary2);
16421
16421
  container.panel(options, build);
16422
16422
  container.flush();
16423
16423
  }, (options.border ?? "rounded") !== "none");
16424
16424
  }
16425
16425
  cell(options = {}, build) {
16426
- const summary = this.summary?.child();
16426
+ const summary2 = this.summary?.child();
16427
16427
  return this.push(options, (surface) => {
16428
- const container = new Container(surface, this.ctx, "column", options, summary);
16428
+ const container = new Container(surface, this.ctx, "column", options, summary2);
16429
16429
  build?.(container);
16430
16430
  container.flush();
16431
16431
  }, options.bordered ?? false);
16432
16432
  }
16433
16433
  row(options = {}, build) {
16434
- const summary = this.summary?.child();
16434
+ const summary2 = this.summary?.child();
16435
16435
  return this.push(options, (surface) => {
16436
- const container = new Container(surface, this.ctx, "row", options, summary);
16436
+ const container = new Container(surface, this.ctx, "row", options, summary2);
16437
16437
  build?.(container);
16438
16438
  container.flush();
16439
16439
  }, options.bordered ?? false);
@@ -16505,13 +16505,13 @@ var init_ui = __esm({
16505
16505
  }
16506
16506
  });
16507
16507
 
16508
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/app.js
16508
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/app.js
16509
16509
  async function createApp(options = {}) {
16510
16510
  return new App(options);
16511
16511
  }
16512
16512
  var App;
16513
16513
  var init_app = __esm({
16514
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/app.js"() {
16514
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/app.js"() {
16515
16515
  "use strict";
16516
16516
  init_buffer();
16517
16517
  init_diff();
@@ -16987,7 +16987,7 @@ var init_app = __esm({
16987
16987
  }
16988
16988
  });
16989
16989
 
16990
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/images.js
16990
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/images.js
16991
16991
  function imageSupport(env3 = process.env) {
16992
16992
  const setting = (env3.HQTUI_IMAGES ?? "").toLowerCase();
16993
16993
  if (setting === "0" || setting === "off" || setting === "false")
@@ -17078,7 +17078,7 @@ function placeholderCell(row, col) {
17078
17078
  }
17079
17079
  var import_node_path5, PLACEHOLDER, DIACRITICS, builtin, moshCache;
17080
17080
  var init_images = __esm({
17081
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/images.js"() {
17081
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/images.js"() {
17082
17082
  "use strict";
17083
17083
  import_node_path5 = require("path");
17084
17084
  init_capabilities();
@@ -17091,9 +17091,9 @@ var init_images = __esm({
17091
17091
  }
17092
17092
  });
17093
17093
 
17094
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/index.js
17094
+ // ../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/index.js
17095
17095
  var init_dist = __esm({
17096
- "../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/index.js"() {
17096
+ "../../../../../node_modules/.pnpm/@profullstack+hqtui@0.11.0/node_modules/@profullstack/hqtui/dist/index.js"() {
17097
17097
  "use strict";
17098
17098
  init_app();
17099
17099
  init_buffer();
@@ -18276,7 +18276,7 @@ function isPublicAddress(ip) {
18276
18276
  if (v === 6) return !/^(::1?$|f[cd]|fe[89ab]|ff)/i.test(ip);
18277
18277
  return false;
18278
18278
  }
18279
- function localMapData(state, geo, hostname6, now = Date.now()) {
18279
+ function localMapData(state, geo, hostname7, now = Date.now()) {
18280
18280
  const by = /* @__PURE__ */ new Map();
18281
18281
  for (const e of state.events) {
18282
18282
  const ip = e.source_ip;
@@ -18300,7 +18300,7 @@ function localMapData(state, geo, hostname6, now = Date.now()) {
18300
18300
  const o = by.get(t.ip);
18301
18301
  if (o) o.count = Math.max(o.count, t.count);
18302
18302
  }
18303
- const servers = geo.self ? [{ id: "self", name: hostname6, ...geo.self, online: state.connection === "live" }] : [];
18303
+ const servers = geo.self ? [{ id: "self", name: hostname7, ...geo.self, online: state.connection === "live" }] : [];
18304
18304
  return { servers, origins: [...by.values()], windowMinutes: 0, generatedAt: new Date(now).toISOString() };
18305
18305
  }
18306
18306
  function sourceAddresses(state) {
@@ -19493,7 +19493,368 @@ var init_dashboard = __esm({
19493
19493
  }
19494
19494
  });
19495
19495
 
19496
- // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
19496
+ // src/tui/action-center.ts
19497
+ var action_center_exports = {};
19498
+ __export(action_center_exports, {
19499
+ startActionCenter: () => startActionCenter
19500
+ });
19501
+ async function getJson(path2) {
19502
+ const response = await cloudFetch(path2);
19503
+ const body = await response.json().catch(() => ({}));
19504
+ if (!response.ok) {
19505
+ const message = typeof body.error === "string" ? body.error : `Request failed (${response.status})`;
19506
+ throw new Error(response.status === 401 ? "Your login expired. Run `threatcrush login` and try again." : message);
19507
+ }
19508
+ return body;
19509
+ }
19510
+ async function loadBoard() {
19511
+ const [orgResult, fleetResult, mapResult] = await Promise.allSettled([
19512
+ getJson("/api/orgs"),
19513
+ getJson("/api/fleet"),
19514
+ getJson("/api/attack-map?window=60")
19515
+ ]);
19516
+ if (orgResult.status === "rejected" || fleetResult.status === "rejected") {
19517
+ const error2 = orgResult.status === "rejected" ? orgResult.reason : fleetResult.reason;
19518
+ throw error2 instanceof Error ? error2 : new Error(String(error2));
19519
+ }
19520
+ const servers = fleetResult.value.servers ?? [];
19521
+ const serverOrgIds = new Set(servers.map((server) => server.org_id));
19522
+ const organizations = (orgResult.value.organizations ?? []).filter((org) => serverOrgIds.has(org.id));
19523
+ const detailResults = [];
19524
+ for (let offset = 0; offset < organizations.length; offset += ORG_REQUEST_CONCURRENCY) {
19525
+ const batch = organizations.slice(offset, offset + ORG_REQUEST_CONCURRENCY);
19526
+ detailResults.push(...await Promise.all(batch.map(async (org) => {
19527
+ const prefix = `/api/orgs/${encodeURIComponent(org.id)}`;
19528
+ const [detections2, pendingActions, executingActions] = await Promise.allSettled([
19529
+ getJson(`${prefix}/detections?limit=${MAX_DETECTIONS}`),
19530
+ getJson(`${prefix}/remediations?limit=200&status=pending`),
19531
+ getJson(`${prefix}/remediations?limit=200&status=executing`)
19532
+ ]);
19533
+ return { detections: detections2, pendingActions, executingActions };
19534
+ })));
19535
+ }
19536
+ const detections = [];
19537
+ const actions = [];
19538
+ let failedOrgs = 0;
19539
+ for (const result of detailResults) {
19540
+ if (result.detections.status === "fulfilled") detections.push(...result.detections.value.detections ?? []);
19541
+ if (result.pendingActions.status === "fulfilled") actions.push(...result.pendingActions.value.remediations ?? []);
19542
+ if (result.executingActions.status === "fulfilled") actions.push(...result.executingActions.value.remediations ?? []);
19543
+ if (result.detections.status === "rejected" || result.pendingActions.status === "rejected" || result.executingActions.status === "rejected") failedOrgs++;
19544
+ }
19545
+ detections.sort((a, b) => Date.parse(b.detected_at) - Date.parse(a.detected_at));
19546
+ actions.sort((a, b) => Date.parse(b.created_at) - Date.parse(a.created_at));
19547
+ const warnings = [
19548
+ failedOrgs ? `Could not load detection or action data for ${failedOrgs} organization(s).` : "",
19549
+ mapResult.status === "rejected" ? "Attack map data is unavailable." : ""
19550
+ ].filter(Boolean);
19551
+ return {
19552
+ data: {
19553
+ servers,
19554
+ detections,
19555
+ actions,
19556
+ map: mapResult.status === "fulfilled" ? mapResult.value : null
19557
+ },
19558
+ warning: warnings.join(" ")
19559
+ };
19560
+ }
19561
+ function recommendation(severity) {
19562
+ if (severity === "critical") return "Investigate host now";
19563
+ if (severity === "high") return "Verify source; block if unauthorized";
19564
+ if (severity === "medium") return "Check if expected, then resolve";
19565
+ return "Review if unexpected";
19566
+ }
19567
+ function time(value) {
19568
+ const date = new Date(value);
19569
+ if (!Number.isFinite(date.getTime())) return "unknown";
19570
+ return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
19571
+ }
19572
+ function connectionColor(connection) {
19573
+ if (connection === "online") return threatcrushTheme.success;
19574
+ if (connection === "no-agent") return threatcrushTheme.muted;
19575
+ return severityColors.high;
19576
+ }
19577
+ function nextValue(values, current, step = 1) {
19578
+ const index = values.indexOf(current);
19579
+ return values[(Math.max(0, index) + step + values.length) % values.length] ?? values[0] ?? current;
19580
+ }
19581
+ async function startActionCenter() {
19582
+ const app = await createApp({
19583
+ theme: threatcrushTheme,
19584
+ title: "ThreatCrush \u2014 Action Center",
19585
+ mouse: true,
19586
+ fps: 20,
19587
+ quitKeys: []
19588
+ });
19589
+ const geo = new GeoResolver(() => app.invalidate());
19590
+ const mapState = initialState();
19591
+ let data = EMPTY;
19592
+ let severity = "all";
19593
+ let fleetId = "all";
19594
+ let serverId = "all";
19595
+ let ipFilter = "";
19596
+ let editingIp = false;
19597
+ let selected = 0;
19598
+ let loading = true;
19599
+ let error2 = "";
19600
+ let warning2 = "";
19601
+ let stopped = false;
19602
+ let refreshing = false;
19603
+ let showMap = false;
19604
+ const refresh = async () => {
19605
+ if (refreshing || stopped) return;
19606
+ refreshing = true;
19607
+ try {
19608
+ const result = await loadBoard();
19609
+ data = result.data;
19610
+ warning2 = result.warning;
19611
+ error2 = "";
19612
+ loading = false;
19613
+ } catch (err) {
19614
+ error2 = err instanceof Error ? err.message : String(err);
19615
+ loading = false;
19616
+ } finally {
19617
+ refreshing = false;
19618
+ app.invalidate();
19619
+ }
19620
+ };
19621
+ const interval = setInterval(() => {
19622
+ void refresh();
19623
+ }, POLL_MS4);
19624
+ interval.unref?.();
19625
+ void refresh();
19626
+ const serverById = () => new Map(data.servers.map((server) => [server.id, server]));
19627
+ const fleets = () => {
19628
+ const seen = /* @__PURE__ */ new Map();
19629
+ for (const server of data.servers) {
19630
+ if (server.fleet_id) seen.set(server.fleet_id, `${server.org_slug} / ${server.fleet_name ?? "Fleet"}`);
19631
+ }
19632
+ return [...seen].map(([id, label]) => ({ id, label })).sort((a, b) => a.label.localeCompare(b.label));
19633
+ };
19634
+ const servers = () => data.servers.filter((server) => fleetId === "all" || server.fleet_id === fleetId).sort((a, b) => `${a.org_slug}/${a.name}`.localeCompare(`${b.org_slug}/${b.name}`));
19635
+ const filtered = () => {
19636
+ const byId = serverById();
19637
+ const ip = ipFilter.trim().toLowerCase();
19638
+ return data.detections.filter((detection) => {
19639
+ const server = byId.get(detection.server_id);
19640
+ return (severity === "all" || detection.severity === severity) && (fleetId === "all" || server?.fleet_id === fleetId) && (serverId === "all" || detection.server_id === serverId) && (!ip || detection.source_ip?.toLowerCase().includes(ip));
19641
+ });
19642
+ };
19643
+ const quit = () => {
19644
+ stopped = true;
19645
+ clearInterval(interval);
19646
+ geo.stop();
19647
+ app.stop();
19648
+ };
19649
+ app.on("key", (event) => {
19650
+ if (editingIp) {
19651
+ if (event.key === "escape") editingIp = false;
19652
+ else if (event.key === "enter" || event.key === "return") editingIp = false;
19653
+ else if (event.key === "backspace") ipFilter = ipFilter.slice(0, -1);
19654
+ else if (event.key === "ctrl+u") ipFilter = "";
19655
+ else if (event.char && event.char >= " " && ipFilter.length < 80) ipFilter += event.char;
19656
+ app.invalidate();
19657
+ return;
19658
+ }
19659
+ switch (event.key) {
19660
+ case "q":
19661
+ case "ctrl+c":
19662
+ quit();
19663
+ break;
19664
+ case "r":
19665
+ void refresh();
19666
+ break;
19667
+ case "m":
19668
+ showMap = !showMap;
19669
+ break;
19670
+ case "/":
19671
+ editingIp = true;
19672
+ break;
19673
+ case "escape":
19674
+ if (ipFilter) ipFilter = "";
19675
+ else if (serverId !== "all") serverId = "all";
19676
+ else if (fleetId !== "all") {
19677
+ fleetId = "all";
19678
+ serverId = "all";
19679
+ } else severity = "all";
19680
+ break;
19681
+ case "s":
19682
+ severity = nextValue(SEVERITIES3, severity);
19683
+ selected = 0;
19684
+ break;
19685
+ case "f": {
19686
+ const values = ["all", ...fleets().map((item) => item.id)];
19687
+ fleetId = nextValue(values, fleetId);
19688
+ serverId = "all";
19689
+ selected = 0;
19690
+ break;
19691
+ }
19692
+ case "h": {
19693
+ const values = ["all", ...servers().map((server) => server.id)];
19694
+ serverId = nextValue(values, serverId);
19695
+ selected = 0;
19696
+ break;
19697
+ }
19698
+ case "up":
19699
+ case "k":
19700
+ selected = Math.max(0, selected - 1);
19701
+ break;
19702
+ case "down":
19703
+ case "j":
19704
+ selected = Math.min(Math.max(0, filtered().length - 1), selected + 1);
19705
+ break;
19706
+ case "home":
19707
+ selected = 0;
19708
+ break;
19709
+ case "end":
19710
+ selected = Math.max(0, filtered().length - 1);
19711
+ break;
19712
+ default:
19713
+ break;
19714
+ }
19715
+ app.invalidate();
19716
+ });
19717
+ app.on("paste", (event) => {
19718
+ if (!editingIp) return;
19719
+ ipFilter = `${ipFilter}${event.text.replace(/[\r\n]/g, "").slice(0, 80 - ipFilter.length)}`;
19720
+ app.invalidate();
19721
+ });
19722
+ app.render(({ ui, theme }) => {
19723
+ if (showMap && data.map) {
19724
+ mapBody(ui, mapState, theme, { data: data.map, geo });
19725
+ ui.statusBar({ size: 1, items: [{ key: "m", label: "events" }, { key: "r", label: "refresh" }, { key: "q", label: "quit" }] });
19726
+ return;
19727
+ }
19728
+ ui.box({ size: 3, border: "rounded", borderColor: theme.border, padding: [0, 1] }, (box) => {
19729
+ box.row({ size: 1 }, (row) => {
19730
+ row.text("\u26A1 THREATCRUSH \xB7 ACTION CENTER", { fg: theme.primary, bold: true, size: 35 });
19731
+ row.text(loading ? "LOADING" : error2 ? "OFFLINE" : "LIVE", {
19732
+ fg: error2 ? severityColors.high : loading ? theme.warning : theme.success,
19733
+ bold: true,
19734
+ size: 8
19735
+ });
19736
+ row.text(error2 || warning2 || "Fleet detections, server health, and queued actions", { fg: error2 ? severityColors.high : theme.muted, size: "fill" });
19737
+ });
19738
+ });
19739
+ const list = filtered();
19740
+ selected = Math.min(selected, Math.max(0, list.length - 1));
19741
+ const selectedDetection = list[selected];
19742
+ const serverMap = serverById();
19743
+ const online = data.servers.filter((server) => server.connection === "online").length;
19744
+ const pending = data.actions.length;
19745
+ ui.row({ size: 4, gap: 1 }, (row) => {
19746
+ summary(row, theme, "SERVERS ONLINE", `${online}/${data.servers.length}`, theme.success);
19747
+ summary(row, theme, "DETECTIONS", String(data.detections.length), severityColors.high);
19748
+ summary(row, theme, "QUEUED ACTIONS", String(pending), theme.warning);
19749
+ summary(row, theme, "FILTERED EVENTS", String(list.length), theme.accent);
19750
+ });
19751
+ ui.row({ size: 1 }, (row) => {
19752
+ const selectedHost = serverMap.get(serverId);
19753
+ row.text(`severity ${severity} \xB7 fleet ${fleetId === "all" ? "all" : fleets().find((x) => x.id === fleetId)?.label ?? "unknown"} \xB7 host ${selectedHost ? `${selectedHost.org_slug}/${selectedHost.name}` : "all"}`, { fg: theme.foreground, size: "fill" });
19754
+ row.text(`source IP ${editingIp ? `/${ipFilter}\u258F` : ipFilter || "all"}`, { fg: editingIp ? theme.primary : theme.muted, size: 24 });
19755
+ });
19756
+ ui.row({ size: "fill", gap: 1 }, (row) => {
19757
+ row.column({ size: "2fr" }, (left) => {
19758
+ left.panel({ title: "LATEST DETECTIONS \xB7 RECOMMENDED ACTION", size: "fill", border: "rounded", borderColor: theme.border, titleColor: theme.primary, padding: [0, 1] }, (panel) => {
19759
+ if (loading) {
19760
+ panel.label("Loading detections\u2026", { fg: theme.muted });
19761
+ return;
19762
+ }
19763
+ if (list.length === 0) {
19764
+ panel.label(error2 ? "Sign in and refresh to load fleet activity." : "No detections match these filters.", { fg: theme.muted });
19765
+ return;
19766
+ }
19767
+ panel.table({
19768
+ rows: list,
19769
+ header: true,
19770
+ selected,
19771
+ followSelection: true,
19772
+ scrollbar: true,
19773
+ columns: [
19774
+ { key: "severity", width: 9, render: (d) => d.severity.toUpperCase(), color: (d) => severityColors[d.severity] },
19775
+ { key: "server_id", width: 20, render: (d) => serverMap.get(d.server_id)?.name ?? "unknown host", color: () => theme.foreground },
19776
+ { key: "source_ip", width: 16, render: (d) => d.source_ip ?? "\u2014", color: () => theme.muted },
19777
+ { key: "title", width: "fill", color: () => theme.foreground },
19778
+ { key: "severity", width: 31, title: "NEXT STEP", render: (d) => recommendation(d.severity), color: (d) => severityColors[d.severity] }
19779
+ ]
19780
+ });
19781
+ });
19782
+ });
19783
+ row.column({ size: "1fr" }, (right) => {
19784
+ right.panel({ title: "SERVERS", size: "2fr", border: "rounded", borderColor: theme.border, titleColor: theme.primary, padding: [0, 1] }, (panel) => {
19785
+ if (data.servers.length === 0) {
19786
+ panel.label("No linked servers.", { fg: theme.muted });
19787
+ return;
19788
+ }
19789
+ panel.table({
19790
+ rows: servers(),
19791
+ header: true,
19792
+ columns: [
19793
+ { key: "connection", width: 9, render: (server) => server.connection, color: (server) => connectionColor(server.connection) },
19794
+ { key: "name", width: "fill", render: (server) => `${server.org_slug} / ${server.name}`, color: () => theme.foreground }
19795
+ ]
19796
+ });
19797
+ });
19798
+ right.panel({ title: "QUEUED ACTIONS", size: "1fr", border: "rounded", borderColor: theme.border, titleColor: theme.primary, padding: [0, 1] }, (panel) => {
19799
+ if (pending === 0) {
19800
+ panel.label("No pending actions.", { fg: theme.muted });
19801
+ return;
19802
+ }
19803
+ for (const action of data.actions.slice(0, 8)) {
19804
+ const host = serverMap.get(action.server_id)?.name ?? "unknown host";
19805
+ panel.row({ size: 1 }, (line2) => {
19806
+ line2.text(`${action.action_type} ${action.target_value}`, { fg: theme.foreground, size: "fill" });
19807
+ line2.text(action.status, { fg: theme.warning, size: 12, align: "right" });
19808
+ });
19809
+ panel.label(`${host} \xB7 ${time(action.created_at)}`, { fg: theme.muted, size: 1 });
19810
+ }
19811
+ });
19812
+ if (selectedDetection) {
19813
+ right.panel({ title: "SELECTED EVENT", size: 1, border: "rounded", borderColor: theme.border, titleColor: theme.primary, padding: [0, 1] }, (panel) => {
19814
+ const host = serverMap.get(selectedDetection.server_id);
19815
+ panel.text(`${selectedDetection.title} \xB7 ${recommendation(selectedDetection.severity)}`, { fg: severityColors[selectedDetection.severity] });
19816
+ panel.label(`${host?.org_slug ?? "org"} / ${host?.name ?? "unknown host"} \xB7 ${time(selectedDetection.detected_at)} \xB7 ${selectedDetection.status}`, { fg: theme.muted, size: 1 });
19817
+ if (selectedDetection.description) panel.label(selectedDetection.description, { fg: theme.foreground, size: 2 });
19818
+ });
19819
+ }
19820
+ });
19821
+ });
19822
+ ui.statusBar({
19823
+ size: 1,
19824
+ items: editingIp ? [{ key: "enter", label: "apply IP filter" }, { key: "esc", label: "cancel" }, { key: "ctrl+u", label: "clear" }] : [{ key: "q", label: "quit" }, { key: "r", label: "refresh" }, { key: "m", label: "attack map" }, { key: "s", label: "severity" }, { key: "f", label: "fleet" }, { key: "h", label: "host" }, { key: "/", label: "source IP" }, { key: "\u2191\u2193", label: "select" }, { key: "esc", label: "clear filters" }]
19825
+ });
19826
+ });
19827
+ try {
19828
+ await app.start();
19829
+ } finally {
19830
+ stopped = true;
19831
+ clearInterval(interval);
19832
+ geo.stop();
19833
+ }
19834
+ }
19835
+ function summary(parent, theme, label, value, color) {
19836
+ parent.panel({ title: label, size: "fill", border: "rounded", borderColor: theme.border, titleColor: theme.muted, padding: [0, 1] }, (panel) => {
19837
+ panel.text(value, { fg: color, bold: true, size: 18 });
19838
+ });
19839
+ }
19840
+ var EMPTY, SEVERITIES3, POLL_MS4, MAX_DETECTIONS, ORG_REQUEST_CONCURRENCY;
19841
+ var init_action_center = __esm({
19842
+ "src/tui/action-center.ts"() {
19843
+ "use strict";
19844
+ init_dist();
19845
+ init_cli_config();
19846
+ init_state();
19847
+ init_map();
19848
+ init_theme2();
19849
+ EMPTY = { servers: [], detections: [], actions: [], map: null };
19850
+ SEVERITIES3 = ["all", "critical", "high", "medium", "low", "info"];
19851
+ POLL_MS4 = 3e4;
19852
+ MAX_DETECTIONS = 200;
19853
+ ORG_REQUEST_CONCURRENCY = 4;
19854
+ }
19855
+ });
19856
+
19857
+ // ../../../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
19497
19858
  var CommanderError = class extends Error {
19498
19859
  /**
19499
19860
  * Constructs the CommanderError class
@@ -19522,7 +19883,7 @@ var InvalidArgumentError = class extends CommanderError {
19522
19883
  }
19523
19884
  };
19524
19885
 
19525
- // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/argument.js
19886
+ // ../../../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/argument.js
19526
19887
  var Argument = class {
19527
19888
  /**
19528
19889
  * Initialize a new command argument with the given name and description.
@@ -19643,7 +20004,7 @@ function humanReadableArgName(arg) {
19643
20004
  return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
19644
20005
  }
19645
20006
 
19646
- // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/command.js
20007
+ // ../../../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/command.js
19647
20008
  var import_node_events = require("events");
19648
20009
  var import_node_child_process = __toESM(require("child_process"), 1);
19649
20010
  var import_node_path = __toESM(require("path"), 1);
@@ -19651,7 +20012,7 @@ var import_node_fs = __toESM(require("fs"), 1);
19651
20012
  var import_node_process = __toESM(require("process"), 1);
19652
20013
  var import_node_util2 = require("util");
19653
20014
 
19654
- // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/help.js
20015
+ // ../../../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/help.js
19655
20016
  var import_node_util = require("util");
19656
20017
  var Help = class {
19657
20018
  constructor() {
@@ -20243,7 +20604,7 @@ ${itemIndentStr}`);
20243
20604
  }
20244
20605
  };
20245
20606
 
20246
- // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/option.js
20607
+ // ../../../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/option.js
20247
20608
  var Option = class {
20248
20609
  /**
20249
20610
  * Initialize a new `Option` with the given `flags` and `description`.
@@ -20549,7 +20910,7 @@ function splitOptionFlags(flags) {
20549
20910
  return { shortFlag, longFlag };
20550
20911
  }
20551
20912
 
20552
- // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/suggestSimilar.js
20913
+ // ../../../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/suggestSimilar.js
20553
20914
  var maxDistance = 3;
20554
20915
  function editDistance(a, b) {
20555
20916
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -20624,7 +20985,7 @@ function suggestSimilar(word, candidates) {
20624
20985
  return "";
20625
20986
  }
20626
20987
 
20627
- // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/command.js
20988
+ // ../../../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/command.js
20628
20989
  var Command = class _Command extends import_node_events.EventEmitter {
20629
20990
  /**
20630
20991
  * Initialize a new `Command`.
@@ -22858,10 +23219,10 @@ function useColor() {
22858
23219
  return void 0;
22859
23220
  }
22860
23221
 
22861
- // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/index.js
23222
+ // ../../../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/index.js
22862
23223
  var program = new Command();
22863
23224
 
22864
- // ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/utilities.js
23225
+ // ../../../../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/utilities.js
22865
23226
  function stringReplaceAll(string, substring, postfix) {
22866
23227
  let index = string.indexOf(substring);
22867
23228
  if (index === -1) {
@@ -22891,7 +23252,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
22891
23252
  return returnValue;
22892
23253
  }
22893
23254
 
22894
- // ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/vendor/ansi-styles/index.js
23255
+ // ../../../../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/vendor/ansi-styles/index.js
22895
23256
  var ANSI_BACKGROUND_OFFSET = 10;
22896
23257
  var ANSI_UNDERLINE_OFFSET = 20;
22897
23258
  var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
@@ -23113,7 +23474,7 @@ function assembleStyles() {
23113
23474
  var ansiStyles = assembleStyles();
23114
23475
  var ansi_styles_default = ansiStyles;
23115
23476
 
23116
- // ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/vendor/supports-color/index.js
23477
+ // ../../../../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/vendor/supports-color/index.js
23117
23478
  var import_node_process2 = __toESM(require("process"), 1);
23118
23479
  var import_node_os = __toESM(require("os"), 1);
23119
23480
  var import_node_tty = __toESM(require("tty"), 1);
@@ -23190,9 +23551,9 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
23190
23551
  return min;
23191
23552
  }
23192
23553
  if (import_node_process2.default.platform === "win32") {
23193
- const osRelease = import_node_os.default.release().split(".");
23194
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
23195
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
23554
+ const osRelease2 = import_node_os.default.release().split(".");
23555
+ if (Number(osRelease2[0]) >= 10 && Number(osRelease2[2]) >= 10586) {
23556
+ return Number(osRelease2[2]) >= 14931 ? 3 : 2;
23196
23557
  }
23197
23558
  return 1;
23198
23559
  }
@@ -23255,7 +23616,7 @@ var supportsColor = {
23255
23616
  };
23256
23617
  var supports_color_default = supportsColor;
23257
23618
 
23258
- // ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/index.js
23619
+ // ../../../../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/index.js
23259
23620
  var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
23260
23621
  var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
23261
23622
  var STYLER = /* @__PURE__ */ Symbol("STYLER");
@@ -23338,8 +23699,8 @@ for (const model of usedModels) {
23338
23699
  styles2[styleName] = {
23339
23700
  get() {
23340
23701
  const styleFunction = function(first, second, third) {
23341
- const open = converters[this.level](first, second, third);
23342
- return createBuilder(this, createStyler(open, close, this[STYLER]), this[IS_EMPTY]);
23702
+ const open2 = converters[this.level](first, second, third);
23703
+ return createBuilder(this, createStyler(open2, close, this[STYLER]), this[IS_EMPTY]);
23343
23704
  };
23344
23705
  Object.defineProperty(this, styleName, { value: styleFunction });
23345
23706
  return styleFunction;
@@ -23363,18 +23724,18 @@ var proto = Object.defineProperties(
23363
23724
  }
23364
23725
  }
23365
23726
  );
23366
- var createStyler = (open, close, parent) => {
23727
+ var createStyler = (open2, close, parent) => {
23367
23728
  let openAll;
23368
23729
  let closeAll;
23369
23730
  if (parent === void 0) {
23370
- openAll = open;
23731
+ openAll = open2;
23371
23732
  closeAll = close;
23372
23733
  } else {
23373
- openAll = parent.openAll + open;
23734
+ openAll = parent.openAll + open2;
23374
23735
  closeAll = close + parent.closeAll;
23375
23736
  }
23376
23737
  return {
23377
- open,
23738
+ open: open2,
23378
23739
  close,
23379
23740
  openAll,
23380
23741
  closeAll,
@@ -23425,10 +23786,10 @@ var source_default = chalk;
23425
23786
 
23426
23787
  // src/index.ts
23427
23788
  var import_readline = __toESM(require("readline"));
23428
- var import_node_child_process26 = require("child_process");
23429
- var import_node_fs61 = require("fs");
23430
- var import_node_path47 = require("path");
23431
- var import_node_os18 = require("os");
23789
+ var import_node_child_process28 = require("child_process");
23790
+ var import_node_fs67 = require("fs");
23791
+ var import_node_path51 = require("path");
23792
+ var import_node_os19 = require("os");
23432
23793
 
23433
23794
  // src/commands/monitor.ts
23434
23795
  var import_node_fs11 = require("fs");
@@ -29662,13 +30023,13 @@ function normalizePathImpl(s, win) {
29662
30023
  if (src < end && buf[src + 1] === BS) buf[src + 1] = SL;
29663
30024
  }
29664
30025
  let skipCopy = false;
29665
- let normalize = true;
30026
+ let normalize3 = true;
29666
30027
  if (src === end) {
29667
30028
  done = true;
29668
30029
  } else if (buf[src + 1] !== SL) {
29669
- normalize = false;
30030
+ normalize3 = false;
29670
30031
  }
29671
- if (normalize) {
30032
+ if (normalize3) {
29672
30033
  if (src !== end && buf[src] === SL) {
29673
30034
  } else if (buf[src] === DOT2) {
29674
30035
  if (dst > 0 && buf[dst - 1] === DOT2) {
@@ -30220,7 +30581,7 @@ var TIMESTAMP = String.raw`(\w{3}\s+\d+\s+[\d:]+|\d{4}-\d{2}-\d{2}T[\d:.]+(?:Z|[
30220
30581
  var AUTH_REGEX = new RegExp(`^${TIMESTAMP}\\s+\\S+\\s+(\\S+?)(?:\\[\\d+\\])?:\\s+(.*)`);
30221
30582
  var SYSLOG_REGEX = new RegExp(`^${TIMESTAMP}\\s+\\S+\\s+(\\S+?)(?:\\[\\d+\\])?:\\s+(.*)`);
30222
30583
  var IP_REGEX = /(?:from|FROM)\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
30223
- var INVALID_USER_REGEX = /(?:for\s+invalid\s+user)\s+(\S+?)(?:\s+from|\s*$)/;
30584
+ var INVALID_USER_REGEX = /\binvalid\s+user\s+(\S+?)(?:\s+from\s|\s+\[?[0-9a-fA-F:.]+\]?\s+port\b|\s*$)/i;
30224
30585
  var USER_REGEX = /(?:for|user)\s+(\S+?)(?:\s+from|\s*$)/;
30225
30586
  function parseNginxLog(line2) {
30226
30587
  const match = line2.match(NGINX_REGEX);
@@ -30284,6 +30645,8 @@ function parseAuthLog(line2) {
30284
30645
  function parseAuthMessage(process11, message, timestamp, raw = message) {
30285
30646
  const ipMatch = message.match(IP_REGEX);
30286
30647
  const userMatch = message.match(INVALID_USER_REGEX) || message.match(USER_REGEX);
30648
+ const ip = ipMatch?.[1] ?? (isSshdProcess(process11) ? sshdPeerIp(message) ?? void 0 : void 0);
30649
+ const user = userMatch?.[1] && userMatch[1].toLowerCase() !== "from" ? userMatch[1] : void 0;
30287
30650
  return {
30288
30651
  timestamp,
30289
30652
  raw,
@@ -30291,8 +30654,8 @@ function parseAuthMessage(process11, message, timestamp, raw = message) {
30291
30654
  fields: {
30292
30655
  process: process11,
30293
30656
  message,
30294
- ip: ipMatch?.[1],
30295
- user: userMatch?.[1]
30657
+ ip,
30658
+ user
30296
30659
  }
30297
30660
  };
30298
30661
  }
@@ -30329,6 +30692,7 @@ function classifySshAuth(entry) {
30329
30692
  ...user ? { details: { user } } : {}
30330
30693
  };
30331
30694
  }
30695
+ if (/^(?:Disconnected from|Connection closed by|Received disconnect from)\s+(?:invalid|authenticating)\s+user\b/i.test(message)) return null;
30332
30696
  if (/invalid user/i.test(message)) {
30333
30697
  return {
30334
30698
  severity: "high",
@@ -30479,6 +30843,8 @@ function parseConfigText(raw) {
30479
30843
  threat_feeds: parsed.threat_feeds,
30480
30844
  privileged: parsed.privileged,
30481
30845
  command_history: parsed.command_history,
30846
+ file_integrity: parsed.file_integrity,
30847
+ edr: parsed.edr,
30482
30848
  lightning: parsed.lightning,
30483
30849
  storage: parsed.storage,
30484
30850
  // TOML's `[abuse-reporter]` parses to a hyphenated key; expose it under
@@ -30539,6 +30905,8 @@ function generateDefaultConfig(detectedServices) {
30539
30905
  cloud: { enabled: true, min_severity: "medium" },
30540
30906
  update: { auto: true, interval: "6h", min_age: "2h" },
30541
30907
  command_history: { enabled: false },
30908
+ "file_integrity": { enabled: false },
30909
+ edr: { enabled: false },
30542
30910
  // Reporting to shared reputation feeds (PRD 0015). On by default but inert
30543
30911
  // until a key is set: nothing is reported without ABUSEIPDB_API_KEY or the
30544
30912
  // key below, and only corroborated, handshake-verified sources ever are.
@@ -31003,8 +31371,8 @@ function signatureOf(r) {
31003
31371
  const shape = r.message.replace(/\b\d{1,3}(?:\.\d{1,3}){3}(?:\/\d+)?\b/g, "<ip>").replace(/\b[0-9a-f]*:[0-9a-f:]+\b/gi, "<ip>").replace(/\d+/g, "#");
31004
31372
  return ["msg", r.module, shape].join("|");
31005
31373
  }
31006
- function findingId(signature) {
31007
- return (0, import_node_crypto2.createHash)("sha1").update(signature).digest("hex").slice(0, 10);
31374
+ function findingId(signature2) {
31375
+ return (0, import_node_crypto2.createHash)("sha1").update(signature2).digest("hex").slice(0, 10);
31008
31376
  }
31009
31377
  function toRecord(event) {
31010
31378
  const d = event.details ?? {};
@@ -31418,11 +31786,11 @@ function watchdogPathCommand(opts) {
31418
31786
  var import_node_fs16 = require("fs");
31419
31787
  var import_node_path15 = require("path");
31420
31788
 
31421
- // ../../node_modules/.pnpm/ora@9.4.1/node_modules/ora/index.js
31789
+ // ../../../../../node_modules/.pnpm/ora@9.4.1/node_modules/ora/index.js
31422
31790
  var import_node_process8 = __toESM(require("process"), 1);
31423
31791
  var import_node_util3 = require("util");
31424
31792
 
31425
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
31793
+ // ../../../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
31426
31794
  var ANSI_BACKGROUND_OFFSET2 = 10;
31427
31795
  var wrapAnsi162 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
31428
31796
  var wrapAnsi2562 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
@@ -31608,7 +31976,7 @@ function assembleStyles2() {
31608
31976
  var ansiStyles2 = assembleStyles2();
31609
31977
  var ansi_styles_default2 = ansiStyles2;
31610
31978
 
31611
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
31979
+ // ../../../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
31612
31980
  var import_node_process3 = __toESM(require("process"), 1);
31613
31981
  var import_node_os6 = __toESM(require("os"), 1);
31614
31982
  var import_node_tty2 = __toESM(require("tty"), 1);
@@ -31675,9 +32043,9 @@ function _supportsColor2(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
31675
32043
  return min;
31676
32044
  }
31677
32045
  if (import_node_process3.default.platform === "win32") {
31678
- const osRelease = import_node_os6.default.release().split(".");
31679
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
31680
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
32046
+ const osRelease2 = import_node_os6.default.release().split(".");
32047
+ if (Number(osRelease2[0]) >= 10 && Number(osRelease2[2]) >= 10586) {
32048
+ return Number(osRelease2[2]) >= 14931 ? 3 : 2;
31681
32049
  }
31682
32050
  return 1;
31683
32051
  }
@@ -31740,7 +32108,7 @@ var supportsColor2 = {
31740
32108
  };
31741
32109
  var supports_color_default2 = supportsColor2;
31742
32110
 
31743
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
32111
+ // ../../../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
31744
32112
  function stringReplaceAll2(string, substring, replacer) {
31745
32113
  let index = string.indexOf(substring);
31746
32114
  if (index === -1) {
@@ -31770,7 +32138,7 @@ function stringEncaseCRLFWithFirstIndex2(string, prefix, postfix, index) {
31770
32138
  return returnValue;
31771
32139
  }
31772
32140
 
31773
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
32141
+ // ../../../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
31774
32142
  var { stdout: stdoutColor2, stderr: stderrColor2 } = supports_color_default2;
31775
32143
  var GENERATOR2 = /* @__PURE__ */ Symbol("GENERATOR");
31776
32144
  var STYLER2 = /* @__PURE__ */ Symbol("STYLER");
@@ -31865,18 +32233,18 @@ var proto2 = Object.defineProperties(() => {
31865
32233
  }
31866
32234
  }
31867
32235
  });
31868
- var createStyler2 = (open, close, parent) => {
32236
+ var createStyler2 = (open2, close, parent) => {
31869
32237
  let openAll;
31870
32238
  let closeAll;
31871
32239
  if (parent === void 0) {
31872
- openAll = open;
32240
+ openAll = open2;
31873
32241
  closeAll = close;
31874
32242
  } else {
31875
- openAll = parent.openAll + open;
32243
+ openAll = parent.openAll + open2;
31876
32244
  closeAll = close + parent.closeAll;
31877
32245
  }
31878
32246
  return {
31879
- open,
32247
+ open: open2,
31880
32248
  close,
31881
32249
  openAll,
31882
32250
  closeAll,
@@ -31917,13 +32285,13 @@ var chalk2 = createChalk2();
31917
32285
  var chalkStderr2 = createChalk2({ level: stderrColor2 ? stderrColor2.level : 0 });
31918
32286
  var source_default2 = chalk2;
31919
32287
 
31920
- // ../../node_modules/.pnpm/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
32288
+ // ../../../../../node_modules/.pnpm/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
31921
32289
  var import_node_process5 = __toESM(require("process"), 1);
31922
32290
 
31923
- // ../../node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
32291
+ // ../../../../../node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
31924
32292
  var import_node_process4 = __toESM(require("process"), 1);
31925
32293
 
31926
- // ../../node_modules/.pnpm/mimic-function@5.0.1/node_modules/mimic-function/index.js
32294
+ // ../../../../../node_modules/.pnpm/mimic-function@5.0.1/node_modules/mimic-function/index.js
31927
32295
  var copyProperty = (to, from, property, ignoreNonConfigurable) => {
31928
32296
  if (property === "length" || property === "prototype") {
31929
32297
  return;
@@ -31969,7 +32337,7 @@ function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
31969
32337
  return to;
31970
32338
  }
31971
32339
 
31972
- // ../../node_modules/.pnpm/onetime@7.0.0/node_modules/onetime/index.js
32340
+ // ../../../../../node_modules/.pnpm/onetime@7.0.0/node_modules/onetime/index.js
31973
32341
  var calledFunctions = /* @__PURE__ */ new WeakMap();
31974
32342
  var onetime = (function_, options = {}) => {
31975
32343
  if (typeof function_ !== "function") {
@@ -32000,7 +32368,7 @@ onetime.callCount = (function_) => {
32000
32368
  };
32001
32369
  var onetime_default = onetime;
32002
32370
 
32003
- // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
32371
+ // ../../../../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
32004
32372
  var signals = [];
32005
32373
  signals.push("SIGHUP", "SIGINT", "SIGTERM");
32006
32374
  if (process.platform !== "win32") {
@@ -32024,7 +32392,7 @@ if (process.platform === "linux") {
32024
32392
  signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
32025
32393
  }
32026
32394
 
32027
- // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
32395
+ // ../../../../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
32028
32396
  var processOk = (process11) => !!process11 && typeof process11 === "object" && typeof process11.removeListener === "function" && typeof process11.emit === "function" && typeof process11.reallyExit === "function" && typeof process11.listeners === "function" && typeof process11.kill === "function" && typeof process11.pid === "number" && typeof process11.on === "function";
32029
32397
  var kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
32030
32398
  var global2 = globalThis;
@@ -32251,7 +32619,7 @@ var {
32251
32619
  unload
32252
32620
  } = signalExitWrap(processOk(process5) ? new SignalExit(process5) : new SignalExitFallback());
32253
32621
 
32254
- // ../../node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
32622
+ // ../../../../../node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
32255
32623
  var terminal = import_node_process4.default.stderr.isTTY ? import_node_process4.default.stderr : import_node_process4.default.stdout.isTTY ? import_node_process4.default.stdout : void 0;
32256
32624
  var restoreCursor = terminal ? onetime_default(() => {
32257
32625
  onExit(() => {
@@ -32261,7 +32629,7 @@ var restoreCursor = terminal ? onetime_default(() => {
32261
32629
  };
32262
32630
  var restore_cursor_default = restoreCursor;
32263
32631
 
32264
- // ../../node_modules/.pnpm/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
32632
+ // ../../../../../node_modules/.pnpm/cli-cursor@5.0.0/node_modules/cli-cursor/index.js
32265
32633
  var isHidden = false;
32266
32634
  var cliCursor = {};
32267
32635
  cliCursor.show = (writableStream = import_node_process5.default.stderr) => {
@@ -32291,7 +32659,7 @@ cliCursor.toggle = (force, writableStream) => {
32291
32659
  };
32292
32660
  var cli_cursor_default = cliCursor;
32293
32661
 
32294
- // ../../node_modules/.pnpm/cli-spinners@3.4.0/node_modules/cli-spinners/spinners.json
32662
+ // ../../../../../node_modules/.pnpm/cli-spinners@3.4.0/node_modules/cli-spinners/spinners.json
32295
32663
  var spinners_default = {
32296
32664
  dots: {
32297
32665
  interval: 80,
@@ -33990,11 +34358,11 @@ var spinners_default = {
33990
34358
  }
33991
34359
  };
33992
34360
 
33993
- // ../../node_modules/.pnpm/cli-spinners@3.4.0/node_modules/cli-spinners/index.js
34361
+ // ../../../../../node_modules/.pnpm/cli-spinners@3.4.0/node_modules/cli-spinners/index.js
33994
34362
  var cli_spinners_default = spinners_default;
33995
34363
  var spinnersList = Object.keys(spinners_default);
33996
34364
 
33997
- // ../../node_modules/.pnpm/log-symbols@7.0.1/node_modules/log-symbols/symbols.js
34365
+ // ../../../../../node_modules/.pnpm/log-symbols@7.0.1/node_modules/log-symbols/symbols.js
33998
34366
  var symbols_exports = {};
33999
34367
  __export(symbols_exports, {
34000
34368
  error: () => error,
@@ -34003,14 +34371,14 @@ __export(symbols_exports, {
34003
34371
  warning: () => warning
34004
34372
  });
34005
34373
 
34006
- // ../../node_modules/.pnpm/yoctocolors@2.2.0/node_modules/yoctocolors/base.js
34374
+ // ../../../../../node_modules/.pnpm/yoctocolors@2.2.0/node_modules/yoctocolors/base.js
34007
34375
  var import_node_tty3 = __toESM(require("tty"), 1);
34008
34376
  var hasColors = import_node_tty3.default?.WriteStream?.prototype?.hasColors?.() ?? false;
34009
- var format = (open, close) => {
34377
+ var format = (open2, close) => {
34010
34378
  if (!hasColors) {
34011
34379
  return (input) => input;
34012
34380
  }
34013
- const openCode = `\x1B[${open}m`;
34381
+ const openCode = `\x1B[${open2}m`;
34014
34382
  const closeCode = `\x1B[${close}m`;
34015
34383
  return (input) => {
34016
34384
  const string = input + "";
@@ -34093,7 +34461,7 @@ var underlineMagentaBright = format("58;5;13", 59);
34093
34461
  var underlineCyanBright = format("58;5;14", 59);
34094
34462
  var underlineWhiteBright = format("58;5;15", 59);
34095
34463
 
34096
- // ../../node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
34464
+ // ../../../../../node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
34097
34465
  var import_node_process6 = __toESM(require("process"), 1);
34098
34466
  function isUnicodeSupported() {
34099
34467
  const { env: env3 } = import_node_process6.default;
@@ -34104,14 +34472,14 @@ function isUnicodeSupported() {
34104
34472
  return Boolean(env3.WT_SESSION) || Boolean(env3.TERMINUS_SUBLIME) || env3.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env3.TERMINAL_EMULATOR === "JetBrains-JediTerm";
34105
34473
  }
34106
34474
 
34107
- // ../../node_modules/.pnpm/log-symbols@7.0.1/node_modules/log-symbols/symbols.js
34475
+ // ../../../../../node_modules/.pnpm/log-symbols@7.0.1/node_modules/log-symbols/symbols.js
34108
34476
  var _isUnicodeSupported = isUnicodeSupported();
34109
34477
  var info = blue2(_isUnicodeSupported ? "\u2139" : "i");
34110
34478
  var success = green2(_isUnicodeSupported ? "\u2714" : "\u221A");
34111
34479
  var warning = yellow(_isUnicodeSupported ? "\u26A0" : "\u203C");
34112
34480
  var error = red2(_isUnicodeSupported ? "\u2716" : "\xD7");
34113
34481
 
34114
- // ../../node_modules/.pnpm/ansi-regex@6.4.0/node_modules/ansi-regex/index.js
34482
+ // ../../../../../node_modules/.pnpm/ansi-regex@6.4.0/node_modules/ansi-regex/index.js
34115
34483
  function ansiRegex({ onlyFirst = false } = {}) {
34116
34484
  const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
34117
34485
  const osc = `(?:(?:\\u001B\\]|\\u009D)[^\\u0007\\u001B\\u009C\\u009D]*${ST})`;
@@ -34120,7 +34488,7 @@ function ansiRegex({ onlyFirst = false } = {}) {
34120
34488
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
34121
34489
  }
34122
34490
 
34123
- // ../../node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.js
34491
+ // ../../../../../node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.js
34124
34492
  var regex = ansiRegex();
34125
34493
  function stripAnsi2(string) {
34126
34494
  if (typeof string !== "string") {
@@ -34132,7 +34500,7 @@ function stripAnsi2(string) {
34132
34500
  return string.replace(regex, "");
34133
34501
  }
34134
34502
 
34135
- // ../../node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/lookup-data.js
34503
+ // ../../../../../node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/lookup-data.js
34136
34504
  var ambiguousMinimalCodePoint = 161;
34137
34505
  var ambiguousMaximumCodePoint = 1114109;
34138
34506
  var ambiguousRanges = [161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188, 191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237, 240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275, 275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324, 328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609, 708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735, 735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040, 1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224, 8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254, 8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453, 8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491, 8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592, 8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706, 8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730, 8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756, 8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804, 8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857, 8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552, 9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654, 9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698, 9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758, 9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836, 9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941, 9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979, 9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879, 57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277, 127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760, 917999, 983040, 1048573, 1048576, 1114109];
@@ -34143,7 +34511,7 @@ var wideMinimalCodePoint = 4352;
34143
34511
  var wideMaximumCodePoint = 262141;
34144
34512
  var wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101594, 101631, 101664, 101760, 101874, 101888, 102801, 102816, 102866, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110888, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110952, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127406, 127406, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128729, 128732, 128735, 128747, 128748, 128756, 128764, 128986, 128986, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129734, 129736, 129736, 129740, 129757, 129759, 129771, 129775, 129786, 131072, 196605, 196608, 262141];
34145
34513
 
34146
- // ../../node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/utilities.js
34514
+ // ../../../../../node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/utilities.js
34147
34515
  var isInRange = (ranges, codePoint) => {
34148
34516
  let low = 0;
34149
34517
  let high = Math.floor(ranges.length / 2) - 1;
@@ -34161,7 +34529,7 @@ var isInRange = (ranges, codePoint) => {
34161
34529
  return false;
34162
34530
  };
34163
34531
 
34164
- // ../../node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/lookup.js
34532
+ // ../../../../../node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/lookup.js
34165
34533
  var commonCjkCodePoint = 19968;
34166
34534
  var [wideFastPathStart, wideFastPathEnd] = /* @__PURE__ */ findWideFastPathRange(wideRanges);
34167
34535
  function findWideFastPathRange(ranges) {
@@ -34202,7 +34570,7 @@ var isWide = (codePoint) => {
34202
34570
  return isInRange(wideRanges, codePoint);
34203
34571
  };
34204
34572
 
34205
- // ../../node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/index.js
34573
+ // ../../../../../node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/index.js
34206
34574
  function validate(codePoint) {
34207
34575
  if (!Number.isSafeInteger(codePoint)) {
34208
34576
  throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
@@ -34216,7 +34584,7 @@ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
34216
34584
  return 1;
34217
34585
  }
34218
34586
 
34219
- // ../../node_modules/.pnpm/string-width@8.3.0/node_modules/string-width/index.js
34587
+ // ../../../../../node_modules/.pnpm/string-width@8.3.0/node_modules/string-width/index.js
34220
34588
  var segmenter = new Intl.Segmenter();
34221
34589
  var visibleCharacterRegex = new RegExp("[^\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Nonspacing_Mark}\\p{Enclosing_Mark}\\p{Surrogate}]", "v");
34222
34590
  var spacingMarkRegex = new RegExp("\\p{Spacing_Mark}", "v");
@@ -34339,14 +34707,14 @@ function stringWidth2(input, options = {}) {
34339
34707
  return width;
34340
34708
  }
34341
34709
 
34342
- // ../../node_modules/.pnpm/is-interactive@2.0.0/node_modules/is-interactive/index.js
34710
+ // ../../../../../node_modules/.pnpm/is-interactive@2.0.0/node_modules/is-interactive/index.js
34343
34711
  function isInteractive({ stream = process.stdout } = {}) {
34344
34712
  return Boolean(
34345
34713
  stream && stream.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env)
34346
34714
  );
34347
34715
  }
34348
34716
 
34349
- // ../../node_modules/.pnpm/stdin-discarder@0.3.2/node_modules/stdin-discarder/index.js
34717
+ // ../../../../../node_modules/.pnpm/stdin-discarder@0.3.2/node_modules/stdin-discarder/index.js
34350
34718
  var import_node_process7 = __toESM(require("process"), 1);
34351
34719
  var ASCII_ETX_CODE = 3;
34352
34720
  var StdinDiscarder = class {
@@ -34412,7 +34780,7 @@ var StdinDiscarder = class {
34412
34780
  var stdinDiscarder = new StdinDiscarder();
34413
34781
  var stdin_discarder_default = Object.freeze(stdinDiscarder);
34414
34782
 
34415
- // ../../node_modules/.pnpm/ora@9.4.1/node_modules/ora/index.js
34783
+ // ../../../../../node_modules/.pnpm/ora@9.4.1/node_modules/ora/index.js
34416
34784
  var RENDER_DEFERRAL_TIMEOUT = 200;
34417
34785
  var SYNCHRONIZED_OUTPUT_ENABLE = "\x1B[?2026h";
34418
34786
  var SYNCHRONIZED_OUTPUT_DISABLE = "\x1B[?2026l";
@@ -36487,8 +36855,8 @@ function fileTextOf(lines) {
36487
36855
  function withoutSingleQuoted(text) {
36488
36856
  return text.replace(/'[^'\n]*'/g, "''");
36489
36857
  }
36490
- function calleeEndingAt(text, open) {
36491
- let end = open;
36858
+ function calleeEndingAt(text, open2) {
36859
+ let end = open2;
36492
36860
  while (end > 0 && (text[end - 1] === " " || text[end - 1] === " ")) end -= 1;
36493
36861
  let start = end;
36494
36862
  while (start > 0 && /[\w$.]/.test(text[start - 1])) start -= 1;
@@ -36643,19 +37011,19 @@ function bufferFilledBeforeUse(ctx) {
36643
37011
  }
36644
37012
  var HEREDOC_OPENER = /<<(-?)\s*(['"]?)([A-Za-z_][\w]*)\2/;
36645
37013
  function insideDisplayedHeredoc(lines, index) {
36646
- let open = null;
37014
+ let open2 = null;
36647
37015
  for (let i = 0; i < index; i += 1) {
36648
37016
  const line2 = lines[i] ?? "";
36649
- if (open) {
36650
- if (line2.trim() === open.terminator) open = null;
37017
+ if (open2) {
37018
+ if (line2.trim() === open2.terminator) open2 = null;
36651
37019
  continue;
36652
37020
  }
36653
37021
  if (line2.includes("<<<")) continue;
36654
37022
  const found = HEREDOC_OPENER.exec(line2);
36655
- if (found) open = { terminator: found[3], opener: line2 };
37023
+ if (found) open2 = { terminator: found[3], opener: line2 };
36656
37024
  }
36657
- if (!open) return false;
36658
- const opener = open.opener.replace(/\s[12]?>&2\b/g, " ");
37025
+ if (!open2) return false;
37026
+ const opener = open2.opener.replace(/\s[12]?>&2\b/g, " ");
36659
37027
  return /^\s*cat\b/.test(opener) && !/>/.test(opener) && !/\|/.test(opener);
36660
37028
  }
36661
37029
  var DISPLAY_STRING = /(\b(?:echo|printf|say|info|warn|error)\s+(?:-[A-Za-z]+\s+)*)((?:"(?:[^"\\\n]|\\.)*"|'[^'\n]*')(?:\s+(?:"(?:[^"\\\n]|\\.)*"|'[^'\n]*'))*)(?=\s*(?:$|;|&&|\|\||[12]?>&2|>\s*\/dev\/(?:stderr|tty)\b|\)|#))/g;
@@ -39655,8 +40023,8 @@ function verifyModuleTrust(name, modulePath) {
39655
40023
  } catch (err) {
39656
40024
  return { ok: false, reason: `could not hash module: ${String(err.message || err)}` };
39657
40025
  }
39658
- const signature = verifyModuleSignature(modulePath, digest);
39659
- if (!signature.ok) return signature;
40026
+ const signature2 = verifyModuleSignature(modulePath, digest);
40027
+ if (!signature2.ok) return signature2;
39660
40028
  const record = readTrustFile().modules[name];
39661
40029
  if (!record) {
39662
40030
  return {
@@ -40543,8 +40911,8 @@ async function runAiScan(target, send, opts = {}) {
40543
40911
  const counts = summarize(findings2);
40544
40912
  const tested = results.length;
40545
40913
  const errored = results.filter((r) => r.error).length;
40546
- const summary = findings2.length === 0 ? `No guardrail failures across ${tested} probe(s)${errored ? ` (${errored} errored)` : ""}` : `${findings2.length}/${tested} probe(s) breached a guardrail: ${counts.critical}C ${counts.high}H ${counts.medium}M ${counts.low}L`;
40547
- return { type: "scan", target, findings: findings2, severity_summary: counts, summary };
40914
+ const summary2 = findings2.length === 0 ? `No guardrail failures across ${tested} probe(s)${errored ? ` (${errored} errored)` : ""}` : `${findings2.length}/${tested} probe(s) breached a guardrail: ${counts.critical}C ${counts.high}H ${counts.medium}M ${counts.low}L`;
40915
+ return { type: "scan", target, findings: findings2, severity_summary: counts, summary: summary2 };
40548
40916
  }
40549
40917
  function httpSender(cfg) {
40550
40918
  const template = cfg.template ?? '{"input":"{{PROMPT}}"}';
@@ -41486,23 +41854,23 @@ function sshArgv(options) {
41486
41854
  return args;
41487
41855
  }
41488
41856
  async function sshConnect(options) {
41489
- const { hostname: hostname6, port, username, identity } = options;
41490
- if (!hostname6) {
41857
+ const { hostname: hostname7, port, username, identity } = options;
41858
+ if (!hostname7) {
41491
41859
  console.log(source_default.red(" No hostname available for this server.\n"));
41492
41860
  return;
41493
41861
  }
41494
41862
  const user = username || "root";
41495
- const problem = sshTargetError({ hostname: hostname6, username: user, port });
41863
+ const problem = sshTargetError({ hostname: hostname7, username: user, port });
41496
41864
  if (problem) {
41497
41865
  console.log(source_default.red(` ${problem}
41498
41866
  `));
41499
41867
  process.exitCode = 1;
41500
41868
  return;
41501
41869
  }
41502
- console.log(source_default.green(` Connecting to ${user}@${hostname6}:${port}...
41870
+ console.log(source_default.green(` Connecting to ${user}@${hostname7}:${port}...
41503
41871
  `));
41504
41872
  console.log(source_default.dim(" (Spawning SSH session \u2014 exit with Ctrl+D or type 'exit')\n"));
41505
- const sshArgs = sshArgv({ hostname: hostname6, username: user, port, identity });
41873
+ const sshArgs = sshArgv({ hostname: hostname7, username: user, port, identity });
41506
41874
  const ssh = (0, import_node_child_process5.spawn)("ssh", sshArgs, { stdio: "inherit" });
41507
41875
  ssh.on("error", (err) => {
41508
41876
  console.log(source_default.red(`
@@ -41521,16 +41889,16 @@ async function sshConnect(options) {
41521
41889
  }
41522
41890
 
41523
41891
  // src/commands/daemon.ts
41524
- var import_node_child_process19 = require("child_process");
41525
- var import_node_fs49 = require("fs");
41526
- var import_node_path38 = require("path");
41527
- var import_node_fs50 = require("fs");
41892
+ var import_node_child_process20 = require("child_process");
41893
+ var import_node_fs51 = require("fs");
41894
+ var import_node_path40 = require("path");
41895
+ var import_node_fs52 = require("fs");
41528
41896
 
41529
41897
  // src/daemon/index.ts
41530
- var import_node_fs48 = require("fs");
41531
- var import_node_child_process18 = require("child_process");
41898
+ var import_node_fs50 = require("fs");
41899
+ var import_node_child_process19 = require("child_process");
41532
41900
  var import_node_os14 = require("os");
41533
- var import_node_path37 = require("path");
41901
+ var import_node_path39 = require("path");
41534
41902
  var import_node_util4 = require("util");
41535
41903
  init_paths();
41536
41904
 
@@ -43669,7 +44037,8 @@ var DEDUPE_MS = 10 * 6e4;
43669
44037
  var MAX_PER_HOUR = 6;
43670
44038
  function smshubText(event, host = (0, import_node_os13.hostname)()) {
43671
44039
  const evidence = event.details?.evidence?.message;
43672
- const text = `ThreatCrush ${event.severity.toUpperCase()} on ${host}: ${event.message}${evidence && !event.message.includes(evidence) ? ` | ${evidence}` : ""}`;
44040
+ const ip = event.source_ip && ![event.message, evidence ?? ""].some((t) => t.includes(event.source_ip)) ? ` from ${event.source_ip}` : "";
44041
+ const text = `ThreatCrush ${event.severity.toUpperCase()} on ${host}: ${event.message}${evidence && !event.message.includes(evidence) ? ` | ${evidence}` : ""}${ip}`;
43673
44042
  return text.replace(/\s+/g, " ").slice(0, 600);
43674
44043
  }
43675
44044
  function smshubChannel(config, opts = {}) {
@@ -44845,8 +45214,8 @@ var AbuseReporter = class {
44845
45214
  if (this.cfg.dryRun) {
44846
45215
  this.opts.log(`[abuse] [DRY-RUN] would report ${ip} (cats ${payload.categories.join(",")}, ${evidence.signals} signals)`);
44847
45216
  } else {
44848
- const summary = results.map((r) => `${r.destination}:${r.ok ? "ok" : "FAIL"} ${r.detail}`).join("; ");
44849
- this.opts.log(`[abuse] reported ${ip} [${record.id}] \u2192 ${summary || "no destinations"}`);
45217
+ const summary2 = results.map((r) => `${r.destination}:${r.ok ? "ok" : "FAIL"} ${r.detail}`).join("; ");
45218
+ this.opts.log(`[abuse] reported ${ip} [${record.id}] \u2192 ${summary2 || "no destinations"}`);
44850
45219
  }
44851
45220
  }
44852
45221
  trimRecent(now) {
@@ -46111,8 +46480,8 @@ var PrivilegeWatch = class {
46111
46480
  writeJson(this.opts.loginsPath, history);
46112
46481
  } catch {
46113
46482
  }
46114
- const summary = Object.entries(history).map(([u, c]) => `${u}: ${Object.keys(c).join("/")}`).join(", ");
46115
- this.opts.log(`[privileged] login baseline from the last 30 days: ${summary || "no public SSH logins"}`);
46483
+ const summary2 = Object.entries(history).map(([u, c]) => `${u}: ${Object.keys(c).join("/")}`).join(", ");
46484
+ this.opts.log(`[privileged] login baseline from the last 30 days: ${summary2 || "no public SSH logins"}`);
46116
46485
  }
46117
46486
  /** An accepted SSH login from a country new for that user. */
46118
46487
  async checkLogin(event) {
@@ -46464,10 +46833,845 @@ var CommandHistoryWatcher = class {
46464
46833
  }
46465
46834
  };
46466
46835
 
46467
- // src/daemon/workers/ssh-intrusion.ts
46836
+ // src/daemon/workers/file-integrity.ts
46468
46837
  var import_node_fs41 = require("fs");
46838
+ var import_promises4 = require("fs/promises");
46839
+ var import_node_crypto11 = require("crypto");
46469
46840
  var import_node_path32 = require("path");
46841
+ var DEFAULT_POLL_MS = 15 * 6e4;
46842
+ var MAX_FILES = 5e4;
46843
+ var MAX_FILE_BYTES = 64 * 1024 * 1024;
46844
+ var MAX_SCAN_BYTES = 512 * 1024 * 1024;
46845
+ var MAX_CHANGES_PER_EVENT = 100;
46846
+ var MAX_WATCH_DIRECTORIES = 2048;
46847
+ var WATCH_DEBOUNCE_MS = 500;
46848
+ var WATCH_MAX_DELAY_MS = 5e3;
46849
+ var MASS_CHANGE_COUNT = 25;
46850
+ var MASS_CHANGE_ENTROPY_RISE_BITS = 0.5;
46851
+ var READ_CHUNK_BYTES = 64 * 1024;
46852
+ var CANARY_CONTENT = "ThreatCrush file integrity canary v1\n";
46853
+ function fileIntegritySettings(section) {
46854
+ const safePath = (value) => {
46855
+ if (typeof value !== "string" || !(0, import_node_path32.isAbsolute)(value) || value.split(import_node_path32.sep).includes("..")) return null;
46856
+ const path2 = (0, import_node_path32.normalize)(value);
46857
+ return path2 === "/" ? null : path2;
46858
+ };
46859
+ const strings = (values) => Array.isArray(values) ? [...new Set(values.map(safePath).filter((path2) => path2 !== null))] : [];
46860
+ const configuredSeconds = section?.poll_interval_seconds;
46861
+ const pollMs = typeof configuredSeconds === "number" && Number.isFinite(configuredSeconds) ? Math.max(60, Math.min(86400, Math.floor(configuredSeconds))) * 1e3 : DEFAULT_POLL_MS;
46862
+ return {
46863
+ // File scans read disk contents (only to hash them), so make this explicit
46864
+ // instead of adding an unannounced I/O load to existing installations.
46865
+ enabled: section?.enabled === true,
46866
+ paths: strings(section?.paths),
46867
+ canaries: strings(section?.canaries),
46868
+ canaryDirectories: strings(section?.canary_directories),
46869
+ pollMs
46870
+ };
46871
+ }
46872
+ function signature(value) {
46873
+ return `${value.sha256};size=${value.size};mode=${value.mode.toString(8)};uid=${value.uid};gid=${value.gid};entropy=${value.entropy.toFixed(3)}`;
46874
+ }
46875
+ async function readState(path2) {
46876
+ try {
46877
+ const parsed = JSON.parse(await (0, import_promises4.readFile)(path2, "utf8"));
46878
+ if (parsed.schema !== 1 || !Array.isArray(parsed.targets) || !parsed.files || typeof parsed.files !== "object") return null;
46879
+ return parsed;
46880
+ } catch {
46881
+ return null;
46882
+ }
46883
+ }
46884
+ async function writeState(path2, state) {
46885
+ await (0, import_promises4.mkdir)((0, import_node_path32.dirname)(path2), { recursive: true, mode: 448 });
46886
+ const temp = `${path2}.${process.pid}.${(0, import_node_crypto11.randomUUID)()}.tmp`;
46887
+ await (0, import_promises4.writeFile)(temp, JSON.stringify(state), { mode: 384 });
46888
+ await (0, import_promises4.rename)(temp, path2);
46889
+ }
46890
+ async function hashFile(path2, handle, size) {
46891
+ const hash = (0, import_node_crypto11.createHash)("sha256");
46892
+ const buffer = Buffer.alloc(READ_CHUNK_BYTES);
46893
+ const counts = new Uint32Array(256);
46894
+ let position = 0;
46895
+ while (position < size) {
46896
+ const { bytesRead } = await handle.read(buffer, 0, Math.min(buffer.length, size - position), position);
46897
+ if (bytesRead === 0) throw new Error(`file changed while reading: ${path2}`);
46898
+ const chunk2 = buffer.subarray(0, bytesRead);
46899
+ hash.update(chunk2);
46900
+ for (const byte of chunk2) counts[byte]++;
46901
+ position += bytesRead;
46902
+ }
46903
+ let entropy = 0;
46904
+ if (size > 0) for (const count of counts) {
46905
+ if (count === 0) continue;
46906
+ const probability = count / size;
46907
+ entropy -= probability * Math.log2(probability);
46908
+ }
46909
+ return { sha256: hash.digest("hex"), entropy };
46910
+ }
46911
+ var OPEN_FILE_FLAGS = import_promises4.constants.O_RDONLY | import_promises4.constants.O_NONBLOCK | (import_promises4.constants.O_NOFOLLOW ?? 0);
46912
+ var OPEN_DIR_FLAGS = OPEN_FILE_FLAGS | import_promises4.constants.O_DIRECTORY;
46913
+ var CREATE_FILE_FLAGS = import_promises4.constants.O_WRONLY | import_promises4.constants.O_CREAT | import_promises4.constants.O_EXCL | import_promises4.constants.O_NOFOLLOW;
46914
+ function autoCanaryPath(directory) {
46915
+ return (0, import_node_path32.join)(directory, ".threatcrush-canary");
46916
+ }
46917
+ async function openAbsoluteDirectory(path2) {
46918
+ const parts = path2.split(import_node_path32.sep).filter((part) => part && part !== ".");
46919
+ if (parts.includes("..")) throw new Error("invalid canary directory");
46920
+ let directory = await (0, import_promises4.open)("/", OPEN_DIR_FLAGS);
46921
+ try {
46922
+ for (const part of parts) {
46923
+ const next = await (0, import_promises4.open)(`/proc/self/fd/${directory.fd}/${part}`, OPEN_DIR_FLAGS);
46924
+ await directory.close();
46925
+ directory = next;
46926
+ }
46927
+ return directory;
46928
+ } catch (error2) {
46929
+ await directory.close().catch(() => void 0);
46930
+ throw error2;
46931
+ }
46932
+ }
46933
+ async function createAutoCanary(path2) {
46934
+ try {
46935
+ const existing = await openAbsoluteTarget(path2);
46936
+ await existing.close();
46937
+ return false;
46938
+ } catch (error2) {
46939
+ if (error2.code !== "ENOENT") return false;
46940
+ }
46941
+ const directory = await openAbsoluteDirectory((0, import_node_path32.dirname)(path2));
46942
+ try {
46943
+ const file = await (0, import_promises4.open)(`/proc/self/fd/${directory.fd}/${(0, import_node_path32.basename)(path2)}`, CREATE_FILE_FLAGS, 438);
46944
+ try {
46945
+ await file.chmod(438);
46946
+ await file.writeFile(CANARY_CONTENT);
46947
+ await file.sync();
46948
+ } finally {
46949
+ await file.close();
46950
+ }
46951
+ return true;
46952
+ } catch (error2) {
46953
+ if (error2.code === "EEXIST") return false;
46954
+ throw error2;
46955
+ } finally {
46956
+ await directory.close();
46957
+ }
46958
+ }
46959
+ async function openAbsoluteTarget(path2) {
46960
+ const parts = path2.split(import_node_path32.sep).filter((part) => part && part !== ".");
46961
+ if (parts.length === 0 || parts.includes("..")) throw new Error("invalid file integrity path");
46962
+ let directory = await (0, import_promises4.open)("/", OPEN_DIR_FLAGS);
46963
+ try {
46964
+ for (const part of parts.slice(0, -1)) {
46965
+ const next = await (0, import_promises4.open)(`/proc/self/fd/${directory.fd}/${part}`, OPEN_DIR_FLAGS);
46966
+ await directory.close();
46967
+ directory = next;
46968
+ }
46969
+ const target = await (0, import_promises4.open)(`/proc/self/fd/${directory.fd}/${parts.at(-1)}`, OPEN_FILE_FLAGS);
46970
+ await directory.close();
46971
+ return target;
46972
+ } catch (error2) {
46973
+ await directory.close().catch(() => void 0);
46974
+ throw error2;
46975
+ }
46976
+ }
46977
+ async function scanTargets(targets, canaries) {
46978
+ const files = {};
46979
+ const directories = [];
46980
+ const visited = /* @__PURE__ */ new Set();
46981
+ const errors = /* @__PURE__ */ new Set();
46982
+ let complete = true;
46983
+ let skipped = 0;
46984
+ let bytes = 0;
46985
+ const walk = async (path2, parent) => {
46986
+ if (visited.has(path2) || !complete) return;
46987
+ visited.add(path2);
46988
+ if (visited.size > MAX_FILES) {
46989
+ complete = false;
46990
+ errors.add(path2);
46991
+ return;
46992
+ }
46993
+ let handle;
46994
+ try {
46995
+ handle = parent ? await (0, import_promises4.open)(`/proc/self/fd/${parent.fd}/${path2.slice(path2.lastIndexOf(import_node_path32.sep) + 1)}`, OPEN_FILE_FLAGS) : await openAbsoluteTarget(path2);
46996
+ const stat = await handle.stat();
46997
+ if (stat.isDirectory()) {
46998
+ directories.push(path2);
46999
+ if (canaries.has(path2)) {
47000
+ complete = false;
47001
+ errors.add(path2);
47002
+ return;
47003
+ }
47004
+ let entries;
47005
+ try {
47006
+ entries = await (0, import_promises4.readdir)(`/proc/self/fd/${handle.fd}`, { withFileTypes: true });
47007
+ } catch {
47008
+ complete = false;
47009
+ errors.add(path2);
47010
+ return;
47011
+ }
47012
+ for (const entry of entries) {
47013
+ await walk((0, import_node_path32.join)(path2, entry.name), handle);
47014
+ if (!complete) return;
47015
+ }
47016
+ return;
47017
+ }
47018
+ if (!stat.isFile()) {
47019
+ skipped++;
47020
+ return;
47021
+ }
47022
+ if (stat.size > MAX_FILE_BYTES || bytes + stat.size > MAX_SCAN_BYTES) {
47023
+ complete = false;
47024
+ errors.add(path2);
47025
+ return;
47026
+ }
47027
+ const { sha256, entropy } = await hashFile(path2, handle, stat.size);
47028
+ const afterRead = await handle.stat();
47029
+ if (afterRead.size !== stat.size || afterRead.mtimeMs !== stat.mtimeMs || afterRead.ctimeMs !== stat.ctimeMs) {
47030
+ throw new Error("file changed while reading");
47031
+ }
47032
+ bytes += stat.size;
47033
+ files[path2] = signature({
47034
+ sha256,
47035
+ entropy,
47036
+ size: stat.size,
47037
+ mode: stat.mode & 4095,
47038
+ uid: stat.uid,
47039
+ gid: stat.gid
47040
+ });
47041
+ } catch (error2) {
47042
+ const code = error2.code;
47043
+ if (code === "ENOENT" && targets.includes(path2)) files[path2] = "missing";
47044
+ else if (code === "ELOOP" && !canaries.has(path2)) skipped++;
47045
+ else if (code === "ENOENT" || code === "ELOOP") {
47046
+ complete = false;
47047
+ errors.add(path2);
47048
+ } else {
47049
+ complete = false;
47050
+ errors.add(path2);
47051
+ }
47052
+ } finally {
47053
+ await handle?.close().catch(() => void 0);
47054
+ }
47055
+ };
47056
+ for (const target of targets) {
47057
+ await walk(target);
47058
+ if (!complete) break;
47059
+ }
47060
+ return { files, directories, complete, skipped, bytes, errorPaths: [...errors].slice(0, 20) };
47061
+ }
47062
+ function changedPaths(before2, after) {
47063
+ const paths = /* @__PURE__ */ new Set([...Object.keys(before2), ...Object.keys(after)]);
47064
+ const changed = [];
47065
+ for (const path2 of paths) {
47066
+ const previous = before2[path2] ?? "missing";
47067
+ const current = after[path2] ?? "missing";
47068
+ const normalized = (value) => typeof value === "string" ? value.replace(/;entropy=\d+(?:\.\d+)?$/, "") : value;
47069
+ if (normalized(previous) !== normalized(current)) changed.push({ path: path2, state: current });
47070
+ }
47071
+ return changed;
47072
+ }
47073
+ function meanEntropy(paths, files) {
47074
+ const values = paths.flatMap((path2) => {
47075
+ const signature2 = files[path2];
47076
+ if (typeof signature2 !== "string") return [];
47077
+ const match = /;entropy=(\d+(?:\.\d+)?)$/.exec(signature2);
47078
+ return match ? [Number(match[1])] : [];
47079
+ });
47080
+ return values.length ? values.reduce((sum, value) => sum + value, 0) / values.length : null;
47081
+ }
47082
+ var FileIntegrityWatch = class {
47083
+ constructor(opts) {
47084
+ this.opts = opts;
47085
+ this.now = opts.now ?? (() => /* @__PURE__ */ new Date());
47086
+ this.canaries = /* @__PURE__ */ new Set([
47087
+ ...opts.settings.canaries,
47088
+ ...opts.settings.canaryDirectories.map(autoCanaryPath)
47089
+ ]);
47090
+ }
47091
+ opts;
47092
+ timer = null;
47093
+ running = false;
47094
+ now;
47095
+ canaries;
47096
+ watchers = /* @__PURE__ */ new Map();
47097
+ eventTimer = null;
47098
+ eventFirstAt = 0;
47099
+ eventScanPending = false;
47100
+ watcherLimitLogged = false;
47101
+ get autoCanaries() {
47102
+ return this.opts.settings.canaryDirectories.map(autoCanaryPath);
47103
+ }
47104
+ async ensureAutoCanaries(allowed) {
47105
+ for (const path2 of this.autoCanaries) {
47106
+ if (!allowed.has(path2)) continue;
47107
+ try {
47108
+ if (await createAutoCanary(path2)) this.opts.log(`[file-integrity] placed a canary at ${path2}`);
47109
+ } catch (error2) {
47110
+ this.opts.log(`[file-integrity] could not place canary at ${path2}: ${error2.message.split("\n")[0]}`);
47111
+ }
47112
+ }
47113
+ }
47114
+ start() {
47115
+ if (!this.opts.settings.enabled) {
47116
+ this.opts.log("[file-integrity] disabled; set [file_integrity] enabled = true to monitor configured paths");
47117
+ return;
47118
+ }
47119
+ const targets = [.../* @__PURE__ */ new Set([...this.opts.settings.paths, ...this.opts.settings.canaries, ...this.autoCanaries])];
47120
+ if (targets.length === 0) {
47121
+ this.opts.log("[file-integrity] enabled with no paths; configure [file_integrity] paths or canaries");
47122
+ return;
47123
+ }
47124
+ this.opts.log(`[file-integrity] monitoring ${targets.length} configured path(s), polling every ${Math.round(this.opts.settings.pollMs / 6e4)}m; content is hashed locally`);
47125
+ void this.scanOnce();
47126
+ this.timer = setInterval(() => {
47127
+ void this.scanOnce();
47128
+ }, this.opts.settings.pollMs);
47129
+ this.timer.unref?.();
47130
+ }
47131
+ stop() {
47132
+ if (this.timer) clearInterval(this.timer);
47133
+ this.timer = null;
47134
+ if (this.eventTimer) clearTimeout(this.eventTimer);
47135
+ this.eventTimer = null;
47136
+ this.eventFirstAt = 0;
47137
+ this.eventScanPending = false;
47138
+ for (const watcher of this.watchers.values()) watcher.close();
47139
+ this.watchers.clear();
47140
+ }
47141
+ refreshWatchers(directories) {
47142
+ const wanted = new Set(directories.slice(0, MAX_WATCH_DIRECTORIES));
47143
+ for (const [path2, watcher] of this.watchers) {
47144
+ if (wanted.has(path2)) continue;
47145
+ watcher.close();
47146
+ this.watchers.delete(path2);
47147
+ }
47148
+ for (const path2 of wanted) {
47149
+ if (this.watchers.has(path2)) continue;
47150
+ try {
47151
+ const watcher = (0, import_node_fs41.watch)(path2, { persistent: false }, () => {
47152
+ this.scheduleEventScan();
47153
+ });
47154
+ watcher.on("error", (error2) => {
47155
+ this.opts.log(`[file-integrity] inotify watch unavailable for ${path2}: ${error2.message}`);
47156
+ watcher.close();
47157
+ this.watchers.delete(path2);
47158
+ });
47159
+ this.watchers.set(path2, watcher);
47160
+ } catch (error2) {
47161
+ this.opts.log(`[file-integrity] inotify watch unavailable for ${path2}: ${error2.message.split("\n")[0]}`);
47162
+ }
47163
+ }
47164
+ if (directories.length > MAX_WATCH_DIRECTORIES && !this.watcherLimitLogged) {
47165
+ this.watcherLimitLogged = true;
47166
+ this.opts.log(`[file-integrity] watching the first ${MAX_WATCH_DIRECTORIES} directories; polling remains the fallback for the rest`);
47167
+ }
47168
+ }
47169
+ /** Debounce bursts, but cap the delay so continuous writes still get scanned. */
47170
+ scheduleEventScan() {
47171
+ this.eventScanPending = true;
47172
+ if (this.eventFirstAt === 0) this.eventFirstAt = Date.now();
47173
+ if (this.running) return;
47174
+ if (this.eventTimer) clearTimeout(this.eventTimer);
47175
+ const dueAt = Math.min(Date.now() + WATCH_DEBOUNCE_MS, this.eventFirstAt + WATCH_MAX_DELAY_MS);
47176
+ this.eventTimer = setTimeout(() => {
47177
+ this.eventTimer = null;
47178
+ if (this.running) return;
47179
+ this.eventScanPending = false;
47180
+ this.eventFirstAt = 0;
47181
+ void this.scanOnce();
47182
+ }, Math.max(0, dueAt - Date.now()));
47183
+ this.eventTimer.unref?.();
47184
+ }
47185
+ async rebaseline() {
47186
+ const targets = [.../* @__PURE__ */ new Set([...this.opts.settings.paths, ...this.opts.settings.canaries, ...this.autoCanaries])];
47187
+ if (!this.opts.settings.enabled || targets.length === 0) return { ok: false, files: 0, reason: "file integrity monitoring is disabled or has no configured paths" };
47188
+ await this.ensureAutoCanaries(new Set(this.autoCanaries));
47189
+ const scan = await scanTargets(targets, this.canaries);
47190
+ if (!scan.complete) return { ok: false, files: Object.keys(scan.files).length, reason: `scan incomplete at ${scan.errorPaths.join(", ") || "configured size limit"}` };
47191
+ const missingCanary = [...this.canaries].find((path2) => scan.files[path2] === "missing");
47192
+ if (missingCanary) return { ok: false, files: Object.keys(scan.files).length, reason: `configured canary does not exist: ${missingCanary}` };
47193
+ const state = { schema: 1, created_at: this.now().toISOString(), targets, files: scan.files };
47194
+ await writeState(this.opts.baselinePath, state);
47195
+ await writeState(this.opts.observedPath, state);
47196
+ return { ok: true, files: Object.keys(scan.files).length };
47197
+ }
47198
+ async scanOnce() {
47199
+ if (this.running) return;
47200
+ this.running = true;
47201
+ try {
47202
+ const baseline = await readState(this.opts.baselinePath);
47203
+ const previousObserved = await readState(this.opts.observedPath);
47204
+ let baselineFilePresent = false;
47205
+ if (!baseline) {
47206
+ try {
47207
+ await (0, import_promises4.lstat)(this.opts.baselinePath);
47208
+ baselineFilePresent = true;
47209
+ } catch (error2) {
47210
+ baselineFilePresent = error2.code !== "ENOENT";
47211
+ }
47212
+ }
47213
+ const canCreate = this.autoCanaries.filter((path2) => {
47214
+ if (!baseline && !baselineFilePresent) return true;
47215
+ return !!baseline && !baseline.targets.includes(path2) && !previousObserved?.targets.includes(path2);
47216
+ });
47217
+ await this.ensureAutoCanaries(new Set(canCreate));
47218
+ const targets = [.../* @__PURE__ */ new Set([...this.opts.settings.paths, ...this.opts.settings.canaries, ...this.autoCanaries])];
47219
+ const current = await scanTargets(targets, this.canaries);
47220
+ if (current.complete) {
47221
+ const directories = new Set(current.directories);
47222
+ for (const path2 of Object.keys(current.files)) {
47223
+ if (!directories.has(path2)) directories.add((0, import_node_path32.dirname)(path2));
47224
+ }
47225
+ this.refreshWatchers([...directories]);
47226
+ }
47227
+ if (!current.complete) {
47228
+ this.opts.log(`[file-integrity] scan incomplete; no baseline or change state updated (${current.errorPaths.join(", ") || "configured scan limits reached"})`);
47229
+ return;
47230
+ }
47231
+ if (!baseline) {
47232
+ if (baselineFilePresent) {
47233
+ this.emit("critical", "File integrity baseline is unreadable; monitoring paused", "file-integrity-baseline-invalid", [
47234
+ { path: this.opts.baselinePath, state: "unreadable" }
47235
+ ]);
47236
+ this.opts.log("[file-integrity] baseline is present but unreadable; it was not replaced");
47237
+ return;
47238
+ }
47239
+ const missingCanary = [...this.canaries].find((path2) => current.files[path2] === "missing");
47240
+ if (missingCanary) {
47241
+ this.opts.log(`[file-integrity] cannot record baseline; configured canary does not exist: ${missingCanary}`);
47242
+ return;
47243
+ }
47244
+ const created = { schema: 1, created_at: this.now().toISOString(), targets, files: current.files };
47245
+ await writeState(this.opts.baselinePath, created);
47246
+ await writeState(this.opts.observedPath, created);
47247
+ this.opts.log(`[file-integrity] initial baseline recorded for ${Object.keys(current.files).length} file(s)`);
47248
+ return;
47249
+ }
47250
+ const observed = previousObserved ?? baseline;
47251
+ const sameTargets = (left, right) => {
47252
+ const sortedLeft = [...left].sort();
47253
+ const sortedRight = [...right].sort();
47254
+ return sortedLeft.length === sortedRight.length && sortedLeft.every((path2, index) => path2 === sortedRight[index]);
47255
+ };
47256
+ if (!sameTargets(baseline.targets, targets)) {
47257
+ const removedCanaries = changedPaths(observed.files, current.files).filter((change) => this.canaries.has(change.path) && observed.targets.includes(change.path));
47258
+ if (removedCanaries.length) {
47259
+ this.emit("critical", "A file integrity canary changed or disappeared", "file-integrity-canary", removedCanaries);
47260
+ }
47261
+ if (!sameTargets(observed.targets, targets)) {
47262
+ this.emit(
47263
+ "medium",
47264
+ "File integrity monitoring paths changed; review them and rebaseline",
47265
+ "file-integrity-scope-changed",
47266
+ targets.map((path2) => ({ path: path2, state: "scope-changed" }))
47267
+ );
47268
+ }
47269
+ await writeState(this.opts.observedPath, { schema: 1, created_at: observed.created_at, targets, files: current.files });
47270
+ return;
47271
+ }
47272
+ const changes = changedPaths(observed.files, current.files);
47273
+ const canaryChanges = changes.filter((change) => this.canaries.has(change.path));
47274
+ if (canaryChanges.length) {
47275
+ this.emit("critical", "A file integrity canary changed or disappeared", "file-integrity-canary", canaryChanges);
47276
+ }
47277
+ const ordinary = changes.filter((change) => !this.canaries.has(change.path));
47278
+ const paths = ordinary.map((change) => change.path);
47279
+ const beforeEntropy = meanEntropy(paths, observed.files);
47280
+ const afterEntropy = meanEntropy(paths, current.files);
47281
+ const entropyRose = beforeEntropy !== null && afterEntropy !== null && afterEntropy - beforeEntropy >= MASS_CHANGE_ENTROPY_RISE_BITS;
47282
+ if (ordinary.length >= MASS_CHANGE_COUNT || ordinary.length >= 10 && entropyRose) {
47283
+ const entropyDetail = entropyRose ? `; mean changed-file entropy rose from ${beforeEntropy?.toFixed(2)} to ${afterEntropy?.toFixed(2)} bits` : "";
47284
+ this.emit("critical", `${ordinary.length} monitored files changed in one scan${entropyDetail}`, "file-integrity-mass-change", ordinary);
47285
+ } else {
47286
+ for (const change of ordinary) {
47287
+ const expected = baseline.files[change.path] ?? "missing";
47288
+ const restored = change.state === expected;
47289
+ this.emit(
47290
+ restored ? "low" : "high",
47291
+ restored ? `Monitored file returned to its baseline: ${change.path}` : `Monitored file changed: ${change.path}`,
47292
+ restored ? "file-integrity-restored" : "file-integrity-changed",
47293
+ [change]
47294
+ );
47295
+ }
47296
+ }
47297
+ const nextObserved = { schema: 1, created_at: observed.created_at, targets, files: current.files };
47298
+ await writeState(this.opts.observedPath, nextObserved);
47299
+ } catch (error2) {
47300
+ this.opts.log(`[file-integrity] scan failed: ${error2.message.split("\n")[0]}`);
47301
+ } finally {
47302
+ this.running = false;
47303
+ if (this.eventScanPending && !this.eventTimer) this.scheduleEventScan();
47304
+ }
47305
+ }
47306
+ emit(severity, message, ruleId, changes) {
47307
+ const event = {
47308
+ timestamp: this.now(),
47309
+ module: "file-integrity",
47310
+ category: "system",
47311
+ severity,
47312
+ message: message.replace(/[\u0000-\u001f\u007f]/g, " ").slice(0, 500),
47313
+ details: {
47314
+ rule_id: ruleId,
47315
+ change_count: changes.length,
47316
+ changes: changes.slice(0, MAX_CHANGES_PER_EVENT).map(({ path: path2, state }) => ({
47317
+ path: path2,
47318
+ state: state === "missing" ? "missing" : "present"
47319
+ })),
47320
+ truncated: changes.length > MAX_CHANGES_PER_EVENT
47321
+ }
47322
+ };
47323
+ try {
47324
+ insertEvent(event);
47325
+ } catch {
47326
+ }
47327
+ this.opts.bus.publish(event);
47328
+ }
47329
+ };
47330
+
47331
+ // src/daemon/workers/edr.ts
47332
+ var import_node_fs42 = require("fs");
47333
+ var import_node_path33 = require("path");
46470
47334
  var import_node_child_process14 = require("child_process");
47335
+ var DEFAULT_AUDIT_LOG = "/var/log/audit/audit.log";
47336
+ var DEFAULT_WEB_USERS = ["www-data", "nginx", "apache", "httpd", "caddy", "node"];
47337
+ var DEFAULT_TEMP_PATHS = ["/tmp", "/var/tmp", "/dev/shm"];
47338
+ var MAX_SEEN_EVENTS = 4096;
47339
+ var WEB_KEY = "threatcrush_edr_web";
47340
+ var TEMP_KEY = "threatcrush_edr_temp";
47341
+ var MINER_KEY = "threatcrush_edr_miner";
47342
+ var CONNECT_KEY = "threatcrush_edr_connect";
47343
+ var LISTEN_KEY = "threatcrush_edr_listen";
47344
+ var CPU_SAMPLE_MS = 15e3;
47345
+ var CPU_SUSTAIN_MS = 6e4;
47346
+ var CPU_THRESHOLD_PERCENT = 80;
47347
+ var SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "dash", "zsh", "ksh", "fish"]);
47348
+ var DOWNLOADERS = /* @__PURE__ */ new Set(["curl", "wget"]);
47349
+ var MINERS = /* @__PURE__ */ new Set(["xmrig", "minerd", "cpuminer", "cpuminer-multi", "kdevtmpfsi", "kinsing", "cryptonight"]);
47350
+ function safeAbsolutePath(value) {
47351
+ if (typeof value !== "string" || !(0, import_node_path33.isAbsolute)(value) || value.split(import_node_path33.sep).includes("..")) return null;
47352
+ const path2 = (0, import_node_path33.normalize)(value);
47353
+ return path2 === "/" ? null : path2;
47354
+ }
47355
+ function edrSettings(section) {
47356
+ const configuredLog = safeAbsolutePath(section?.audit_log_path) ?? DEFAULT_AUDIT_LOG;
47357
+ const configuredUsers = Array.isArray(section?.web_service_users) ? [...new Set(section.web_service_users.map((value) => String(value).trim()).filter((value) => /^[a-z_][a-z0-9_-]*\$?$/i.test(value)))] : DEFAULT_WEB_USERS;
47358
+ const configuredPaths = Array.isArray(section?.temp_exec_paths) ? [...new Set(section.temp_exec_paths.map(safeAbsolutePath).filter((path2) => path2 !== null))] : DEFAULT_TEMP_PATHS;
47359
+ const seconds = section?.poll_interval_seconds;
47360
+ const pollMs = typeof seconds === "number" && Number.isFinite(seconds) ? Math.max(1, Math.min(60, Math.floor(seconds))) * 1e3 : 2e3;
47361
+ const baselineSeconds = section?.network_baseline_seconds;
47362
+ return {
47363
+ enabled: section?.enabled === true,
47364
+ auditLogPath: configuredLog,
47365
+ webServiceUsers: configuredUsers,
47366
+ tempExecPaths: configuredPaths,
47367
+ watchNetworkSyscalls: section?.watch_network_syscalls === true,
47368
+ networkBaselineMs: typeof baselineSeconds === "number" && Number.isFinite(baselineSeconds) ? Math.max(0, Math.min(3600, Math.floor(baselineSeconds))) * 1e3 : 6e4,
47369
+ watchUnknownTempCpu: section?.watch_unknown_temp_cpu !== false,
47370
+ pollMs
47371
+ };
47372
+ }
47373
+ function parseAuditFields(line2) {
47374
+ const fields = {};
47375
+ const pattern = /(?:^|\s)([A-Za-z0-9_]+)=("(?:\\.|[^"\\])*"|\S+)/g;
47376
+ for (const match of line2.matchAll(pattern)) {
47377
+ const raw = match[2];
47378
+ fields[match[1]] = raw.startsWith('"') && raw.endsWith('"') ? raw.slice(1, -1).replace(/\\(["\\])/g, "$1") : raw;
47379
+ }
47380
+ return fields;
47381
+ }
47382
+ function parseAuditRecord(line2) {
47383
+ const header2 = /^type=SYSCALL\b.*?\bmsg=audit\((\d+(?:\.\d+)?):(\d+)\):/.exec(line2);
47384
+ if (!header2) return null;
47385
+ const fields = parseAuditFields(line2);
47386
+ if (fields.success !== "yes" || !fields.key || fields.key === "(null)") return null;
47387
+ const executable = fields.exe ?? "";
47388
+ const euid = Number(fields.euid);
47389
+ const seconds = Number(header2[1]);
47390
+ if (!executable.startsWith("/") || !Number.isInteger(euid) || !Number.isFinite(seconds)) return null;
47391
+ const pid = Number(fields.pid);
47392
+ const ppid = Number(fields.ppid);
47393
+ return {
47394
+ timestamp: new Date(seconds * 1e3),
47395
+ serial: header2[2],
47396
+ key: fields.key,
47397
+ executable,
47398
+ comm: fields.comm ?? (0, import_node_path33.basename)(executable),
47399
+ euid,
47400
+ ...Number.isInteger(pid) && pid > 0 ? { pid } : {},
47401
+ ...Number.isInteger(ppid) && ppid > 0 ? { ppid } : {}
47402
+ };
47403
+ }
47404
+ function accountNames2() {
47405
+ let raw = "";
47406
+ try {
47407
+ raw = (0, import_node_child_process14.execFileSync)("getent", ["passwd"], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
47408
+ } catch {
47409
+ try {
47410
+ raw = (0, import_node_fs42.readFileSync)("/etc/passwd", "utf8");
47411
+ } catch {
47412
+ return /* @__PURE__ */ new Map();
47413
+ }
47414
+ }
47415
+ const out = /* @__PURE__ */ new Map();
47416
+ for (const line2 of raw.split("\n")) {
47417
+ const fields = line2.split(":");
47418
+ const uid = Number(fields[2]);
47419
+ if (fields[0] && Number.isInteger(uid)) out.set(uid, fields[0]);
47420
+ }
47421
+ return out;
47422
+ }
47423
+ function pathWithin(path2, root) {
47424
+ return path2 === root || path2.startsWith(`${root.replace(/\/$/, "")}/`);
47425
+ }
47426
+ function executableInWorldWritableDirectory(executable) {
47427
+ try {
47428
+ return ((0, import_node_fs42.statSync)((0, import_node_path33.dirname)(executable)).mode & 2) !== 0;
47429
+ } catch {
47430
+ return false;
47431
+ }
47432
+ }
47433
+ function clean(value) {
47434
+ return value.replace(/[\u0000-\u001f\u007f]/g, " ").slice(0, 400);
47435
+ }
47436
+ var EdrWatch = class {
47437
+ constructor(opts) {
47438
+ this.opts = opts;
47439
+ this.usersById = accountNames2();
47440
+ const wanted = new Set(opts.settings.webServiceUsers.map((name) => name.toLowerCase()));
47441
+ this.webIds = new Set([...this.usersById].filter(([, name]) => wanted.has(name.toLowerCase())).map(([uid]) => uid));
47442
+ this.loadNetworkBaseline();
47443
+ }
47444
+ opts;
47445
+ tail = null;
47446
+ timer = null;
47447
+ cpuTimer = null;
47448
+ usersById;
47449
+ webIds;
47450
+ seen = /* @__PURE__ */ new Set();
47451
+ listenersSeen = /* @__PURE__ */ new Set();
47452
+ outboundExecutables = /* @__PURE__ */ new Set();
47453
+ cpuSamples = /* @__PURE__ */ new Map();
47454
+ networkStartedAt = Date.now();
47455
+ ticksPerSecond = this.readTicksPerSecond();
47456
+ baselineWriteFailed = false;
47457
+ start() {
47458
+ if (!this.opts.settings.enabled) {
47459
+ this.opts.log("[edr] disabled; set [edr] enabled = true after installing the generated audit rules");
47460
+ return;
47461
+ }
47462
+ if (!(0, import_node_fs42.existsSync)(this.opts.settings.auditLogPath)) {
47463
+ this.opts.log(`[edr] audit log not found at ${this.opts.settings.auditLogPath}; auditd detections are unavailable`);
47464
+ } else {
47465
+ try {
47466
+ (0, import_node_fs42.accessSync)(this.opts.settings.auditLogPath, import_node_fs42.constants.R_OK);
47467
+ this.tail = new LogTail(this.opts.settings.auditLogPath);
47468
+ this.timer = setInterval(() => this.poll(), this.opts.settings.pollMs);
47469
+ this.timer.unref?.();
47470
+ this.opts.log(`[edr] watching selected auditd events in ${this.opts.settings.auditLogPath}; command arguments and remote addresses are discarded`);
47471
+ } catch {
47472
+ this.opts.log(`[edr] cannot read ${this.opts.settings.auditLogPath}; run the daemon with permission to read the audit log`);
47473
+ }
47474
+ }
47475
+ if (this.opts.settings.watchUnknownTempCpu) {
47476
+ this.cpuTimer = setInterval(() => this.sampleTemporaryProcesses(), CPU_SAMPLE_MS);
47477
+ this.cpuTimer.unref?.();
47478
+ this.sampleTemporaryProcesses();
47479
+ this.opts.log(`[edr] watching temporary-path processes for sustained CPU use (${CPU_THRESHOLD_PERCENT}% for ${CPU_SUSTAIN_MS / 1e3}s)`);
47480
+ }
47481
+ }
47482
+ stop() {
47483
+ if (this.timer) clearInterval(this.timer);
47484
+ if (this.cpuTimer) clearInterval(this.cpuTimer);
47485
+ this.timer = null;
47486
+ this.cpuTimer = null;
47487
+ this.tail = null;
47488
+ this.seen.clear();
47489
+ this.listenersSeen.clear();
47490
+ this.cpuSamples.clear();
47491
+ }
47492
+ poll() {
47493
+ if (!this.tail) return 0;
47494
+ return this.tail.poll((line2) => {
47495
+ const record = parseAuditRecord(line2);
47496
+ if (!record) return;
47497
+ const dedupeKey2 = `${record.timestamp.getTime()}:${record.serial}:${record.key}`;
47498
+ if (this.seen.has(dedupeKey2)) return;
47499
+ this.seen.add(dedupeKey2);
47500
+ if (this.seen.size > MAX_SEEN_EVENTS) this.seen.delete(this.seen.values().next().value);
47501
+ const event = this.classify(record);
47502
+ if (!event) return;
47503
+ this.publish(event);
47504
+ });
47505
+ }
47506
+ publish(event) {
47507
+ try {
47508
+ insertEvent(event);
47509
+ } catch {
47510
+ }
47511
+ this.opts.bus.publish(event);
47512
+ }
47513
+ classify(execution) {
47514
+ const name = (0, import_node_path33.basename)(execution.executable).toLowerCase();
47515
+ const account = this.usersById.get(execution.euid) ?? String(execution.euid);
47516
+ let severity;
47517
+ let ruleId;
47518
+ let message;
47519
+ if (execution.key === CONNECT_KEY) {
47520
+ const wasKnown = this.outboundExecutables.has(execution.executable);
47521
+ this.rememberOutboundExecutable(execution.executable);
47522
+ if (SHELLS.has(name) || SHELLS.has(execution.comm.toLowerCase())) {
47523
+ severity = "high";
47524
+ ruleId = "edr-shell-network-connect";
47525
+ message = `Possible reverse-shell behavior: shell ${execution.executable} opened an outbound connection`;
47526
+ } else if (!wasKnown && Date.now() - this.networkStartedAt >= this.opts.settings.networkBaselineMs) {
47527
+ severity = "medium";
47528
+ ruleId = "edr-new-outbound-executable";
47529
+ message = `Previously unseen executable opened an outbound connection: ${execution.executable}`;
47530
+ } else {
47531
+ return null;
47532
+ }
47533
+ } else if (execution.key === LISTEN_KEY) {
47534
+ const listenerKey = `${execution.pid ?? execution.serial}:${execution.executable}`;
47535
+ if (this.listenersSeen.has(listenerKey)) return null;
47536
+ this.listenersSeen.add(listenerKey);
47537
+ if (this.listenersSeen.size > MAX_SEEN_EVENTS) this.listenersSeen.delete(this.listenersSeen.values().next().value);
47538
+ severity = "medium";
47539
+ ruleId = "edr-process-listener";
47540
+ message = `Process began listening for inbound connections: ${execution.executable}`;
47541
+ } else if (execution.key === WEB_KEY && this.webIds.has(execution.euid) && (SHELLS.has(name) || DOWNLOADERS.has(name))) {
47542
+ severity = "high";
47543
+ ruleId = "edr-web-service-tool";
47544
+ message = `Web service account ${account} executed ${name}: ${execution.executable}`;
47545
+ } else if (execution.key === TEMP_KEY && (this.opts.settings.tempExecPaths.some((path2) => pathWithin(execution.executable, path2)) || executableInWorldWritableDirectory(execution.executable))) {
47546
+ severity = "high";
47547
+ ruleId = "edr-writable-path-execution";
47548
+ message = `Executable launched from a temporary or world-writable directory: ${execution.executable}`;
47549
+ } else if (execution.key === MINER_KEY && MINERS.has(name)) {
47550
+ severity = "critical";
47551
+ ruleId = "edr-known-miner-execution";
47552
+ message = `Known cryptocurrency miner executed: ${execution.executable}`;
47553
+ } else {
47554
+ return null;
47555
+ }
47556
+ return {
47557
+ timestamp: execution.timestamp,
47558
+ module: "edr",
47559
+ category: "system",
47560
+ severity,
47561
+ message: clean(message),
47562
+ details: {
47563
+ rule_id: ruleId,
47564
+ executable: clean(execution.executable),
47565
+ account,
47566
+ euid: execution.euid,
47567
+ ...execution.pid ? { pid: execution.pid } : {},
47568
+ ...execution.ppid ? { ppid: execution.ppid } : {},
47569
+ audit_serial: execution.serial
47570
+ }
47571
+ };
47572
+ }
47573
+ loadNetworkBaseline() {
47574
+ const path2 = this.opts.networkBaselinePath;
47575
+ if (!path2) return;
47576
+ try {
47577
+ const parsed = JSON.parse((0, import_node_fs42.readFileSync)(path2, "utf8"));
47578
+ if (Array.isArray(parsed)) {
47579
+ for (const value of parsed.slice(0, 1e4)) {
47580
+ if (typeof value === "string" && value.startsWith("/")) this.outboundExecutables.add(value);
47581
+ }
47582
+ }
47583
+ } catch {
47584
+ }
47585
+ }
47586
+ rememberOutboundExecutable(executable) {
47587
+ if (this.outboundExecutables.has(executable)) return;
47588
+ this.outboundExecutables.add(executable);
47589
+ if (this.outboundExecutables.size > 1e4) this.outboundExecutables.delete(this.outboundExecutables.values().next().value);
47590
+ const path2 = this.opts.networkBaselinePath;
47591
+ if (!path2) return;
47592
+ try {
47593
+ const temp = `${path2}.${process.pid}.tmp`;
47594
+ (0, import_node_fs42.writeFileSync)(temp, `${JSON.stringify([...this.outboundExecutables])}
47595
+ `, { mode: 384 });
47596
+ (0, import_node_fs42.renameSync)(temp, path2);
47597
+ this.baselineWriteFailed = false;
47598
+ } catch (error2) {
47599
+ if (!this.baselineWriteFailed) this.opts.log(`[edr] could not persist outbound executable baseline: ${error2.message.split("\n")[0]}`);
47600
+ this.baselineWriteFailed = true;
47601
+ }
47602
+ }
47603
+ readTicksPerSecond() {
47604
+ try {
47605
+ const value = Number((0, import_node_child_process14.execFileSync)("getconf", ["CLK_TCK"], { encoding: "utf8", timeout: 2e3, stdio: ["ignore", "pipe", "ignore"] }).trim());
47606
+ if (Number.isFinite(value) && value > 0) return value;
47607
+ } catch {
47608
+ }
47609
+ return 100;
47610
+ }
47611
+ sampleTemporaryProcesses() {
47612
+ if (!this.opts.settings.enabled || !this.opts.settings.watchUnknownTempCpu) return;
47613
+ const now = Date.now();
47614
+ const current = /* @__PURE__ */ new Map();
47615
+ let pids;
47616
+ try {
47617
+ pids = (0, import_node_fs42.readdirSync)("/proc");
47618
+ } catch {
47619
+ return;
47620
+ }
47621
+ for (const pid of pids) {
47622
+ if (!/^\d+$/.test(pid)) continue;
47623
+ const proc = `/proc/${pid}`;
47624
+ try {
47625
+ const raw = (0, import_node_fs42.readFileSync)(`${proc}/stat`, "utf8");
47626
+ const end = raw.lastIndexOf(")");
47627
+ if (end < 0) continue;
47628
+ const fields = raw.slice(end + 1).trim().split(/\s+/);
47629
+ const userTicks = Number(fields[11]);
47630
+ const systemTicks = Number(fields[12]);
47631
+ const startTicks = fields[19];
47632
+ if (!Number.isFinite(userTicks) || !Number.isFinite(systemTicks) || !startTicks) continue;
47633
+ let executable = (0, import_node_fs42.readlinkSync)(`${proc}/exe`);
47634
+ executable = executable.replace(/ \(deleted\)$/, "");
47635
+ if (!this.opts.settings.tempExecPaths.some((path2) => pathWithin(executable, path2))) continue;
47636
+ const name = (0, import_node_path33.basename)(executable).toLowerCase();
47637
+ if (MINERS.has(name)) continue;
47638
+ const key = `${pid}:${startTicks}`;
47639
+ const ticks = userTicks + systemTicks;
47640
+ const previous = this.cpuSamples.get(key);
47641
+ if (!previous) {
47642
+ current.set(key, { ticks, firstAt: now, accumulatedTicks: 0, alerted: false });
47643
+ continue;
47644
+ }
47645
+ const delta = Math.max(0, ticks - previous.ticks);
47646
+ const accumulatedTicks = previous.accumulatedTicks + delta;
47647
+ const elapsedMs = Math.max(1, now - previous.firstAt);
47648
+ const cpuPercent = accumulatedTicks * 1e5 / (this.ticksPerSecond * elapsedMs);
47649
+ const sample = { ticks, firstAt: previous.firstAt, accumulatedTicks, alerted: previous.alerted };
47650
+ current.set(key, sample);
47651
+ if (!sample.alerted && elapsedMs >= CPU_SUSTAIN_MS && cpuPercent >= CPU_THRESHOLD_PERCENT) {
47652
+ sample.alerted = true;
47653
+ const event = {
47654
+ timestamp: new Date(now),
47655
+ module: "edr",
47656
+ category: "system",
47657
+ severity: "high",
47658
+ message: `Unknown executable in a temporary directory sustained ${cpuPercent.toFixed(0)}% CPU: ${clean(executable)}`,
47659
+ details: { rule_id: "edr-temp-high-cpu", executable: clean(executable), pid: Number(pid), cpu_percent: Number(cpuPercent.toFixed(1)), sustained_seconds: Math.floor(elapsedMs / 1e3) }
47660
+ };
47661
+ this.publish(event);
47662
+ }
47663
+ } catch {
47664
+ }
47665
+ }
47666
+ this.cpuSamples.clear();
47667
+ for (const [key, sample] of current) this.cpuSamples.set(key, sample);
47668
+ }
47669
+ };
47670
+
47671
+ // src/daemon/workers/ssh-intrusion.ts
47672
+ var import_node_fs43 = require("fs");
47673
+ var import_node_path34 = require("path");
47674
+ var import_node_child_process15 = require("child_process");
46471
47675
 
46472
47676
  // src/core/asn.ts
46473
47677
  var import_node_dns = require("dns");
@@ -46660,35 +47864,35 @@ function parseKeyLoginsByFingerprint(text) {
46660
47864
  }
46661
47865
  function readJson2(path2) {
46662
47866
  try {
46663
- return JSON.parse((0, import_node_fs41.readFileSync)(path2, "utf-8"));
47867
+ return JSON.parse((0, import_node_fs43.readFileSync)(path2, "utf-8"));
46664
47868
  } catch {
46665
47869
  return null;
46666
47870
  }
46667
47871
  }
46668
47872
  function writeJson2(path2, value) {
46669
- (0, import_node_fs41.mkdirSync)((0, import_node_path32.dirname)(path2), { recursive: true });
46670
- (0, import_node_fs41.writeFileSync)(`${path2}.tmp`, JSON.stringify(value));
46671
- (0, import_node_fs41.renameSync)(`${path2}.tmp`, path2);
47873
+ (0, import_node_fs43.mkdirSync)((0, import_node_path34.dirname)(path2), { recursive: true });
47874
+ (0, import_node_fs43.writeFileSync)(`${path2}.tmp`, JSON.stringify(value));
47875
+ (0, import_node_fs43.renameSync)(`${path2}.tmp`, path2);
46672
47876
  }
46673
47877
  var fsIO2 = {
46674
47878
  readFile: (p) => {
46675
47879
  try {
46676
- return (0, import_node_fs41.readFileSync)(p, "utf-8");
47880
+ return (0, import_node_fs43.readFileSync)(p, "utf-8");
46677
47881
  } catch {
46678
47882
  return null;
46679
47883
  }
46680
47884
  },
46681
47885
  readDir: (p) => {
46682
47886
  try {
46683
- return (0, import_node_fs41.readdirSync)(p);
47887
+ return (0, import_node_fs43.readdirSync)(p);
46684
47888
  } catch {
46685
47889
  return null;
46686
47890
  }
46687
47891
  },
46688
- exists: (p) => (0, import_node_fs41.existsSync)(p)
47892
+ exists: (p) => (0, import_node_fs43.existsSync)(p)
46689
47893
  };
46690
47894
  function defaultRun4(cmd, args) {
46691
- const res = (0, import_node_child_process14.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 6e4, maxBuffer: 64 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
47895
+ const res = (0, import_node_child_process15.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 6e4, maxBuffer: 64 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
46692
47896
  return res.status === 0 ? res.stdout : null;
46693
47897
  }
46694
47898
  var SshIntrusionWatch = class {
@@ -46886,7 +48090,7 @@ var SshIntrusionWatch = class {
46886
48090
  };
46887
48091
 
46888
48092
  // src/daemon/workers/lightning-watch.ts
46889
- var import_node_fs42 = require("fs");
48093
+ var import_node_fs44 = require("fs");
46890
48094
  var DEFAULT_CLN_LOGS = [
46891
48095
  "/home/lightning/.lightning/cln.log",
46892
48096
  "/root/.lightning/cln.log",
@@ -46942,9 +48146,9 @@ var LightningWatch = class {
46942
48146
  if (this.opts.enabled === false) return [];
46943
48147
  const found = [];
46944
48148
  for (const path2 of this.opts.paths?.length ? this.opts.paths : DEFAULT_CLN_LOGS) {
46945
- if (!(0, import_node_fs42.existsSync)(path2)) continue;
48149
+ if (!(0, import_node_fs44.existsSync)(path2)) continue;
46946
48150
  try {
46947
- (0, import_node_fs42.accessSync)(path2, import_node_fs42.constants.R_OK);
48151
+ (0, import_node_fs44.accessSync)(path2, import_node_fs44.constants.R_OK);
46948
48152
  } catch {
46949
48153
  continue;
46950
48154
  }
@@ -46979,8 +48183,8 @@ var LightningWatch = class {
46979
48183
  };
46980
48184
 
46981
48185
  // src/core/tor-exits.ts
46982
- var import_node_fs43 = require("fs");
46983
- var import_node_path33 = require("path");
48186
+ var import_node_fs45 = require("fs");
48187
+ var import_node_path35 = require("path");
46984
48188
  var import_node_net15 = require("net");
46985
48189
  var TOR_BULK_EXIT_LIST_URL = "https://check.torproject.org/torbulkexitlist";
46986
48190
  function parseTorExitList(text) {
@@ -47048,10 +48252,10 @@ var TorExitList = class _TorExitList {
47048
48252
  }
47049
48253
  loadCache() {
47050
48254
  try {
47051
- if (!(0, import_node_fs43.existsSync)(this.opts.cachePath)) return false;
47052
- const parsed = parseTorExitList((0, import_node_fs43.readFileSync)(this.opts.cachePath, "utf-8"));
48255
+ if (!(0, import_node_fs45.existsSync)(this.opts.cachePath)) return false;
48256
+ const parsed = parseTorExitList((0, import_node_fs45.readFileSync)(this.opts.cachePath, "utf-8"));
47053
48257
  if (parsed.size === 0) return false;
47054
- this.load(parsed, (0, import_node_fs43.statSync)(this.opts.cachePath).mtimeMs);
48258
+ this.load(parsed, (0, import_node_fs45.statSync)(this.opts.cachePath).mtimeMs);
47055
48259
  this.log(`[tor] loaded ${parsed.size} Tor exit addresses from cache (${new Date(this.updatedAt).toISOString()})`);
47056
48260
  return true;
47057
48261
  } catch (err) {
@@ -47083,9 +48287,9 @@ var TorExitList = class _TorExitList {
47083
48287
  const before2 = this.exits.size;
47084
48288
  this.load(parsed);
47085
48289
  try {
47086
- (0, import_node_fs43.mkdirSync)((0, import_node_path33.dirname)(this.opts.cachePath), { recursive: true });
47087
- (0, import_node_fs43.writeFileSync)(`${this.opts.cachePath}.tmp`, [...parsed].join("\n") + "\n");
47088
- (0, import_node_fs43.renameSync)(`${this.opts.cachePath}.tmp`, this.opts.cachePath);
48290
+ (0, import_node_fs45.mkdirSync)((0, import_node_path35.dirname)(this.opts.cachePath), { recursive: true });
48291
+ (0, import_node_fs45.writeFileSync)(`${this.opts.cachePath}.tmp`, [...parsed].join("\n") + "\n");
48292
+ (0, import_node_fs45.renameSync)(`${this.opts.cachePath}.tmp`, this.opts.cachePath);
47089
48293
  } catch (err) {
47090
48294
  this.log(`[tor] could not save the exit list cache: ${err.message}`);
47091
48295
  }
@@ -47303,8 +48507,8 @@ var RuleEngine = class {
47303
48507
  };
47304
48508
 
47305
48509
  // src/daemon/rules/loader.ts
47306
- var import_node_fs44 = require("fs");
47307
- var import_node_path34 = require("path");
48510
+ var import_node_fs46 = require("fs");
48511
+ var import_node_path36 = require("path");
47308
48512
 
47309
48513
  // src/daemon/rules/default-rules.ts
47310
48514
  var AT_CRS_THRESHOLD = { field: "severity", operator: "regex", value: "^(high|critical)$" };
@@ -47895,11 +49099,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
47895
49099
  function loadAllRules(customDir) {
47896
49100
  const rules = [...DEFAULT_RULES];
47897
49101
  const dir = customDir || RULES_DIR;
47898
- if ((0, import_node_fs44.existsSync)(dir)) {
47899
- const files = (0, import_node_fs44.readdirSync)(dir).filter((f) => f.endsWith(".json"));
49102
+ if ((0, import_node_fs46.existsSync)(dir)) {
49103
+ const files = (0, import_node_fs46.readdirSync)(dir).filter((f) => f.endsWith(".json"));
47900
49104
  for (const file of files) {
47901
49105
  try {
47902
- const raw = (0, import_node_fs44.readFileSync)((0, import_node_path34.join)(dir, file), "utf-8");
49106
+ const raw = (0, import_node_fs46.readFileSync)((0, import_node_path36.join)(dir, file), "utf-8");
47903
49107
  const parsed = JSON.parse(raw);
47904
49108
  const customRules = Array.isArray(parsed) ? parsed : [parsed];
47905
49109
  for (const rule of customRules) {
@@ -47930,9 +49134,9 @@ function loadAllRules(customDir) {
47930
49134
  }
47931
49135
 
47932
49136
  // src/daemon/firewall/adapters.ts
47933
- var import_node_child_process15 = require("child_process");
47934
- var import_node_fs45 = require("fs");
47935
- var import_node_path35 = require("path");
49137
+ var import_node_child_process16 = require("child_process");
49138
+ var import_node_fs47 = require("fs");
49139
+ var import_node_path37 = require("path");
47936
49140
  var import_node_net16 = require("net");
47937
49141
  function assertValidFirewallIp(ip) {
47938
49142
  if ((0, import_node_net16.isIP)(ip) !== 4) {
@@ -47945,9 +49149,9 @@ function assertBannableIp(ip) {
47945
49149
  }
47946
49150
  }
47947
49151
  function writeIfAbsent(path2, contents) {
47948
- (0, import_node_fs45.mkdirSync)((0, import_node_path35.dirname)(path2), { recursive: true });
49152
+ (0, import_node_fs47.mkdirSync)((0, import_node_path37.dirname)(path2), { recursive: true });
47949
49153
  try {
47950
- (0, import_node_fs45.writeFileSync)(path2, contents, { flag: "wx" });
49154
+ (0, import_node_fs47.writeFileSync)(path2, contents, { flag: "wx" });
47951
49155
  } catch (err) {
47952
49156
  if (err.code !== "EEXIST") throw err;
47953
49157
  }
@@ -47966,11 +49170,11 @@ var Fail2banAdapter = class {
47966
49170
  enforces = true;
47967
49171
  jailReady = false;
47968
49172
  isAvailable() {
47969
- const result = (0, import_node_child_process15.spawnSync)("fail2ban-client", ["ping"], { stdio: "pipe" });
49173
+ const result = (0, import_node_child_process16.spawnSync)("fail2ban-client", ["ping"], { stdio: "pipe" });
47970
49174
  return result.status === 0;
47971
49175
  }
47972
49176
  client(args) {
47973
- return (0, import_node_child_process15.execFileSync)("fail2ban-client", args, {
49177
+ return (0, import_node_child_process16.execFileSync)("fail2ban-client", args, {
47974
49178
  encoding: "utf-8",
47975
49179
  stdio: ["ignore", "pipe", "pipe"]
47976
49180
  });
@@ -48066,35 +49270,35 @@ var NftablesAdapter = class {
48066
49270
  table = "threatcrush";
48067
49271
  set = "blocklist";
48068
49272
  isAvailable() {
48069
- const result = (0, import_node_child_process15.spawnSync)("nft", ["--version"], { stdio: "pipe" });
49273
+ const result = (0, import_node_child_process16.spawnSync)("nft", ["--version"], { stdio: "pipe" });
48070
49274
  return result.status === 0;
48071
49275
  }
48072
49276
  ensureSetup() {
48073
49277
  try {
48074
- (0, import_node_child_process15.execSync)(`nft list table inet ${this.table} 2>/dev/null`, { stdio: "pipe" });
49278
+ (0, import_node_child_process16.execSync)(`nft list table inet ${this.table} 2>/dev/null`, { stdio: "pipe" });
48075
49279
  } catch {
48076
- (0, import_node_child_process15.execSync)(`nft add table inet ${this.table}`);
48077
- (0, import_node_child_process15.execSync)(`nft add set inet ${this.table} ${this.set} '{ type ipv4_addr; flags timeout; }'`);
48078
- (0, import_node_child_process15.execSync)(`nft add chain inet ${this.table} input '{ type filter hook input priority -1; policy accept; }'`);
48079
- (0, import_node_child_process15.execSync)(`nft add rule inet ${this.table} input ip saddr @${this.set} drop`);
49280
+ (0, import_node_child_process16.execSync)(`nft add table inet ${this.table}`);
49281
+ (0, import_node_child_process16.execSync)(`nft add set inet ${this.table} ${this.set} '{ type ipv4_addr; flags timeout; }'`);
49282
+ (0, import_node_child_process16.execSync)(`nft add chain inet ${this.table} input '{ type filter hook input priority -1; policy accept; }'`);
49283
+ (0, import_node_child_process16.execSync)(`nft add rule inet ${this.table} input ip saddr @${this.set} drop`);
48080
49284
  }
48081
49285
  }
48082
49286
  async block(ip) {
48083
49287
  assertValidFirewallIp(ip);
48084
49288
  this.ensureSetup();
48085
- (0, import_node_child_process15.execSync)(`nft add element inet ${this.table} ${this.set} '{ ${ip} }'`);
49289
+ (0, import_node_child_process16.execSync)(`nft add element inet ${this.table} ${this.set} '{ ${ip} }'`);
48086
49290
  }
48087
49291
  async unblock(ip) {
48088
49292
  assertValidFirewallIp(ip);
48089
49293
  try {
48090
- (0, import_node_child_process15.execSync)(`nft delete element inet ${this.table} ${this.set} '{ ${ip} }'`);
49294
+ (0, import_node_child_process16.execSync)(`nft delete element inet ${this.table} ${this.set} '{ ${ip} }'`);
48091
49295
  } catch {
48092
49296
  }
48093
49297
  }
48094
49298
  async isBlocked(ip) {
48095
49299
  assertValidFirewallIp(ip);
48096
49300
  try {
48097
- const output = (0, import_node_child_process15.execSync)(`nft list set inet ${this.table} ${this.set}`, { encoding: "utf-8" });
49301
+ const output = (0, import_node_child_process16.execSync)(`nft list set inet ${this.table} ${this.set}`, { encoding: "utf-8" });
48098
49302
  return output.includes(ip);
48099
49303
  } catch {
48100
49304
  return false;
@@ -48102,7 +49306,7 @@ var NftablesAdapter = class {
48102
49306
  }
48103
49307
  async listBlocked() {
48104
49308
  try {
48105
- const output = (0, import_node_child_process15.execSync)(`nft list set inet ${this.table} ${this.set}`, { encoding: "utf-8" });
49309
+ const output = (0, import_node_child_process16.execSync)(`nft list set inet ${this.table} ${this.set}`, { encoding: "utf-8" });
48106
49310
  const match = output.match(/elements\s*=\s*\{([^}]*)\}/);
48107
49311
  if (!match) return [];
48108
49312
  return match[1].split(",").map((s) => s.trim().split(/\s/)[0]).filter(Boolean);
@@ -48115,34 +49319,34 @@ var IptablesAdapter = class {
48115
49319
  name = "iptables";
48116
49320
  chain = "THREATCRUSH";
48117
49321
  isAvailable() {
48118
- const result = (0, import_node_child_process15.spawnSync)("iptables", ["--version"], { stdio: "pipe" });
49322
+ const result = (0, import_node_child_process16.spawnSync)("iptables", ["--version"], { stdio: "pipe" });
48119
49323
  return result.status === 0;
48120
49324
  }
48121
49325
  ensureChain() {
48122
49326
  try {
48123
- (0, import_node_child_process15.execSync)(`iptables -n -L ${this.chain} 2>/dev/null`, { stdio: "pipe" });
49327
+ (0, import_node_child_process16.execSync)(`iptables -n -L ${this.chain} 2>/dev/null`, { stdio: "pipe" });
48124
49328
  } catch {
48125
- (0, import_node_child_process15.execSync)(`iptables -N ${this.chain}`);
48126
- (0, import_node_child_process15.execSync)(`iptables -I INPUT 1 -j ${this.chain}`);
49329
+ (0, import_node_child_process16.execSync)(`iptables -N ${this.chain}`);
49330
+ (0, import_node_child_process16.execSync)(`iptables -I INPUT 1 -j ${this.chain}`);
48127
49331
  }
48128
49332
  }
48129
49333
  async block(ip) {
48130
49334
  assertValidFirewallIp(ip);
48131
49335
  this.ensureChain();
48132
49336
  if (await this.isBlocked(ip)) return;
48133
- (0, import_node_child_process15.execSync)(`iptables -A ${this.chain} -s ${ip} -j DROP`);
49337
+ (0, import_node_child_process16.execSync)(`iptables -A ${this.chain} -s ${ip} -j DROP`);
48134
49338
  }
48135
49339
  async unblock(ip) {
48136
49340
  assertValidFirewallIp(ip);
48137
49341
  try {
48138
- (0, import_node_child_process15.execSync)(`iptables -D ${this.chain} -s ${ip} -j DROP`);
49342
+ (0, import_node_child_process16.execSync)(`iptables -D ${this.chain} -s ${ip} -j DROP`);
48139
49343
  } catch {
48140
49344
  }
48141
49345
  }
48142
49346
  async isBlocked(ip) {
48143
49347
  assertValidFirewallIp(ip);
48144
49348
  try {
48145
- const output = (0, import_node_child_process15.execSync)(`iptables -n -L ${this.chain}`, { encoding: "utf-8" });
49349
+ const output = (0, import_node_child_process16.execSync)(`iptables -n -L ${this.chain}`, { encoding: "utf-8" });
48146
49350
  return output.includes(ip);
48147
49351
  } catch {
48148
49352
  return false;
@@ -48150,7 +49354,7 @@ var IptablesAdapter = class {
48150
49354
  }
48151
49355
  async listBlocked() {
48152
49356
  try {
48153
- const output = (0, import_node_child_process15.execSync)(`iptables -n -L ${this.chain}`, { encoding: "utf-8" });
49357
+ const output = (0, import_node_child_process16.execSync)(`iptables -n -L ${this.chain}`, { encoding: "utf-8" });
48154
49358
  const ips = [];
48155
49359
  for (const line2 of output.split("\n")) {
48156
49360
  const match = line2.match(/DROP\s+all\s+--\s+(\d+\.\d+\.\d+\.\d+)/);
@@ -48206,8 +49410,8 @@ function detectFirewallAdapter(backend = "auto") {
48206
49410
  }
48207
49411
 
48208
49412
  // src/daemon/firewall/remediation.ts
48209
- var import_node_fs46 = require("fs");
48210
- var import_node_child_process16 = require("child_process");
49413
+ var import_node_fs48 = require("fs");
49414
+ var import_node_child_process17 = require("child_process");
48211
49415
  var import_node_net17 = require("net");
48212
49416
  init_paths();
48213
49417
  init_backoff();
@@ -48278,19 +49482,19 @@ var defaultDiscovery = {
48278
49482
  const snapshot = takeSnapshot({
48279
49483
  readFile: (p) => {
48280
49484
  try {
48281
- return (0, import_node_fs46.readFileSync)(p, "utf-8");
49485
+ return (0, import_node_fs48.readFileSync)(p, "utf-8");
48282
49486
  } catch {
48283
49487
  return null;
48284
49488
  }
48285
49489
  },
48286
49490
  readDir: (p) => {
48287
49491
  try {
48288
- return (0, import_node_fs46.readdirSync)(p);
49492
+ return (0, import_node_fs48.readdirSync)(p);
48289
49493
  } catch {
48290
49494
  return null;
48291
49495
  }
48292
49496
  },
48293
- exists: (p) => (0, import_node_fs46.existsSync)(p)
49497
+ exists: (p) => (0, import_node_fs48.existsSync)(p)
48294
49498
  });
48295
49499
  const out = /* @__PURE__ */ new Set();
48296
49500
  for (const keys of Object.values(snapshot.keys)) {
@@ -48299,7 +49503,7 @@ var defaultDiscovery = {
48299
49503
  return out;
48300
49504
  },
48301
49505
  keyLoginJournal: (sinceSeconds) => new Promise((resolve8) => {
48302
- (0, import_node_child_process16.execFile)(
49506
+ (0, import_node_child_process17.execFile)(
48303
49507
  "journalctl",
48304
49508
  ["_COMM=sshd", "_COMM=sshd-session", `--since=-${Math.ceil(sinceSeconds / 86400)}d`, "-o", "short-unix", "--no-pager", "--grep", "Accepted publickey"],
48305
49509
  { maxBuffer: 32 * 1024 * 1024, timeout: 6e4 },
@@ -48803,7 +50007,7 @@ var RemediationManager = class {
48803
50007
  }
48804
50008
  logLine(line2) {
48805
50009
  try {
48806
- (0, import_node_fs46.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
50010
+ (0, import_node_fs48.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
48807
50011
  `);
48808
50012
  } catch {
48809
50013
  }
@@ -48847,19 +50051,19 @@ function remediationSettings(section) {
48847
50051
  init_backoff();
48848
50052
 
48849
50053
  // src/daemon/watchdog-service.ts
48850
- var import_node_fs47 = require("fs");
48851
- var import_node_path36 = require("path");
50054
+ var import_node_fs49 = require("fs");
50055
+ var import_node_path38 = require("path");
48852
50056
  function defaultShareGid() {
48853
50057
  const isRoot4 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
48854
50058
  if (!isRoot4) return void 0;
48855
50059
  try {
48856
- return (0, import_node_fs47.statSync)("/var/log/auth.log").gid;
50060
+ return (0, import_node_fs49.statSync)("/var/log/auth.log").gid;
48857
50061
  } catch {
48858
50062
  return void 0;
48859
50063
  }
48860
50064
  }
48861
50065
  function startWatchdog(opts) {
48862
- const dir = opts.config?.dir ?? (0, import_node_path36.join)(opts.stateDir, WATCHDOG_DIRNAME);
50066
+ const dir = opts.config?.dir ?? (0, import_node_path38.join)(opts.stateDir, WATCHDOG_DIRNAME);
48863
50067
  const base = { dir, logged: 0, answered: 0, errored: 0 };
48864
50068
  if (opts.config?.enabled === false) {
48865
50069
  opts.log("[watchdog] off ([watchdog] enabled = false)");
@@ -48953,7 +50157,7 @@ async function flushTelemetry(timeoutMs = 2e3) {
48953
50157
  }
48954
50158
 
48955
50159
  // src/core/node-runtime.ts
48956
- var import_node_child_process17 = require("child_process");
50160
+ var import_node_child_process18 = require("child_process");
48957
50161
  var MIN_DAEMON_NODE_MAJOR = 22;
48958
50162
  function nodeMajor(version) {
48959
50163
  const m = String(version ?? "").trim().replace(/^v/, "").match(/^(\d+)\./);
@@ -48967,23 +50171,23 @@ function daemonNodeProblem(version) {
48967
50171
  }
48968
50172
  function versionOfNode(path2) {
48969
50173
  if (path2 === process.execPath) return process.versions.node;
48970
- const res = (0, import_node_child_process17.spawnSync)(path2, ["-p", "process.versions.node"], { encoding: "utf-8", timeout: 5e3 });
50174
+ const res = (0, import_node_child_process18.spawnSync)(path2, ["-p", "process.versions.node"], { encoding: "utf-8", timeout: 5e3 });
48971
50175
  return res.status === 0 ? res.stdout.trim() : null;
48972
50176
  }
48973
50177
 
48974
50178
  // src/daemon/index.ts
48975
50179
  function readVersion2() {
48976
50180
  try {
48977
- const pkg = JSON.parse((0, import_node_fs48.readFileSync)((0, import_node_path37.join)(__dirname, "..", "package.json"), "utf-8"));
50181
+ const pkg = JSON.parse((0, import_node_fs50.readFileSync)((0, import_node_path39.join)(__dirname, "..", "package.json"), "utf-8"));
48978
50182
  return pkg.version || "0.0.0";
48979
50183
  } catch {
48980
50184
  return "0.0.0";
48981
50185
  }
48982
50186
  }
48983
50187
  async function runHardeningChecks() {
48984
- const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process18.execFile)(
50188
+ const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process19.execFile)(
48985
50189
  process.execPath,
48986
- [(0, import_node_path37.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
50190
+ [(0, import_node_path39.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
48987
50191
  { timeout: 12e4, maxBuffer: 4 * 1024 * 1024 }
48988
50192
  );
48989
50193
  const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
@@ -48995,9 +50199,9 @@ async function runHardeningChecks() {
48995
50199
  return patches ? [...findings2, patches] : findings2;
48996
50200
  }
48997
50201
  async function runPatchCheck() {
48998
- const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process18.execFile)(
50202
+ const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process19.execFile)(
48999
50203
  process.execPath,
49000
- [(0, import_node_path37.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
50204
+ [(0, import_node_path39.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
49001
50205
  { timeout: 3e5, maxBuffer: 16 * 1024 * 1024 }
49002
50206
  );
49003
50207
  const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
@@ -49005,7 +50209,7 @@ async function runPatchCheck() {
49005
50209
  }
49006
50210
  function logLine(line2) {
49007
50211
  try {
49008
- (0, import_node_fs48.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
50212
+ (0, import_node_fs50.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
49009
50213
  `);
49010
50214
  } catch {
49011
50215
  }
@@ -49030,9 +50234,9 @@ async function runDaemon() {
49030
50234
  logLine(`[daemon] starting threatcrushd v${version} mode=${PATHS.mode}`);
49031
50235
  const restartDaemon = () => {
49032
50236
  if (PATHS.mode === "system") {
49033
- (0, import_node_child_process18.spawn)("systemctl", ["restart", "threatcrushd"], { detached: true, stdio: "ignore" }).unref();
50237
+ (0, import_node_child_process19.spawn)("systemctl", ["restart", "threatcrushd"], { detached: true, stdio: "ignore" }).unref();
49034
50238
  } else {
49035
- (0, import_node_child_process18.spawn)(process.execPath, process.argv.slice(1), { detached: true, stdio: "ignore" }).unref();
50239
+ (0, import_node_child_process19.spawn)(process.execPath, process.argv.slice(1), { detached: true, stdio: "ignore" }).unref();
49036
50240
  setTimeout(() => process.exit(0), 500).unref();
49037
50241
  }
49038
50242
  };
@@ -49047,7 +50251,7 @@ async function runDaemon() {
49047
50251
  } catch (err) {
49048
50252
  logLine(`[daemon] state db unavailable: ${err.message}`);
49049
50253
  }
49050
- const loaded = loadDaemonConfig(PATHS.configFile, (0, import_node_path37.join)(PATHS.stateDir, "threatcrushd.conf.last-good"));
50254
+ const loaded = loadDaemonConfig(PATHS.configFile, (0, import_node_path39.join)(PATHS.stateDir, "threatcrushd.conf.last-good"));
49051
50255
  const config = loaded.config;
49052
50256
  if (loaded.error) {
49053
50257
  logLine(`[daemon] CONFIG ERROR: ${loaded.error}; ${loaded.usedLastGood ? "running on the last config that parsed" : "no earlier good copy, running on DEFAULTS (no protected list)"}`);
@@ -49115,7 +50319,7 @@ async function runDaemon() {
49115
50319
  const threatFeeds = new ThreatFeeds({
49116
50320
  settings: { ...feedSettings, allow: [...feedSettings.allow, ...remediation.getAllowlist()] },
49117
50321
  enforcing: !remediationStatus.dry_run && firewallAdapter.enforces !== false,
49118
- cachePath: (0, import_node_path37.join)(PATHS.stateDir, "threat-feeds.json"),
50322
+ cachePath: (0, import_node_path39.join)(PATHS.stateDir, "threat-feeds.json"),
49119
50323
  bus,
49120
50324
  log: logLine
49121
50325
  });
@@ -49123,9 +50327,9 @@ async function runDaemon() {
49123
50327
  const privilegeWatch = new PrivilegeWatch({
49124
50328
  settings: privilegeSettings(config.privileged),
49125
50329
  bus,
49126
- snapshotPath: (0, import_node_path37.join)(PATHS.stateDir, "privileges.json"),
49127
- loginsPath: (0, import_node_path37.join)(PATHS.stateDir, "login-countries.json"),
49128
- cursorPath: (0, import_node_path37.join)(PATHS.stateDir, "sudo-cursor.json"),
50330
+ snapshotPath: (0, import_node_path39.join)(PATHS.stateDir, "privileges.json"),
50331
+ loginsPath: (0, import_node_path39.join)(PATHS.stateDir, "login-countries.json"),
50332
+ cursorPath: (0, import_node_path39.join)(PATHS.stateDir, "sudo-cursor.json"),
49129
50333
  log: logLine
49130
50334
  });
49131
50335
  privilegeWatch.start();
@@ -49136,8 +50340,23 @@ async function runDaemon() {
49136
50340
  log: logLine
49137
50341
  });
49138
50342
  commandHistory.start();
50343
+ const fileIntegrity = new FileIntegrityWatch({
50344
+ bus,
50345
+ settings: fileIntegritySettings(config.file_integrity),
50346
+ baselinePath: (0, import_node_path39.join)(PATHS.stateDir, "file-integrity-baseline.json"),
50347
+ observedPath: (0, import_node_path39.join)(PATHS.stateDir, "file-integrity-observed.json"),
50348
+ log: logLine
50349
+ });
50350
+ fileIntegrity.start();
50351
+ const edr = new EdrWatch({
50352
+ bus,
50353
+ settings: edrSettings(config.edr),
50354
+ networkBaselinePath: (0, import_node_path39.join)(PATHS.stateDir, "edr-outbound-executables.json"),
50355
+ log: logLine
50356
+ });
50357
+ edr.start();
49139
50358
  const torExits = new TorExitList({
49140
- cachePath: (0, import_node_path37.join)(PATHS.stateDir, "tor-exits.txt"),
50359
+ cachePath: (0, import_node_path39.join)(PATHS.stateDir, "tor-exits.txt"),
49141
50360
  url: config.remediation?.tor_exit_list_url,
49142
50361
  log: logLine
49143
50362
  });
@@ -49145,7 +50364,7 @@ async function runDaemon() {
49145
50364
  bus,
49146
50365
  manager: remediation,
49147
50366
  tor: torExits,
49148
- historyPath: (0, import_node_path37.join)(PATHS.stateDir, "key-logins.json"),
50367
+ historyPath: (0, import_node_path39.join)(PATHS.stateDir, "key-logins.json"),
49149
50368
  keyLoginWatch: config.privileged?.key_login_watch !== false,
49150
50369
  log: logLine
49151
50370
  });
@@ -49192,7 +50411,7 @@ async function runDaemon() {
49192
50411
  version,
49193
50412
  hostname: (0, import_node_os14.hostname)(),
49194
50413
  minSeverity,
49195
- spoolPath: (0, import_node_path37.join)(PATHS.stateDir, "cloud-spool.jsonl"),
50414
+ spoolPath: (0, import_node_path39.join)(PATHS.stateDir, "cloud-spool.jsonl"),
49196
50415
  log: logLine,
49197
50416
  ruleModules: new Set(ruleEngine.getRules().flatMap((rule) => rule.source_types)),
49198
50417
  runHardening: runHardeningChecks
@@ -49225,8 +50444,8 @@ async function runDaemon() {
49225
50444
  const autoUpdate = autoUpdateRef = new AutoUpdate({
49226
50445
  version,
49227
50446
  settings: updateSettings(config.update),
49228
- pkgRoot: (0, import_node_path37.join)(__dirname, ".."),
49229
- statePath: (0, import_node_path37.join)(PATHS.stateDir, "auto-update.json"),
50447
+ pkgRoot: (0, import_node_path39.join)(__dirname, ".."),
50448
+ statePath: (0, import_node_path39.join)(PATHS.stateDir, "auto-update.json"),
49230
50449
  bus,
49231
50450
  log: logLine,
49232
50451
  restartDaemon
@@ -49285,6 +50504,14 @@ async function runDaemon() {
49285
50504
  commandHistory.stop();
49286
50505
  } catch {
49287
50506
  }
50507
+ try {
50508
+ fileIntegrity.stop();
50509
+ } catch {
50510
+ }
50511
+ try {
50512
+ edr.stop();
50513
+ } catch {
50514
+ }
49288
50515
  try {
49289
50516
  sshIntrusion.stop();
49290
50517
  } catch {
@@ -49328,7 +50555,7 @@ var SYSTEM_SOCKET = "/var/run/threatcrush/threatcrushd.sock";
49328
50555
  function isRoot2() {
49329
50556
  return typeof process.getuid === "function" && process.getuid() === 0;
49330
50557
  }
49331
- var DAEMON_ENTRY = (0, import_node_path38.join)(__dirname, "daemon.js");
50558
+ var DAEMON_ENTRY = (0, import_node_path40.join)(__dirname, "daemon.js");
49332
50559
  async function daemonForeground() {
49333
50560
  await runDaemon();
49334
50561
  }
@@ -49349,7 +50576,7 @@ async function daemonStart() {
49349
50576
  return;
49350
50577
  }
49351
50578
  ensureRuntimeDirs();
49352
- if (!(0, import_node_fs49.existsSync)(DAEMON_ENTRY)) {
50579
+ if (!(0, import_node_fs51.existsSync)(DAEMON_ENTRY)) {
49353
50580
  console.log(source_default.red(` Daemon entry not found at ${DAEMON_ENTRY}.`));
49354
50581
  console.log(source_default.dim(" Reinstall with `threatcrush update` or `pnpm run build` in the cli package."));
49355
50582
  return;
@@ -49357,8 +50584,8 @@ async function daemonStart() {
49357
50584
  let out;
49358
50585
  let err;
49359
50586
  try {
49360
- out = (0, import_node_fs50.openSync)(PATHS.logFile, "a");
49361
- err = (0, import_node_fs50.openSync)(PATHS.logFile, "a");
50587
+ out = (0, import_node_fs52.openSync)(PATHS.logFile, "a");
50588
+ err = (0, import_node_fs52.openSync)(PATHS.logFile, "a");
49362
50589
  } catch (e) {
49363
50590
  const code = e.code;
49364
50591
  console.log(source_default.red(` \u2717 Cannot write daemon log at ${PATHS.logFile} (${code ?? "error"}).`));
@@ -49371,7 +50598,7 @@ async function daemonStart() {
49371
50598
  }
49372
50599
  return;
49373
50600
  }
49374
- const child = (0, import_node_child_process19.spawn)(process.execPath, [DAEMON_ENTRY], {
50601
+ const child = (0, import_node_child_process20.spawn)(process.execPath, [DAEMON_ENTRY], {
49375
50602
  detached: true,
49376
50603
  stdio: ["ignore", out, err],
49377
50604
  env: { ...process.env, THREATCRUSH_DAEMON: "1" }
@@ -49446,41 +50673,41 @@ async function waitForExit(pid, timeoutMs) {
49446
50673
  }
49447
50674
  async function releaseStaleSocket() {
49448
50675
  const deadline = Date.now() + 2e3;
49449
- while ((0, import_node_fs49.existsSync)(PATHS.socket) && Date.now() < deadline) {
50676
+ while ((0, import_node_fs51.existsSync)(PATHS.socket) && Date.now() < deadline) {
49450
50677
  await new Promise((r) => setTimeout(r, 50));
49451
50678
  }
49452
- if ((0, import_node_fs49.existsSync)(PATHS.socket)) {
50679
+ if ((0, import_node_fs51.existsSync)(PATHS.socket)) {
49453
50680
  try {
49454
- (0, import_node_fs49.unlinkSync)(PATHS.socket);
50681
+ (0, import_node_fs51.unlinkSync)(PATHS.socket);
49455
50682
  } catch {
49456
50683
  }
49457
50684
  }
49458
50685
  }
49459
50686
 
49460
50687
  // src/commands/service.ts
49461
- var import_node_child_process20 = require("child_process");
49462
- var import_node_fs51 = require("fs");
49463
- var import_node_path39 = require("path");
50688
+ var import_node_child_process21 = require("child_process");
50689
+ var import_node_fs53 = require("fs");
50690
+ var import_node_path41 = require("path");
49464
50691
  var import_node_os15 = require("os");
49465
50692
  var UNIT_PATH = "/etc/systemd/system/threatcrushd.service";
49466
50693
  var DAEMON_UNIT_NAME = "threatcrushd.service";
49467
50694
  function resolveTemplate() {
49468
- const templatePath = (0, import_node_path39.join)(__dirname, "systemd", "threatcrushd.service");
49469
- if (!(0, import_node_fs51.existsSync)(templatePath)) {
50695
+ const templatePath = (0, import_node_path41.join)(__dirname, "systemd", "threatcrushd.service");
50696
+ if (!(0, import_node_fs53.existsSync)(templatePath)) {
49470
50697
  throw new Error(`systemd unit template not found at ${templatePath}`);
49471
50698
  }
49472
- return (0, import_node_fs51.readFileSync)(templatePath, "utf-8");
50699
+ return (0, import_node_fs53.readFileSync)(templatePath, "utf-8");
49473
50700
  }
49474
50701
  function stableBinPath(binPath) {
49475
50702
  const stable = binPath.replace(/\/\.pnpm\/[^/]+\/node_modules\//, "/node_modules/");
49476
50703
  if (stable === binPath) return binPath;
49477
- return (0, import_node_fs51.existsSync)(stable) ? stable : binPath;
50704
+ return (0, import_node_fs53.existsSync)(stable) ? stable : binPath;
49478
50705
  }
49479
50706
  function resolveBinPath() {
49480
50707
  const arg = process.argv[1];
49481
- if (arg && (0, import_node_fs51.existsSync)(arg)) return stableBinPath(arg);
50708
+ if (arg && (0, import_node_fs53.existsSync)(arg)) return stableBinPath(arg);
49482
50709
  try {
49483
- return (0, import_node_child_process20.execSync)("command -v threatcrush", { encoding: "utf-8" }).trim();
50710
+ return (0, import_node_child_process21.execSync)("command -v threatcrush", { encoding: "utf-8" }).trim();
49484
50711
  } catch {
49485
50712
  return "threatcrush";
49486
50713
  }
@@ -49488,11 +50715,11 @@ function resolveBinPath() {
49488
50715
  function stableNodePath(execPath) {
49489
50716
  const stable = execPath.replace(/(\/installs\/node\/)[^/]+\//, "$1latest/");
49490
50717
  if (stable === execPath) return execPath;
49491
- return (0, import_node_fs51.existsSync)(stable) ? stable : execPath;
50718
+ return (0, import_node_fs53.existsSync)(stable) ? stable : execPath;
49492
50719
  }
49493
50720
  function looksLikeNodeScript(path2) {
49494
50721
  try {
49495
- const head = (0, import_node_fs51.readFileSync)(path2, "utf-8").slice(0, 120);
50722
+ const head = (0, import_node_fs53.readFileSync)(path2, "utf-8").slice(0, 120);
49496
50723
  return /^#!.*\bnode\b/.test(head);
49497
50724
  } catch {
49498
50725
  return false;
@@ -49519,20 +50746,20 @@ function isRoot3() {
49519
50746
  return typeof process.getuid === "function" && process.getuid() === 0;
49520
50747
  }
49521
50748
  function reexecWithSudo(args) {
49522
- if ((0, import_node_child_process20.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
50749
+ if ((0, import_node_child_process21.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
49523
50750
  console.log(source_default.dim(" This needs root \u2014 sudo will ask for your password.\n"));
49524
50751
  const bin = resolveBinPath();
49525
50752
  const argv = looksLikeNodeScript(bin) ? [stableNodePath(process.execPath), bin, ...args] : [bin, ...args];
49526
- const result = (0, import_node_child_process20.spawnSync)("sudo", argv, { stdio: "inherit" });
50753
+ const result = (0, import_node_child_process21.spawnSync)("sudo", argv, { stdio: "inherit" });
49527
50754
  return result.status === 0;
49528
50755
  }
49529
50756
  function callerHome() {
49530
50757
  const user = process.env.SUDO_USER;
49531
50758
  if (!user) return null;
49532
50759
  try {
49533
- const line2 = (0, import_node_child_process20.execSync)(`getent passwd ${user}`, { encoding: "utf-8" }).trim();
50760
+ const line2 = (0, import_node_child_process21.execSync)(`getent passwd ${user}`, { encoding: "utf-8" }).trim();
49534
50761
  const home = line2.split(":")[5];
49535
- return home && (0, import_node_fs51.existsSync)(home) ? home : null;
50762
+ return home && (0, import_node_fs53.existsSync)(home) ? home : null;
49536
50763
  } catch {
49537
50764
  return null;
49538
50765
  }
@@ -49540,13 +50767,13 @@ function callerHome() {
49540
50767
  function stopUserModeDaemon() {
49541
50768
  const home = callerHome();
49542
50769
  if (!home) return;
49543
- const runDir = (0, import_node_path39.join)(home, ".threatcrush", "run");
49544
- const pidFile = (0, import_node_path39.join)(runDir, "threatcrushd.pid");
49545
- const socket = (0, import_node_path39.join)(runDir, "threatcrushd.sock");
49546
- if (!(0, import_node_fs51.existsSync)(pidFile) && !(0, import_node_fs51.existsSync)(socket)) return;
50770
+ const runDir = (0, import_node_path41.join)(home, ".threatcrush", "run");
50771
+ const pidFile = (0, import_node_path41.join)(runDir, "threatcrushd.pid");
50772
+ const socket = (0, import_node_path41.join)(runDir, "threatcrushd.sock");
50773
+ if (!(0, import_node_fs53.existsSync)(pidFile) && !(0, import_node_fs53.existsSync)(socket)) return;
49547
50774
  let pid = null;
49548
50775
  try {
49549
- pid = Number.parseInt((0, import_node_fs51.readFileSync)(pidFile, "utf-8").trim(), 10);
50776
+ pid = Number.parseInt((0, import_node_fs53.readFileSync)(pidFile, "utf-8").trim(), 10);
49550
50777
  } catch {
49551
50778
  pid = null;
49552
50779
  }
@@ -49559,13 +50786,13 @@ function stopUserModeDaemon() {
49559
50786
  }
49560
50787
  for (const path2 of [socket, pidFile]) {
49561
50788
  try {
49562
- if ((0, import_node_fs51.existsSync)(path2)) (0, import_node_fs51.rmSync)(path2);
50789
+ if ((0, import_node_fs53.existsSync)(path2)) (0, import_node_fs53.rmSync)(path2);
49563
50790
  } catch {
49564
50791
  }
49565
50792
  }
49566
50793
  }
49567
50794
  function unitIsActive() {
49568
- const result = (0, import_node_child_process20.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT_NAME], { stdio: "pipe" });
50795
+ const result = (0, import_node_child_process21.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT_NAME], { stdio: "pipe" });
49569
50796
  return result.status === 0;
49570
50797
  }
49571
50798
  async function installServiceCommand() {
@@ -49576,8 +50803,8 @@ async function installServiceCommand() {
49576
50803
  return;
49577
50804
  }
49578
50805
  const noSystemd = systemdUnavailableReason({
49579
- hasSystemctl: (0, import_node_child_process20.spawnSync)("sh", ["-c", "command -v systemctl"], { stdio: "ignore" }).status === 0,
49580
- booted: (0, import_node_fs51.existsSync)("/run/systemd/system")
50806
+ hasSystemctl: (0, import_node_child_process21.spawnSync)("sh", ["-c", "command -v systemctl"], { stdio: "ignore" }).status === 0,
50807
+ booted: (0, import_node_fs53.existsSync)("/run/systemd/system")
49581
50808
  });
49582
50809
  if (noSystemd) {
49583
50810
  console.log(source_default.red(` \u2717 systemd isn't available here: ${noSystemd}.`));
@@ -49599,7 +50826,7 @@ async function installServiceCommand() {
49599
50826
  const isNodeScript = looksLikeNodeScript(binPath);
49600
50827
  let nodePath = stableNodePath(process.execPath);
49601
50828
  if (isNodeScript && nodeVersionDir(binPath)) {
49602
- binPath = (0, import_node_fs51.realpathSync)(binPath);
50829
+ binPath = (0, import_node_fs53.realpathSync)(binPath);
49603
50830
  nodePath = process.execPath;
49604
50831
  }
49605
50832
  if (isNodeScript) {
@@ -49612,11 +50839,11 @@ async function installServiceCommand() {
49612
50839
  }
49613
50840
  }
49614
50841
  const exec = execStartCommand(binPath, nodePath, isNodeScript);
49615
- const configDir = (0, import_node_path39.join)((0, import_node_os15.homedir)(), ".threatcrush");
50842
+ const configDir = (0, import_node_path41.join)((0, import_node_os15.homedir)(), ".threatcrush");
49616
50843
  const commandHistoryEnabled = commandHistorySettings(loadConfig().command_history).enabled;
49617
50844
  const historyPaths = commandHistoryEnabled ? historyWritableHomes() : [];
49618
50845
  const unit = renderUnit(resolveTemplate(), { exec, binPath, configDir, historyPaths });
49619
- (0, import_node_fs51.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
50846
+ (0, import_node_fs53.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
49620
50847
  console.log(source_default.green(` \u2713 Installed unit file: ${UNIT_PATH}`));
49621
50848
  console.log(source_default.dim(` ExecStart=${exec}`));
49622
50849
  const nodeDir = nodeVersionDir(nodePath);
@@ -49631,8 +50858,8 @@ async function installServiceCommand() {
49631
50858
  installLogrotate();
49632
50859
  stopUserModeDaemon();
49633
50860
  try {
49634
- (0, import_node_child_process20.execSync)("systemctl daemon-reload", { stdio: "inherit" });
49635
- (0, import_node_child_process20.execSync)(`systemctl enable --now ${DAEMON_UNIT_NAME}`, { stdio: "inherit" });
50861
+ (0, import_node_child_process21.execSync)("systemctl daemon-reload", { stdio: "inherit" });
50862
+ (0, import_node_child_process21.execSync)(`systemctl enable --now ${DAEMON_UNIT_NAME}`, { stdio: "inherit" });
49636
50863
  } catch (err) {
49637
50864
  console.log(source_default.yellow(` ! systemctl error: ${err.message}`));
49638
50865
  console.log(source_default.dim(` Logs: journalctl -u ${DAEMON_UNIT_NAME} -n 50`));
@@ -49669,9 +50896,9 @@ function renderLogrotate(logDir = "/var/log/threatcrush") {
49669
50896
  ].join("\n");
49670
50897
  }
49671
50898
  function installLogrotate() {
49672
- if (!(0, import_node_fs51.existsSync)((0, import_node_path39.dirname)(LOGROTATE_PATH))) return;
50899
+ if (!(0, import_node_fs53.existsSync)((0, import_node_path41.dirname)(LOGROTATE_PATH))) return;
49673
50900
  try {
49674
- (0, import_node_fs51.writeFileSync)(LOGROTATE_PATH, renderLogrotate(), { mode: 420 });
50901
+ (0, import_node_fs53.writeFileSync)(LOGROTATE_PATH, renderLogrotate(), { mode: 420 });
49675
50902
  console.log(source_default.green(` \u2713 Log rotation: ${LOGROTATE_PATH} (daily or 200M, keeps 7)`));
49676
50903
  } catch (err) {
49677
50904
  console.log(source_default.yellow(` ! Could not install log rotation: ${err.message}`));
@@ -49693,20 +50920,20 @@ function ensureSystemDirs(configDir) {
49693
50920
  ];
49694
50921
  let admGid2 = null;
49695
50922
  try {
49696
- admGid2 = (0, import_node_fs51.statSync)("/var/log/auth.log").gid;
50923
+ admGid2 = (0, import_node_fs53.statSync)("/var/log/auth.log").gid;
49697
50924
  } catch {
49698
50925
  }
49699
50926
  for (const { path: path2, groupWritable, sticky } of dirs) {
49700
50927
  try {
49701
- (0, import_node_fs51.mkdirSync)(path2, { recursive: true });
50928
+ (0, import_node_fs53.mkdirSync)(path2, { recursive: true });
49702
50929
  } catch {
49703
50930
  }
49704
50931
  try {
49705
50932
  if (groupWritable && admGid2 !== null) {
49706
- (0, import_node_fs51.chmodSync)(path2, sticky ? 1533 : 509);
49707
- (0, import_node_child_process20.execSync)(`chgrp adm ${path2}`, { stdio: "ignore" });
50933
+ (0, import_node_fs53.chmodSync)(path2, sticky ? 1533 : 509);
50934
+ (0, import_node_child_process21.execSync)(`chgrp adm ${path2}`, { stdio: "ignore" });
49708
50935
  } else {
49709
- (0, import_node_fs51.chmodSync)(path2, 493);
50936
+ (0, import_node_fs53.chmodSync)(path2, 493);
49710
50937
  }
49711
50938
  } catch {
49712
50939
  }
@@ -49726,29 +50953,29 @@ async function uninstallServiceCommand() {
49726
50953
  return;
49727
50954
  }
49728
50955
  try {
49729
- (0, import_node_child_process20.execSync)("systemctl stop threatcrushd.service", { stdio: "inherit" });
50956
+ (0, import_node_child_process21.execSync)("systemctl stop threatcrushd.service", { stdio: "inherit" });
49730
50957
  } catch {
49731
50958
  }
49732
50959
  try {
49733
- (0, import_node_child_process20.execSync)("systemctl disable threatcrushd.service", { stdio: "inherit" });
50960
+ (0, import_node_child_process21.execSync)("systemctl disable threatcrushd.service", { stdio: "inherit" });
49734
50961
  } catch {
49735
50962
  }
49736
50963
  try {
49737
- if ((0, import_node_fs51.existsSync)(UNIT_PATH)) {
49738
- (0, import_node_child_process20.execSync)(`rm -f ${UNIT_PATH}`);
50964
+ if ((0, import_node_fs53.existsSync)(UNIT_PATH)) {
50965
+ (0, import_node_child_process21.execSync)(`rm -f ${UNIT_PATH}`);
49739
50966
  console.log(source_default.green(` \u2713 Removed unit file: ${UNIT_PATH}`));
49740
50967
  }
49741
50968
  } catch {
49742
50969
  }
49743
50970
  try {
49744
- (0, import_node_child_process20.execSync)("systemctl daemon-reload", { stdio: "inherit" });
50971
+ (0, import_node_child_process21.execSync)("systemctl daemon-reload", { stdio: "inherit" });
49745
50972
  } catch {
49746
50973
  }
49747
50974
  console.log(source_default.green(" \u2713 threatcrushd service removed."));
49748
50975
  }
49749
50976
 
49750
50977
  // src/commands/save.ts
49751
- var import_node_fs52 = require("fs");
50978
+ var import_node_fs54 = require("fs");
49752
50979
  var import_toml5 = __toESM(require_toml());
49753
50980
  init_cli_config();
49754
50981
  init_paths();
@@ -49787,9 +51014,9 @@ async function saveCommand(opts = {}) {
49787
51014
  }
49788
51015
  const path2 = opts.config ?? PATHS.configFile;
49789
51016
  let config = {};
49790
- if ((0, import_node_fs52.existsSync)(path2)) {
51017
+ if ((0, import_node_fs54.existsSync)(path2)) {
49791
51018
  try {
49792
- config = import_toml5.default.parse((0, import_node_fs52.readFileSync)(path2, "utf-8"));
51019
+ config = import_toml5.default.parse((0, import_node_fs54.readFileSync)(path2, "utf-8"));
49793
51020
  } catch (err) {
49794
51021
  console.log(source_default.red(` \u2717 ${path2} is not valid TOML: ${err.message}
49795
51022
  `));
@@ -49902,8 +51129,8 @@ function welcomeCommand() {
49902
51129
  }
49903
51130
 
49904
51131
  // src/commands/properties.ts
49905
- var import_node_fs53 = require("fs");
49906
- var import_node_path40 = require("path");
51132
+ var import_node_fs55 = require("fs");
51133
+ var import_node_path42 = require("path");
49907
51134
  var import_node_readline4 = __toESM(require("readline"));
49908
51135
  init_cli_config();
49909
51136
  var API_URL6 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
@@ -50233,8 +51460,8 @@ async function propertiesRunsCommand(opts) {
50233
51460
  }
50234
51461
  }
50235
51462
  function parseImportFile(path2) {
50236
- const ext = (0, import_node_path40.extname)(path2).toLowerCase();
50237
- const raw = (0, import_node_fs53.readFileSync)(path2, "utf-8");
51463
+ const ext = (0, import_node_path42.extname)(path2).toLowerCase();
51464
+ const raw = (0, import_node_fs55.readFileSync)(path2, "utf-8");
50238
51465
  if (ext === ".json") {
50239
51466
  const parsed = JSON.parse(raw);
50240
51467
  if (!Array.isArray(parsed)) throw new Error("JSON must be an array of objects");
@@ -50429,19 +51656,226 @@ async function rulesCommand(opts) {
50429
51656
  }
50430
51657
 
50431
51658
  // src/commands/harden.ts
50432
- var import_node_fs54 = require("fs");
50433
- var import_node_child_process21 = require("child_process");
51659
+ var import_node_fs57 = require("fs");
51660
+ var import_node_child_process22 = require("child_process");
50434
51661
  init_cli_config();
51662
+
51663
+ // src/commands/cis-report.ts
51664
+ var import_node_os16 = require("os");
51665
+ var import_node_fs56 = require("fs");
51666
+ var CIS_UBUNTU_URL = "https://www.cisecurity.org/benchmark/ubuntu_linux";
51667
+ var CIS_DEBIAN_URL = "https://www.cisecurity.org/benchmark/debian_linux";
51668
+ var UBUNTU_2404_CIS_CONTROL_SOURCE = "https://github.com/ComplianceAsCode/content/blob/v0.1.78/controls/cis_ubuntu2404.yml";
51669
+ var EDITIONS = {
51670
+ ubuntu: {
51671
+ "26.04": { version: "1.0.0", name: "CIS Ubuntu Linux 26.04 LTS", source: CIS_UBUNTU_URL },
51672
+ "24.04": { version: "2.0.0", name: "CIS Ubuntu Linux 24.04 LTS", source: CIS_UBUNTU_URL },
51673
+ "22.04": { version: "3.0.0", name: "CIS Ubuntu Linux 22.04 LTS", source: CIS_UBUNTU_URL },
51674
+ "20.04": { version: "3.0.0", name: "CIS Ubuntu Linux 20.04 LTS", source: CIS_UBUNTU_URL }
51675
+ },
51676
+ debian: {
51677
+ "13": { version: "1.1.0", name: "CIS Debian Linux 13", source: CIS_DEBIAN_URL },
51678
+ "12": { version: "2.0.0", name: "CIS Debian Linux 12", source: CIS_DEBIAN_URL },
51679
+ "11": { version: "2.0.0", name: "CIS Debian Linux 11", source: CIS_DEBIAN_URL }
51680
+ }
51681
+ };
51682
+ function osRelease() {
51683
+ let raw = "";
51684
+ try {
51685
+ raw = (0, import_node_fs56.readFileSync)("/etc/os-release", "utf8");
51686
+ } catch {
51687
+ return {};
51688
+ }
51689
+ const fields = {};
51690
+ for (const line2 of raw.split("\n")) {
51691
+ const match = /^([A-Z0-9_]+)=(.*)$/.exec(line2);
51692
+ if (!match) continue;
51693
+ const value = match[2].trim().replace(/^(["'])(.*)\1$/, "$2");
51694
+ fields[match[1]] = value;
51695
+ }
51696
+ return fields;
51697
+ }
51698
+ var VERIFIED_CHECK_MAPPINGS = {
51699
+ ubuntu: {
51700
+ "24.04": {
51701
+ "ssh-root-login": {
51702
+ ids: ["5.1.20"],
51703
+ source: UBUNTU_2404_CIS_CONTROL_SOURCE,
51704
+ osId: "ubuntu",
51705
+ osVersion: "24.04",
51706
+ benchmarkName: "CIS Ubuntu Linux 24.04 LTS",
51707
+ benchmarkVersion: "1.0.0"
51708
+ }
51709
+ }
51710
+ }
51711
+ };
51712
+ function tagCisMappings(findings2, os4 = osRelease()) {
51713
+ const distro = os4.ID?.toLowerCase() ?? "";
51714
+ const version = os4.VERSION_ID ?? "";
51715
+ const checkMappings = VERIFIED_CHECK_MAPPINGS[distro]?.[version] ?? {};
51716
+ return findings2.map((finding) => {
51717
+ const mapping = checkMappings[finding.key];
51718
+ const ids = mapping?.ids ?? [];
51719
+ const status = mapping ? "verified" : "unverified";
51720
+ return {
51721
+ ...finding,
51722
+ cis_control_ids: ids,
51723
+ cis_mapping_status: status,
51724
+ ...mapping ? { cis_mapping_source: mapping.source } : {},
51725
+ ...mapping ? { cis_mapping_benchmark: `${mapping.benchmarkName} v${mapping.benchmarkVersion}` } : {},
51726
+ details: {
51727
+ ...finding.details ?? {},
51728
+ cis_control_ids: ids,
51729
+ cis_mapping_status: status,
51730
+ ...mapping ? { cis_mapping_source: mapping.source } : {},
51731
+ ...mapping ? {
51732
+ cis_profile_os_id: mapping.osId,
51733
+ cis_profile_os_version: mapping.osVersion,
51734
+ cis_profile_name: mapping.benchmarkName,
51735
+ cis_profile_version: mapping.benchmarkVersion
51736
+ } : {}
51737
+ }
51738
+ };
51739
+ });
51740
+ }
51741
+ function buildCisEvidenceReport(findings2, score, now = /* @__PURE__ */ new Date()) {
51742
+ const os4 = osRelease();
51743
+ const id = os4.ID?.toLowerCase() ?? null;
51744
+ const version = os4.VERSION_ID ?? null;
51745
+ const edition = id && version ? EDITIONS[id]?.[version] : void 0;
51746
+ const checks = tagCisMappings(findings2, os4).map((finding) => ({
51747
+ ...finding,
51748
+ cis_control_ids: finding.cis_control_ids ?? [],
51749
+ mapping_status: finding.cis_mapping_status ?? "unverified",
51750
+ ...finding.cis_mapping_source ? { mapping_source: finding.cis_mapping_source } : {},
51751
+ ...finding.cis_mapping_benchmark ? { mapping_benchmark: finding.cis_mapping_benchmark } : {}
51752
+ }));
51753
+ const mappedControls = new Set(checks.flatMap((check2) => check2.mapping_status === "verified" ? check2.cis_control_ids : []));
51754
+ return {
51755
+ schema_version: 1,
51756
+ generated_at: now.toISOString(),
51757
+ benchmark_catalog_checked_at: "2026-11-01",
51758
+ host: { hostname: (0, import_node_os16.hostname)(), os_id: id, os_version: version, pretty_name: os4.PRETTY_NAME ?? null },
51759
+ benchmark: edition ? { name: edition.name, version: edition.version, source: edition.source } : null,
51760
+ assessment: "partial",
51761
+ mapped_controls: mappedControls.size,
51762
+ total_checks: findings2.length,
51763
+ hardening_score: score,
51764
+ checks,
51765
+ limitations: [
51766
+ "This report contains ThreatCrush hardening checks only; it does not assess a CIS Benchmark profile.",
51767
+ "The verified SSH mapping uses the CIS Ubuntu 24.04 LTS v1.0.0 implementation. The current CIS catalog lists v2.0.0; no mapping to v2.0.0 is claimed. Other checks remain unverified.",
51768
+ "A PASS is a result for the named ThreatCrush check, not a CIS control pass or a certification claim."
51769
+ ]
51770
+ };
51771
+ }
51772
+ function renderCisMarkdown(report) {
51773
+ const benchmark = report.benchmark ? `${report.benchmark.name} v${report.benchmark.version} (${report.benchmark.source})` : "No CIS Benchmark edition is known for this OS release";
51774
+ const rows2 = report.checks.map((check2) => {
51775
+ const facts = check2.details ? ` Observed data: ${JSON.stringify(check2.details)}` : "";
51776
+ const evidence = `${check2.explanation}${facts}`.replace(/[|\r\n]+/g, " ").trim();
51777
+ const recommendation2 = check2.recommendation?.replace(/[|\r\n]+/g, " ").trim() ?? "\u2014";
51778
+ const mapping = check2.cis_control_ids.length ? check2.cis_control_ids.join(", ") : "Unverified";
51779
+ const reference = [check2.mapping_benchmark, check2.mapping_source].filter(Boolean).join("; ");
51780
+ const source = reference ? ` (${reference})` : "";
51781
+ return `| ${check2.key} | ${check2.status.toUpperCase()} | ${mapping}${source} | ${evidence} | ${recommendation2} |`;
51782
+ });
51783
+ return [
51784
+ "# CIS benchmark evidence report",
51785
+ "",
51786
+ "> Partial ThreatCrush evidence only. This is not a CIS Benchmark assessment or certification report.",
51787
+ "",
51788
+ `- Generated: ${report.generated_at}`,
51789
+ `- CIS edition catalog checked: ${report.benchmark_catalog_checked_at}`,
51790
+ `- Host: ${report.host.hostname}`,
51791
+ `- OS: ${report.host.pretty_name ?? "unknown"} (${report.host.os_id ?? "unknown"} ${report.host.os_version ?? "unknown"})`,
51792
+ `- Benchmark edition: ${benchmark}`,
51793
+ `- ThreatCrush hardening score: ${report.hardening_score}/100`,
51794
+ `- Mapped CIS controls: ${report.mapped_controls}`,
51795
+ "",
51796
+ "| Check | Result | CIS mapping | Evidence | Recommendation |",
51797
+ "|---|---|---|---|---|",
51798
+ ...rows2,
51799
+ "",
51800
+ "## Limitations",
51801
+ "",
51802
+ ...report.limitations.map((limitation) => `- ${limitation}`),
51803
+ ""
51804
+ ].join("\n");
51805
+ }
51806
+ function pdfEscape(value) {
51807
+ return value.replace(/[^\x20-\x7e]/g, "?").replace(/[\\()]/g, "\\$&");
51808
+ }
51809
+ function renderCisPdf(markdown) {
51810
+ const lines = markdown.split("\n").flatMap((line2) => {
51811
+ const safe = line2.replace(/[^\x20-\x7e]/g, "?");
51812
+ if (safe.length <= 96) return [safe];
51813
+ const parts = [];
51814
+ for (let i = 0; i < safe.length; i += 96) parts.push(safe.slice(i, i + 96));
51815
+ return parts;
51816
+ });
51817
+ const pages = [];
51818
+ for (let i = 0; i < lines.length; i += 48) pages.push(lines.slice(i, i + 48));
51819
+ if (pages.length === 0) pages.push([]);
51820
+ const objects = [];
51821
+ const pageRefs = [];
51822
+ objects.push("<< /Type /Catalog /Pages 2 0 R >>");
51823
+ objects.push("");
51824
+ objects.push("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>");
51825
+ pages.forEach((page, index) => {
51826
+ const pageId = 4 + index * 2;
51827
+ const streamId = pageId + 1;
51828
+ pageRefs.push(`${pageId} 0 R`);
51829
+ const text = ["BT", "/F1 9 Tf", "50 760 Td", "14 TL", ...page.flatMap((line2) => [`(${pdfEscape(line2)}) Tj`, "T*"]), "ET"].join("\n");
51830
+ objects.push(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 3 0 R >> >> /Contents ${streamId} 0 R >>`);
51831
+ objects.push(`<< /Length ${Buffer.byteLength(text, "ascii")} >>
51832
+ stream
51833
+ ${text}
51834
+ endstream`);
51835
+ });
51836
+ objects[1] = `<< /Type /Pages /Kids [${pageRefs.join(" ")}] /Count ${pages.length} >>`;
51837
+ let pdf = "%PDF-1.4\n";
51838
+ const offsets = [0];
51839
+ objects.forEach((object, index) => {
51840
+ offsets.push(Buffer.byteLength(pdf, "ascii"));
51841
+ pdf += `${index + 1} 0 obj
51842
+ ${object}
51843
+ endobj
51844
+ `;
51845
+ });
51846
+ const xref = Buffer.byteLength(pdf, "ascii");
51847
+ pdf += `xref
51848
+ 0 ${objects.length + 1}
51849
+ 0000000000 65535 f
51850
+ `;
51851
+ for (const offset of offsets.slice(1)) pdf += `${String(offset).padStart(10, "0")} 00000 n
51852
+ `;
51853
+ pdf += `trailer
51854
+ << /Size ${objects.length + 1} /Root 1 0 R >>
51855
+ startxref
51856
+ ${xref}
51857
+ %%EOF
51858
+ `;
51859
+ return Buffer.from(pdf, "ascii");
51860
+ }
51861
+ function writeCisReport(path2, format2, report) {
51862
+ const markdown = renderCisMarkdown(report);
51863
+ const content = format2 === "json" ? `${JSON.stringify(report, null, 2)}
51864
+ ` : format2 === "pdf" ? renderCisPdf(markdown) : markdown;
51865
+ (0, import_node_fs56.writeFileSync)(path2, content);
51866
+ }
51867
+
51868
+ // src/commands/harden.ts
50435
51869
  function tryExec(cmd) {
50436
51870
  try {
50437
- return (0, import_node_child_process21.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
51871
+ return (0, import_node_child_process22.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
50438
51872
  } catch {
50439
51873
  return null;
50440
51874
  }
50441
51875
  }
50442
51876
  function tryRead(path2) {
50443
51877
  try {
50444
- return (0, import_node_fs54.readFileSync)(path2, "utf-8");
51878
+ return (0, import_node_fs57.readFileSync)(path2, "utf-8");
50445
51879
  } catch {
50446
51880
  return null;
50447
51881
  }
@@ -50478,34 +51912,44 @@ function checkSshPasswordAuth() {
50478
51912
  };
50479
51913
  }
50480
51914
  function checkSshRootLogin() {
50481
- const config = tryRead("/etc/ssh/sshd_config");
50482
- if (!config) {
51915
+ const effective = tryExec("sshd -T 2>/dev/null");
51916
+ if (!effective) {
50483
51917
  return {
50484
51918
  key: "ssh-root-login",
50485
51919
  status: "warn",
50486
51920
  severity: "high",
50487
51921
  title: "SSH Root Login",
50488
- explanation: "Could not read sshd_config.",
51922
+ explanation: "Could not read the effective sshd configuration with `sshd -T`.",
50489
51923
  recommendation: 'Set "PermitRootLogin no" in /etc/ssh/sshd_config.'
50490
51924
  };
50491
51925
  }
50492
- const match = config.match(/^\s*PermitRootLogin\s+(\S+)/mi);
50493
- if (!match || match[1] === "yes") {
51926
+ const match = effective.match(/^permitrootlogin\s+(\S+)/mi);
51927
+ if (!match) {
51928
+ return {
51929
+ key: "ssh-root-login",
51930
+ status: "warn",
51931
+ severity: "high",
51932
+ title: "SSH Root Login",
51933
+ explanation: "The effective sshd output did not include PermitRootLogin.",
51934
+ recommendation: 'Set "PermitRootLogin no" in the effective SSH server configuration.'
51935
+ };
51936
+ }
51937
+ if (match[1].toLowerCase() !== "no") {
50494
51938
  return {
50495
51939
  key: "ssh-root-login",
50496
51940
  status: "fail",
50497
51941
  severity: "high",
50498
- title: "Root SSH Login Enabled",
50499
- explanation: "Direct root login via SSH is permitted. Attackers frequently target root.",
50500
- recommendation: 'Set "PermitRootLogin no" or "PermitRootLogin prohibit-password" in /etc/ssh/sshd_config.'
51942
+ title: "Root SSH Login Not Fully Disabled",
51943
+ explanation: `The effective PermitRootLogin value is "${match[1]}"; CIS requires it to be "no".`,
51944
+ recommendation: 'Set "PermitRootLogin no" in the effective SSH server configuration.'
50501
51945
  };
50502
51946
  }
50503
51947
  return {
50504
51948
  key: "ssh-root-login",
50505
51949
  status: "pass",
50506
51950
  severity: "high",
50507
- title: "Root SSH Login Restricted",
50508
- explanation: `PermitRootLogin is set to "${match[1]}".`
51951
+ title: "Root SSH Login Disabled",
51952
+ explanation: 'The effective PermitRootLogin value is "no".'
50509
51953
  };
50510
51954
  }
50511
51955
  function checkSshWeakConfig() {
@@ -50545,8 +51989,8 @@ function checkSshWeakConfig() {
50545
51989
  };
50546
51990
  }
50547
51991
  function checkAutoUpdates() {
50548
- const unattended = (0, import_node_fs54.existsSync)("/etc/apt/apt.conf.d/20auto-upgrades") || (0, import_node_fs54.existsSync)("/etc/apt/apt.conf.d/50unattended-upgrades");
50549
- const dnfAuto = (0, import_node_fs54.existsSync)("/etc/dnf/automatic.conf");
51992
+ const unattended = (0, import_node_fs57.existsSync)("/etc/apt/apt.conf.d/20auto-upgrades") || (0, import_node_fs57.existsSync)("/etc/apt/apt.conf.d/50unattended-upgrades");
51993
+ const dnfAuto = (0, import_node_fs57.existsSync)("/etc/dnf/automatic.conf");
50550
51994
  if (unattended || dnfAuto) {
50551
51995
  return {
50552
51996
  key: "auto-updates",
@@ -50672,7 +52116,7 @@ function checkFail2ban() {
50672
52116
  explanation: "fail2ban is installed and running."
50673
52117
  };
50674
52118
  }
50675
- if ((0, import_node_fs54.existsSync)("/etc/fail2ban/fail2ban.conf")) {
52119
+ if ((0, import_node_fs57.existsSync)("/etc/fail2ban/fail2ban.conf")) {
50676
52120
  return {
50677
52121
  key: checkKey,
50678
52122
  status: "warn",
@@ -50772,6 +52216,9 @@ function computeScore(results) {
50772
52216
  if (maxScore === 0) return 100;
50773
52217
  return Math.max(0, Math.round((maxScore - deductions) / maxScore * 100));
50774
52218
  }
52219
+ function cisLabel(result) {
52220
+ return result.cis_control_ids?.length ? `CIS ${result.cis_mapping_benchmark ?? "mapping"}: ${result.cis_control_ids.join(", ")}` : "CIS: mapping unverified";
52221
+ }
50775
52222
  async function uploadFindings(results, json2) {
50776
52223
  const say = (line2) => json2 ? console.error(line2) : console.log(line2);
50777
52224
  const link = currentLink();
@@ -50806,14 +52253,42 @@ async function uploadFindings(results, json2) {
50806
52253
  say("");
50807
52254
  }
50808
52255
  async function hardenCommand(opts) {
50809
- if (!opts.json) {
52256
+ if (!opts.json && !opts.report) {
50810
52257
  banner();
50811
52258
  logger.info("Running hardening scan...\n");
50812
52259
  }
50813
- const spinner = opts.json ? null : ora({ text: "Scanning system configuration...", color: "green" }).start();
50814
- const results = runAllChecks();
52260
+ const spinner = opts.json || opts.report ? null : ora({ text: "Scanning system configuration...", color: "green" }).start();
52261
+ const results = tagCisMappings(runAllChecks());
50815
52262
  const score = computeScore(results);
50816
52263
  if (spinner) spinner.succeed("Hardening scan complete\n");
52264
+ if (opts.report) {
52265
+ if (opts.report !== "cis") {
52266
+ console.error(source_default.red(` Unknown report framework "${opts.report}". Use cis.`));
52267
+ process.exitCode = 1;
52268
+ return;
52269
+ }
52270
+ const format2 = opts.format ?? (opts.json ? "json" : "md");
52271
+ if (format2 !== "md" && format2 !== "pdf" && format2 !== "json") {
52272
+ console.error(source_default.red(` Unknown report format "${format2}". Use md, pdf, or json.`));
52273
+ process.exitCode = 1;
52274
+ return;
52275
+ }
52276
+ if (format2 === "pdf" && !opts.output) {
52277
+ console.error(source_default.red(" PDF output requires --output <path>."));
52278
+ process.exitCode = 1;
52279
+ return;
52280
+ }
52281
+ const report = buildCisEvidenceReport(results, score);
52282
+ if (opts.output) {
52283
+ writeCisReport(opts.output, format2, report);
52284
+ console.error(source_default.green(` Wrote partial CIS evidence report to ${opts.output}`));
52285
+ } else {
52286
+ const markdown = renderCisMarkdown(report);
52287
+ console.log(format2 === "json" ? JSON.stringify(report, null, 2) : markdown);
52288
+ }
52289
+ if (opts.upload !== false) await uploadFindings(results, true);
52290
+ return;
52291
+ }
50817
52292
  if (opts.json) {
50818
52293
  console.log(JSON.stringify({ score, findings: results }, null, 2));
50819
52294
  if (opts.upload !== false) await uploadFindings(results, true);
@@ -50831,6 +52306,7 @@ async function hardenCommand(opts) {
50831
52306
  for (const r of fails) {
50832
52307
  console.log(` ${source_default.red("\u2717")} ${source_default.white.bold(r.title)}`);
50833
52308
  console.log(` ${source_default.gray(r.explanation)}`);
52309
+ console.log(` ${source_default.gray(cisLabel(r))}`);
50834
52310
  if (r.recommendation) console.log(` ${source_default.yellow("Fix:")} ${r.recommendation}`);
50835
52311
  console.log();
50836
52312
  }
@@ -50840,6 +52316,7 @@ async function hardenCommand(opts) {
50840
52316
  for (const r of warns) {
50841
52317
  console.log(` ${source_default.yellow("!")} ${source_default.white.bold(r.title)}`);
50842
52318
  console.log(` ${source_default.gray(r.explanation)}`);
52319
+ console.log(` ${source_default.gray(cisLabel(r))}`);
50843
52320
  if (r.recommendation) console.log(` ${source_default.yellow("Fix:")} ${r.recommendation}`);
50844
52321
  console.log();
50845
52322
  }
@@ -50848,6 +52325,7 @@ async function hardenCommand(opts) {
50848
52325
  console.log(source_default.green.bold(" PASS"));
50849
52326
  for (const r of passes) {
50850
52327
  console.log(` ${source_default.green("\u2713")} ${source_default.white(r.title)}`);
52328
+ console.log(` ${source_default.gray(cisLabel(r))}`);
50851
52329
  }
50852
52330
  console.log();
50853
52331
  }
@@ -50858,9 +52336,9 @@ async function hardenCommand(opts) {
50858
52336
  }
50859
52337
 
50860
52338
  // src/core/patches/index.ts
50861
- var import_node_fs55 = require("fs");
50862
- var import_node_path41 = require("path");
50863
- var import_node_child_process22 = require("child_process");
52339
+ var import_node_fs58 = require("fs");
52340
+ var import_node_path43 = require("path");
52341
+ var import_node_child_process23 = require("child_process");
50864
52342
  var import_node_util5 = require("util");
50865
52343
 
50866
52344
  // src/core/patches/dpkg-version.ts
@@ -50920,7 +52398,7 @@ var STALE_AFTER_MS = 2 * 864e5;
50920
52398
  var SEVERITIES2 = ["info", "low", "medium", "high", "critical"];
50921
52399
  var RANK = { info: 0, low: 1, medium: 2, high: 3, critical: 4 };
50922
52400
  var defaultExec = async (file, args) => {
50923
- const { stdout } = await (0, import_node_util5.promisify)(import_node_child_process22.execFile)(file, args, {
52401
+ const { stdout } = await (0, import_node_util5.promisify)(import_node_child_process23.execFile)(file, args, {
50924
52402
  timeout: 12e4,
50925
52403
  maxBuffer: 32 * 1024 * 1024,
50926
52404
  env: { ...process.env, LC_ALL: "C" }
@@ -51019,9 +52497,9 @@ async function osvRecords(doFetch, ecosystem, source, version) {
51019
52497
  function newestReleaseMtime(dir) {
51020
52498
  try {
51021
52499
  let newest = 0;
51022
- for (const name of (0, import_node_fs55.readdirSync)(dir)) {
52500
+ for (const name of (0, import_node_fs58.readdirSync)(dir)) {
51023
52501
  if (!/Release$/.test(name)) continue;
51024
- newest = Math.max(newest, (0, import_node_fs55.statSync)((0, import_node_path41.join)(dir, name)).mtimeMs);
52502
+ newest = Math.max(newest, (0, import_node_fs58.statSync)((0, import_node_path43.join)(dir, name)).mtimeMs);
51025
52503
  }
51026
52504
  return newest > 0 ? new Date(newest) : null;
51027
52505
  } catch {
@@ -51038,7 +52516,7 @@ async function checkPatches(opts = {}) {
51038
52516
  let osText = opts.osRelease;
51039
52517
  if (osText === void 0) {
51040
52518
  try {
51041
- osText = (0, import_node_fs55.readFileSync)("/etc/os-release", "utf-8");
52519
+ osText = (0, import_node_fs58.readFileSync)("/etc/os-release", "utf-8");
51042
52520
  } catch {
51043
52521
  osText = "";
51044
52522
  }
@@ -51265,26 +52743,26 @@ async function patchesCommand(opts) {
51265
52743
 
51266
52744
  // src/commands/feeds.ts
51267
52745
  var import_node_net18 = require("net");
51268
- var import_node_path43 = require("path");
52746
+ var import_node_path45 = require("path");
51269
52747
  init_paths();
51270
52748
 
51271
52749
  // src/commands/feeds-resolver.ts
51272
- var import_node_child_process23 = require("child_process");
51273
- var import_node_fs56 = require("fs");
51274
- var import_node_path42 = require("path");
52750
+ var import_node_child_process24 = require("child_process");
52751
+ var import_node_fs59 = require("fs");
52752
+ var import_node_path44 = require("path");
51275
52753
  var realIO = {
51276
- exists: (p) => (0, import_node_fs56.existsSync)(p),
52754
+ exists: (p) => (0, import_node_fs59.existsSync)(p),
51277
52755
  read: (p) => {
51278
52756
  try {
51279
- return (0, import_node_fs56.readFileSync)(p, "utf-8");
52757
+ return (0, import_node_fs59.readFileSync)(p, "utf-8");
51280
52758
  } catch {
51281
52759
  return null;
51282
52760
  }
51283
52761
  },
51284
- write: (p, c) => (0, import_node_fs56.writeFileSync)(p, c),
51285
- remove: (p) => (0, import_node_fs56.rmSync)(p, { force: true }),
52762
+ write: (p, c) => (0, import_node_fs59.writeFileSync)(p, c),
52763
+ remove: (p) => (0, import_node_fs59.rmSync)(p, { force: true }),
51286
52764
  run: (cmd, args) => {
51287
- const r = (0, import_node_child_process23.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 3e4 });
52765
+ const r = (0, import_node_child_process24.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 3e4 });
51288
52766
  return { code: r.status ?? 1, out: `${r.stdout ?? ""}${r.stderr ?? ""}`.trim() };
51289
52767
  }
51290
52768
  };
@@ -51292,17 +52770,17 @@ var APPARMOR_LOCAL = "/etc/apparmor.d/local/usr.sbin.unbound";
51292
52770
  var APPARMOR_PROFILE = "/etc/apparmor.d/usr.sbin.unbound";
51293
52771
  function hookContent(resolver, stateDir) {
51294
52772
  const head = "# Installed by `threatcrush feeds resolver install`; `threatcrush feeds resolver remove` takes it out.\n";
51295
- return resolver === "dnsmasq" ? `${head}addn-hosts=${(0, import_node_path42.join)(stateDir, RESOLVER_FILES.hosts)}
51296
- ` : `${head}include: "${(0, import_node_path42.join)(stateDir, RESOLVER_FILES.unbound)}"
52773
+ return resolver === "dnsmasq" ? `${head}addn-hosts=${(0, import_node_path44.join)(stateDir, RESOLVER_FILES.hosts)}
52774
+ ` : `${head}include: "${(0, import_node_path44.join)(stateDir, RESOLVER_FILES.unbound)}"
51297
52775
  `;
51298
52776
  }
51299
52777
  function apparmorRule(stateDir) {
51300
- return ` ${(0, import_node_path42.join)(stateDir, RESOLVER_FILES.unbound)} r, # threatcrush`;
52778
+ return ` ${(0, import_node_path44.join)(stateDir, RESOLVER_FILES.unbound)} r, # threatcrush`;
51301
52779
  }
51302
52780
  function detectResolvers(io = realIO) {
51303
52781
  const found = [];
51304
- if (io.exists((0, import_node_path42.dirname)(RESOLVER_HOOKS.dnsmasq)) && io.run("dnsmasq", ["--version"]).code === 0) found.push("dnsmasq");
51305
- if (io.exists((0, import_node_path42.dirname)(RESOLVER_HOOKS.unbound)) && io.run("unbound-checkconf", ["-h"]).code !== 127) found.push("unbound");
52782
+ if (io.exists((0, import_node_path44.dirname)(RESOLVER_HOOKS.dnsmasq)) && io.run("dnsmasq", ["--version"]).code === 0) found.push("dnsmasq");
52783
+ if (io.exists((0, import_node_path44.dirname)(RESOLVER_HOOKS.unbound)) && io.run("unbound-checkconf", ["-h"]).code !== 127) found.push("unbound");
51306
52784
  return found;
51307
52785
  }
51308
52786
  function check(resolver, io) {
@@ -51315,7 +52793,7 @@ function restartIfActive(resolver, io) {
51315
52793
  }
51316
52794
  function installHook(resolver, stateDir, io = realIO) {
51317
52795
  const hook = RESOLVER_HOOKS[resolver];
51318
- const file = (0, import_node_path42.join)(stateDir, resolver === "dnsmasq" ? RESOLVER_FILES.hosts : RESOLVER_FILES.unbound);
52796
+ const file = (0, import_node_path44.join)(stateDir, resolver === "dnsmasq" ? RESOLVER_FILES.hosts : RESOLVER_FILES.unbound);
51319
52797
  if (!io.exists(file)) io.write(file, resolver === "dnsmasq" ? hostsBlocklist([]) : unboundBlocklist([]));
51320
52798
  io.write(hook, hookContent(resolver, stateDir));
51321
52799
  if (resolver === "unbound" && io.exists(APPARMOR_LOCAL)) {
@@ -51376,8 +52854,8 @@ function resolverCommand(sub, stateDir, io = realIO) {
51376
52854
  }
51377
52855
  return failed ? 1 : 0;
51378
52856
  }
51379
- const hosts = io.read((0, import_node_path42.join)(stateDir, RESOLVER_FILES.hosts));
51380
- const unbound = io.read((0, import_node_path42.join)(stateDir, RESOLVER_FILES.unbound));
52857
+ const hosts = io.read((0, import_node_path44.join)(stateDir, RESOLVER_FILES.hosts));
52858
+ const unbound = io.read((0, import_node_path44.join)(stateDir, RESOLVER_FILES.unbound));
51381
52859
  console.log(` resolvers here: ${found.join(", ") || "none that can block (systemd-resolved only?)"}`);
51382
52860
  for (const r of ["dnsmasq", "unbound"]) {
51383
52861
  console.log(` ${r.padEnd(8)} hook ${io.exists(RESOLVER_HOOKS[r]) ? source_default.green("installed") : source_default.gray("not installed")}`);
@@ -51389,11 +52867,11 @@ function resolverCommand(sub, stateDir, io = realIO) {
51389
52867
  // src/commands/feeds.ts
51390
52868
  async function loadSet() {
51391
52869
  for (const dir of [SYSTEM_PATHS.stateDir, USER_PATHS.stateDir]) {
51392
- const path2 = (0, import_node_path43.join)(dir, "threat-feeds.json");
52870
+ const path2 = (0, import_node_path45.join)(dir, "threat-feeds.json");
51393
52871
  const set = readFeedCache(path2);
51394
52872
  if (set) return { set, from: path2 };
51395
52873
  }
51396
- const settings = threatFeedSettings(loadConfig((0, import_node_path43.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).threat_feeds);
52874
+ const settings = threatFeedSettings(loadConfig((0, import_node_path45.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).threat_feeds);
51397
52875
  return { set: await fetchFeeds(settings), from: "abuse.ch (live; no daemon cache readable)" };
51398
52876
  }
51399
52877
  async function feedsCommand(action, value, opts) {
@@ -51437,21 +52915,21 @@ async function feedsCommand(action, value, opts) {
51437
52915
  }
51438
52916
 
51439
52917
  // src/commands/tor.ts
51440
- var import_node_fs57 = require("fs");
52918
+ var import_node_fs60 = require("fs");
51441
52919
  var import_node_net19 = require("net");
51442
- var import_node_path44 = require("path");
52920
+ var import_node_path46 = require("path");
51443
52921
  init_paths();
51444
52922
  async function torCommand(action, value, opts) {
51445
52923
  let exits = /* @__PURE__ */ new Set();
51446
52924
  let from = "";
51447
52925
  let updated = null;
51448
52926
  for (const dir of [SYSTEM_PATHS.stateDir, USER_PATHS.stateDir]) {
51449
- const path2 = (0, import_node_path44.join)(dir, "tor-exits.txt");
52927
+ const path2 = (0, import_node_path46.join)(dir, "tor-exits.txt");
51450
52928
  try {
51451
- if (!(0, import_node_fs57.existsSync)(path2)) continue;
51452
- exits = parseTorExitList((0, import_node_fs57.readFileSync)(path2, "utf-8"));
52929
+ if (!(0, import_node_fs60.existsSync)(path2)) continue;
52930
+ exits = parseTorExitList((0, import_node_fs60.readFileSync)(path2, "utf-8"));
51453
52931
  from = path2;
51454
- updated = (0, import_node_fs57.statSync)(path2).mtime;
52932
+ updated = (0, import_node_fs60.statSync)(path2).mtime;
51455
52933
  break;
51456
52934
  } catch {
51457
52935
  }
@@ -51467,7 +52945,7 @@ async function torCommand(action, value, opts) {
51467
52945
  } catch {
51468
52946
  }
51469
52947
  }
51470
- const remediation = loadConfig((0, import_node_path44.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).remediation;
52948
+ const remediation = loadConfig((0, import_node_path46.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).remediation;
51471
52949
  const ban = remediation?.block_tor_ssh !== false && remediation?.enabled !== false;
51472
52950
  if (action === "check") {
51473
52951
  if (!value || !(0, import_node_net19.isIP)(value)) {
@@ -51498,14 +52976,14 @@ async function torCommand(action, value, opts) {
51498
52976
  }
51499
52977
 
51500
52978
  // src/commands/reputation.ts
51501
- var import_node_os16 = require("os");
51502
- var import_node_fs58 = require("fs");
51503
- var import_node_path45 = require("path");
52979
+ var import_node_os17 = require("os");
52980
+ var import_node_fs61 = require("fs");
52981
+ var import_node_path47 = require("path");
51504
52982
  var API_URL7 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
51505
- var CONFIG_PATH4 = (0, import_node_path45.join)((0, import_node_os16.homedir)(), ".threatcrush", "config.json");
52983
+ var CONFIG_PATH4 = (0, import_node_path47.join)((0, import_node_os17.homedir)(), ".threatcrush", "config.json");
51506
52984
  function readConfig3() {
51507
52985
  try {
51508
- return JSON.parse((0, import_node_fs58.readFileSync)(CONFIG_PATH4, "utf-8"));
52986
+ return JSON.parse((0, import_node_fs61.readFileSync)(CONFIG_PATH4, "utf-8"));
51509
52987
  } catch {
51510
52988
  return {};
51511
52989
  }
@@ -51693,7 +53171,7 @@ async function reputationSubscribeCommand(opts) {
51693
53171
  }
51694
53172
 
51695
53173
  // src/commands/privileged.ts
51696
- var import_node_fs59 = require("fs");
53174
+ var import_node_fs62 = require("fs");
51697
53175
  init_paths();
51698
53176
  var SEV2 = {
51699
53177
  critical: source_default.red.bold,
@@ -51706,19 +53184,19 @@ async function privilegedCommand(opts) {
51706
53184
  const snapshot = takeSnapshot({
51707
53185
  readFile: (p) => {
51708
53186
  try {
51709
- return (0, import_node_fs59.readFileSync)(p, "utf-8");
53187
+ return (0, import_node_fs62.readFileSync)(p, "utf-8");
51710
53188
  } catch {
51711
53189
  return null;
51712
53190
  }
51713
53191
  },
51714
53192
  readDir: (p) => {
51715
53193
  try {
51716
- return (0, import_node_fs59.readdirSync)(p);
53194
+ return (0, import_node_fs62.readdirSync)(p);
51717
53195
  } catch {
51718
53196
  return null;
51719
53197
  }
51720
53198
  },
51721
- exists: (p) => (0, import_node_fs59.existsSync)(p)
53199
+ exists: (p) => (0, import_node_fs62.existsSync)(p)
51722
53200
  });
51723
53201
  let events = [];
51724
53202
  let ledgerNote = "";
@@ -51759,6 +53237,259 @@ async function privilegedCommand(opts) {
51759
53237
  console.log();
51760
53238
  }
51761
53239
 
53240
+ // src/commands/integrity.ts
53241
+ var import_node_fs63 = require("fs");
53242
+ var import_node_path48 = require("path");
53243
+ init_paths();
53244
+ function readState2(path2) {
53245
+ try {
53246
+ return JSON.parse((0, import_node_fs63.readFileSync)(path2, "utf8"));
53247
+ } catch {
53248
+ return null;
53249
+ }
53250
+ }
53251
+ function changedCount(baseline, observed) {
53252
+ if (!baseline?.files || !observed?.files) return 0;
53253
+ const paths = /* @__PURE__ */ new Set([...Object.keys(baseline.files), ...Object.keys(observed.files)]);
53254
+ let changed = 0;
53255
+ for (const path2 of paths) {
53256
+ const normalizeSignature = (value) => value.replace(/;entropy=\d+(?:\.\d+)?$/, "");
53257
+ const before2 = baseline.files[path2] ?? "missing";
53258
+ const after = observed.files[path2] ?? "missing";
53259
+ if (normalizeSignature(before2) !== normalizeSignature(after)) changed++;
53260
+ }
53261
+ return changed;
53262
+ }
53263
+ async function integrityCommand(action = "status", opts = {}) {
53264
+ const config = loadConfig();
53265
+ const settings = fileIntegritySettings(config.file_integrity);
53266
+ const systemBaseline = (0, import_node_path48.join)(SYSTEM_PATHS.stateDir, "file-integrity-baseline.json");
53267
+ const useSystemState = PATHS.mode === "system" || systemDaemonPresent() || (0, import_node_fs63.existsSync)(systemBaseline);
53268
+ const stateDir = useSystemState ? SYSTEM_PATHS.stateDir : PATHS.stateDir;
53269
+ const baselinePath = (0, import_node_path48.join)(stateDir, "file-integrity-baseline.json");
53270
+ const observedPath = (0, import_node_path48.join)(stateDir, "file-integrity-observed.json");
53271
+ if (action === "rebaseline") {
53272
+ const watch3 = new FileIntegrityWatch({
53273
+ bus: { publish: () => void 0 },
53274
+ settings,
53275
+ baselinePath,
53276
+ observedPath,
53277
+ log: (line2) => {
53278
+ if (!opts.json) console.log(source_default.gray(` ${line2}`));
53279
+ }
53280
+ });
53281
+ let result;
53282
+ try {
53283
+ result = await watch3.rebaseline();
53284
+ } catch (error2) {
53285
+ result = { ok: false, files: 0, reason: error2.message };
53286
+ }
53287
+ if (opts.json) console.log(JSON.stringify({ action, ...result }, null, 2));
53288
+ else if (result.ok) console.log(source_default.green(` Baseline refreshed for ${result.files} file(s).`));
53289
+ else console.error(source_default.red(` Could not refresh the baseline: ${result.reason}.`));
53290
+ if (!result.ok) process.exitCode = 1;
53291
+ return;
53292
+ }
53293
+ if (action !== "status") {
53294
+ console.error(source_default.red(` Unknown action "${action}". Use status or rebaseline.`));
53295
+ process.exitCode = 1;
53296
+ return;
53297
+ }
53298
+ const baseline = readState2(baselinePath);
53299
+ const observed = readState2(observedPath);
53300
+ const configuredTargets = [.../* @__PURE__ */ new Set([...settings.paths, ...settings.canaries, ...settings.canaryDirectories.map(autoCanaryPath)])];
53301
+ const scopeMatches = !baseline?.targets || baseline.targets.length === configuredTargets.length && [...baseline.targets].sort().every((path2, index) => path2 === [...configuredTargets].sort()[index]);
53302
+ const report = {
53303
+ enabled: settings.enabled,
53304
+ paths: settings.paths,
53305
+ canaries: settings.canaries,
53306
+ canary_directories: settings.canaryDirectories,
53307
+ poll_interval_seconds: settings.pollMs / 1e3,
53308
+ baseline_at: baseline?.created_at ?? null,
53309
+ files_monitored: Object.keys(baseline?.files ?? {}).length,
53310
+ changed_files: scopeMatches ? changedCount(baseline, observed) : null,
53311
+ scope_matches: scopeMatches,
53312
+ baseline_available: baseline !== null,
53313
+ state_path: baselinePath
53314
+ };
53315
+ if (opts.json) {
53316
+ console.log(JSON.stringify(report, null, 2));
53317
+ return;
53318
+ }
53319
+ console.log(` ${source_default.white.bold("File integrity")} ${report.enabled ? source_default.green("enabled") : source_default.gray("disabled")}`);
53320
+ if (report.paths.length) console.log(` Paths: ${report.paths.join(", ")}`);
53321
+ if (report.canaries.length) console.log(` Canary files: ${report.canaries.join(", ")}`);
53322
+ if (settings.canaryDirectories.length) console.log(` Canary directories: ${settings.canaryDirectories.join(", ")}`);
53323
+ console.log(` Poll interval: ${report.poll_interval_seconds}s`);
53324
+ if (!baseline) {
53325
+ console.log(source_default.gray(` No baseline at ${baselinePath}. Enable monitoring and start the daemon to record one.`));
53326
+ } else {
53327
+ console.log(` Baseline: ${report.baseline_at} (${report.files_monitored} files)`);
53328
+ if (!report.scope_matches) console.log(source_default.yellow(" Configured paths changed; run rebaseline after reviewing the new scope."));
53329
+ else {
53330
+ console.log(` Current differences: ${report.changed_files}`);
53331
+ if (report.changed_files) console.log(source_default.yellow(" Review the daemon event log; refresh only after confirming the changes are expected."));
53332
+ }
53333
+ }
53334
+ console.log(source_default.gray(" Hashes and file contents stay local. Rebaseline: sudo threatcrush integrity rebaseline"));
53335
+ }
53336
+
53337
+ // src/commands/edr.ts
53338
+ var import_node_fs65 = require("fs");
53339
+ init_paths();
53340
+
53341
+ // src/daemon/auditd/rules.ts
53342
+ var import_node_fs64 = require("fs");
53343
+ var import_node_child_process25 = require("child_process");
53344
+ var import_node_path49 = require("path");
53345
+ var WEB_TOOLS = ["sh", "bash", "dash", "zsh", "curl", "wget"];
53346
+ var MINER_NAMES = ["xmrig", "minerd", "cpuminer", "cpuminer-multi", "kdevtmpfsi", "kinsing", "cryptonight"];
53347
+ var CONNECT_KEY2 = "threatcrush_edr_connect";
53348
+ var LISTEN_KEY2 = "threatcrush_edr_listen";
53349
+ function passwdByName() {
53350
+ let raw = "";
53351
+ try {
53352
+ raw = (0, import_node_child_process25.execFileSync)("getent", ["passwd"], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
53353
+ } catch {
53354
+ try {
53355
+ raw = (0, import_node_fs64.readFileSync)("/etc/passwd", "utf8");
53356
+ } catch {
53357
+ return /* @__PURE__ */ new Map();
53358
+ }
53359
+ }
53360
+ const out = /* @__PURE__ */ new Map();
53361
+ for (const line2 of raw.split("\n")) {
53362
+ const fields = line2.split(":");
53363
+ const uid = Number(fields[2]);
53364
+ if (fields[0] && Number.isInteger(uid)) out.set(fields[0], uid);
53365
+ }
53366
+ return out;
53367
+ }
53368
+ function existingExecutables(names) {
53369
+ const paths = /* @__PURE__ */ new Set();
53370
+ for (const name of names) {
53371
+ for (const prefix of ["/bin", "/usr/bin", "/usr/local/bin"]) {
53372
+ const candidate = `${prefix}/${name}`;
53373
+ try {
53374
+ if (!(0, import_node_fs64.existsSync)(candidate) || !(0, import_node_fs64.statSync)(candidate).isFile()) continue;
53375
+ paths.add((0, import_node_fs64.realpathSync)(candidate));
53376
+ } catch {
53377
+ }
53378
+ }
53379
+ }
53380
+ return [...paths].sort();
53381
+ }
53382
+ function existingDirectories(paths) {
53383
+ return [...new Set(paths)].filter((path2) => {
53384
+ if (!(0, import_node_path49.isAbsolute)(path2) || /[\s\r\n]/.test(path2)) return false;
53385
+ try {
53386
+ return (0, import_node_fs64.statSync)(path2).isDirectory();
53387
+ } catch {
53388
+ return false;
53389
+ }
53390
+ }).sort();
53391
+ }
53392
+ function generateAuditRules(settings) {
53393
+ const rules = /* @__PURE__ */ new Set();
53394
+ const warnings = [];
53395
+ const ids = passwdByName();
53396
+ const serviceIds = [...new Set(settings.webServiceUsers.flatMap((name) => {
53397
+ const uid = ids.get(name);
53398
+ return uid === void 0 ? [] : [uid];
53399
+ }))].sort((a, b) => a - b);
53400
+ const missingUsers = settings.webServiceUsers.filter((name) => !ids.has(name));
53401
+ if (missingUsers.length) warnings.push(`service account(s) not found in /etc/passwd: ${missingUsers.join(", ")}`);
53402
+ if (serviceIds.length === 0) warnings.push("no web-service account UIDs resolved; web child-process rules were not generated");
53403
+ const architectures = process.arch === "x64" ? ["b64", "b32"] : process.arch === "ia32" ? ["b32"] : ["b64"];
53404
+ const tools = existingExecutables(WEB_TOOLS);
53405
+ for (const arch of architectures) {
53406
+ for (const uid of serviceIds) {
53407
+ for (const executable of tools) {
53408
+ rules.add(`-a always,exit -F arch=${arch} -S execve,execveat -F success=1 -F euid=${uid} -F exe=${executable} -k threatcrush_edr_web`);
53409
+ }
53410
+ }
53411
+ for (const directory of existingDirectories(settings.tempExecPaths)) {
53412
+ rules.add(`-a always,exit -F arch=${arch} -F dir=${directory} -F perm=x -k threatcrush_edr_temp`);
53413
+ }
53414
+ for (const comm of MINER_NAMES) {
53415
+ rules.add(`-a always,exit -F arch=${arch} -S execve,execveat -F success=1 -F comm=${comm} -k threatcrush_edr_miner`);
53416
+ }
53417
+ if (settings.watchNetworkSyscalls) {
53418
+ rules.add(`-a always,exit -F arch=${arch} -S connect -F success=1 -k ${CONNECT_KEY2}`);
53419
+ rules.add(`-a always,exit -F arch=${arch} -S listen -F success=1 -k ${LISTEN_KEY2}`);
53420
+ }
53421
+ }
53422
+ if (tools.length === 0) warnings.push("no configured shell or downloader executables were found");
53423
+ if (existingDirectories(settings.tempExecPaths).length === 0) warnings.push("no configured temporary execution directories exist");
53424
+ if (settings.watchNetworkSyscalls) warnings.push("network syscall rules can generate substantial audit volume; review host capacity and retention before loading");
53425
+ return { rules: [...rules], warnings };
53426
+ }
53427
+
53428
+ // src/commands/edr.ts
53429
+ async function edrCommand(action = "status", opts = {}) {
53430
+ const settings = edrSettings(loadConfig().edr);
53431
+ if (action === "rules") {
53432
+ const generated = generateAuditRules(settings);
53433
+ console.log("# Generated by threatcrush edr rules. Review before loading with auditd.");
53434
+ console.log("# auditd may also write EXECVE argument records for matching syscalls;");
53435
+ console.log("# ThreatCrush reads only SYSCALL metadata and discards command arguments.");
53436
+ for (const warning2 of generated.warnings) console.log(`# NOTE: ${warning2}`);
53437
+ if (generated.rules.length) console.log(generated.rules.join("\n"));
53438
+ return;
53439
+ }
53440
+ if (action !== "status") {
53441
+ console.error(source_default.red(` Unknown action "${action}". Use status or rules.`));
53442
+ process.exitCode = 1;
53443
+ return;
53444
+ }
53445
+ let readable = false;
53446
+ try {
53447
+ if ((0, import_node_fs65.existsSync)(settings.auditLogPath)) (0, import_node_fs65.accessSync)(settings.auditLogPath, import_node_fs65.constants.R_OK);
53448
+ readable = (0, import_node_fs65.existsSync)(settings.auditLogPath);
53449
+ } catch {
53450
+ }
53451
+ let events = [];
53452
+ let stateNote = null;
53453
+ try {
53454
+ initStateDB(PATHS.stateDb);
53455
+ events = getModuleEvents("edr", Number(opts.limit) || 25);
53456
+ } catch {
53457
+ stateNote = `the daemon state database (${PATHS.stateDb}) is not readable here`;
53458
+ }
53459
+ const report = {
53460
+ enabled: settings.enabled,
53461
+ audit_log_path: settings.auditLogPath,
53462
+ audit_log_readable: readable,
53463
+ web_service_users: settings.webServiceUsers,
53464
+ temp_exec_paths: settings.tempExecPaths,
53465
+ watch_network_syscalls: settings.watchNetworkSyscalls,
53466
+ network_baseline_seconds: settings.networkBaselineMs / 1e3,
53467
+ watch_unknown_temp_cpu: settings.watchUnknownTempCpu,
53468
+ poll_interval_seconds: settings.pollMs / 1e3,
53469
+ state_note: stateNote,
53470
+ events
53471
+ };
53472
+ if (opts.json) {
53473
+ console.log(JSON.stringify(report, null, 2));
53474
+ return;
53475
+ }
53476
+ console.log(` ${source_default.white.bold("EDR audit watch")} ${settings.enabled ? source_default.green("enabled") : source_default.gray("disabled")}`);
53477
+ console.log(` Audit log: ${settings.auditLogPath} (${readable ? source_default.green("readable") : source_default.yellow("unavailable")})`);
53478
+ console.log(` Service accounts: ${settings.webServiceUsers.join(", ") || "none configured"}`);
53479
+ console.log(` Temporary execution paths: ${settings.tempExecPaths.join(", ") || "none configured"}`);
53480
+ console.log(` Network syscalls: ${settings.watchNetworkSyscalls ? `enabled (learn ${settings.networkBaselineMs / 1e3}s)` : "disabled"}`);
53481
+ console.log(` Temporary-path CPU watch: ${settings.watchUnknownTempCpu ? "enabled" : "disabled"}`);
53482
+ console.log(` Recent EDR events: ${events.length}`);
53483
+ if (stateNote) console.log(source_default.gray(` ${stateNote}`));
53484
+ if (!settings.enabled) console.log(source_default.gray(" Enable [edr] only after reviewing `threatcrush edr rules` and loading them in auditd."));
53485
+ for (const event of events) {
53486
+ const severity = String(event.severity ?? "info");
53487
+ const color = severity === "critical" ? source_default.red.bold : severity === "high" ? source_default.red : source_default.yellow;
53488
+ console.log(` ${color(severity.padEnd(8))} ${String(event.message ?? "")}`);
53489
+ }
53490
+ console.log();
53491
+ }
53492
+
51762
53493
  // src/commands/firewall.ts
51763
53494
  init_ipc_client();
51764
53495
  init_paths();
@@ -51900,7 +53631,7 @@ async function allowlistCommand(opts) {
51900
53631
  }
51901
53632
 
51902
53633
  // src/commands/abuse.ts
51903
- var import_node_fs60 = require("fs");
53634
+ var import_node_fs66 = require("fs");
51904
53635
  init_paths();
51905
53636
  function rows(records) {
51906
53637
  if (records.length === 0) {
@@ -51960,7 +53691,7 @@ function abuseRetractCommand(id, opts = {}) {
51960
53691
  );
51961
53692
  }
51962
53693
  function abuseStatusCommand(opts = {}) {
51963
- const config = loadConfig((0, import_node_fs60.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
53694
+ const config = loadConfig((0, import_node_fs66.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
51964
53695
  const cfg = resolveConfig(config.abuse_reporter);
51965
53696
  const hasKey2 = Boolean(cfg.keys.abuseipdb || cfg.keys.stopforumspam);
51966
53697
  const active2 = cfg.enabled && (cfg.dryRun || hasKey2);
@@ -51983,11 +53714,11 @@ function abuseStatusCommand(opts = {}) {
51983
53714
  init_paths();
51984
53715
 
51985
53716
  // src/upgrade.ts
51986
- var import_node_child_process24 = require("child_process");
53717
+ var import_node_child_process26 = require("child_process");
51987
53718
  var PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
51988
53719
  var defaultRunner = (cmd) => {
51989
53720
  try {
51990
- return (0, import_node_child_process24.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
53721
+ return (0, import_node_child_process26.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
51991
53722
  } catch {
51992
53723
  return null;
51993
53724
  }
@@ -52128,9 +53859,9 @@ function installUserAgent(target = globalThis) {
52128
53859
  }
52129
53860
 
52130
53861
  // src/core/cloud-upload.ts
52131
- var import_node_child_process25 = require("child_process");
52132
- var import_node_os17 = require("os");
52133
- var import_node_path46 = require("path");
53862
+ var import_node_child_process27 = require("child_process");
53863
+ var import_node_os18 = require("os");
53864
+ var import_node_path50 = require("path");
52134
53865
  init_cli_config();
52135
53866
  function uploadDisabled(upload, env3 = process.env) {
52136
53867
  if (upload === false) return true;
@@ -52149,8 +53880,8 @@ function cleanUrl(raw) {
52149
53880
  return raw.split(/[?#]/)[0];
52150
53881
  }
52151
53882
  }
52152
- function repoTarget(path2, run = (args) => (0, import_node_child_process25.execFileSync)("git", args, { cwd: (0, import_node_path46.resolve)(path2), encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5e3 }).trim()) {
52153
- const abs = (0, import_node_path46.resolve)(path2);
53883
+ function repoTarget(path2, run = (args) => (0, import_node_child_process27.execFileSync)("git", args, { cwd: (0, import_node_path50.resolve)(path2), encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5e3 }).trim()) {
53884
+ const abs = (0, import_node_path50.resolve)(path2);
52154
53885
  try {
52155
53886
  const root = run(["rev-parse", "--show-toplevel"]);
52156
53887
  const sub = abs === root ? "." : abs.slice(root.length + 1);
@@ -52163,9 +53894,9 @@ function repoTarget(path2, run = (args) => (0, import_node_child_process25.execF
52163
53894
  const m = /^(?:[a-z+]+:\/\/)?(?:[^@/]+@)?([^/:]+)[:/](.+?)(?:\.git)?\/?$/i.exec(remote);
52164
53895
  if (m) return { target: `${m[1]}/${m[2]}`, root, sub };
52165
53896
  }
52166
- return { target: `${(0, import_node_os17.hostname)()}:${root}`, root, sub };
53897
+ return { target: `${(0, import_node_os18.hostname)()}:${root}`, root, sub };
52167
53898
  } catch {
52168
- return { target: `${(0, import_node_os17.hostname)()}:${abs}`, root: abs, sub: "." };
53899
+ return { target: `${(0, import_node_os18.hostname)()}:${abs}`, root: abs, sub: "." };
52169
53900
  }
52170
53901
  }
52171
53902
  async function uploadResult(result, opts) {
@@ -52522,25 +54253,25 @@ ${source_default.dim(" C R U S H")}
52522
54253
  var API_URL8 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
52523
54254
  var PKG_NAME2 = "@profullstack/threatcrush";
52524
54255
  var DESKTOP_PKG_NAME = "@profullstack/threatcrush-desktop";
52525
- var INSTALL_CONFIG_PATH = (0, import_node_path47.join)((0, import_node_os18.homedir)(), ".threatcrush", "install.json");
54256
+ var INSTALL_CONFIG_PATH = (0, import_node_path51.join)((0, import_node_os19.homedir)(), ".threatcrush", "install.json");
52526
54257
  function detectPackageManager() {
52527
54258
  try {
52528
- const npmGlobal = (0, import_node_child_process26.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
54259
+ const npmGlobal = (0, import_node_child_process28.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
52529
54260
  if (npmGlobal.includes(PKG_NAME2)) return "npm";
52530
54261
  } catch {
52531
54262
  }
52532
54263
  try {
52533
- (0, import_node_child_process26.execSync)("pnpm --version", { stdio: "pipe" });
54264
+ (0, import_node_child_process28.execSync)("pnpm --version", { stdio: "pipe" });
52534
54265
  return "pnpm";
52535
54266
  } catch {
52536
54267
  }
52537
54268
  try {
52538
- (0, import_node_child_process26.execSync)("yarn --version", { stdio: "pipe" });
54269
+ (0, import_node_child_process28.execSync)("yarn --version", { stdio: "pipe" });
52539
54270
  return "yarn";
52540
54271
  } catch {
52541
54272
  }
52542
54273
  try {
52543
- (0, import_node_child_process26.execSync)("bun --version", { stdio: "pipe" });
54274
+ (0, import_node_child_process28.execSync)("bun --version", { stdio: "pipe" });
52544
54275
  return "bun";
52545
54276
  } catch {
52546
54277
  }
@@ -52548,14 +54279,14 @@ function detectPackageManager() {
52548
54279
  }
52549
54280
  function readInstallConfig() {
52550
54281
  try {
52551
- return JSON.parse((0, import_node_fs61.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
54282
+ return JSON.parse((0, import_node_fs67.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
52552
54283
  } catch {
52553
54284
  return {};
52554
54285
  }
52555
54286
  }
52556
54287
  function packageLooksInstalled(pm, pkgName) {
52557
54288
  try {
52558
- const output = (0, import_node_child_process26.execSync)(globalListCommand(pm, pkgName), {
54289
+ const output = (0, import_node_child_process28.execSync)(globalListCommand(pm, pkgName), {
52559
54290
  encoding: "utf-8",
52560
54291
  stdio: ["pipe", "pipe", "pipe"]
52561
54292
  });
@@ -52658,14 +54389,14 @@ async function promoteUnprivilegedDaemon() {
52658
54389
  function restartSystemdDaemon() {
52659
54390
  const asRoot = typeof process.getuid === "function" && process.getuid() === 0;
52660
54391
  const argv = asRoot ? ["systemctl", "restart", DAEMON_UNIT] : ["sudo", "systemctl", "restart", DAEMON_UNIT];
52661
- if (!asRoot && (0, import_node_child_process26.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
54392
+ if (!asRoot && (0, import_node_child_process28.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
52662
54393
  const [cmd, ...args] = argv;
52663
- if ((0, import_node_child_process26.spawnSync)(cmd, args, { stdio: "inherit" }).status !== 0) return false;
52664
- return (0, import_node_child_process26.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT], { stdio: "pipe" }).status === 0;
54394
+ if ((0, import_node_child_process28.spawnSync)(cmd, args, { stdio: "inherit" }).status !== 0) return false;
54395
+ return (0, import_node_child_process28.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT], { stdio: "pipe" }).status === 0;
52665
54396
  }
52666
54397
  function execQuiet(cmd) {
52667
54398
  try {
52668
- return (0, import_node_child_process26.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
54399
+ return (0, import_node_child_process28.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
52669
54400
  } catch {
52670
54401
  return null;
52671
54402
  }
@@ -52717,6 +54448,10 @@ program2.command("monitor").description("Watch nginx, auth and syslog for attack
52717
54448
  program2.command("tui").description("Interactive security dashboard (htop for security)").alias("dashboard").option("--demo", "Run on canned events instead of connecting to the daemon").action(async (opts) => {
52718
54449
  await monitorCommand({ tui: true, demo: opts.demo });
52719
54450
  });
54451
+ program2.command("action-center").description("Fleet-wide terminal view of detections, server health, and queued actions").alias("actions").action(async () => {
54452
+ const { startActionCenter: startActionCenter2 } = await Promise.resolve().then(() => (init_action_center(), action_center_exports));
54453
+ await startActionCenter2();
54454
+ });
52720
54455
  program2.command("map").description("Live world map of where attacks on this server come from").option("--demo", "Show canned attacks instead of connecting to the daemon").addHelpText("after", `
52721
54456
  Addresses from the daemon's live feed are placed with threatcrush.com/api/geo
52722
54457
  (DB-IP City Lite); this server is placed by the address it reaches us from.
@@ -52897,7 +54632,7 @@ program2.command("status").description("Show daemon status and loaded modules").
52897
54632
  program2.command("rules").description("Manage detection rules").argument("[action]", "list | show", "list").argument("[id]", "Rule ID (for show)").action(async (action, id) => {
52898
54633
  await rulesCommand({ action, id });
52899
54634
  });
52900
- program2.command("harden").description("Run hardening security scan").option("--json", "Output results as JSON").option("--no-upload", "Do not upload findings to the dashboard (uploaded when this machine is linked)").action(async (opts) => {
54635
+ program2.command("harden").description("Run hardening security scan").option("--json", "Output results as JSON").option("--report <framework>", "Export evidence report (cis)").option("--format <format>", "Report format: md, pdf, or json").option("--output <path>", "Write the report to a file (PDF requires this)").option("--no-upload", "Do not upload findings to the dashboard (uploaded when this machine is linked)").action(async (opts) => {
52901
54636
  await hardenCommand(opts);
52902
54637
  });
52903
54638
  program2.command("patches").description("List OS packages with a security update waiting, and the CVEs it fixes (Debian/Ubuntu)").option("--json", "Output the report as JSON").option("--no-upload", "Do not upload the result to the dashboard (uploaded when this machine is linked)").action(async (opts) => {
@@ -52925,6 +54660,12 @@ reputationCmd.command("subscribe").description("Pay for Reputation Pro in crypto
52925
54660
  program2.command("privileged").description("Who can become root here (uid 0, sudo groups, sudoers, SSH keys) and the daemon's record of changes and sudo commands").option("--json", "Output as JSON").option("--limit <n>", "How many recent events to show", "25").action(async (opts) => {
52926
54661
  await privilegedCommand(opts);
52927
54662
  });
54663
+ program2.command("integrity [action]").description("Inspect file integrity monitoring or refresh its local baseline (status | rebaseline)").option("--json", "Output as JSON").action(async (action, opts) => {
54664
+ await integrityCommand(action, opts);
54665
+ });
54666
+ program2.command("edr [action]").description("Auditd-backed process detection status or narrowly scoped rule template (status | rules)").option("--json", "Output status as JSON").option("--limit <n>", "How many recent events to show", "25").action(async (action, opts) => {
54667
+ await edrCommand(action, opts);
54668
+ });
52928
54669
  program2.command("block").description("Block an IP address via the firewall").argument("<ip>", "IP address to block").option("--ttl <duration>", "Block duration (e.g. 1h, 30m, 1d)").action(async (ip, opts) => {
52929
54670
  await blockCommand(ip, opts);
52930
54671
  });
@@ -52961,7 +54702,7 @@ program2.command("uninstall-service").description("Remove the threatcrushd syste
52961
54702
  program2.command("logs").description("Tail daemon logs").action(async () => {
52962
54703
  console.log(LOGO2);
52963
54704
  const logPath2 = PATHS.logFile;
52964
- if (!(0, import_node_fs61.existsSync)(logPath2)) {
54705
+ if (!(0, import_node_fs67.existsSync)(logPath2)) {
52965
54706
  console.log(source_default.yellow(` No log file found at ${logPath2}`));
52966
54707
  console.log(source_default.dim(" Start the daemon first with `threatcrush start`\n"));
52967
54708
  return;
@@ -52969,7 +54710,7 @@ program2.command("logs").description("Tail daemon logs").action(async () => {
52969
54710
  console.log(source_default.green(` Tailing ${logPath2}...
52970
54711
  `));
52971
54712
  console.log(source_default.gray(" Press Ctrl+C to stop\n"));
52972
- (0, import_node_child_process26.execSync)(`tail -f ${logPath2}`, { stdio: "inherit" });
54713
+ (0, import_node_child_process28.execSync)(`tail -f ${logPath2}`, { stdio: "inherit" });
52973
54714
  });
52974
54715
  program2.command("update").description("Update ThreatCrush CLI and installed bundle").option("--cli", "Update CLI only").option("--modules", "Update modules only").option("--desktop", "Update desktop app too").action(async (opts) => {
52975
54716
  console.log(LOGO2);
@@ -52981,7 +54722,7 @@ program2.command("update").description("Update ThreatCrush CLI and installed bun
52981
54722
  for (const cmd of commands2) {
52982
54723
  console.log(source_default.green(` \u2192 ${cmd}
52983
54724
  `));
52984
- (0, import_node_child_process26.execSync)(cmd, { stdio: "inherit" });
54725
+ (0, import_node_child_process28.execSync)(cmd, { stdio: "inherit" });
52985
54726
  }
52986
54727
  console.log(source_default.green("\n \u2713 Modules updated successfully!\n"));
52987
54728
  await reportIfStillStale();
@@ -53006,7 +54747,7 @@ program2.command("update").description("Update ThreatCrush CLI and installed bun
53006
54747
  for (const cmd of commands) {
53007
54748
  console.log(source_default.green(` \u2192 ${cmd}
53008
54749
  `));
53009
- (0, import_node_child_process26.execSync)(cmd, { stdio: "inherit" });
54750
+ (0, import_node_child_process28.execSync)(cmd, { stdio: "inherit" });
53010
54751
  }
53011
54752
  console.log(source_default.green("\n \u2713 ThreatCrush updated successfully!\n"));
53012
54753
  if (installMode === "desktop") {
@@ -53057,7 +54798,7 @@ program2.command("remove").description("Uninstall ThreatCrush and the installed
53057
54798
  for (const cmd of commands) {
53058
54799
  console.log(source_default.green(` \u2192 ${cmd}
53059
54800
  `));
53060
- (0, import_node_child_process26.execSync)(cmd, { stdio: "inherit" });
54801
+ (0, import_node_child_process28.execSync)(cmd, { stdio: "inherit" });
53061
54802
  }
53062
54803
  console.log(source_default.green("\n \u2713 ThreatCrush has been uninstalled.\n"));
53063
54804
  console.log(source_default.dim(" We're sorry to see you go! \u{1F44B}\n"));
@@ -53134,10 +54875,10 @@ storeCmd.command("search <query>").description("Search for modules in the store"
53134
54875
  });
53135
54876
  storeCmd.command("publish <url>").description("Publish a module from a git URL or web URL").action(async (url) => {
53136
54877
  console.log(LOGO2);
53137
- const configPath = (0, import_node_path47.join)((0, import_node_os18.homedir)(), ".threatcrush", "config.json");
54878
+ const configPath = (0, import_node_path51.join)((0, import_node_os19.homedir)(), ".threatcrush", "config.json");
53138
54879
  let email = "";
53139
54880
  try {
53140
- const config = JSON.parse((0, import_node_fs61.readFileSync)(configPath, "utf-8"));
54881
+ const config = JSON.parse((0, import_node_fs67.readFileSync)(configPath, "utf-8"));
53141
54882
  email = config.email || "";
53142
54883
  } catch {
53143
54884
  }
@@ -53154,9 +54895,9 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
53154
54895
  return;
53155
54896
  }
53156
54897
  try {
53157
- const dir = (0, import_node_path47.join)((0, import_node_os18.homedir)(), ".threatcrush");
53158
- if (!(0, import_node_fs61.existsSync)(dir)) (0, import_node_fs61.mkdirSync)(dir, { recursive: true });
53159
- (0, import_node_fs61.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
54898
+ const dir = (0, import_node_path51.join)((0, import_node_os19.homedir)(), ".threatcrush");
54899
+ if (!(0, import_node_fs67.existsSync)(dir)) (0, import_node_fs67.mkdirSync)(dir, { recursive: true });
54900
+ (0, import_node_fs67.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
53160
54901
  console.log(source_default.dim(` Saved email to ${configPath}`));
53161
54902
  } catch {
53162
54903
  }