@profullstack/threatcrush 0.13.65 → 0.13.67

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);
@@ -30250,7 +30611,7 @@ function parseCaddyAccessLog(line2) {
30250
30611
  } catch {
30251
30612
  return null;
30252
30613
  }
30253
- if (entry.logger !== "http.log.access") return null;
30614
+ if (typeof entry.logger !== "string" || !/^http\.log\.access(?:\.log\d+)?$/.test(entry.logger)) return null;
30254
30615
  const request = entry.request;
30255
30616
  if (!request || typeof request !== "object" || Array.isArray(request)) return null;
30256
30617
  const req = request;
@@ -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
 
@@ -44845,8 +45213,8 @@ var AbuseReporter = class {
44845
45213
  if (this.cfg.dryRun) {
44846
45214
  this.opts.log(`[abuse] [DRY-RUN] would report ${ip} (cats ${payload.categories.join(",")}, ${evidence.signals} signals)`);
44847
45215
  } 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"}`);
45216
+ const summary2 = results.map((r) => `${r.destination}:${r.ok ? "ok" : "FAIL"} ${r.detail}`).join("; ");
45217
+ this.opts.log(`[abuse] reported ${ip} [${record.id}] \u2192 ${summary2 || "no destinations"}`);
44850
45218
  }
44851
45219
  }
44852
45220
  trimRecent(now) {
@@ -46111,8 +46479,8 @@ var PrivilegeWatch = class {
46111
46479
  writeJson(this.opts.loginsPath, history);
46112
46480
  } catch {
46113
46481
  }
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"}`);
46482
+ const summary2 = Object.entries(history).map(([u, c]) => `${u}: ${Object.keys(c).join("/")}`).join(", ");
46483
+ this.opts.log(`[privileged] login baseline from the last 30 days: ${summary2 || "no public SSH logins"}`);
46116
46484
  }
46117
46485
  /** An accepted SSH login from a country new for that user. */
46118
46486
  async checkLogin(event) {
@@ -46464,10 +46832,845 @@ var CommandHistoryWatcher = class {
46464
46832
  }
46465
46833
  };
46466
46834
 
46467
- // src/daemon/workers/ssh-intrusion.ts
46835
+ // src/daemon/workers/file-integrity.ts
46468
46836
  var import_node_fs41 = require("fs");
46837
+ var import_promises4 = require("fs/promises");
46838
+ var import_node_crypto11 = require("crypto");
46469
46839
  var import_node_path32 = require("path");
46840
+ var DEFAULT_POLL_MS = 15 * 6e4;
46841
+ var MAX_FILES = 5e4;
46842
+ var MAX_FILE_BYTES = 64 * 1024 * 1024;
46843
+ var MAX_SCAN_BYTES = 512 * 1024 * 1024;
46844
+ var MAX_CHANGES_PER_EVENT = 100;
46845
+ var MAX_WATCH_DIRECTORIES = 2048;
46846
+ var WATCH_DEBOUNCE_MS = 500;
46847
+ var WATCH_MAX_DELAY_MS = 5e3;
46848
+ var MASS_CHANGE_COUNT = 25;
46849
+ var MASS_CHANGE_ENTROPY_RISE_BITS = 0.5;
46850
+ var READ_CHUNK_BYTES = 64 * 1024;
46851
+ var CANARY_CONTENT = "ThreatCrush file integrity canary v1\n";
46852
+ function fileIntegritySettings(section) {
46853
+ const safePath = (value) => {
46854
+ if (typeof value !== "string" || !(0, import_node_path32.isAbsolute)(value) || value.split(import_node_path32.sep).includes("..")) return null;
46855
+ const path2 = (0, import_node_path32.normalize)(value);
46856
+ return path2 === "/" ? null : path2;
46857
+ };
46858
+ const strings = (values) => Array.isArray(values) ? [...new Set(values.map(safePath).filter((path2) => path2 !== null))] : [];
46859
+ const configuredSeconds = section?.poll_interval_seconds;
46860
+ const pollMs = typeof configuredSeconds === "number" && Number.isFinite(configuredSeconds) ? Math.max(60, Math.min(86400, Math.floor(configuredSeconds))) * 1e3 : DEFAULT_POLL_MS;
46861
+ return {
46862
+ // File scans read disk contents (only to hash them), so make this explicit
46863
+ // instead of adding an unannounced I/O load to existing installations.
46864
+ enabled: section?.enabled === true,
46865
+ paths: strings(section?.paths),
46866
+ canaries: strings(section?.canaries),
46867
+ canaryDirectories: strings(section?.canary_directories),
46868
+ pollMs
46869
+ };
46870
+ }
46871
+ function signature(value) {
46872
+ return `${value.sha256};size=${value.size};mode=${value.mode.toString(8)};uid=${value.uid};gid=${value.gid};entropy=${value.entropy.toFixed(3)}`;
46873
+ }
46874
+ async function readState(path2) {
46875
+ try {
46876
+ const parsed = JSON.parse(await (0, import_promises4.readFile)(path2, "utf8"));
46877
+ if (parsed.schema !== 1 || !Array.isArray(parsed.targets) || !parsed.files || typeof parsed.files !== "object") return null;
46878
+ return parsed;
46879
+ } catch {
46880
+ return null;
46881
+ }
46882
+ }
46883
+ async function writeState(path2, state) {
46884
+ await (0, import_promises4.mkdir)((0, import_node_path32.dirname)(path2), { recursive: true, mode: 448 });
46885
+ const temp = `${path2}.${process.pid}.${(0, import_node_crypto11.randomUUID)()}.tmp`;
46886
+ await (0, import_promises4.writeFile)(temp, JSON.stringify(state), { mode: 384 });
46887
+ await (0, import_promises4.rename)(temp, path2);
46888
+ }
46889
+ async function hashFile(path2, handle, size) {
46890
+ const hash = (0, import_node_crypto11.createHash)("sha256");
46891
+ const buffer = Buffer.alloc(READ_CHUNK_BYTES);
46892
+ const counts = new Uint32Array(256);
46893
+ let position = 0;
46894
+ while (position < size) {
46895
+ const { bytesRead } = await handle.read(buffer, 0, Math.min(buffer.length, size - position), position);
46896
+ if (bytesRead === 0) throw new Error(`file changed while reading: ${path2}`);
46897
+ const chunk2 = buffer.subarray(0, bytesRead);
46898
+ hash.update(chunk2);
46899
+ for (const byte of chunk2) counts[byte]++;
46900
+ position += bytesRead;
46901
+ }
46902
+ let entropy = 0;
46903
+ if (size > 0) for (const count of counts) {
46904
+ if (count === 0) continue;
46905
+ const probability = count / size;
46906
+ entropy -= probability * Math.log2(probability);
46907
+ }
46908
+ return { sha256: hash.digest("hex"), entropy };
46909
+ }
46910
+ var OPEN_FILE_FLAGS = import_promises4.constants.O_RDONLY | import_promises4.constants.O_NONBLOCK | (import_promises4.constants.O_NOFOLLOW ?? 0);
46911
+ var OPEN_DIR_FLAGS = OPEN_FILE_FLAGS | import_promises4.constants.O_DIRECTORY;
46912
+ var CREATE_FILE_FLAGS = import_promises4.constants.O_WRONLY | import_promises4.constants.O_CREAT | import_promises4.constants.O_EXCL | import_promises4.constants.O_NOFOLLOW;
46913
+ function autoCanaryPath(directory) {
46914
+ return (0, import_node_path32.join)(directory, ".threatcrush-canary");
46915
+ }
46916
+ async function openAbsoluteDirectory(path2) {
46917
+ const parts = path2.split(import_node_path32.sep).filter((part) => part && part !== ".");
46918
+ if (parts.includes("..")) throw new Error("invalid canary directory");
46919
+ let directory = await (0, import_promises4.open)("/", OPEN_DIR_FLAGS);
46920
+ try {
46921
+ for (const part of parts) {
46922
+ const next = await (0, import_promises4.open)(`/proc/self/fd/${directory.fd}/${part}`, OPEN_DIR_FLAGS);
46923
+ await directory.close();
46924
+ directory = next;
46925
+ }
46926
+ return directory;
46927
+ } catch (error2) {
46928
+ await directory.close().catch(() => void 0);
46929
+ throw error2;
46930
+ }
46931
+ }
46932
+ async function createAutoCanary(path2) {
46933
+ try {
46934
+ const existing = await openAbsoluteTarget(path2);
46935
+ await existing.close();
46936
+ return false;
46937
+ } catch (error2) {
46938
+ if (error2.code !== "ENOENT") return false;
46939
+ }
46940
+ const directory = await openAbsoluteDirectory((0, import_node_path32.dirname)(path2));
46941
+ try {
46942
+ const file = await (0, import_promises4.open)(`/proc/self/fd/${directory.fd}/${(0, import_node_path32.basename)(path2)}`, CREATE_FILE_FLAGS, 438);
46943
+ try {
46944
+ await file.chmod(438);
46945
+ await file.writeFile(CANARY_CONTENT);
46946
+ await file.sync();
46947
+ } finally {
46948
+ await file.close();
46949
+ }
46950
+ return true;
46951
+ } catch (error2) {
46952
+ if (error2.code === "EEXIST") return false;
46953
+ throw error2;
46954
+ } finally {
46955
+ await directory.close();
46956
+ }
46957
+ }
46958
+ async function openAbsoluteTarget(path2) {
46959
+ const parts = path2.split(import_node_path32.sep).filter((part) => part && part !== ".");
46960
+ if (parts.length === 0 || parts.includes("..")) throw new Error("invalid file integrity path");
46961
+ let directory = await (0, import_promises4.open)("/", OPEN_DIR_FLAGS);
46962
+ try {
46963
+ for (const part of parts.slice(0, -1)) {
46964
+ const next = await (0, import_promises4.open)(`/proc/self/fd/${directory.fd}/${part}`, OPEN_DIR_FLAGS);
46965
+ await directory.close();
46966
+ directory = next;
46967
+ }
46968
+ const target = await (0, import_promises4.open)(`/proc/self/fd/${directory.fd}/${parts.at(-1)}`, OPEN_FILE_FLAGS);
46969
+ await directory.close();
46970
+ return target;
46971
+ } catch (error2) {
46972
+ await directory.close().catch(() => void 0);
46973
+ throw error2;
46974
+ }
46975
+ }
46976
+ async function scanTargets(targets, canaries) {
46977
+ const files = {};
46978
+ const directories = [];
46979
+ const visited = /* @__PURE__ */ new Set();
46980
+ const errors = /* @__PURE__ */ new Set();
46981
+ let complete = true;
46982
+ let skipped = 0;
46983
+ let bytes = 0;
46984
+ const walk = async (path2, parent) => {
46985
+ if (visited.has(path2) || !complete) return;
46986
+ visited.add(path2);
46987
+ if (visited.size > MAX_FILES) {
46988
+ complete = false;
46989
+ errors.add(path2);
46990
+ return;
46991
+ }
46992
+ let handle;
46993
+ try {
46994
+ 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);
46995
+ const stat = await handle.stat();
46996
+ if (stat.isDirectory()) {
46997
+ directories.push(path2);
46998
+ if (canaries.has(path2)) {
46999
+ complete = false;
47000
+ errors.add(path2);
47001
+ return;
47002
+ }
47003
+ let entries;
47004
+ try {
47005
+ entries = await (0, import_promises4.readdir)(`/proc/self/fd/${handle.fd}`, { withFileTypes: true });
47006
+ } catch {
47007
+ complete = false;
47008
+ errors.add(path2);
47009
+ return;
47010
+ }
47011
+ for (const entry of entries) {
47012
+ await walk((0, import_node_path32.join)(path2, entry.name), handle);
47013
+ if (!complete) return;
47014
+ }
47015
+ return;
47016
+ }
47017
+ if (!stat.isFile()) {
47018
+ skipped++;
47019
+ return;
47020
+ }
47021
+ if (stat.size > MAX_FILE_BYTES || bytes + stat.size > MAX_SCAN_BYTES) {
47022
+ complete = false;
47023
+ errors.add(path2);
47024
+ return;
47025
+ }
47026
+ const { sha256, entropy } = await hashFile(path2, handle, stat.size);
47027
+ const afterRead = await handle.stat();
47028
+ if (afterRead.size !== stat.size || afterRead.mtimeMs !== stat.mtimeMs || afterRead.ctimeMs !== stat.ctimeMs) {
47029
+ throw new Error("file changed while reading");
47030
+ }
47031
+ bytes += stat.size;
47032
+ files[path2] = signature({
47033
+ sha256,
47034
+ entropy,
47035
+ size: stat.size,
47036
+ mode: stat.mode & 4095,
47037
+ uid: stat.uid,
47038
+ gid: stat.gid
47039
+ });
47040
+ } catch (error2) {
47041
+ const code = error2.code;
47042
+ if (code === "ENOENT" && targets.includes(path2)) files[path2] = "missing";
47043
+ else if (code === "ELOOP" && !canaries.has(path2)) skipped++;
47044
+ else if (code === "ENOENT" || code === "ELOOP") {
47045
+ complete = false;
47046
+ errors.add(path2);
47047
+ } else {
47048
+ complete = false;
47049
+ errors.add(path2);
47050
+ }
47051
+ } finally {
47052
+ await handle?.close().catch(() => void 0);
47053
+ }
47054
+ };
47055
+ for (const target of targets) {
47056
+ await walk(target);
47057
+ if (!complete) break;
47058
+ }
47059
+ return { files, directories, complete, skipped, bytes, errorPaths: [...errors].slice(0, 20) };
47060
+ }
47061
+ function changedPaths(before2, after) {
47062
+ const paths = /* @__PURE__ */ new Set([...Object.keys(before2), ...Object.keys(after)]);
47063
+ const changed = [];
47064
+ for (const path2 of paths) {
47065
+ const previous = before2[path2] ?? "missing";
47066
+ const current = after[path2] ?? "missing";
47067
+ const normalized = (value) => typeof value === "string" ? value.replace(/;entropy=\d+(?:\.\d+)?$/, "") : value;
47068
+ if (normalized(previous) !== normalized(current)) changed.push({ path: path2, state: current });
47069
+ }
47070
+ return changed;
47071
+ }
47072
+ function meanEntropy(paths, files) {
47073
+ const values = paths.flatMap((path2) => {
47074
+ const signature2 = files[path2];
47075
+ if (typeof signature2 !== "string") return [];
47076
+ const match = /;entropy=(\d+(?:\.\d+)?)$/.exec(signature2);
47077
+ return match ? [Number(match[1])] : [];
47078
+ });
47079
+ return values.length ? values.reduce((sum, value) => sum + value, 0) / values.length : null;
47080
+ }
47081
+ var FileIntegrityWatch = class {
47082
+ constructor(opts) {
47083
+ this.opts = opts;
47084
+ this.now = opts.now ?? (() => /* @__PURE__ */ new Date());
47085
+ this.canaries = /* @__PURE__ */ new Set([
47086
+ ...opts.settings.canaries,
47087
+ ...opts.settings.canaryDirectories.map(autoCanaryPath)
47088
+ ]);
47089
+ }
47090
+ opts;
47091
+ timer = null;
47092
+ running = false;
47093
+ now;
47094
+ canaries;
47095
+ watchers = /* @__PURE__ */ new Map();
47096
+ eventTimer = null;
47097
+ eventFirstAt = 0;
47098
+ eventScanPending = false;
47099
+ watcherLimitLogged = false;
47100
+ get autoCanaries() {
47101
+ return this.opts.settings.canaryDirectories.map(autoCanaryPath);
47102
+ }
47103
+ async ensureAutoCanaries(allowed) {
47104
+ for (const path2 of this.autoCanaries) {
47105
+ if (!allowed.has(path2)) continue;
47106
+ try {
47107
+ if (await createAutoCanary(path2)) this.opts.log(`[file-integrity] placed a canary at ${path2}`);
47108
+ } catch (error2) {
47109
+ this.opts.log(`[file-integrity] could not place canary at ${path2}: ${error2.message.split("\n")[0]}`);
47110
+ }
47111
+ }
47112
+ }
47113
+ start() {
47114
+ if (!this.opts.settings.enabled) {
47115
+ this.opts.log("[file-integrity] disabled; set [file_integrity] enabled = true to monitor configured paths");
47116
+ return;
47117
+ }
47118
+ const targets = [.../* @__PURE__ */ new Set([...this.opts.settings.paths, ...this.opts.settings.canaries, ...this.autoCanaries])];
47119
+ if (targets.length === 0) {
47120
+ this.opts.log("[file-integrity] enabled with no paths; configure [file_integrity] paths or canaries");
47121
+ return;
47122
+ }
47123
+ 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`);
47124
+ void this.scanOnce();
47125
+ this.timer = setInterval(() => {
47126
+ void this.scanOnce();
47127
+ }, this.opts.settings.pollMs);
47128
+ this.timer.unref?.();
47129
+ }
47130
+ stop() {
47131
+ if (this.timer) clearInterval(this.timer);
47132
+ this.timer = null;
47133
+ if (this.eventTimer) clearTimeout(this.eventTimer);
47134
+ this.eventTimer = null;
47135
+ this.eventFirstAt = 0;
47136
+ this.eventScanPending = false;
47137
+ for (const watcher of this.watchers.values()) watcher.close();
47138
+ this.watchers.clear();
47139
+ }
47140
+ refreshWatchers(directories) {
47141
+ const wanted = new Set(directories.slice(0, MAX_WATCH_DIRECTORIES));
47142
+ for (const [path2, watcher] of this.watchers) {
47143
+ if (wanted.has(path2)) continue;
47144
+ watcher.close();
47145
+ this.watchers.delete(path2);
47146
+ }
47147
+ for (const path2 of wanted) {
47148
+ if (this.watchers.has(path2)) continue;
47149
+ try {
47150
+ const watcher = (0, import_node_fs41.watch)(path2, { persistent: false }, () => {
47151
+ this.scheduleEventScan();
47152
+ });
47153
+ watcher.on("error", (error2) => {
47154
+ this.opts.log(`[file-integrity] inotify watch unavailable for ${path2}: ${error2.message}`);
47155
+ watcher.close();
47156
+ this.watchers.delete(path2);
47157
+ });
47158
+ this.watchers.set(path2, watcher);
47159
+ } catch (error2) {
47160
+ this.opts.log(`[file-integrity] inotify watch unavailable for ${path2}: ${error2.message.split("\n")[0]}`);
47161
+ }
47162
+ }
47163
+ if (directories.length > MAX_WATCH_DIRECTORIES && !this.watcherLimitLogged) {
47164
+ this.watcherLimitLogged = true;
47165
+ this.opts.log(`[file-integrity] watching the first ${MAX_WATCH_DIRECTORIES} directories; polling remains the fallback for the rest`);
47166
+ }
47167
+ }
47168
+ /** Debounce bursts, but cap the delay so continuous writes still get scanned. */
47169
+ scheduleEventScan() {
47170
+ this.eventScanPending = true;
47171
+ if (this.eventFirstAt === 0) this.eventFirstAt = Date.now();
47172
+ if (this.running) return;
47173
+ if (this.eventTimer) clearTimeout(this.eventTimer);
47174
+ const dueAt = Math.min(Date.now() + WATCH_DEBOUNCE_MS, this.eventFirstAt + WATCH_MAX_DELAY_MS);
47175
+ this.eventTimer = setTimeout(() => {
47176
+ this.eventTimer = null;
47177
+ if (this.running) return;
47178
+ this.eventScanPending = false;
47179
+ this.eventFirstAt = 0;
47180
+ void this.scanOnce();
47181
+ }, Math.max(0, dueAt - Date.now()));
47182
+ this.eventTimer.unref?.();
47183
+ }
47184
+ async rebaseline() {
47185
+ const targets = [.../* @__PURE__ */ new Set([...this.opts.settings.paths, ...this.opts.settings.canaries, ...this.autoCanaries])];
47186
+ if (!this.opts.settings.enabled || targets.length === 0) return { ok: false, files: 0, reason: "file integrity monitoring is disabled or has no configured paths" };
47187
+ await this.ensureAutoCanaries(new Set(this.autoCanaries));
47188
+ const scan = await scanTargets(targets, this.canaries);
47189
+ if (!scan.complete) return { ok: false, files: Object.keys(scan.files).length, reason: `scan incomplete at ${scan.errorPaths.join(", ") || "configured size limit"}` };
47190
+ const missingCanary = [...this.canaries].find((path2) => scan.files[path2] === "missing");
47191
+ if (missingCanary) return { ok: false, files: Object.keys(scan.files).length, reason: `configured canary does not exist: ${missingCanary}` };
47192
+ const state = { schema: 1, created_at: this.now().toISOString(), targets, files: scan.files };
47193
+ await writeState(this.opts.baselinePath, state);
47194
+ await writeState(this.opts.observedPath, state);
47195
+ return { ok: true, files: Object.keys(scan.files).length };
47196
+ }
47197
+ async scanOnce() {
47198
+ if (this.running) return;
47199
+ this.running = true;
47200
+ try {
47201
+ const baseline = await readState(this.opts.baselinePath);
47202
+ const previousObserved = await readState(this.opts.observedPath);
47203
+ let baselineFilePresent = false;
47204
+ if (!baseline) {
47205
+ try {
47206
+ await (0, import_promises4.lstat)(this.opts.baselinePath);
47207
+ baselineFilePresent = true;
47208
+ } catch (error2) {
47209
+ baselineFilePresent = error2.code !== "ENOENT";
47210
+ }
47211
+ }
47212
+ const canCreate = this.autoCanaries.filter((path2) => {
47213
+ if (!baseline && !baselineFilePresent) return true;
47214
+ return !!baseline && !baseline.targets.includes(path2) && !previousObserved?.targets.includes(path2);
47215
+ });
47216
+ await this.ensureAutoCanaries(new Set(canCreate));
47217
+ const targets = [.../* @__PURE__ */ new Set([...this.opts.settings.paths, ...this.opts.settings.canaries, ...this.autoCanaries])];
47218
+ const current = await scanTargets(targets, this.canaries);
47219
+ if (current.complete) {
47220
+ const directories = new Set(current.directories);
47221
+ for (const path2 of Object.keys(current.files)) {
47222
+ if (!directories.has(path2)) directories.add((0, import_node_path32.dirname)(path2));
47223
+ }
47224
+ this.refreshWatchers([...directories]);
47225
+ }
47226
+ if (!current.complete) {
47227
+ this.opts.log(`[file-integrity] scan incomplete; no baseline or change state updated (${current.errorPaths.join(", ") || "configured scan limits reached"})`);
47228
+ return;
47229
+ }
47230
+ if (!baseline) {
47231
+ if (baselineFilePresent) {
47232
+ this.emit("critical", "File integrity baseline is unreadable; monitoring paused", "file-integrity-baseline-invalid", [
47233
+ { path: this.opts.baselinePath, state: "unreadable" }
47234
+ ]);
47235
+ this.opts.log("[file-integrity] baseline is present but unreadable; it was not replaced");
47236
+ return;
47237
+ }
47238
+ const missingCanary = [...this.canaries].find((path2) => current.files[path2] === "missing");
47239
+ if (missingCanary) {
47240
+ this.opts.log(`[file-integrity] cannot record baseline; configured canary does not exist: ${missingCanary}`);
47241
+ return;
47242
+ }
47243
+ const created = { schema: 1, created_at: this.now().toISOString(), targets, files: current.files };
47244
+ await writeState(this.opts.baselinePath, created);
47245
+ await writeState(this.opts.observedPath, created);
47246
+ this.opts.log(`[file-integrity] initial baseline recorded for ${Object.keys(current.files).length} file(s)`);
47247
+ return;
47248
+ }
47249
+ const observed = previousObserved ?? baseline;
47250
+ const sameTargets = (left, right) => {
47251
+ const sortedLeft = [...left].sort();
47252
+ const sortedRight = [...right].sort();
47253
+ return sortedLeft.length === sortedRight.length && sortedLeft.every((path2, index) => path2 === sortedRight[index]);
47254
+ };
47255
+ if (!sameTargets(baseline.targets, targets)) {
47256
+ const removedCanaries = changedPaths(observed.files, current.files).filter((change) => this.canaries.has(change.path) && observed.targets.includes(change.path));
47257
+ if (removedCanaries.length) {
47258
+ this.emit("critical", "A file integrity canary changed or disappeared", "file-integrity-canary", removedCanaries);
47259
+ }
47260
+ if (!sameTargets(observed.targets, targets)) {
47261
+ this.emit(
47262
+ "medium",
47263
+ "File integrity monitoring paths changed; review them and rebaseline",
47264
+ "file-integrity-scope-changed",
47265
+ targets.map((path2) => ({ path: path2, state: "scope-changed" }))
47266
+ );
47267
+ }
47268
+ await writeState(this.opts.observedPath, { schema: 1, created_at: observed.created_at, targets, files: current.files });
47269
+ return;
47270
+ }
47271
+ const changes = changedPaths(observed.files, current.files);
47272
+ const canaryChanges = changes.filter((change) => this.canaries.has(change.path));
47273
+ if (canaryChanges.length) {
47274
+ this.emit("critical", "A file integrity canary changed or disappeared", "file-integrity-canary", canaryChanges);
47275
+ }
47276
+ const ordinary = changes.filter((change) => !this.canaries.has(change.path));
47277
+ const paths = ordinary.map((change) => change.path);
47278
+ const beforeEntropy = meanEntropy(paths, observed.files);
47279
+ const afterEntropy = meanEntropy(paths, current.files);
47280
+ const entropyRose = beforeEntropy !== null && afterEntropy !== null && afterEntropy - beforeEntropy >= MASS_CHANGE_ENTROPY_RISE_BITS;
47281
+ if (ordinary.length >= MASS_CHANGE_COUNT || ordinary.length >= 10 && entropyRose) {
47282
+ const entropyDetail = entropyRose ? `; mean changed-file entropy rose from ${beforeEntropy?.toFixed(2)} to ${afterEntropy?.toFixed(2)} bits` : "";
47283
+ this.emit("critical", `${ordinary.length} monitored files changed in one scan${entropyDetail}`, "file-integrity-mass-change", ordinary);
47284
+ } else {
47285
+ for (const change of ordinary) {
47286
+ const expected = baseline.files[change.path] ?? "missing";
47287
+ const restored = change.state === expected;
47288
+ this.emit(
47289
+ restored ? "low" : "high",
47290
+ restored ? `Monitored file returned to its baseline: ${change.path}` : `Monitored file changed: ${change.path}`,
47291
+ restored ? "file-integrity-restored" : "file-integrity-changed",
47292
+ [change]
47293
+ );
47294
+ }
47295
+ }
47296
+ const nextObserved = { schema: 1, created_at: observed.created_at, targets, files: current.files };
47297
+ await writeState(this.opts.observedPath, nextObserved);
47298
+ } catch (error2) {
47299
+ this.opts.log(`[file-integrity] scan failed: ${error2.message.split("\n")[0]}`);
47300
+ } finally {
47301
+ this.running = false;
47302
+ if (this.eventScanPending && !this.eventTimer) this.scheduleEventScan();
47303
+ }
47304
+ }
47305
+ emit(severity, message, ruleId, changes) {
47306
+ const event = {
47307
+ timestamp: this.now(),
47308
+ module: "file-integrity",
47309
+ category: "system",
47310
+ severity,
47311
+ message: message.replace(/[\u0000-\u001f\u007f]/g, " ").slice(0, 500),
47312
+ details: {
47313
+ rule_id: ruleId,
47314
+ change_count: changes.length,
47315
+ changes: changes.slice(0, MAX_CHANGES_PER_EVENT).map(({ path: path2, state }) => ({
47316
+ path: path2,
47317
+ state: state === "missing" ? "missing" : "present"
47318
+ })),
47319
+ truncated: changes.length > MAX_CHANGES_PER_EVENT
47320
+ }
47321
+ };
47322
+ try {
47323
+ insertEvent(event);
47324
+ } catch {
47325
+ }
47326
+ this.opts.bus.publish(event);
47327
+ }
47328
+ };
47329
+
47330
+ // src/daemon/workers/edr.ts
47331
+ var import_node_fs42 = require("fs");
47332
+ var import_node_path33 = require("path");
46470
47333
  var import_node_child_process14 = require("child_process");
47334
+ var DEFAULT_AUDIT_LOG = "/var/log/audit/audit.log";
47335
+ var DEFAULT_WEB_USERS = ["www-data", "nginx", "apache", "httpd", "caddy", "node"];
47336
+ var DEFAULT_TEMP_PATHS = ["/tmp", "/var/tmp", "/dev/shm"];
47337
+ var MAX_SEEN_EVENTS = 4096;
47338
+ var WEB_KEY = "threatcrush_edr_web";
47339
+ var TEMP_KEY = "threatcrush_edr_temp";
47340
+ var MINER_KEY = "threatcrush_edr_miner";
47341
+ var CONNECT_KEY = "threatcrush_edr_connect";
47342
+ var LISTEN_KEY = "threatcrush_edr_listen";
47343
+ var CPU_SAMPLE_MS = 15e3;
47344
+ var CPU_SUSTAIN_MS = 6e4;
47345
+ var CPU_THRESHOLD_PERCENT = 80;
47346
+ var SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "dash", "zsh", "ksh", "fish"]);
47347
+ var DOWNLOADERS = /* @__PURE__ */ new Set(["curl", "wget"]);
47348
+ var MINERS = /* @__PURE__ */ new Set(["xmrig", "minerd", "cpuminer", "cpuminer-multi", "kdevtmpfsi", "kinsing", "cryptonight"]);
47349
+ function safeAbsolutePath(value) {
47350
+ if (typeof value !== "string" || !(0, import_node_path33.isAbsolute)(value) || value.split(import_node_path33.sep).includes("..")) return null;
47351
+ const path2 = (0, import_node_path33.normalize)(value);
47352
+ return path2 === "/" ? null : path2;
47353
+ }
47354
+ function edrSettings(section) {
47355
+ const configuredLog = safeAbsolutePath(section?.audit_log_path) ?? DEFAULT_AUDIT_LOG;
47356
+ 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;
47357
+ const configuredPaths = Array.isArray(section?.temp_exec_paths) ? [...new Set(section.temp_exec_paths.map(safeAbsolutePath).filter((path2) => path2 !== null))] : DEFAULT_TEMP_PATHS;
47358
+ const seconds = section?.poll_interval_seconds;
47359
+ const pollMs = typeof seconds === "number" && Number.isFinite(seconds) ? Math.max(1, Math.min(60, Math.floor(seconds))) * 1e3 : 2e3;
47360
+ const baselineSeconds = section?.network_baseline_seconds;
47361
+ return {
47362
+ enabled: section?.enabled === true,
47363
+ auditLogPath: configuredLog,
47364
+ webServiceUsers: configuredUsers,
47365
+ tempExecPaths: configuredPaths,
47366
+ watchNetworkSyscalls: section?.watch_network_syscalls === true,
47367
+ networkBaselineMs: typeof baselineSeconds === "number" && Number.isFinite(baselineSeconds) ? Math.max(0, Math.min(3600, Math.floor(baselineSeconds))) * 1e3 : 6e4,
47368
+ watchUnknownTempCpu: section?.watch_unknown_temp_cpu !== false,
47369
+ pollMs
47370
+ };
47371
+ }
47372
+ function parseAuditFields(line2) {
47373
+ const fields = {};
47374
+ const pattern = /(?:^|\s)([A-Za-z0-9_]+)=("(?:\\.|[^"\\])*"|\S+)/g;
47375
+ for (const match of line2.matchAll(pattern)) {
47376
+ const raw = match[2];
47377
+ fields[match[1]] = raw.startsWith('"') && raw.endsWith('"') ? raw.slice(1, -1).replace(/\\(["\\])/g, "$1") : raw;
47378
+ }
47379
+ return fields;
47380
+ }
47381
+ function parseAuditRecord(line2) {
47382
+ const header2 = /^type=SYSCALL\b.*?\bmsg=audit\((\d+(?:\.\d+)?):(\d+)\):/.exec(line2);
47383
+ if (!header2) return null;
47384
+ const fields = parseAuditFields(line2);
47385
+ if (fields.success !== "yes" || !fields.key || fields.key === "(null)") return null;
47386
+ const executable = fields.exe ?? "";
47387
+ const euid = Number(fields.euid);
47388
+ const seconds = Number(header2[1]);
47389
+ if (!executable.startsWith("/") || !Number.isInteger(euid) || !Number.isFinite(seconds)) return null;
47390
+ const pid = Number(fields.pid);
47391
+ const ppid = Number(fields.ppid);
47392
+ return {
47393
+ timestamp: new Date(seconds * 1e3),
47394
+ serial: header2[2],
47395
+ key: fields.key,
47396
+ executable,
47397
+ comm: fields.comm ?? (0, import_node_path33.basename)(executable),
47398
+ euid,
47399
+ ...Number.isInteger(pid) && pid > 0 ? { pid } : {},
47400
+ ...Number.isInteger(ppid) && ppid > 0 ? { ppid } : {}
47401
+ };
47402
+ }
47403
+ function accountNames2() {
47404
+ let raw = "";
47405
+ try {
47406
+ raw = (0, import_node_child_process14.execFileSync)("getent", ["passwd"], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
47407
+ } catch {
47408
+ try {
47409
+ raw = (0, import_node_fs42.readFileSync)("/etc/passwd", "utf8");
47410
+ } catch {
47411
+ return /* @__PURE__ */ new Map();
47412
+ }
47413
+ }
47414
+ const out = /* @__PURE__ */ new Map();
47415
+ for (const line2 of raw.split("\n")) {
47416
+ const fields = line2.split(":");
47417
+ const uid = Number(fields[2]);
47418
+ if (fields[0] && Number.isInteger(uid)) out.set(uid, fields[0]);
47419
+ }
47420
+ return out;
47421
+ }
47422
+ function pathWithin(path2, root) {
47423
+ return path2 === root || path2.startsWith(`${root.replace(/\/$/, "")}/`);
47424
+ }
47425
+ function executableInWorldWritableDirectory(executable) {
47426
+ try {
47427
+ return ((0, import_node_fs42.statSync)((0, import_node_path33.dirname)(executable)).mode & 2) !== 0;
47428
+ } catch {
47429
+ return false;
47430
+ }
47431
+ }
47432
+ function clean(value) {
47433
+ return value.replace(/[\u0000-\u001f\u007f]/g, " ").slice(0, 400);
47434
+ }
47435
+ var EdrWatch = class {
47436
+ constructor(opts) {
47437
+ this.opts = opts;
47438
+ this.usersById = accountNames2();
47439
+ const wanted = new Set(opts.settings.webServiceUsers.map((name) => name.toLowerCase()));
47440
+ this.webIds = new Set([...this.usersById].filter(([, name]) => wanted.has(name.toLowerCase())).map(([uid]) => uid));
47441
+ this.loadNetworkBaseline();
47442
+ }
47443
+ opts;
47444
+ tail = null;
47445
+ timer = null;
47446
+ cpuTimer = null;
47447
+ usersById;
47448
+ webIds;
47449
+ seen = /* @__PURE__ */ new Set();
47450
+ listenersSeen = /* @__PURE__ */ new Set();
47451
+ outboundExecutables = /* @__PURE__ */ new Set();
47452
+ cpuSamples = /* @__PURE__ */ new Map();
47453
+ networkStartedAt = Date.now();
47454
+ ticksPerSecond = this.readTicksPerSecond();
47455
+ baselineWriteFailed = false;
47456
+ start() {
47457
+ if (!this.opts.settings.enabled) {
47458
+ this.opts.log("[edr] disabled; set [edr] enabled = true after installing the generated audit rules");
47459
+ return;
47460
+ }
47461
+ if (!(0, import_node_fs42.existsSync)(this.opts.settings.auditLogPath)) {
47462
+ this.opts.log(`[edr] audit log not found at ${this.opts.settings.auditLogPath}; auditd detections are unavailable`);
47463
+ } else {
47464
+ try {
47465
+ (0, import_node_fs42.accessSync)(this.opts.settings.auditLogPath, import_node_fs42.constants.R_OK);
47466
+ this.tail = new LogTail(this.opts.settings.auditLogPath);
47467
+ this.timer = setInterval(() => this.poll(), this.opts.settings.pollMs);
47468
+ this.timer.unref?.();
47469
+ this.opts.log(`[edr] watching selected auditd events in ${this.opts.settings.auditLogPath}; command arguments and remote addresses are discarded`);
47470
+ } catch {
47471
+ this.opts.log(`[edr] cannot read ${this.opts.settings.auditLogPath}; run the daemon with permission to read the audit log`);
47472
+ }
47473
+ }
47474
+ if (this.opts.settings.watchUnknownTempCpu) {
47475
+ this.cpuTimer = setInterval(() => this.sampleTemporaryProcesses(), CPU_SAMPLE_MS);
47476
+ this.cpuTimer.unref?.();
47477
+ this.sampleTemporaryProcesses();
47478
+ this.opts.log(`[edr] watching temporary-path processes for sustained CPU use (${CPU_THRESHOLD_PERCENT}% for ${CPU_SUSTAIN_MS / 1e3}s)`);
47479
+ }
47480
+ }
47481
+ stop() {
47482
+ if (this.timer) clearInterval(this.timer);
47483
+ if (this.cpuTimer) clearInterval(this.cpuTimer);
47484
+ this.timer = null;
47485
+ this.cpuTimer = null;
47486
+ this.tail = null;
47487
+ this.seen.clear();
47488
+ this.listenersSeen.clear();
47489
+ this.cpuSamples.clear();
47490
+ }
47491
+ poll() {
47492
+ if (!this.tail) return 0;
47493
+ return this.tail.poll((line2) => {
47494
+ const record = parseAuditRecord(line2);
47495
+ if (!record) return;
47496
+ const dedupeKey2 = `${record.timestamp.getTime()}:${record.serial}:${record.key}`;
47497
+ if (this.seen.has(dedupeKey2)) return;
47498
+ this.seen.add(dedupeKey2);
47499
+ if (this.seen.size > MAX_SEEN_EVENTS) this.seen.delete(this.seen.values().next().value);
47500
+ const event = this.classify(record);
47501
+ if (!event) return;
47502
+ this.publish(event);
47503
+ });
47504
+ }
47505
+ publish(event) {
47506
+ try {
47507
+ insertEvent(event);
47508
+ } catch {
47509
+ }
47510
+ this.opts.bus.publish(event);
47511
+ }
47512
+ classify(execution) {
47513
+ const name = (0, import_node_path33.basename)(execution.executable).toLowerCase();
47514
+ const account = this.usersById.get(execution.euid) ?? String(execution.euid);
47515
+ let severity;
47516
+ let ruleId;
47517
+ let message;
47518
+ if (execution.key === CONNECT_KEY) {
47519
+ const wasKnown = this.outboundExecutables.has(execution.executable);
47520
+ this.rememberOutboundExecutable(execution.executable);
47521
+ if (SHELLS.has(name) || SHELLS.has(execution.comm.toLowerCase())) {
47522
+ severity = "high";
47523
+ ruleId = "edr-shell-network-connect";
47524
+ message = `Possible reverse-shell behavior: shell ${execution.executable} opened an outbound connection`;
47525
+ } else if (!wasKnown && Date.now() - this.networkStartedAt >= this.opts.settings.networkBaselineMs) {
47526
+ severity = "medium";
47527
+ ruleId = "edr-new-outbound-executable";
47528
+ message = `Previously unseen executable opened an outbound connection: ${execution.executable}`;
47529
+ } else {
47530
+ return null;
47531
+ }
47532
+ } else if (execution.key === LISTEN_KEY) {
47533
+ const listenerKey = `${execution.pid ?? execution.serial}:${execution.executable}`;
47534
+ if (this.listenersSeen.has(listenerKey)) return null;
47535
+ this.listenersSeen.add(listenerKey);
47536
+ if (this.listenersSeen.size > MAX_SEEN_EVENTS) this.listenersSeen.delete(this.listenersSeen.values().next().value);
47537
+ severity = "medium";
47538
+ ruleId = "edr-process-listener";
47539
+ message = `Process began listening for inbound connections: ${execution.executable}`;
47540
+ } else if (execution.key === WEB_KEY && this.webIds.has(execution.euid) && (SHELLS.has(name) || DOWNLOADERS.has(name))) {
47541
+ severity = "high";
47542
+ ruleId = "edr-web-service-tool";
47543
+ message = `Web service account ${account} executed ${name}: ${execution.executable}`;
47544
+ } else if (execution.key === TEMP_KEY && (this.opts.settings.tempExecPaths.some((path2) => pathWithin(execution.executable, path2)) || executableInWorldWritableDirectory(execution.executable))) {
47545
+ severity = "high";
47546
+ ruleId = "edr-writable-path-execution";
47547
+ message = `Executable launched from a temporary or world-writable directory: ${execution.executable}`;
47548
+ } else if (execution.key === MINER_KEY && MINERS.has(name)) {
47549
+ severity = "critical";
47550
+ ruleId = "edr-known-miner-execution";
47551
+ message = `Known cryptocurrency miner executed: ${execution.executable}`;
47552
+ } else {
47553
+ return null;
47554
+ }
47555
+ return {
47556
+ timestamp: execution.timestamp,
47557
+ module: "edr",
47558
+ category: "system",
47559
+ severity,
47560
+ message: clean(message),
47561
+ details: {
47562
+ rule_id: ruleId,
47563
+ executable: clean(execution.executable),
47564
+ account,
47565
+ euid: execution.euid,
47566
+ ...execution.pid ? { pid: execution.pid } : {},
47567
+ ...execution.ppid ? { ppid: execution.ppid } : {},
47568
+ audit_serial: execution.serial
47569
+ }
47570
+ };
47571
+ }
47572
+ loadNetworkBaseline() {
47573
+ const path2 = this.opts.networkBaselinePath;
47574
+ if (!path2) return;
47575
+ try {
47576
+ const parsed = JSON.parse((0, import_node_fs42.readFileSync)(path2, "utf8"));
47577
+ if (Array.isArray(parsed)) {
47578
+ for (const value of parsed.slice(0, 1e4)) {
47579
+ if (typeof value === "string" && value.startsWith("/")) this.outboundExecutables.add(value);
47580
+ }
47581
+ }
47582
+ } catch {
47583
+ }
47584
+ }
47585
+ rememberOutboundExecutable(executable) {
47586
+ if (this.outboundExecutables.has(executable)) return;
47587
+ this.outboundExecutables.add(executable);
47588
+ if (this.outboundExecutables.size > 1e4) this.outboundExecutables.delete(this.outboundExecutables.values().next().value);
47589
+ const path2 = this.opts.networkBaselinePath;
47590
+ if (!path2) return;
47591
+ try {
47592
+ const temp = `${path2}.${process.pid}.tmp`;
47593
+ (0, import_node_fs42.writeFileSync)(temp, `${JSON.stringify([...this.outboundExecutables])}
47594
+ `, { mode: 384 });
47595
+ (0, import_node_fs42.renameSync)(temp, path2);
47596
+ this.baselineWriteFailed = false;
47597
+ } catch (error2) {
47598
+ if (!this.baselineWriteFailed) this.opts.log(`[edr] could not persist outbound executable baseline: ${error2.message.split("\n")[0]}`);
47599
+ this.baselineWriteFailed = true;
47600
+ }
47601
+ }
47602
+ readTicksPerSecond() {
47603
+ try {
47604
+ const value = Number((0, import_node_child_process14.execFileSync)("getconf", ["CLK_TCK"], { encoding: "utf8", timeout: 2e3, stdio: ["ignore", "pipe", "ignore"] }).trim());
47605
+ if (Number.isFinite(value) && value > 0) return value;
47606
+ } catch {
47607
+ }
47608
+ return 100;
47609
+ }
47610
+ sampleTemporaryProcesses() {
47611
+ if (!this.opts.settings.enabled || !this.opts.settings.watchUnknownTempCpu) return;
47612
+ const now = Date.now();
47613
+ const current = /* @__PURE__ */ new Map();
47614
+ let pids;
47615
+ try {
47616
+ pids = (0, import_node_fs42.readdirSync)("/proc");
47617
+ } catch {
47618
+ return;
47619
+ }
47620
+ for (const pid of pids) {
47621
+ if (!/^\d+$/.test(pid)) continue;
47622
+ const proc = `/proc/${pid}`;
47623
+ try {
47624
+ const raw = (0, import_node_fs42.readFileSync)(`${proc}/stat`, "utf8");
47625
+ const end = raw.lastIndexOf(")");
47626
+ if (end < 0) continue;
47627
+ const fields = raw.slice(end + 1).trim().split(/\s+/);
47628
+ const userTicks = Number(fields[11]);
47629
+ const systemTicks = Number(fields[12]);
47630
+ const startTicks = fields[19];
47631
+ if (!Number.isFinite(userTicks) || !Number.isFinite(systemTicks) || !startTicks) continue;
47632
+ let executable = (0, import_node_fs42.readlinkSync)(`${proc}/exe`);
47633
+ executable = executable.replace(/ \(deleted\)$/, "");
47634
+ if (!this.opts.settings.tempExecPaths.some((path2) => pathWithin(executable, path2))) continue;
47635
+ const name = (0, import_node_path33.basename)(executable).toLowerCase();
47636
+ if (MINERS.has(name)) continue;
47637
+ const key = `${pid}:${startTicks}`;
47638
+ const ticks = userTicks + systemTicks;
47639
+ const previous = this.cpuSamples.get(key);
47640
+ if (!previous) {
47641
+ current.set(key, { ticks, firstAt: now, accumulatedTicks: 0, alerted: false });
47642
+ continue;
47643
+ }
47644
+ const delta = Math.max(0, ticks - previous.ticks);
47645
+ const accumulatedTicks = previous.accumulatedTicks + delta;
47646
+ const elapsedMs = Math.max(1, now - previous.firstAt);
47647
+ const cpuPercent = accumulatedTicks * 1e5 / (this.ticksPerSecond * elapsedMs);
47648
+ const sample = { ticks, firstAt: previous.firstAt, accumulatedTicks, alerted: previous.alerted };
47649
+ current.set(key, sample);
47650
+ if (!sample.alerted && elapsedMs >= CPU_SUSTAIN_MS && cpuPercent >= CPU_THRESHOLD_PERCENT) {
47651
+ sample.alerted = true;
47652
+ const event = {
47653
+ timestamp: new Date(now),
47654
+ module: "edr",
47655
+ category: "system",
47656
+ severity: "high",
47657
+ message: `Unknown executable in a temporary directory sustained ${cpuPercent.toFixed(0)}% CPU: ${clean(executable)}`,
47658
+ 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) }
47659
+ };
47660
+ this.publish(event);
47661
+ }
47662
+ } catch {
47663
+ }
47664
+ }
47665
+ this.cpuSamples.clear();
47666
+ for (const [key, sample] of current) this.cpuSamples.set(key, sample);
47667
+ }
47668
+ };
47669
+
47670
+ // src/daemon/workers/ssh-intrusion.ts
47671
+ var import_node_fs43 = require("fs");
47672
+ var import_node_path34 = require("path");
47673
+ var import_node_child_process15 = require("child_process");
46471
47674
 
46472
47675
  // src/core/asn.ts
46473
47676
  var import_node_dns = require("dns");
@@ -46660,35 +47863,35 @@ function parseKeyLoginsByFingerprint(text) {
46660
47863
  }
46661
47864
  function readJson2(path2) {
46662
47865
  try {
46663
- return JSON.parse((0, import_node_fs41.readFileSync)(path2, "utf-8"));
47866
+ return JSON.parse((0, import_node_fs43.readFileSync)(path2, "utf-8"));
46664
47867
  } catch {
46665
47868
  return null;
46666
47869
  }
46667
47870
  }
46668
47871
  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);
47872
+ (0, import_node_fs43.mkdirSync)((0, import_node_path34.dirname)(path2), { recursive: true });
47873
+ (0, import_node_fs43.writeFileSync)(`${path2}.tmp`, JSON.stringify(value));
47874
+ (0, import_node_fs43.renameSync)(`${path2}.tmp`, path2);
46672
47875
  }
46673
47876
  var fsIO2 = {
46674
47877
  readFile: (p) => {
46675
47878
  try {
46676
- return (0, import_node_fs41.readFileSync)(p, "utf-8");
47879
+ return (0, import_node_fs43.readFileSync)(p, "utf-8");
46677
47880
  } catch {
46678
47881
  return null;
46679
47882
  }
46680
47883
  },
46681
47884
  readDir: (p) => {
46682
47885
  try {
46683
- return (0, import_node_fs41.readdirSync)(p);
47886
+ return (0, import_node_fs43.readdirSync)(p);
46684
47887
  } catch {
46685
47888
  return null;
46686
47889
  }
46687
47890
  },
46688
- exists: (p) => (0, import_node_fs41.existsSync)(p)
47891
+ exists: (p) => (0, import_node_fs43.existsSync)(p)
46689
47892
  };
46690
47893
  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"] });
47894
+ const res = (0, import_node_child_process15.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 6e4, maxBuffer: 64 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
46692
47895
  return res.status === 0 ? res.stdout : null;
46693
47896
  }
46694
47897
  var SshIntrusionWatch = class {
@@ -46886,7 +48089,7 @@ var SshIntrusionWatch = class {
46886
48089
  };
46887
48090
 
46888
48091
  // src/daemon/workers/lightning-watch.ts
46889
- var import_node_fs42 = require("fs");
48092
+ var import_node_fs44 = require("fs");
46890
48093
  var DEFAULT_CLN_LOGS = [
46891
48094
  "/home/lightning/.lightning/cln.log",
46892
48095
  "/root/.lightning/cln.log",
@@ -46942,9 +48145,9 @@ var LightningWatch = class {
46942
48145
  if (this.opts.enabled === false) return [];
46943
48146
  const found = [];
46944
48147
  for (const path2 of this.opts.paths?.length ? this.opts.paths : DEFAULT_CLN_LOGS) {
46945
- if (!(0, import_node_fs42.existsSync)(path2)) continue;
48148
+ if (!(0, import_node_fs44.existsSync)(path2)) continue;
46946
48149
  try {
46947
- (0, import_node_fs42.accessSync)(path2, import_node_fs42.constants.R_OK);
48150
+ (0, import_node_fs44.accessSync)(path2, import_node_fs44.constants.R_OK);
46948
48151
  } catch {
46949
48152
  continue;
46950
48153
  }
@@ -46979,8 +48182,8 @@ var LightningWatch = class {
46979
48182
  };
46980
48183
 
46981
48184
  // src/core/tor-exits.ts
46982
- var import_node_fs43 = require("fs");
46983
- var import_node_path33 = require("path");
48185
+ var import_node_fs45 = require("fs");
48186
+ var import_node_path35 = require("path");
46984
48187
  var import_node_net15 = require("net");
46985
48188
  var TOR_BULK_EXIT_LIST_URL = "https://check.torproject.org/torbulkexitlist";
46986
48189
  function parseTorExitList(text) {
@@ -47048,10 +48251,10 @@ var TorExitList = class _TorExitList {
47048
48251
  }
47049
48252
  loadCache() {
47050
48253
  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"));
48254
+ if (!(0, import_node_fs45.existsSync)(this.opts.cachePath)) return false;
48255
+ const parsed = parseTorExitList((0, import_node_fs45.readFileSync)(this.opts.cachePath, "utf-8"));
47053
48256
  if (parsed.size === 0) return false;
47054
- this.load(parsed, (0, import_node_fs43.statSync)(this.opts.cachePath).mtimeMs);
48257
+ this.load(parsed, (0, import_node_fs45.statSync)(this.opts.cachePath).mtimeMs);
47055
48258
  this.log(`[tor] loaded ${parsed.size} Tor exit addresses from cache (${new Date(this.updatedAt).toISOString()})`);
47056
48259
  return true;
47057
48260
  } catch (err) {
@@ -47083,9 +48286,9 @@ var TorExitList = class _TorExitList {
47083
48286
  const before2 = this.exits.size;
47084
48287
  this.load(parsed);
47085
48288
  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);
48289
+ (0, import_node_fs45.mkdirSync)((0, import_node_path35.dirname)(this.opts.cachePath), { recursive: true });
48290
+ (0, import_node_fs45.writeFileSync)(`${this.opts.cachePath}.tmp`, [...parsed].join("\n") + "\n");
48291
+ (0, import_node_fs45.renameSync)(`${this.opts.cachePath}.tmp`, this.opts.cachePath);
47089
48292
  } catch (err) {
47090
48293
  this.log(`[tor] could not save the exit list cache: ${err.message}`);
47091
48294
  }
@@ -47303,8 +48506,8 @@ var RuleEngine = class {
47303
48506
  };
47304
48507
 
47305
48508
  // src/daemon/rules/loader.ts
47306
- var import_node_fs44 = require("fs");
47307
- var import_node_path34 = require("path");
48509
+ var import_node_fs46 = require("fs");
48510
+ var import_node_path36 = require("path");
47308
48511
 
47309
48512
  // src/daemon/rules/default-rules.ts
47310
48513
  var AT_CRS_THRESHOLD = { field: "severity", operator: "regex", value: "^(high|critical)$" };
@@ -47895,11 +49098,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
47895
49098
  function loadAllRules(customDir) {
47896
49099
  const rules = [...DEFAULT_RULES];
47897
49100
  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"));
49101
+ if ((0, import_node_fs46.existsSync)(dir)) {
49102
+ const files = (0, import_node_fs46.readdirSync)(dir).filter((f) => f.endsWith(".json"));
47900
49103
  for (const file of files) {
47901
49104
  try {
47902
- const raw = (0, import_node_fs44.readFileSync)((0, import_node_path34.join)(dir, file), "utf-8");
49105
+ const raw = (0, import_node_fs46.readFileSync)((0, import_node_path36.join)(dir, file), "utf-8");
47903
49106
  const parsed = JSON.parse(raw);
47904
49107
  const customRules = Array.isArray(parsed) ? parsed : [parsed];
47905
49108
  for (const rule of customRules) {
@@ -47930,9 +49133,9 @@ function loadAllRules(customDir) {
47930
49133
  }
47931
49134
 
47932
49135
  // 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");
49136
+ var import_node_child_process16 = require("child_process");
49137
+ var import_node_fs47 = require("fs");
49138
+ var import_node_path37 = require("path");
47936
49139
  var import_node_net16 = require("net");
47937
49140
  function assertValidFirewallIp(ip) {
47938
49141
  if ((0, import_node_net16.isIP)(ip) !== 4) {
@@ -47945,9 +49148,9 @@ function assertBannableIp(ip) {
47945
49148
  }
47946
49149
  }
47947
49150
  function writeIfAbsent(path2, contents) {
47948
- (0, import_node_fs45.mkdirSync)((0, import_node_path35.dirname)(path2), { recursive: true });
49151
+ (0, import_node_fs47.mkdirSync)((0, import_node_path37.dirname)(path2), { recursive: true });
47949
49152
  try {
47950
- (0, import_node_fs45.writeFileSync)(path2, contents, { flag: "wx" });
49153
+ (0, import_node_fs47.writeFileSync)(path2, contents, { flag: "wx" });
47951
49154
  } catch (err) {
47952
49155
  if (err.code !== "EEXIST") throw err;
47953
49156
  }
@@ -47966,11 +49169,11 @@ var Fail2banAdapter = class {
47966
49169
  enforces = true;
47967
49170
  jailReady = false;
47968
49171
  isAvailable() {
47969
- const result = (0, import_node_child_process15.spawnSync)("fail2ban-client", ["ping"], { stdio: "pipe" });
49172
+ const result = (0, import_node_child_process16.spawnSync)("fail2ban-client", ["ping"], { stdio: "pipe" });
47970
49173
  return result.status === 0;
47971
49174
  }
47972
49175
  client(args) {
47973
- return (0, import_node_child_process15.execFileSync)("fail2ban-client", args, {
49176
+ return (0, import_node_child_process16.execFileSync)("fail2ban-client", args, {
47974
49177
  encoding: "utf-8",
47975
49178
  stdio: ["ignore", "pipe", "pipe"]
47976
49179
  });
@@ -48066,35 +49269,35 @@ var NftablesAdapter = class {
48066
49269
  table = "threatcrush";
48067
49270
  set = "blocklist";
48068
49271
  isAvailable() {
48069
- const result = (0, import_node_child_process15.spawnSync)("nft", ["--version"], { stdio: "pipe" });
49272
+ const result = (0, import_node_child_process16.spawnSync)("nft", ["--version"], { stdio: "pipe" });
48070
49273
  return result.status === 0;
48071
49274
  }
48072
49275
  ensureSetup() {
48073
49276
  try {
48074
- (0, import_node_child_process15.execSync)(`nft list table inet ${this.table} 2>/dev/null`, { stdio: "pipe" });
49277
+ (0, import_node_child_process16.execSync)(`nft list table inet ${this.table} 2>/dev/null`, { stdio: "pipe" });
48075
49278
  } 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`);
49279
+ (0, import_node_child_process16.execSync)(`nft add table inet ${this.table}`);
49280
+ (0, import_node_child_process16.execSync)(`nft add set inet ${this.table} ${this.set} '{ type ipv4_addr; flags timeout; }'`);
49281
+ (0, import_node_child_process16.execSync)(`nft add chain inet ${this.table} input '{ type filter hook input priority -1; policy accept; }'`);
49282
+ (0, import_node_child_process16.execSync)(`nft add rule inet ${this.table} input ip saddr @${this.set} drop`);
48080
49283
  }
48081
49284
  }
48082
49285
  async block(ip) {
48083
49286
  assertValidFirewallIp(ip);
48084
49287
  this.ensureSetup();
48085
- (0, import_node_child_process15.execSync)(`nft add element inet ${this.table} ${this.set} '{ ${ip} }'`);
49288
+ (0, import_node_child_process16.execSync)(`nft add element inet ${this.table} ${this.set} '{ ${ip} }'`);
48086
49289
  }
48087
49290
  async unblock(ip) {
48088
49291
  assertValidFirewallIp(ip);
48089
49292
  try {
48090
- (0, import_node_child_process15.execSync)(`nft delete element inet ${this.table} ${this.set} '{ ${ip} }'`);
49293
+ (0, import_node_child_process16.execSync)(`nft delete element inet ${this.table} ${this.set} '{ ${ip} }'`);
48091
49294
  } catch {
48092
49295
  }
48093
49296
  }
48094
49297
  async isBlocked(ip) {
48095
49298
  assertValidFirewallIp(ip);
48096
49299
  try {
48097
- const output = (0, import_node_child_process15.execSync)(`nft list set inet ${this.table} ${this.set}`, { encoding: "utf-8" });
49300
+ const output = (0, import_node_child_process16.execSync)(`nft list set inet ${this.table} ${this.set}`, { encoding: "utf-8" });
48098
49301
  return output.includes(ip);
48099
49302
  } catch {
48100
49303
  return false;
@@ -48102,7 +49305,7 @@ var NftablesAdapter = class {
48102
49305
  }
48103
49306
  async listBlocked() {
48104
49307
  try {
48105
- const output = (0, import_node_child_process15.execSync)(`nft list set inet ${this.table} ${this.set}`, { encoding: "utf-8" });
49308
+ const output = (0, import_node_child_process16.execSync)(`nft list set inet ${this.table} ${this.set}`, { encoding: "utf-8" });
48106
49309
  const match = output.match(/elements\s*=\s*\{([^}]*)\}/);
48107
49310
  if (!match) return [];
48108
49311
  return match[1].split(",").map((s) => s.trim().split(/\s/)[0]).filter(Boolean);
@@ -48115,34 +49318,34 @@ var IptablesAdapter = class {
48115
49318
  name = "iptables";
48116
49319
  chain = "THREATCRUSH";
48117
49320
  isAvailable() {
48118
- const result = (0, import_node_child_process15.spawnSync)("iptables", ["--version"], { stdio: "pipe" });
49321
+ const result = (0, import_node_child_process16.spawnSync)("iptables", ["--version"], { stdio: "pipe" });
48119
49322
  return result.status === 0;
48120
49323
  }
48121
49324
  ensureChain() {
48122
49325
  try {
48123
- (0, import_node_child_process15.execSync)(`iptables -n -L ${this.chain} 2>/dev/null`, { stdio: "pipe" });
49326
+ (0, import_node_child_process16.execSync)(`iptables -n -L ${this.chain} 2>/dev/null`, { stdio: "pipe" });
48124
49327
  } 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}`);
49328
+ (0, import_node_child_process16.execSync)(`iptables -N ${this.chain}`);
49329
+ (0, import_node_child_process16.execSync)(`iptables -I INPUT 1 -j ${this.chain}`);
48127
49330
  }
48128
49331
  }
48129
49332
  async block(ip) {
48130
49333
  assertValidFirewallIp(ip);
48131
49334
  this.ensureChain();
48132
49335
  if (await this.isBlocked(ip)) return;
48133
- (0, import_node_child_process15.execSync)(`iptables -A ${this.chain} -s ${ip} -j DROP`);
49336
+ (0, import_node_child_process16.execSync)(`iptables -A ${this.chain} -s ${ip} -j DROP`);
48134
49337
  }
48135
49338
  async unblock(ip) {
48136
49339
  assertValidFirewallIp(ip);
48137
49340
  try {
48138
- (0, import_node_child_process15.execSync)(`iptables -D ${this.chain} -s ${ip} -j DROP`);
49341
+ (0, import_node_child_process16.execSync)(`iptables -D ${this.chain} -s ${ip} -j DROP`);
48139
49342
  } catch {
48140
49343
  }
48141
49344
  }
48142
49345
  async isBlocked(ip) {
48143
49346
  assertValidFirewallIp(ip);
48144
49347
  try {
48145
- const output = (0, import_node_child_process15.execSync)(`iptables -n -L ${this.chain}`, { encoding: "utf-8" });
49348
+ const output = (0, import_node_child_process16.execSync)(`iptables -n -L ${this.chain}`, { encoding: "utf-8" });
48146
49349
  return output.includes(ip);
48147
49350
  } catch {
48148
49351
  return false;
@@ -48150,7 +49353,7 @@ var IptablesAdapter = class {
48150
49353
  }
48151
49354
  async listBlocked() {
48152
49355
  try {
48153
- const output = (0, import_node_child_process15.execSync)(`iptables -n -L ${this.chain}`, { encoding: "utf-8" });
49356
+ const output = (0, import_node_child_process16.execSync)(`iptables -n -L ${this.chain}`, { encoding: "utf-8" });
48154
49357
  const ips = [];
48155
49358
  for (const line2 of output.split("\n")) {
48156
49359
  const match = line2.match(/DROP\s+all\s+--\s+(\d+\.\d+\.\d+\.\d+)/);
@@ -48206,8 +49409,8 @@ function detectFirewallAdapter(backend = "auto") {
48206
49409
  }
48207
49410
 
48208
49411
  // src/daemon/firewall/remediation.ts
48209
- var import_node_fs46 = require("fs");
48210
- var import_node_child_process16 = require("child_process");
49412
+ var import_node_fs48 = require("fs");
49413
+ var import_node_child_process17 = require("child_process");
48211
49414
  var import_node_net17 = require("net");
48212
49415
  init_paths();
48213
49416
  init_backoff();
@@ -48278,19 +49481,19 @@ var defaultDiscovery = {
48278
49481
  const snapshot = takeSnapshot({
48279
49482
  readFile: (p) => {
48280
49483
  try {
48281
- return (0, import_node_fs46.readFileSync)(p, "utf-8");
49484
+ return (0, import_node_fs48.readFileSync)(p, "utf-8");
48282
49485
  } catch {
48283
49486
  return null;
48284
49487
  }
48285
49488
  },
48286
49489
  readDir: (p) => {
48287
49490
  try {
48288
- return (0, import_node_fs46.readdirSync)(p);
49491
+ return (0, import_node_fs48.readdirSync)(p);
48289
49492
  } catch {
48290
49493
  return null;
48291
49494
  }
48292
49495
  },
48293
- exists: (p) => (0, import_node_fs46.existsSync)(p)
49496
+ exists: (p) => (0, import_node_fs48.existsSync)(p)
48294
49497
  });
48295
49498
  const out = /* @__PURE__ */ new Set();
48296
49499
  for (const keys of Object.values(snapshot.keys)) {
@@ -48299,7 +49502,7 @@ var defaultDiscovery = {
48299
49502
  return out;
48300
49503
  },
48301
49504
  keyLoginJournal: (sinceSeconds) => new Promise((resolve8) => {
48302
- (0, import_node_child_process16.execFile)(
49505
+ (0, import_node_child_process17.execFile)(
48303
49506
  "journalctl",
48304
49507
  ["_COMM=sshd", "_COMM=sshd-session", `--since=-${Math.ceil(sinceSeconds / 86400)}d`, "-o", "short-unix", "--no-pager", "--grep", "Accepted publickey"],
48305
49508
  { maxBuffer: 32 * 1024 * 1024, timeout: 6e4 },
@@ -48803,7 +50006,7 @@ var RemediationManager = class {
48803
50006
  }
48804
50007
  logLine(line2) {
48805
50008
  try {
48806
- (0, import_node_fs46.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
50009
+ (0, import_node_fs48.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
48807
50010
  `);
48808
50011
  } catch {
48809
50012
  }
@@ -48847,19 +50050,19 @@ function remediationSettings(section) {
48847
50050
  init_backoff();
48848
50051
 
48849
50052
  // src/daemon/watchdog-service.ts
48850
- var import_node_fs47 = require("fs");
48851
- var import_node_path36 = require("path");
50053
+ var import_node_fs49 = require("fs");
50054
+ var import_node_path38 = require("path");
48852
50055
  function defaultShareGid() {
48853
50056
  const isRoot4 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
48854
50057
  if (!isRoot4) return void 0;
48855
50058
  try {
48856
- return (0, import_node_fs47.statSync)("/var/log/auth.log").gid;
50059
+ return (0, import_node_fs49.statSync)("/var/log/auth.log").gid;
48857
50060
  } catch {
48858
50061
  return void 0;
48859
50062
  }
48860
50063
  }
48861
50064
  function startWatchdog(opts) {
48862
- const dir = opts.config?.dir ?? (0, import_node_path36.join)(opts.stateDir, WATCHDOG_DIRNAME);
50065
+ const dir = opts.config?.dir ?? (0, import_node_path38.join)(opts.stateDir, WATCHDOG_DIRNAME);
48863
50066
  const base = { dir, logged: 0, answered: 0, errored: 0 };
48864
50067
  if (opts.config?.enabled === false) {
48865
50068
  opts.log("[watchdog] off ([watchdog] enabled = false)");
@@ -48953,7 +50156,7 @@ async function flushTelemetry(timeoutMs = 2e3) {
48953
50156
  }
48954
50157
 
48955
50158
  // src/core/node-runtime.ts
48956
- var import_node_child_process17 = require("child_process");
50159
+ var import_node_child_process18 = require("child_process");
48957
50160
  var MIN_DAEMON_NODE_MAJOR = 22;
48958
50161
  function nodeMajor(version) {
48959
50162
  const m = String(version ?? "").trim().replace(/^v/, "").match(/^(\d+)\./);
@@ -48967,23 +50170,23 @@ function daemonNodeProblem(version) {
48967
50170
  }
48968
50171
  function versionOfNode(path2) {
48969
50172
  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 });
50173
+ const res = (0, import_node_child_process18.spawnSync)(path2, ["-p", "process.versions.node"], { encoding: "utf-8", timeout: 5e3 });
48971
50174
  return res.status === 0 ? res.stdout.trim() : null;
48972
50175
  }
48973
50176
 
48974
50177
  // src/daemon/index.ts
48975
50178
  function readVersion2() {
48976
50179
  try {
48977
- const pkg = JSON.parse((0, import_node_fs48.readFileSync)((0, import_node_path37.join)(__dirname, "..", "package.json"), "utf-8"));
50180
+ const pkg = JSON.parse((0, import_node_fs50.readFileSync)((0, import_node_path39.join)(__dirname, "..", "package.json"), "utf-8"));
48978
50181
  return pkg.version || "0.0.0";
48979
50182
  } catch {
48980
50183
  return "0.0.0";
48981
50184
  }
48982
50185
  }
48983
50186
  async function runHardeningChecks() {
48984
- const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process18.execFile)(
50187
+ const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process19.execFile)(
48985
50188
  process.execPath,
48986
- [(0, import_node_path37.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
50189
+ [(0, import_node_path39.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
48987
50190
  { timeout: 12e4, maxBuffer: 4 * 1024 * 1024 }
48988
50191
  );
48989
50192
  const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
@@ -48995,9 +50198,9 @@ async function runHardeningChecks() {
48995
50198
  return patches ? [...findings2, patches] : findings2;
48996
50199
  }
48997
50200
  async function runPatchCheck() {
48998
- const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process18.execFile)(
50201
+ const { stdout } = await (0, import_node_util4.promisify)(import_node_child_process19.execFile)(
48999
50202
  process.execPath,
49000
- [(0, import_node_path37.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
50203
+ [(0, import_node_path39.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
49001
50204
  { timeout: 3e5, maxBuffer: 16 * 1024 * 1024 }
49002
50205
  );
49003
50206
  const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
@@ -49005,7 +50208,7 @@ async function runPatchCheck() {
49005
50208
  }
49006
50209
  function logLine(line2) {
49007
50210
  try {
49008
- (0, import_node_fs48.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
50211
+ (0, import_node_fs50.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
49009
50212
  `);
49010
50213
  } catch {
49011
50214
  }
@@ -49030,9 +50233,9 @@ async function runDaemon() {
49030
50233
  logLine(`[daemon] starting threatcrushd v${version} mode=${PATHS.mode}`);
49031
50234
  const restartDaemon = () => {
49032
50235
  if (PATHS.mode === "system") {
49033
- (0, import_node_child_process18.spawn)("systemctl", ["restart", "threatcrushd"], { detached: true, stdio: "ignore" }).unref();
50236
+ (0, import_node_child_process19.spawn)("systemctl", ["restart", "threatcrushd"], { detached: true, stdio: "ignore" }).unref();
49034
50237
  } else {
49035
- (0, import_node_child_process18.spawn)(process.execPath, process.argv.slice(1), { detached: true, stdio: "ignore" }).unref();
50238
+ (0, import_node_child_process19.spawn)(process.execPath, process.argv.slice(1), { detached: true, stdio: "ignore" }).unref();
49036
50239
  setTimeout(() => process.exit(0), 500).unref();
49037
50240
  }
49038
50241
  };
@@ -49047,7 +50250,7 @@ async function runDaemon() {
49047
50250
  } catch (err) {
49048
50251
  logLine(`[daemon] state db unavailable: ${err.message}`);
49049
50252
  }
49050
- const loaded = loadDaemonConfig(PATHS.configFile, (0, import_node_path37.join)(PATHS.stateDir, "threatcrushd.conf.last-good"));
50253
+ const loaded = loadDaemonConfig(PATHS.configFile, (0, import_node_path39.join)(PATHS.stateDir, "threatcrushd.conf.last-good"));
49051
50254
  const config = loaded.config;
49052
50255
  if (loaded.error) {
49053
50256
  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 +50318,7 @@ async function runDaemon() {
49115
50318
  const threatFeeds = new ThreatFeeds({
49116
50319
  settings: { ...feedSettings, allow: [...feedSettings.allow, ...remediation.getAllowlist()] },
49117
50320
  enforcing: !remediationStatus.dry_run && firewallAdapter.enforces !== false,
49118
- cachePath: (0, import_node_path37.join)(PATHS.stateDir, "threat-feeds.json"),
50321
+ cachePath: (0, import_node_path39.join)(PATHS.stateDir, "threat-feeds.json"),
49119
50322
  bus,
49120
50323
  log: logLine
49121
50324
  });
@@ -49123,9 +50326,9 @@ async function runDaemon() {
49123
50326
  const privilegeWatch = new PrivilegeWatch({
49124
50327
  settings: privilegeSettings(config.privileged),
49125
50328
  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"),
50329
+ snapshotPath: (0, import_node_path39.join)(PATHS.stateDir, "privileges.json"),
50330
+ loginsPath: (0, import_node_path39.join)(PATHS.stateDir, "login-countries.json"),
50331
+ cursorPath: (0, import_node_path39.join)(PATHS.stateDir, "sudo-cursor.json"),
49129
50332
  log: logLine
49130
50333
  });
49131
50334
  privilegeWatch.start();
@@ -49136,8 +50339,23 @@ async function runDaemon() {
49136
50339
  log: logLine
49137
50340
  });
49138
50341
  commandHistory.start();
50342
+ const fileIntegrity = new FileIntegrityWatch({
50343
+ bus,
50344
+ settings: fileIntegritySettings(config.file_integrity),
50345
+ baselinePath: (0, import_node_path39.join)(PATHS.stateDir, "file-integrity-baseline.json"),
50346
+ observedPath: (0, import_node_path39.join)(PATHS.stateDir, "file-integrity-observed.json"),
50347
+ log: logLine
50348
+ });
50349
+ fileIntegrity.start();
50350
+ const edr = new EdrWatch({
50351
+ bus,
50352
+ settings: edrSettings(config.edr),
50353
+ networkBaselinePath: (0, import_node_path39.join)(PATHS.stateDir, "edr-outbound-executables.json"),
50354
+ log: logLine
50355
+ });
50356
+ edr.start();
49139
50357
  const torExits = new TorExitList({
49140
- cachePath: (0, import_node_path37.join)(PATHS.stateDir, "tor-exits.txt"),
50358
+ cachePath: (0, import_node_path39.join)(PATHS.stateDir, "tor-exits.txt"),
49141
50359
  url: config.remediation?.tor_exit_list_url,
49142
50360
  log: logLine
49143
50361
  });
@@ -49145,7 +50363,7 @@ async function runDaemon() {
49145
50363
  bus,
49146
50364
  manager: remediation,
49147
50365
  tor: torExits,
49148
- historyPath: (0, import_node_path37.join)(PATHS.stateDir, "key-logins.json"),
50366
+ historyPath: (0, import_node_path39.join)(PATHS.stateDir, "key-logins.json"),
49149
50367
  keyLoginWatch: config.privileged?.key_login_watch !== false,
49150
50368
  log: logLine
49151
50369
  });
@@ -49192,7 +50410,7 @@ async function runDaemon() {
49192
50410
  version,
49193
50411
  hostname: (0, import_node_os14.hostname)(),
49194
50412
  minSeverity,
49195
- spoolPath: (0, import_node_path37.join)(PATHS.stateDir, "cloud-spool.jsonl"),
50413
+ spoolPath: (0, import_node_path39.join)(PATHS.stateDir, "cloud-spool.jsonl"),
49196
50414
  log: logLine,
49197
50415
  ruleModules: new Set(ruleEngine.getRules().flatMap((rule) => rule.source_types)),
49198
50416
  runHardening: runHardeningChecks
@@ -49225,8 +50443,8 @@ async function runDaemon() {
49225
50443
  const autoUpdate = autoUpdateRef = new AutoUpdate({
49226
50444
  version,
49227
50445
  settings: updateSettings(config.update),
49228
- pkgRoot: (0, import_node_path37.join)(__dirname, ".."),
49229
- statePath: (0, import_node_path37.join)(PATHS.stateDir, "auto-update.json"),
50446
+ pkgRoot: (0, import_node_path39.join)(__dirname, ".."),
50447
+ statePath: (0, import_node_path39.join)(PATHS.stateDir, "auto-update.json"),
49230
50448
  bus,
49231
50449
  log: logLine,
49232
50450
  restartDaemon
@@ -49285,6 +50503,14 @@ async function runDaemon() {
49285
50503
  commandHistory.stop();
49286
50504
  } catch {
49287
50505
  }
50506
+ try {
50507
+ fileIntegrity.stop();
50508
+ } catch {
50509
+ }
50510
+ try {
50511
+ edr.stop();
50512
+ } catch {
50513
+ }
49288
50514
  try {
49289
50515
  sshIntrusion.stop();
49290
50516
  } catch {
@@ -49328,7 +50554,7 @@ var SYSTEM_SOCKET = "/var/run/threatcrush/threatcrushd.sock";
49328
50554
  function isRoot2() {
49329
50555
  return typeof process.getuid === "function" && process.getuid() === 0;
49330
50556
  }
49331
- var DAEMON_ENTRY = (0, import_node_path38.join)(__dirname, "daemon.js");
50557
+ var DAEMON_ENTRY = (0, import_node_path40.join)(__dirname, "daemon.js");
49332
50558
  async function daemonForeground() {
49333
50559
  await runDaemon();
49334
50560
  }
@@ -49349,7 +50575,7 @@ async function daemonStart() {
49349
50575
  return;
49350
50576
  }
49351
50577
  ensureRuntimeDirs();
49352
- if (!(0, import_node_fs49.existsSync)(DAEMON_ENTRY)) {
50578
+ if (!(0, import_node_fs51.existsSync)(DAEMON_ENTRY)) {
49353
50579
  console.log(source_default.red(` Daemon entry not found at ${DAEMON_ENTRY}.`));
49354
50580
  console.log(source_default.dim(" Reinstall with `threatcrush update` or `pnpm run build` in the cli package."));
49355
50581
  return;
@@ -49357,8 +50583,8 @@ async function daemonStart() {
49357
50583
  let out;
49358
50584
  let err;
49359
50585
  try {
49360
- out = (0, import_node_fs50.openSync)(PATHS.logFile, "a");
49361
- err = (0, import_node_fs50.openSync)(PATHS.logFile, "a");
50586
+ out = (0, import_node_fs52.openSync)(PATHS.logFile, "a");
50587
+ err = (0, import_node_fs52.openSync)(PATHS.logFile, "a");
49362
50588
  } catch (e) {
49363
50589
  const code = e.code;
49364
50590
  console.log(source_default.red(` \u2717 Cannot write daemon log at ${PATHS.logFile} (${code ?? "error"}).`));
@@ -49371,7 +50597,7 @@ async function daemonStart() {
49371
50597
  }
49372
50598
  return;
49373
50599
  }
49374
- const child = (0, import_node_child_process19.spawn)(process.execPath, [DAEMON_ENTRY], {
50600
+ const child = (0, import_node_child_process20.spawn)(process.execPath, [DAEMON_ENTRY], {
49375
50601
  detached: true,
49376
50602
  stdio: ["ignore", out, err],
49377
50603
  env: { ...process.env, THREATCRUSH_DAEMON: "1" }
@@ -49446,41 +50672,41 @@ async function waitForExit(pid, timeoutMs) {
49446
50672
  }
49447
50673
  async function releaseStaleSocket() {
49448
50674
  const deadline = Date.now() + 2e3;
49449
- while ((0, import_node_fs49.existsSync)(PATHS.socket) && Date.now() < deadline) {
50675
+ while ((0, import_node_fs51.existsSync)(PATHS.socket) && Date.now() < deadline) {
49450
50676
  await new Promise((r) => setTimeout(r, 50));
49451
50677
  }
49452
- if ((0, import_node_fs49.existsSync)(PATHS.socket)) {
50678
+ if ((0, import_node_fs51.existsSync)(PATHS.socket)) {
49453
50679
  try {
49454
- (0, import_node_fs49.unlinkSync)(PATHS.socket);
50680
+ (0, import_node_fs51.unlinkSync)(PATHS.socket);
49455
50681
  } catch {
49456
50682
  }
49457
50683
  }
49458
50684
  }
49459
50685
 
49460
50686
  // 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");
50687
+ var import_node_child_process21 = require("child_process");
50688
+ var import_node_fs53 = require("fs");
50689
+ var import_node_path41 = require("path");
49464
50690
  var import_node_os15 = require("os");
49465
50691
  var UNIT_PATH = "/etc/systemd/system/threatcrushd.service";
49466
50692
  var DAEMON_UNIT_NAME = "threatcrushd.service";
49467
50693
  function resolveTemplate() {
49468
- const templatePath = (0, import_node_path39.join)(__dirname, "systemd", "threatcrushd.service");
49469
- if (!(0, import_node_fs51.existsSync)(templatePath)) {
50694
+ const templatePath = (0, import_node_path41.join)(__dirname, "systemd", "threatcrushd.service");
50695
+ if (!(0, import_node_fs53.existsSync)(templatePath)) {
49470
50696
  throw new Error(`systemd unit template not found at ${templatePath}`);
49471
50697
  }
49472
- return (0, import_node_fs51.readFileSync)(templatePath, "utf-8");
50698
+ return (0, import_node_fs53.readFileSync)(templatePath, "utf-8");
49473
50699
  }
49474
50700
  function stableBinPath(binPath) {
49475
50701
  const stable = binPath.replace(/\/\.pnpm\/[^/]+\/node_modules\//, "/node_modules/");
49476
50702
  if (stable === binPath) return binPath;
49477
- return (0, import_node_fs51.existsSync)(stable) ? stable : binPath;
50703
+ return (0, import_node_fs53.existsSync)(stable) ? stable : binPath;
49478
50704
  }
49479
50705
  function resolveBinPath() {
49480
50706
  const arg = process.argv[1];
49481
- if (arg && (0, import_node_fs51.existsSync)(arg)) return stableBinPath(arg);
50707
+ if (arg && (0, import_node_fs53.existsSync)(arg)) return stableBinPath(arg);
49482
50708
  try {
49483
- return (0, import_node_child_process20.execSync)("command -v threatcrush", { encoding: "utf-8" }).trim();
50709
+ return (0, import_node_child_process21.execSync)("command -v threatcrush", { encoding: "utf-8" }).trim();
49484
50710
  } catch {
49485
50711
  return "threatcrush";
49486
50712
  }
@@ -49488,11 +50714,11 @@ function resolveBinPath() {
49488
50714
  function stableNodePath(execPath) {
49489
50715
  const stable = execPath.replace(/(\/installs\/node\/)[^/]+\//, "$1latest/");
49490
50716
  if (stable === execPath) return execPath;
49491
- return (0, import_node_fs51.existsSync)(stable) ? stable : execPath;
50717
+ return (0, import_node_fs53.existsSync)(stable) ? stable : execPath;
49492
50718
  }
49493
50719
  function looksLikeNodeScript(path2) {
49494
50720
  try {
49495
- const head = (0, import_node_fs51.readFileSync)(path2, "utf-8").slice(0, 120);
50721
+ const head = (0, import_node_fs53.readFileSync)(path2, "utf-8").slice(0, 120);
49496
50722
  return /^#!.*\bnode\b/.test(head);
49497
50723
  } catch {
49498
50724
  return false;
@@ -49519,20 +50745,20 @@ function isRoot3() {
49519
50745
  return typeof process.getuid === "function" && process.getuid() === 0;
49520
50746
  }
49521
50747
  function reexecWithSudo(args) {
49522
- if ((0, import_node_child_process20.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
50748
+ if ((0, import_node_child_process21.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
49523
50749
  console.log(source_default.dim(" This needs root \u2014 sudo will ask for your password.\n"));
49524
50750
  const bin = resolveBinPath();
49525
50751
  const argv = looksLikeNodeScript(bin) ? [stableNodePath(process.execPath), bin, ...args] : [bin, ...args];
49526
- const result = (0, import_node_child_process20.spawnSync)("sudo", argv, { stdio: "inherit" });
50752
+ const result = (0, import_node_child_process21.spawnSync)("sudo", argv, { stdio: "inherit" });
49527
50753
  return result.status === 0;
49528
50754
  }
49529
50755
  function callerHome() {
49530
50756
  const user = process.env.SUDO_USER;
49531
50757
  if (!user) return null;
49532
50758
  try {
49533
- const line2 = (0, import_node_child_process20.execSync)(`getent passwd ${user}`, { encoding: "utf-8" }).trim();
50759
+ const line2 = (0, import_node_child_process21.execSync)(`getent passwd ${user}`, { encoding: "utf-8" }).trim();
49534
50760
  const home = line2.split(":")[5];
49535
- return home && (0, import_node_fs51.existsSync)(home) ? home : null;
50761
+ return home && (0, import_node_fs53.existsSync)(home) ? home : null;
49536
50762
  } catch {
49537
50763
  return null;
49538
50764
  }
@@ -49540,13 +50766,13 @@ function callerHome() {
49540
50766
  function stopUserModeDaemon() {
49541
50767
  const home = callerHome();
49542
50768
  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;
50769
+ const runDir = (0, import_node_path41.join)(home, ".threatcrush", "run");
50770
+ const pidFile = (0, import_node_path41.join)(runDir, "threatcrushd.pid");
50771
+ const socket = (0, import_node_path41.join)(runDir, "threatcrushd.sock");
50772
+ if (!(0, import_node_fs53.existsSync)(pidFile) && !(0, import_node_fs53.existsSync)(socket)) return;
49547
50773
  let pid = null;
49548
50774
  try {
49549
- pid = Number.parseInt((0, import_node_fs51.readFileSync)(pidFile, "utf-8").trim(), 10);
50775
+ pid = Number.parseInt((0, import_node_fs53.readFileSync)(pidFile, "utf-8").trim(), 10);
49550
50776
  } catch {
49551
50777
  pid = null;
49552
50778
  }
@@ -49559,13 +50785,13 @@ function stopUserModeDaemon() {
49559
50785
  }
49560
50786
  for (const path2 of [socket, pidFile]) {
49561
50787
  try {
49562
- if ((0, import_node_fs51.existsSync)(path2)) (0, import_node_fs51.rmSync)(path2);
50788
+ if ((0, import_node_fs53.existsSync)(path2)) (0, import_node_fs53.rmSync)(path2);
49563
50789
  } catch {
49564
50790
  }
49565
50791
  }
49566
50792
  }
49567
50793
  function unitIsActive() {
49568
- const result = (0, import_node_child_process20.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT_NAME], { stdio: "pipe" });
50794
+ const result = (0, import_node_child_process21.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT_NAME], { stdio: "pipe" });
49569
50795
  return result.status === 0;
49570
50796
  }
49571
50797
  async function installServiceCommand() {
@@ -49576,8 +50802,8 @@ async function installServiceCommand() {
49576
50802
  return;
49577
50803
  }
49578
50804
  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")
50805
+ hasSystemctl: (0, import_node_child_process21.spawnSync)("sh", ["-c", "command -v systemctl"], { stdio: "ignore" }).status === 0,
50806
+ booted: (0, import_node_fs53.existsSync)("/run/systemd/system")
49581
50807
  });
49582
50808
  if (noSystemd) {
49583
50809
  console.log(source_default.red(` \u2717 systemd isn't available here: ${noSystemd}.`));
@@ -49599,7 +50825,7 @@ async function installServiceCommand() {
49599
50825
  const isNodeScript = looksLikeNodeScript(binPath);
49600
50826
  let nodePath = stableNodePath(process.execPath);
49601
50827
  if (isNodeScript && nodeVersionDir(binPath)) {
49602
- binPath = (0, import_node_fs51.realpathSync)(binPath);
50828
+ binPath = (0, import_node_fs53.realpathSync)(binPath);
49603
50829
  nodePath = process.execPath;
49604
50830
  }
49605
50831
  if (isNodeScript) {
@@ -49612,11 +50838,11 @@ async function installServiceCommand() {
49612
50838
  }
49613
50839
  }
49614
50840
  const exec = execStartCommand(binPath, nodePath, isNodeScript);
49615
- const configDir = (0, import_node_path39.join)((0, import_node_os15.homedir)(), ".threatcrush");
50841
+ const configDir = (0, import_node_path41.join)((0, import_node_os15.homedir)(), ".threatcrush");
49616
50842
  const commandHistoryEnabled = commandHistorySettings(loadConfig().command_history).enabled;
49617
50843
  const historyPaths = commandHistoryEnabled ? historyWritableHomes() : [];
49618
50844
  const unit = renderUnit(resolveTemplate(), { exec, binPath, configDir, historyPaths });
49619
- (0, import_node_fs51.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
50845
+ (0, import_node_fs53.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
49620
50846
  console.log(source_default.green(` \u2713 Installed unit file: ${UNIT_PATH}`));
49621
50847
  console.log(source_default.dim(` ExecStart=${exec}`));
49622
50848
  const nodeDir = nodeVersionDir(nodePath);
@@ -49631,8 +50857,8 @@ async function installServiceCommand() {
49631
50857
  installLogrotate();
49632
50858
  stopUserModeDaemon();
49633
50859
  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" });
50860
+ (0, import_node_child_process21.execSync)("systemctl daemon-reload", { stdio: "inherit" });
50861
+ (0, import_node_child_process21.execSync)(`systemctl enable --now ${DAEMON_UNIT_NAME}`, { stdio: "inherit" });
49636
50862
  } catch (err) {
49637
50863
  console.log(source_default.yellow(` ! systemctl error: ${err.message}`));
49638
50864
  console.log(source_default.dim(` Logs: journalctl -u ${DAEMON_UNIT_NAME} -n 50`));
@@ -49669,9 +50895,9 @@ function renderLogrotate(logDir = "/var/log/threatcrush") {
49669
50895
  ].join("\n");
49670
50896
  }
49671
50897
  function installLogrotate() {
49672
- if (!(0, import_node_fs51.existsSync)((0, import_node_path39.dirname)(LOGROTATE_PATH))) return;
50898
+ if (!(0, import_node_fs53.existsSync)((0, import_node_path41.dirname)(LOGROTATE_PATH))) return;
49673
50899
  try {
49674
- (0, import_node_fs51.writeFileSync)(LOGROTATE_PATH, renderLogrotate(), { mode: 420 });
50900
+ (0, import_node_fs53.writeFileSync)(LOGROTATE_PATH, renderLogrotate(), { mode: 420 });
49675
50901
  console.log(source_default.green(` \u2713 Log rotation: ${LOGROTATE_PATH} (daily or 200M, keeps 7)`));
49676
50902
  } catch (err) {
49677
50903
  console.log(source_default.yellow(` ! Could not install log rotation: ${err.message}`));
@@ -49693,20 +50919,20 @@ function ensureSystemDirs(configDir) {
49693
50919
  ];
49694
50920
  let admGid2 = null;
49695
50921
  try {
49696
- admGid2 = (0, import_node_fs51.statSync)("/var/log/auth.log").gid;
50922
+ admGid2 = (0, import_node_fs53.statSync)("/var/log/auth.log").gid;
49697
50923
  } catch {
49698
50924
  }
49699
50925
  for (const { path: path2, groupWritable, sticky } of dirs) {
49700
50926
  try {
49701
- (0, import_node_fs51.mkdirSync)(path2, { recursive: true });
50927
+ (0, import_node_fs53.mkdirSync)(path2, { recursive: true });
49702
50928
  } catch {
49703
50929
  }
49704
50930
  try {
49705
50931
  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" });
50932
+ (0, import_node_fs53.chmodSync)(path2, sticky ? 1533 : 509);
50933
+ (0, import_node_child_process21.execSync)(`chgrp adm ${path2}`, { stdio: "ignore" });
49708
50934
  } else {
49709
- (0, import_node_fs51.chmodSync)(path2, 493);
50935
+ (0, import_node_fs53.chmodSync)(path2, 493);
49710
50936
  }
49711
50937
  } catch {
49712
50938
  }
@@ -49726,29 +50952,29 @@ async function uninstallServiceCommand() {
49726
50952
  return;
49727
50953
  }
49728
50954
  try {
49729
- (0, import_node_child_process20.execSync)("systemctl stop threatcrushd.service", { stdio: "inherit" });
50955
+ (0, import_node_child_process21.execSync)("systemctl stop threatcrushd.service", { stdio: "inherit" });
49730
50956
  } catch {
49731
50957
  }
49732
50958
  try {
49733
- (0, import_node_child_process20.execSync)("systemctl disable threatcrushd.service", { stdio: "inherit" });
50959
+ (0, import_node_child_process21.execSync)("systemctl disable threatcrushd.service", { stdio: "inherit" });
49734
50960
  } catch {
49735
50961
  }
49736
50962
  try {
49737
- if ((0, import_node_fs51.existsSync)(UNIT_PATH)) {
49738
- (0, import_node_child_process20.execSync)(`rm -f ${UNIT_PATH}`);
50963
+ if ((0, import_node_fs53.existsSync)(UNIT_PATH)) {
50964
+ (0, import_node_child_process21.execSync)(`rm -f ${UNIT_PATH}`);
49739
50965
  console.log(source_default.green(` \u2713 Removed unit file: ${UNIT_PATH}`));
49740
50966
  }
49741
50967
  } catch {
49742
50968
  }
49743
50969
  try {
49744
- (0, import_node_child_process20.execSync)("systemctl daemon-reload", { stdio: "inherit" });
50970
+ (0, import_node_child_process21.execSync)("systemctl daemon-reload", { stdio: "inherit" });
49745
50971
  } catch {
49746
50972
  }
49747
50973
  console.log(source_default.green(" \u2713 threatcrushd service removed."));
49748
50974
  }
49749
50975
 
49750
50976
  // src/commands/save.ts
49751
- var import_node_fs52 = require("fs");
50977
+ var import_node_fs54 = require("fs");
49752
50978
  var import_toml5 = __toESM(require_toml());
49753
50979
  init_cli_config();
49754
50980
  init_paths();
@@ -49787,9 +51013,9 @@ async function saveCommand(opts = {}) {
49787
51013
  }
49788
51014
  const path2 = opts.config ?? PATHS.configFile;
49789
51015
  let config = {};
49790
- if ((0, import_node_fs52.existsSync)(path2)) {
51016
+ if ((0, import_node_fs54.existsSync)(path2)) {
49791
51017
  try {
49792
- config = import_toml5.default.parse((0, import_node_fs52.readFileSync)(path2, "utf-8"));
51018
+ config = import_toml5.default.parse((0, import_node_fs54.readFileSync)(path2, "utf-8"));
49793
51019
  } catch (err) {
49794
51020
  console.log(source_default.red(` \u2717 ${path2} is not valid TOML: ${err.message}
49795
51021
  `));
@@ -49902,8 +51128,8 @@ function welcomeCommand() {
49902
51128
  }
49903
51129
 
49904
51130
  // src/commands/properties.ts
49905
- var import_node_fs53 = require("fs");
49906
- var import_node_path40 = require("path");
51131
+ var import_node_fs55 = require("fs");
51132
+ var import_node_path42 = require("path");
49907
51133
  var import_node_readline4 = __toESM(require("readline"));
49908
51134
  init_cli_config();
49909
51135
  var API_URL6 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
@@ -50233,8 +51459,8 @@ async function propertiesRunsCommand(opts) {
50233
51459
  }
50234
51460
  }
50235
51461
  function parseImportFile(path2) {
50236
- const ext = (0, import_node_path40.extname)(path2).toLowerCase();
50237
- const raw = (0, import_node_fs53.readFileSync)(path2, "utf-8");
51462
+ const ext = (0, import_node_path42.extname)(path2).toLowerCase();
51463
+ const raw = (0, import_node_fs55.readFileSync)(path2, "utf-8");
50238
51464
  if (ext === ".json") {
50239
51465
  const parsed = JSON.parse(raw);
50240
51466
  if (!Array.isArray(parsed)) throw new Error("JSON must be an array of objects");
@@ -50429,19 +51655,226 @@ async function rulesCommand(opts) {
50429
51655
  }
50430
51656
 
50431
51657
  // src/commands/harden.ts
50432
- var import_node_fs54 = require("fs");
50433
- var import_node_child_process21 = require("child_process");
51658
+ var import_node_fs57 = require("fs");
51659
+ var import_node_child_process22 = require("child_process");
50434
51660
  init_cli_config();
51661
+
51662
+ // src/commands/cis-report.ts
51663
+ var import_node_os16 = require("os");
51664
+ var import_node_fs56 = require("fs");
51665
+ var CIS_UBUNTU_URL = "https://www.cisecurity.org/benchmark/ubuntu_linux";
51666
+ var CIS_DEBIAN_URL = "https://www.cisecurity.org/benchmark/debian_linux";
51667
+ var UBUNTU_2404_CIS_CONTROL_SOURCE = "https://github.com/ComplianceAsCode/content/blob/v0.1.78/controls/cis_ubuntu2404.yml";
51668
+ var EDITIONS = {
51669
+ ubuntu: {
51670
+ "26.04": { version: "1.0.0", name: "CIS Ubuntu Linux 26.04 LTS", source: CIS_UBUNTU_URL },
51671
+ "24.04": { version: "2.0.0", name: "CIS Ubuntu Linux 24.04 LTS", source: CIS_UBUNTU_URL },
51672
+ "22.04": { version: "3.0.0", name: "CIS Ubuntu Linux 22.04 LTS", source: CIS_UBUNTU_URL },
51673
+ "20.04": { version: "3.0.0", name: "CIS Ubuntu Linux 20.04 LTS", source: CIS_UBUNTU_URL }
51674
+ },
51675
+ debian: {
51676
+ "13": { version: "1.1.0", name: "CIS Debian Linux 13", source: CIS_DEBIAN_URL },
51677
+ "12": { version: "2.0.0", name: "CIS Debian Linux 12", source: CIS_DEBIAN_URL },
51678
+ "11": { version: "2.0.0", name: "CIS Debian Linux 11", source: CIS_DEBIAN_URL }
51679
+ }
51680
+ };
51681
+ function osRelease() {
51682
+ let raw = "";
51683
+ try {
51684
+ raw = (0, import_node_fs56.readFileSync)("/etc/os-release", "utf8");
51685
+ } catch {
51686
+ return {};
51687
+ }
51688
+ const fields = {};
51689
+ for (const line2 of raw.split("\n")) {
51690
+ const match = /^([A-Z0-9_]+)=(.*)$/.exec(line2);
51691
+ if (!match) continue;
51692
+ const value = match[2].trim().replace(/^(["'])(.*)\1$/, "$2");
51693
+ fields[match[1]] = value;
51694
+ }
51695
+ return fields;
51696
+ }
51697
+ var VERIFIED_CHECK_MAPPINGS = {
51698
+ ubuntu: {
51699
+ "24.04": {
51700
+ "ssh-root-login": {
51701
+ ids: ["5.1.20"],
51702
+ source: UBUNTU_2404_CIS_CONTROL_SOURCE,
51703
+ osId: "ubuntu",
51704
+ osVersion: "24.04",
51705
+ benchmarkName: "CIS Ubuntu Linux 24.04 LTS",
51706
+ benchmarkVersion: "1.0.0"
51707
+ }
51708
+ }
51709
+ }
51710
+ };
51711
+ function tagCisMappings(findings2, os4 = osRelease()) {
51712
+ const distro = os4.ID?.toLowerCase() ?? "";
51713
+ const version = os4.VERSION_ID ?? "";
51714
+ const checkMappings = VERIFIED_CHECK_MAPPINGS[distro]?.[version] ?? {};
51715
+ return findings2.map((finding) => {
51716
+ const mapping = checkMappings[finding.key];
51717
+ const ids = mapping?.ids ?? [];
51718
+ const status = mapping ? "verified" : "unverified";
51719
+ return {
51720
+ ...finding,
51721
+ cis_control_ids: ids,
51722
+ cis_mapping_status: status,
51723
+ ...mapping ? { cis_mapping_source: mapping.source } : {},
51724
+ ...mapping ? { cis_mapping_benchmark: `${mapping.benchmarkName} v${mapping.benchmarkVersion}` } : {},
51725
+ details: {
51726
+ ...finding.details ?? {},
51727
+ cis_control_ids: ids,
51728
+ cis_mapping_status: status,
51729
+ ...mapping ? { cis_mapping_source: mapping.source } : {},
51730
+ ...mapping ? {
51731
+ cis_profile_os_id: mapping.osId,
51732
+ cis_profile_os_version: mapping.osVersion,
51733
+ cis_profile_name: mapping.benchmarkName,
51734
+ cis_profile_version: mapping.benchmarkVersion
51735
+ } : {}
51736
+ }
51737
+ };
51738
+ });
51739
+ }
51740
+ function buildCisEvidenceReport(findings2, score, now = /* @__PURE__ */ new Date()) {
51741
+ const os4 = osRelease();
51742
+ const id = os4.ID?.toLowerCase() ?? null;
51743
+ const version = os4.VERSION_ID ?? null;
51744
+ const edition = id && version ? EDITIONS[id]?.[version] : void 0;
51745
+ const checks = tagCisMappings(findings2, os4).map((finding) => ({
51746
+ ...finding,
51747
+ cis_control_ids: finding.cis_control_ids ?? [],
51748
+ mapping_status: finding.cis_mapping_status ?? "unverified",
51749
+ ...finding.cis_mapping_source ? { mapping_source: finding.cis_mapping_source } : {},
51750
+ ...finding.cis_mapping_benchmark ? { mapping_benchmark: finding.cis_mapping_benchmark } : {}
51751
+ }));
51752
+ const mappedControls = new Set(checks.flatMap((check2) => check2.mapping_status === "verified" ? check2.cis_control_ids : []));
51753
+ return {
51754
+ schema_version: 1,
51755
+ generated_at: now.toISOString(),
51756
+ benchmark_catalog_checked_at: "2026-11-01",
51757
+ host: { hostname: (0, import_node_os16.hostname)(), os_id: id, os_version: version, pretty_name: os4.PRETTY_NAME ?? null },
51758
+ benchmark: edition ? { name: edition.name, version: edition.version, source: edition.source } : null,
51759
+ assessment: "partial",
51760
+ mapped_controls: mappedControls.size,
51761
+ total_checks: findings2.length,
51762
+ hardening_score: score,
51763
+ checks,
51764
+ limitations: [
51765
+ "This report contains ThreatCrush hardening checks only; it does not assess a CIS Benchmark profile.",
51766
+ "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.",
51767
+ "A PASS is a result for the named ThreatCrush check, not a CIS control pass or a certification claim."
51768
+ ]
51769
+ };
51770
+ }
51771
+ function renderCisMarkdown(report) {
51772
+ const benchmark = report.benchmark ? `${report.benchmark.name} v${report.benchmark.version} (${report.benchmark.source})` : "No CIS Benchmark edition is known for this OS release";
51773
+ const rows2 = report.checks.map((check2) => {
51774
+ const facts = check2.details ? ` Observed data: ${JSON.stringify(check2.details)}` : "";
51775
+ const evidence = `${check2.explanation}${facts}`.replace(/[|\r\n]+/g, " ").trim();
51776
+ const recommendation2 = check2.recommendation?.replace(/[|\r\n]+/g, " ").trim() ?? "\u2014";
51777
+ const mapping = check2.cis_control_ids.length ? check2.cis_control_ids.join(", ") : "Unverified";
51778
+ const reference = [check2.mapping_benchmark, check2.mapping_source].filter(Boolean).join("; ");
51779
+ const source = reference ? ` (${reference})` : "";
51780
+ return `| ${check2.key} | ${check2.status.toUpperCase()} | ${mapping}${source} | ${evidence} | ${recommendation2} |`;
51781
+ });
51782
+ return [
51783
+ "# CIS benchmark evidence report",
51784
+ "",
51785
+ "> Partial ThreatCrush evidence only. This is not a CIS Benchmark assessment or certification report.",
51786
+ "",
51787
+ `- Generated: ${report.generated_at}`,
51788
+ `- CIS edition catalog checked: ${report.benchmark_catalog_checked_at}`,
51789
+ `- Host: ${report.host.hostname}`,
51790
+ `- OS: ${report.host.pretty_name ?? "unknown"} (${report.host.os_id ?? "unknown"} ${report.host.os_version ?? "unknown"})`,
51791
+ `- Benchmark edition: ${benchmark}`,
51792
+ `- ThreatCrush hardening score: ${report.hardening_score}/100`,
51793
+ `- Mapped CIS controls: ${report.mapped_controls}`,
51794
+ "",
51795
+ "| Check | Result | CIS mapping | Evidence | Recommendation |",
51796
+ "|---|---|---|---|---|",
51797
+ ...rows2,
51798
+ "",
51799
+ "## Limitations",
51800
+ "",
51801
+ ...report.limitations.map((limitation) => `- ${limitation}`),
51802
+ ""
51803
+ ].join("\n");
51804
+ }
51805
+ function pdfEscape(value) {
51806
+ return value.replace(/[^\x20-\x7e]/g, "?").replace(/[\\()]/g, "\\$&");
51807
+ }
51808
+ function renderCisPdf(markdown) {
51809
+ const lines = markdown.split("\n").flatMap((line2) => {
51810
+ const safe = line2.replace(/[^\x20-\x7e]/g, "?");
51811
+ if (safe.length <= 96) return [safe];
51812
+ const parts = [];
51813
+ for (let i = 0; i < safe.length; i += 96) parts.push(safe.slice(i, i + 96));
51814
+ return parts;
51815
+ });
51816
+ const pages = [];
51817
+ for (let i = 0; i < lines.length; i += 48) pages.push(lines.slice(i, i + 48));
51818
+ if (pages.length === 0) pages.push([]);
51819
+ const objects = [];
51820
+ const pageRefs = [];
51821
+ objects.push("<< /Type /Catalog /Pages 2 0 R >>");
51822
+ objects.push("");
51823
+ objects.push("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>");
51824
+ pages.forEach((page, index) => {
51825
+ const pageId = 4 + index * 2;
51826
+ const streamId = pageId + 1;
51827
+ pageRefs.push(`${pageId} 0 R`);
51828
+ const text = ["BT", "/F1 9 Tf", "50 760 Td", "14 TL", ...page.flatMap((line2) => [`(${pdfEscape(line2)}) Tj`, "T*"]), "ET"].join("\n");
51829
+ objects.push(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 3 0 R >> >> /Contents ${streamId} 0 R >>`);
51830
+ objects.push(`<< /Length ${Buffer.byteLength(text, "ascii")} >>
51831
+ stream
51832
+ ${text}
51833
+ endstream`);
51834
+ });
51835
+ objects[1] = `<< /Type /Pages /Kids [${pageRefs.join(" ")}] /Count ${pages.length} >>`;
51836
+ let pdf = "%PDF-1.4\n";
51837
+ const offsets = [0];
51838
+ objects.forEach((object, index) => {
51839
+ offsets.push(Buffer.byteLength(pdf, "ascii"));
51840
+ pdf += `${index + 1} 0 obj
51841
+ ${object}
51842
+ endobj
51843
+ `;
51844
+ });
51845
+ const xref = Buffer.byteLength(pdf, "ascii");
51846
+ pdf += `xref
51847
+ 0 ${objects.length + 1}
51848
+ 0000000000 65535 f
51849
+ `;
51850
+ for (const offset of offsets.slice(1)) pdf += `${String(offset).padStart(10, "0")} 00000 n
51851
+ `;
51852
+ pdf += `trailer
51853
+ << /Size ${objects.length + 1} /Root 1 0 R >>
51854
+ startxref
51855
+ ${xref}
51856
+ %%EOF
51857
+ `;
51858
+ return Buffer.from(pdf, "ascii");
51859
+ }
51860
+ function writeCisReport(path2, format2, report) {
51861
+ const markdown = renderCisMarkdown(report);
51862
+ const content = format2 === "json" ? `${JSON.stringify(report, null, 2)}
51863
+ ` : format2 === "pdf" ? renderCisPdf(markdown) : markdown;
51864
+ (0, import_node_fs56.writeFileSync)(path2, content);
51865
+ }
51866
+
51867
+ // src/commands/harden.ts
50435
51868
  function tryExec(cmd) {
50436
51869
  try {
50437
- return (0, import_node_child_process21.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
51870
+ return (0, import_node_child_process22.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
50438
51871
  } catch {
50439
51872
  return null;
50440
51873
  }
50441
51874
  }
50442
51875
  function tryRead(path2) {
50443
51876
  try {
50444
- return (0, import_node_fs54.readFileSync)(path2, "utf-8");
51877
+ return (0, import_node_fs57.readFileSync)(path2, "utf-8");
50445
51878
  } catch {
50446
51879
  return null;
50447
51880
  }
@@ -50478,34 +51911,44 @@ function checkSshPasswordAuth() {
50478
51911
  };
50479
51912
  }
50480
51913
  function checkSshRootLogin() {
50481
- const config = tryRead("/etc/ssh/sshd_config");
50482
- if (!config) {
51914
+ const effective = tryExec("sshd -T 2>/dev/null");
51915
+ if (!effective) {
50483
51916
  return {
50484
51917
  key: "ssh-root-login",
50485
51918
  status: "warn",
50486
51919
  severity: "high",
50487
51920
  title: "SSH Root Login",
50488
- explanation: "Could not read sshd_config.",
51921
+ explanation: "Could not read the effective sshd configuration with `sshd -T`.",
50489
51922
  recommendation: 'Set "PermitRootLogin no" in /etc/ssh/sshd_config.'
50490
51923
  };
50491
51924
  }
50492
- const match = config.match(/^\s*PermitRootLogin\s+(\S+)/mi);
50493
- if (!match || match[1] === "yes") {
51925
+ const match = effective.match(/^permitrootlogin\s+(\S+)/mi);
51926
+ if (!match) {
51927
+ return {
51928
+ key: "ssh-root-login",
51929
+ status: "warn",
51930
+ severity: "high",
51931
+ title: "SSH Root Login",
51932
+ explanation: "The effective sshd output did not include PermitRootLogin.",
51933
+ recommendation: 'Set "PermitRootLogin no" in the effective SSH server configuration.'
51934
+ };
51935
+ }
51936
+ if (match[1].toLowerCase() !== "no") {
50494
51937
  return {
50495
51938
  key: "ssh-root-login",
50496
51939
  status: "fail",
50497
51940
  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.'
51941
+ title: "Root SSH Login Not Fully Disabled",
51942
+ explanation: `The effective PermitRootLogin value is "${match[1]}"; CIS requires it to be "no".`,
51943
+ recommendation: 'Set "PermitRootLogin no" in the effective SSH server configuration.'
50501
51944
  };
50502
51945
  }
50503
51946
  return {
50504
51947
  key: "ssh-root-login",
50505
51948
  status: "pass",
50506
51949
  severity: "high",
50507
- title: "Root SSH Login Restricted",
50508
- explanation: `PermitRootLogin is set to "${match[1]}".`
51950
+ title: "Root SSH Login Disabled",
51951
+ explanation: 'The effective PermitRootLogin value is "no".'
50509
51952
  };
50510
51953
  }
50511
51954
  function checkSshWeakConfig() {
@@ -50545,8 +51988,8 @@ function checkSshWeakConfig() {
50545
51988
  };
50546
51989
  }
50547
51990
  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");
51991
+ 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");
51992
+ const dnfAuto = (0, import_node_fs57.existsSync)("/etc/dnf/automatic.conf");
50550
51993
  if (unattended || dnfAuto) {
50551
51994
  return {
50552
51995
  key: "auto-updates",
@@ -50672,7 +52115,7 @@ function checkFail2ban() {
50672
52115
  explanation: "fail2ban is installed and running."
50673
52116
  };
50674
52117
  }
50675
- if ((0, import_node_fs54.existsSync)("/etc/fail2ban/fail2ban.conf")) {
52118
+ if ((0, import_node_fs57.existsSync)("/etc/fail2ban/fail2ban.conf")) {
50676
52119
  return {
50677
52120
  key: checkKey,
50678
52121
  status: "warn",
@@ -50772,6 +52215,9 @@ function computeScore(results) {
50772
52215
  if (maxScore === 0) return 100;
50773
52216
  return Math.max(0, Math.round((maxScore - deductions) / maxScore * 100));
50774
52217
  }
52218
+ function cisLabel(result) {
52219
+ return result.cis_control_ids?.length ? `CIS ${result.cis_mapping_benchmark ?? "mapping"}: ${result.cis_control_ids.join(", ")}` : "CIS: mapping unverified";
52220
+ }
50775
52221
  async function uploadFindings(results, json2) {
50776
52222
  const say = (line2) => json2 ? console.error(line2) : console.log(line2);
50777
52223
  const link = currentLink();
@@ -50806,14 +52252,42 @@ async function uploadFindings(results, json2) {
50806
52252
  say("");
50807
52253
  }
50808
52254
  async function hardenCommand(opts) {
50809
- if (!opts.json) {
52255
+ if (!opts.json && !opts.report) {
50810
52256
  banner();
50811
52257
  logger.info("Running hardening scan...\n");
50812
52258
  }
50813
- const spinner = opts.json ? null : ora({ text: "Scanning system configuration...", color: "green" }).start();
50814
- const results = runAllChecks();
52259
+ const spinner = opts.json || opts.report ? null : ora({ text: "Scanning system configuration...", color: "green" }).start();
52260
+ const results = tagCisMappings(runAllChecks());
50815
52261
  const score = computeScore(results);
50816
52262
  if (spinner) spinner.succeed("Hardening scan complete\n");
52263
+ if (opts.report) {
52264
+ if (opts.report !== "cis") {
52265
+ console.error(source_default.red(` Unknown report framework "${opts.report}". Use cis.`));
52266
+ process.exitCode = 1;
52267
+ return;
52268
+ }
52269
+ const format2 = opts.format ?? (opts.json ? "json" : "md");
52270
+ if (format2 !== "md" && format2 !== "pdf" && format2 !== "json") {
52271
+ console.error(source_default.red(` Unknown report format "${format2}". Use md, pdf, or json.`));
52272
+ process.exitCode = 1;
52273
+ return;
52274
+ }
52275
+ if (format2 === "pdf" && !opts.output) {
52276
+ console.error(source_default.red(" PDF output requires --output <path>."));
52277
+ process.exitCode = 1;
52278
+ return;
52279
+ }
52280
+ const report = buildCisEvidenceReport(results, score);
52281
+ if (opts.output) {
52282
+ writeCisReport(opts.output, format2, report);
52283
+ console.error(source_default.green(` Wrote partial CIS evidence report to ${opts.output}`));
52284
+ } else {
52285
+ const markdown = renderCisMarkdown(report);
52286
+ console.log(format2 === "json" ? JSON.stringify(report, null, 2) : markdown);
52287
+ }
52288
+ if (opts.upload !== false) await uploadFindings(results, true);
52289
+ return;
52290
+ }
50817
52291
  if (opts.json) {
50818
52292
  console.log(JSON.stringify({ score, findings: results }, null, 2));
50819
52293
  if (opts.upload !== false) await uploadFindings(results, true);
@@ -50831,6 +52305,7 @@ async function hardenCommand(opts) {
50831
52305
  for (const r of fails) {
50832
52306
  console.log(` ${source_default.red("\u2717")} ${source_default.white.bold(r.title)}`);
50833
52307
  console.log(` ${source_default.gray(r.explanation)}`);
52308
+ console.log(` ${source_default.gray(cisLabel(r))}`);
50834
52309
  if (r.recommendation) console.log(` ${source_default.yellow("Fix:")} ${r.recommendation}`);
50835
52310
  console.log();
50836
52311
  }
@@ -50840,6 +52315,7 @@ async function hardenCommand(opts) {
50840
52315
  for (const r of warns) {
50841
52316
  console.log(` ${source_default.yellow("!")} ${source_default.white.bold(r.title)}`);
50842
52317
  console.log(` ${source_default.gray(r.explanation)}`);
52318
+ console.log(` ${source_default.gray(cisLabel(r))}`);
50843
52319
  if (r.recommendation) console.log(` ${source_default.yellow("Fix:")} ${r.recommendation}`);
50844
52320
  console.log();
50845
52321
  }
@@ -50848,6 +52324,7 @@ async function hardenCommand(opts) {
50848
52324
  console.log(source_default.green.bold(" PASS"));
50849
52325
  for (const r of passes) {
50850
52326
  console.log(` ${source_default.green("\u2713")} ${source_default.white(r.title)}`);
52327
+ console.log(` ${source_default.gray(cisLabel(r))}`);
50851
52328
  }
50852
52329
  console.log();
50853
52330
  }
@@ -50858,9 +52335,9 @@ async function hardenCommand(opts) {
50858
52335
  }
50859
52336
 
50860
52337
  // 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");
52338
+ var import_node_fs58 = require("fs");
52339
+ var import_node_path43 = require("path");
52340
+ var import_node_child_process23 = require("child_process");
50864
52341
  var import_node_util5 = require("util");
50865
52342
 
50866
52343
  // src/core/patches/dpkg-version.ts
@@ -50920,7 +52397,7 @@ var STALE_AFTER_MS = 2 * 864e5;
50920
52397
  var SEVERITIES2 = ["info", "low", "medium", "high", "critical"];
50921
52398
  var RANK = { info: 0, low: 1, medium: 2, high: 3, critical: 4 };
50922
52399
  var defaultExec = async (file, args) => {
50923
- const { stdout } = await (0, import_node_util5.promisify)(import_node_child_process22.execFile)(file, args, {
52400
+ const { stdout } = await (0, import_node_util5.promisify)(import_node_child_process23.execFile)(file, args, {
50924
52401
  timeout: 12e4,
50925
52402
  maxBuffer: 32 * 1024 * 1024,
50926
52403
  env: { ...process.env, LC_ALL: "C" }
@@ -51019,9 +52496,9 @@ async function osvRecords(doFetch, ecosystem, source, version) {
51019
52496
  function newestReleaseMtime(dir) {
51020
52497
  try {
51021
52498
  let newest = 0;
51022
- for (const name of (0, import_node_fs55.readdirSync)(dir)) {
52499
+ for (const name of (0, import_node_fs58.readdirSync)(dir)) {
51023
52500
  if (!/Release$/.test(name)) continue;
51024
- newest = Math.max(newest, (0, import_node_fs55.statSync)((0, import_node_path41.join)(dir, name)).mtimeMs);
52501
+ newest = Math.max(newest, (0, import_node_fs58.statSync)((0, import_node_path43.join)(dir, name)).mtimeMs);
51025
52502
  }
51026
52503
  return newest > 0 ? new Date(newest) : null;
51027
52504
  } catch {
@@ -51038,7 +52515,7 @@ async function checkPatches(opts = {}) {
51038
52515
  let osText = opts.osRelease;
51039
52516
  if (osText === void 0) {
51040
52517
  try {
51041
- osText = (0, import_node_fs55.readFileSync)("/etc/os-release", "utf-8");
52518
+ osText = (0, import_node_fs58.readFileSync)("/etc/os-release", "utf-8");
51042
52519
  } catch {
51043
52520
  osText = "";
51044
52521
  }
@@ -51265,26 +52742,26 @@ async function patchesCommand(opts) {
51265
52742
 
51266
52743
  // src/commands/feeds.ts
51267
52744
  var import_node_net18 = require("net");
51268
- var import_node_path43 = require("path");
52745
+ var import_node_path45 = require("path");
51269
52746
  init_paths();
51270
52747
 
51271
52748
  // 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");
52749
+ var import_node_child_process24 = require("child_process");
52750
+ var import_node_fs59 = require("fs");
52751
+ var import_node_path44 = require("path");
51275
52752
  var realIO = {
51276
- exists: (p) => (0, import_node_fs56.existsSync)(p),
52753
+ exists: (p) => (0, import_node_fs59.existsSync)(p),
51277
52754
  read: (p) => {
51278
52755
  try {
51279
- return (0, import_node_fs56.readFileSync)(p, "utf-8");
52756
+ return (0, import_node_fs59.readFileSync)(p, "utf-8");
51280
52757
  } catch {
51281
52758
  return null;
51282
52759
  }
51283
52760
  },
51284
- write: (p, c) => (0, import_node_fs56.writeFileSync)(p, c),
51285
- remove: (p) => (0, import_node_fs56.rmSync)(p, { force: true }),
52761
+ write: (p, c) => (0, import_node_fs59.writeFileSync)(p, c),
52762
+ remove: (p) => (0, import_node_fs59.rmSync)(p, { force: true }),
51286
52763
  run: (cmd, args) => {
51287
- const r = (0, import_node_child_process23.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 3e4 });
52764
+ const r = (0, import_node_child_process24.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 3e4 });
51288
52765
  return { code: r.status ?? 1, out: `${r.stdout ?? ""}${r.stderr ?? ""}`.trim() };
51289
52766
  }
51290
52767
  };
@@ -51292,17 +52769,17 @@ var APPARMOR_LOCAL = "/etc/apparmor.d/local/usr.sbin.unbound";
51292
52769
  var APPARMOR_PROFILE = "/etc/apparmor.d/usr.sbin.unbound";
51293
52770
  function hookContent(resolver, stateDir) {
51294
52771
  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)}"
52772
+ return resolver === "dnsmasq" ? `${head}addn-hosts=${(0, import_node_path44.join)(stateDir, RESOLVER_FILES.hosts)}
52773
+ ` : `${head}include: "${(0, import_node_path44.join)(stateDir, RESOLVER_FILES.unbound)}"
51297
52774
  `;
51298
52775
  }
51299
52776
  function apparmorRule(stateDir) {
51300
- return ` ${(0, import_node_path42.join)(stateDir, RESOLVER_FILES.unbound)} r, # threatcrush`;
52777
+ return ` ${(0, import_node_path44.join)(stateDir, RESOLVER_FILES.unbound)} r, # threatcrush`;
51301
52778
  }
51302
52779
  function detectResolvers(io = realIO) {
51303
52780
  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");
52781
+ if (io.exists((0, import_node_path44.dirname)(RESOLVER_HOOKS.dnsmasq)) && io.run("dnsmasq", ["--version"]).code === 0) found.push("dnsmasq");
52782
+ if (io.exists((0, import_node_path44.dirname)(RESOLVER_HOOKS.unbound)) && io.run("unbound-checkconf", ["-h"]).code !== 127) found.push("unbound");
51306
52783
  return found;
51307
52784
  }
51308
52785
  function check(resolver, io) {
@@ -51315,7 +52792,7 @@ function restartIfActive(resolver, io) {
51315
52792
  }
51316
52793
  function installHook(resolver, stateDir, io = realIO) {
51317
52794
  const hook = RESOLVER_HOOKS[resolver];
51318
- const file = (0, import_node_path42.join)(stateDir, resolver === "dnsmasq" ? RESOLVER_FILES.hosts : RESOLVER_FILES.unbound);
52795
+ const file = (0, import_node_path44.join)(stateDir, resolver === "dnsmasq" ? RESOLVER_FILES.hosts : RESOLVER_FILES.unbound);
51319
52796
  if (!io.exists(file)) io.write(file, resolver === "dnsmasq" ? hostsBlocklist([]) : unboundBlocklist([]));
51320
52797
  io.write(hook, hookContent(resolver, stateDir));
51321
52798
  if (resolver === "unbound" && io.exists(APPARMOR_LOCAL)) {
@@ -51376,8 +52853,8 @@ function resolverCommand(sub, stateDir, io = realIO) {
51376
52853
  }
51377
52854
  return failed ? 1 : 0;
51378
52855
  }
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));
52856
+ const hosts = io.read((0, import_node_path44.join)(stateDir, RESOLVER_FILES.hosts));
52857
+ const unbound = io.read((0, import_node_path44.join)(stateDir, RESOLVER_FILES.unbound));
51381
52858
  console.log(` resolvers here: ${found.join(", ") || "none that can block (systemd-resolved only?)"}`);
51382
52859
  for (const r of ["dnsmasq", "unbound"]) {
51383
52860
  console.log(` ${r.padEnd(8)} hook ${io.exists(RESOLVER_HOOKS[r]) ? source_default.green("installed") : source_default.gray("not installed")}`);
@@ -51389,11 +52866,11 @@ function resolverCommand(sub, stateDir, io = realIO) {
51389
52866
  // src/commands/feeds.ts
51390
52867
  async function loadSet() {
51391
52868
  for (const dir of [SYSTEM_PATHS.stateDir, USER_PATHS.stateDir]) {
51392
- const path2 = (0, import_node_path43.join)(dir, "threat-feeds.json");
52869
+ const path2 = (0, import_node_path45.join)(dir, "threat-feeds.json");
51393
52870
  const set = readFeedCache(path2);
51394
52871
  if (set) return { set, from: path2 };
51395
52872
  }
51396
- const settings = threatFeedSettings(loadConfig((0, import_node_path43.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).threat_feeds);
52873
+ const settings = threatFeedSettings(loadConfig((0, import_node_path45.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).threat_feeds);
51397
52874
  return { set: await fetchFeeds(settings), from: "abuse.ch (live; no daemon cache readable)" };
51398
52875
  }
51399
52876
  async function feedsCommand(action, value, opts) {
@@ -51437,21 +52914,21 @@ async function feedsCommand(action, value, opts) {
51437
52914
  }
51438
52915
 
51439
52916
  // src/commands/tor.ts
51440
- var import_node_fs57 = require("fs");
52917
+ var import_node_fs60 = require("fs");
51441
52918
  var import_node_net19 = require("net");
51442
- var import_node_path44 = require("path");
52919
+ var import_node_path46 = require("path");
51443
52920
  init_paths();
51444
52921
  async function torCommand(action, value, opts) {
51445
52922
  let exits = /* @__PURE__ */ new Set();
51446
52923
  let from = "";
51447
52924
  let updated = null;
51448
52925
  for (const dir of [SYSTEM_PATHS.stateDir, USER_PATHS.stateDir]) {
51449
- const path2 = (0, import_node_path44.join)(dir, "tor-exits.txt");
52926
+ const path2 = (0, import_node_path46.join)(dir, "tor-exits.txt");
51450
52927
  try {
51451
- if (!(0, import_node_fs57.existsSync)(path2)) continue;
51452
- exits = parseTorExitList((0, import_node_fs57.readFileSync)(path2, "utf-8"));
52928
+ if (!(0, import_node_fs60.existsSync)(path2)) continue;
52929
+ exits = parseTorExitList((0, import_node_fs60.readFileSync)(path2, "utf-8"));
51453
52930
  from = path2;
51454
- updated = (0, import_node_fs57.statSync)(path2).mtime;
52931
+ updated = (0, import_node_fs60.statSync)(path2).mtime;
51455
52932
  break;
51456
52933
  } catch {
51457
52934
  }
@@ -51467,7 +52944,7 @@ async function torCommand(action, value, opts) {
51467
52944
  } catch {
51468
52945
  }
51469
52946
  }
51470
- const remediation = loadConfig((0, import_node_path44.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).remediation;
52947
+ const remediation = loadConfig((0, import_node_path46.join)(SYSTEM_PATHS.configDir, "threatcrushd.conf")).remediation;
51471
52948
  const ban = remediation?.block_tor_ssh !== false && remediation?.enabled !== false;
51472
52949
  if (action === "check") {
51473
52950
  if (!value || !(0, import_node_net19.isIP)(value)) {
@@ -51498,14 +52975,14 @@ async function torCommand(action, value, opts) {
51498
52975
  }
51499
52976
 
51500
52977
  // 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");
52978
+ var import_node_os17 = require("os");
52979
+ var import_node_fs61 = require("fs");
52980
+ var import_node_path47 = require("path");
51504
52981
  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");
52982
+ var CONFIG_PATH4 = (0, import_node_path47.join)((0, import_node_os17.homedir)(), ".threatcrush", "config.json");
51506
52983
  function readConfig3() {
51507
52984
  try {
51508
- return JSON.parse((0, import_node_fs58.readFileSync)(CONFIG_PATH4, "utf-8"));
52985
+ return JSON.parse((0, import_node_fs61.readFileSync)(CONFIG_PATH4, "utf-8"));
51509
52986
  } catch {
51510
52987
  return {};
51511
52988
  }
@@ -51693,7 +53170,7 @@ async function reputationSubscribeCommand(opts) {
51693
53170
  }
51694
53171
 
51695
53172
  // src/commands/privileged.ts
51696
- var import_node_fs59 = require("fs");
53173
+ var import_node_fs62 = require("fs");
51697
53174
  init_paths();
51698
53175
  var SEV2 = {
51699
53176
  critical: source_default.red.bold,
@@ -51706,19 +53183,19 @@ async function privilegedCommand(opts) {
51706
53183
  const snapshot = takeSnapshot({
51707
53184
  readFile: (p) => {
51708
53185
  try {
51709
- return (0, import_node_fs59.readFileSync)(p, "utf-8");
53186
+ return (0, import_node_fs62.readFileSync)(p, "utf-8");
51710
53187
  } catch {
51711
53188
  return null;
51712
53189
  }
51713
53190
  },
51714
53191
  readDir: (p) => {
51715
53192
  try {
51716
- return (0, import_node_fs59.readdirSync)(p);
53193
+ return (0, import_node_fs62.readdirSync)(p);
51717
53194
  } catch {
51718
53195
  return null;
51719
53196
  }
51720
53197
  },
51721
- exists: (p) => (0, import_node_fs59.existsSync)(p)
53198
+ exists: (p) => (0, import_node_fs62.existsSync)(p)
51722
53199
  });
51723
53200
  let events = [];
51724
53201
  let ledgerNote = "";
@@ -51759,6 +53236,259 @@ async function privilegedCommand(opts) {
51759
53236
  console.log();
51760
53237
  }
51761
53238
 
53239
+ // src/commands/integrity.ts
53240
+ var import_node_fs63 = require("fs");
53241
+ var import_node_path48 = require("path");
53242
+ init_paths();
53243
+ function readState2(path2) {
53244
+ try {
53245
+ return JSON.parse((0, import_node_fs63.readFileSync)(path2, "utf8"));
53246
+ } catch {
53247
+ return null;
53248
+ }
53249
+ }
53250
+ function changedCount(baseline, observed) {
53251
+ if (!baseline?.files || !observed?.files) return 0;
53252
+ const paths = /* @__PURE__ */ new Set([...Object.keys(baseline.files), ...Object.keys(observed.files)]);
53253
+ let changed = 0;
53254
+ for (const path2 of paths) {
53255
+ const normalizeSignature = (value) => value.replace(/;entropy=\d+(?:\.\d+)?$/, "");
53256
+ const before2 = baseline.files[path2] ?? "missing";
53257
+ const after = observed.files[path2] ?? "missing";
53258
+ if (normalizeSignature(before2) !== normalizeSignature(after)) changed++;
53259
+ }
53260
+ return changed;
53261
+ }
53262
+ async function integrityCommand(action = "status", opts = {}) {
53263
+ const config = loadConfig();
53264
+ const settings = fileIntegritySettings(config.file_integrity);
53265
+ const systemBaseline = (0, import_node_path48.join)(SYSTEM_PATHS.stateDir, "file-integrity-baseline.json");
53266
+ const useSystemState = PATHS.mode === "system" || systemDaemonPresent() || (0, import_node_fs63.existsSync)(systemBaseline);
53267
+ const stateDir = useSystemState ? SYSTEM_PATHS.stateDir : PATHS.stateDir;
53268
+ const baselinePath = (0, import_node_path48.join)(stateDir, "file-integrity-baseline.json");
53269
+ const observedPath = (0, import_node_path48.join)(stateDir, "file-integrity-observed.json");
53270
+ if (action === "rebaseline") {
53271
+ const watch3 = new FileIntegrityWatch({
53272
+ bus: { publish: () => void 0 },
53273
+ settings,
53274
+ baselinePath,
53275
+ observedPath,
53276
+ log: (line2) => {
53277
+ if (!opts.json) console.log(source_default.gray(` ${line2}`));
53278
+ }
53279
+ });
53280
+ let result;
53281
+ try {
53282
+ result = await watch3.rebaseline();
53283
+ } catch (error2) {
53284
+ result = { ok: false, files: 0, reason: error2.message };
53285
+ }
53286
+ if (opts.json) console.log(JSON.stringify({ action, ...result }, null, 2));
53287
+ else if (result.ok) console.log(source_default.green(` Baseline refreshed for ${result.files} file(s).`));
53288
+ else console.error(source_default.red(` Could not refresh the baseline: ${result.reason}.`));
53289
+ if (!result.ok) process.exitCode = 1;
53290
+ return;
53291
+ }
53292
+ if (action !== "status") {
53293
+ console.error(source_default.red(` Unknown action "${action}". Use status or rebaseline.`));
53294
+ process.exitCode = 1;
53295
+ return;
53296
+ }
53297
+ const baseline = readState2(baselinePath);
53298
+ const observed = readState2(observedPath);
53299
+ const configuredTargets = [.../* @__PURE__ */ new Set([...settings.paths, ...settings.canaries, ...settings.canaryDirectories.map(autoCanaryPath)])];
53300
+ const scopeMatches = !baseline?.targets || baseline.targets.length === configuredTargets.length && [...baseline.targets].sort().every((path2, index) => path2 === [...configuredTargets].sort()[index]);
53301
+ const report = {
53302
+ enabled: settings.enabled,
53303
+ paths: settings.paths,
53304
+ canaries: settings.canaries,
53305
+ canary_directories: settings.canaryDirectories,
53306
+ poll_interval_seconds: settings.pollMs / 1e3,
53307
+ baseline_at: baseline?.created_at ?? null,
53308
+ files_monitored: Object.keys(baseline?.files ?? {}).length,
53309
+ changed_files: scopeMatches ? changedCount(baseline, observed) : null,
53310
+ scope_matches: scopeMatches,
53311
+ baseline_available: baseline !== null,
53312
+ state_path: baselinePath
53313
+ };
53314
+ if (opts.json) {
53315
+ console.log(JSON.stringify(report, null, 2));
53316
+ return;
53317
+ }
53318
+ console.log(` ${source_default.white.bold("File integrity")} ${report.enabled ? source_default.green("enabled") : source_default.gray("disabled")}`);
53319
+ if (report.paths.length) console.log(` Paths: ${report.paths.join(", ")}`);
53320
+ if (report.canaries.length) console.log(` Canary files: ${report.canaries.join(", ")}`);
53321
+ if (settings.canaryDirectories.length) console.log(` Canary directories: ${settings.canaryDirectories.join(", ")}`);
53322
+ console.log(` Poll interval: ${report.poll_interval_seconds}s`);
53323
+ if (!baseline) {
53324
+ console.log(source_default.gray(` No baseline at ${baselinePath}. Enable monitoring and start the daemon to record one.`));
53325
+ } else {
53326
+ console.log(` Baseline: ${report.baseline_at} (${report.files_monitored} files)`);
53327
+ if (!report.scope_matches) console.log(source_default.yellow(" Configured paths changed; run rebaseline after reviewing the new scope."));
53328
+ else {
53329
+ console.log(` Current differences: ${report.changed_files}`);
53330
+ if (report.changed_files) console.log(source_default.yellow(" Review the daemon event log; refresh only after confirming the changes are expected."));
53331
+ }
53332
+ }
53333
+ console.log(source_default.gray(" Hashes and file contents stay local. Rebaseline: sudo threatcrush integrity rebaseline"));
53334
+ }
53335
+
53336
+ // src/commands/edr.ts
53337
+ var import_node_fs65 = require("fs");
53338
+ init_paths();
53339
+
53340
+ // src/daemon/auditd/rules.ts
53341
+ var import_node_fs64 = require("fs");
53342
+ var import_node_child_process25 = require("child_process");
53343
+ var import_node_path49 = require("path");
53344
+ var WEB_TOOLS = ["sh", "bash", "dash", "zsh", "curl", "wget"];
53345
+ var MINER_NAMES = ["xmrig", "minerd", "cpuminer", "cpuminer-multi", "kdevtmpfsi", "kinsing", "cryptonight"];
53346
+ var CONNECT_KEY2 = "threatcrush_edr_connect";
53347
+ var LISTEN_KEY2 = "threatcrush_edr_listen";
53348
+ function passwdByName() {
53349
+ let raw = "";
53350
+ try {
53351
+ raw = (0, import_node_child_process25.execFileSync)("getent", ["passwd"], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
53352
+ } catch {
53353
+ try {
53354
+ raw = (0, import_node_fs64.readFileSync)("/etc/passwd", "utf8");
53355
+ } catch {
53356
+ return /* @__PURE__ */ new Map();
53357
+ }
53358
+ }
53359
+ const out = /* @__PURE__ */ new Map();
53360
+ for (const line2 of raw.split("\n")) {
53361
+ const fields = line2.split(":");
53362
+ const uid = Number(fields[2]);
53363
+ if (fields[0] && Number.isInteger(uid)) out.set(fields[0], uid);
53364
+ }
53365
+ return out;
53366
+ }
53367
+ function existingExecutables(names) {
53368
+ const paths = /* @__PURE__ */ new Set();
53369
+ for (const name of names) {
53370
+ for (const prefix of ["/bin", "/usr/bin", "/usr/local/bin"]) {
53371
+ const candidate = `${prefix}/${name}`;
53372
+ try {
53373
+ if (!(0, import_node_fs64.existsSync)(candidate) || !(0, import_node_fs64.statSync)(candidate).isFile()) continue;
53374
+ paths.add((0, import_node_fs64.realpathSync)(candidate));
53375
+ } catch {
53376
+ }
53377
+ }
53378
+ }
53379
+ return [...paths].sort();
53380
+ }
53381
+ function existingDirectories(paths) {
53382
+ return [...new Set(paths)].filter((path2) => {
53383
+ if (!(0, import_node_path49.isAbsolute)(path2) || /[\s\r\n]/.test(path2)) return false;
53384
+ try {
53385
+ return (0, import_node_fs64.statSync)(path2).isDirectory();
53386
+ } catch {
53387
+ return false;
53388
+ }
53389
+ }).sort();
53390
+ }
53391
+ function generateAuditRules(settings) {
53392
+ const rules = /* @__PURE__ */ new Set();
53393
+ const warnings = [];
53394
+ const ids = passwdByName();
53395
+ const serviceIds = [...new Set(settings.webServiceUsers.flatMap((name) => {
53396
+ const uid = ids.get(name);
53397
+ return uid === void 0 ? [] : [uid];
53398
+ }))].sort((a, b) => a - b);
53399
+ const missingUsers = settings.webServiceUsers.filter((name) => !ids.has(name));
53400
+ if (missingUsers.length) warnings.push(`service account(s) not found in /etc/passwd: ${missingUsers.join(", ")}`);
53401
+ if (serviceIds.length === 0) warnings.push("no web-service account UIDs resolved; web child-process rules were not generated");
53402
+ const architectures = process.arch === "x64" ? ["b64", "b32"] : process.arch === "ia32" ? ["b32"] : ["b64"];
53403
+ const tools = existingExecutables(WEB_TOOLS);
53404
+ for (const arch of architectures) {
53405
+ for (const uid of serviceIds) {
53406
+ for (const executable of tools) {
53407
+ rules.add(`-a always,exit -F arch=${arch} -S execve,execveat -F success=1 -F euid=${uid} -F exe=${executable} -k threatcrush_edr_web`);
53408
+ }
53409
+ }
53410
+ for (const directory of existingDirectories(settings.tempExecPaths)) {
53411
+ rules.add(`-a always,exit -F arch=${arch} -F dir=${directory} -F perm=x -k threatcrush_edr_temp`);
53412
+ }
53413
+ for (const comm of MINER_NAMES) {
53414
+ rules.add(`-a always,exit -F arch=${arch} -S execve,execveat -F success=1 -F comm=${comm} -k threatcrush_edr_miner`);
53415
+ }
53416
+ if (settings.watchNetworkSyscalls) {
53417
+ rules.add(`-a always,exit -F arch=${arch} -S connect -F success=1 -k ${CONNECT_KEY2}`);
53418
+ rules.add(`-a always,exit -F arch=${arch} -S listen -F success=1 -k ${LISTEN_KEY2}`);
53419
+ }
53420
+ }
53421
+ if (tools.length === 0) warnings.push("no configured shell or downloader executables were found");
53422
+ if (existingDirectories(settings.tempExecPaths).length === 0) warnings.push("no configured temporary execution directories exist");
53423
+ if (settings.watchNetworkSyscalls) warnings.push("network syscall rules can generate substantial audit volume; review host capacity and retention before loading");
53424
+ return { rules: [...rules], warnings };
53425
+ }
53426
+
53427
+ // src/commands/edr.ts
53428
+ async function edrCommand(action = "status", opts = {}) {
53429
+ const settings = edrSettings(loadConfig().edr);
53430
+ if (action === "rules") {
53431
+ const generated = generateAuditRules(settings);
53432
+ console.log("# Generated by threatcrush edr rules. Review before loading with auditd.");
53433
+ console.log("# auditd may also write EXECVE argument records for matching syscalls;");
53434
+ console.log("# ThreatCrush reads only SYSCALL metadata and discards command arguments.");
53435
+ for (const warning2 of generated.warnings) console.log(`# NOTE: ${warning2}`);
53436
+ if (generated.rules.length) console.log(generated.rules.join("\n"));
53437
+ return;
53438
+ }
53439
+ if (action !== "status") {
53440
+ console.error(source_default.red(` Unknown action "${action}". Use status or rules.`));
53441
+ process.exitCode = 1;
53442
+ return;
53443
+ }
53444
+ let readable = false;
53445
+ try {
53446
+ if ((0, import_node_fs65.existsSync)(settings.auditLogPath)) (0, import_node_fs65.accessSync)(settings.auditLogPath, import_node_fs65.constants.R_OK);
53447
+ readable = (0, import_node_fs65.existsSync)(settings.auditLogPath);
53448
+ } catch {
53449
+ }
53450
+ let events = [];
53451
+ let stateNote = null;
53452
+ try {
53453
+ initStateDB(PATHS.stateDb);
53454
+ events = getModuleEvents("edr", Number(opts.limit) || 25);
53455
+ } catch {
53456
+ stateNote = `the daemon state database (${PATHS.stateDb}) is not readable here`;
53457
+ }
53458
+ const report = {
53459
+ enabled: settings.enabled,
53460
+ audit_log_path: settings.auditLogPath,
53461
+ audit_log_readable: readable,
53462
+ web_service_users: settings.webServiceUsers,
53463
+ temp_exec_paths: settings.tempExecPaths,
53464
+ watch_network_syscalls: settings.watchNetworkSyscalls,
53465
+ network_baseline_seconds: settings.networkBaselineMs / 1e3,
53466
+ watch_unknown_temp_cpu: settings.watchUnknownTempCpu,
53467
+ poll_interval_seconds: settings.pollMs / 1e3,
53468
+ state_note: stateNote,
53469
+ events
53470
+ };
53471
+ if (opts.json) {
53472
+ console.log(JSON.stringify(report, null, 2));
53473
+ return;
53474
+ }
53475
+ console.log(` ${source_default.white.bold("EDR audit watch")} ${settings.enabled ? source_default.green("enabled") : source_default.gray("disabled")}`);
53476
+ console.log(` Audit log: ${settings.auditLogPath} (${readable ? source_default.green("readable") : source_default.yellow("unavailable")})`);
53477
+ console.log(` Service accounts: ${settings.webServiceUsers.join(", ") || "none configured"}`);
53478
+ console.log(` Temporary execution paths: ${settings.tempExecPaths.join(", ") || "none configured"}`);
53479
+ console.log(` Network syscalls: ${settings.watchNetworkSyscalls ? `enabled (learn ${settings.networkBaselineMs / 1e3}s)` : "disabled"}`);
53480
+ console.log(` Temporary-path CPU watch: ${settings.watchUnknownTempCpu ? "enabled" : "disabled"}`);
53481
+ console.log(` Recent EDR events: ${events.length}`);
53482
+ if (stateNote) console.log(source_default.gray(` ${stateNote}`));
53483
+ if (!settings.enabled) console.log(source_default.gray(" Enable [edr] only after reviewing `threatcrush edr rules` and loading them in auditd."));
53484
+ for (const event of events) {
53485
+ const severity = String(event.severity ?? "info");
53486
+ const color = severity === "critical" ? source_default.red.bold : severity === "high" ? source_default.red : source_default.yellow;
53487
+ console.log(` ${color(severity.padEnd(8))} ${String(event.message ?? "")}`);
53488
+ }
53489
+ console.log();
53490
+ }
53491
+
51762
53492
  // src/commands/firewall.ts
51763
53493
  init_ipc_client();
51764
53494
  init_paths();
@@ -51900,7 +53630,7 @@ async function allowlistCommand(opts) {
51900
53630
  }
51901
53631
 
51902
53632
  // src/commands/abuse.ts
51903
- var import_node_fs60 = require("fs");
53633
+ var import_node_fs66 = require("fs");
51904
53634
  init_paths();
51905
53635
  function rows(records) {
51906
53636
  if (records.length === 0) {
@@ -51960,7 +53690,7 @@ function abuseRetractCommand(id, opts = {}) {
51960
53690
  );
51961
53691
  }
51962
53692
  function abuseStatusCommand(opts = {}) {
51963
- const config = loadConfig((0, import_node_fs60.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
53693
+ const config = loadConfig((0, import_node_fs66.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
51964
53694
  const cfg = resolveConfig(config.abuse_reporter);
51965
53695
  const hasKey2 = Boolean(cfg.keys.abuseipdb || cfg.keys.stopforumspam);
51966
53696
  const active2 = cfg.enabled && (cfg.dryRun || hasKey2);
@@ -51983,11 +53713,11 @@ function abuseStatusCommand(opts = {}) {
51983
53713
  init_paths();
51984
53714
 
51985
53715
  // src/upgrade.ts
51986
- var import_node_child_process24 = require("child_process");
53716
+ var import_node_child_process26 = require("child_process");
51987
53717
  var PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
51988
53718
  var defaultRunner = (cmd) => {
51989
53719
  try {
51990
- return (0, import_node_child_process24.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
53720
+ return (0, import_node_child_process26.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
51991
53721
  } catch {
51992
53722
  return null;
51993
53723
  }
@@ -52128,9 +53858,9 @@ function installUserAgent(target = globalThis) {
52128
53858
  }
52129
53859
 
52130
53860
  // 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");
53861
+ var import_node_child_process27 = require("child_process");
53862
+ var import_node_os18 = require("os");
53863
+ var import_node_path50 = require("path");
52134
53864
  init_cli_config();
52135
53865
  function uploadDisabled(upload, env3 = process.env) {
52136
53866
  if (upload === false) return true;
@@ -52149,8 +53879,8 @@ function cleanUrl(raw) {
52149
53879
  return raw.split(/[?#]/)[0];
52150
53880
  }
52151
53881
  }
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);
53882
+ 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()) {
53883
+ const abs = (0, import_node_path50.resolve)(path2);
52154
53884
  try {
52155
53885
  const root = run(["rev-parse", "--show-toplevel"]);
52156
53886
  const sub = abs === root ? "." : abs.slice(root.length + 1);
@@ -52163,9 +53893,9 @@ function repoTarget(path2, run = (args) => (0, import_node_child_process25.execF
52163
53893
  const m = /^(?:[a-z+]+:\/\/)?(?:[^@/]+@)?([^/:]+)[:/](.+?)(?:\.git)?\/?$/i.exec(remote);
52164
53894
  if (m) return { target: `${m[1]}/${m[2]}`, root, sub };
52165
53895
  }
52166
- return { target: `${(0, import_node_os17.hostname)()}:${root}`, root, sub };
53896
+ return { target: `${(0, import_node_os18.hostname)()}:${root}`, root, sub };
52167
53897
  } catch {
52168
- return { target: `${(0, import_node_os17.hostname)()}:${abs}`, root: abs, sub: "." };
53898
+ return { target: `${(0, import_node_os18.hostname)()}:${abs}`, root: abs, sub: "." };
52169
53899
  }
52170
53900
  }
52171
53901
  async function uploadResult(result, opts) {
@@ -52522,25 +54252,25 @@ ${source_default.dim(" C R U S H")}
52522
54252
  var API_URL8 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
52523
54253
  var PKG_NAME2 = "@profullstack/threatcrush";
52524
54254
  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");
54255
+ var INSTALL_CONFIG_PATH = (0, import_node_path51.join)((0, import_node_os19.homedir)(), ".threatcrush", "install.json");
52526
54256
  function detectPackageManager() {
52527
54257
  try {
52528
- const npmGlobal = (0, import_node_child_process26.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
54258
+ const npmGlobal = (0, import_node_child_process28.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
52529
54259
  if (npmGlobal.includes(PKG_NAME2)) return "npm";
52530
54260
  } catch {
52531
54261
  }
52532
54262
  try {
52533
- (0, import_node_child_process26.execSync)("pnpm --version", { stdio: "pipe" });
54263
+ (0, import_node_child_process28.execSync)("pnpm --version", { stdio: "pipe" });
52534
54264
  return "pnpm";
52535
54265
  } catch {
52536
54266
  }
52537
54267
  try {
52538
- (0, import_node_child_process26.execSync)("yarn --version", { stdio: "pipe" });
54268
+ (0, import_node_child_process28.execSync)("yarn --version", { stdio: "pipe" });
52539
54269
  return "yarn";
52540
54270
  } catch {
52541
54271
  }
52542
54272
  try {
52543
- (0, import_node_child_process26.execSync)("bun --version", { stdio: "pipe" });
54273
+ (0, import_node_child_process28.execSync)("bun --version", { stdio: "pipe" });
52544
54274
  return "bun";
52545
54275
  } catch {
52546
54276
  }
@@ -52548,14 +54278,14 @@ function detectPackageManager() {
52548
54278
  }
52549
54279
  function readInstallConfig() {
52550
54280
  try {
52551
- return JSON.parse((0, import_node_fs61.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
54281
+ return JSON.parse((0, import_node_fs67.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
52552
54282
  } catch {
52553
54283
  return {};
52554
54284
  }
52555
54285
  }
52556
54286
  function packageLooksInstalled(pm, pkgName) {
52557
54287
  try {
52558
- const output = (0, import_node_child_process26.execSync)(globalListCommand(pm, pkgName), {
54288
+ const output = (0, import_node_child_process28.execSync)(globalListCommand(pm, pkgName), {
52559
54289
  encoding: "utf-8",
52560
54290
  stdio: ["pipe", "pipe", "pipe"]
52561
54291
  });
@@ -52658,14 +54388,14 @@ async function promoteUnprivilegedDaemon() {
52658
54388
  function restartSystemdDaemon() {
52659
54389
  const asRoot = typeof process.getuid === "function" && process.getuid() === 0;
52660
54390
  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;
54391
+ if (!asRoot && (0, import_node_child_process28.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
52662
54392
  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;
54393
+ if ((0, import_node_child_process28.spawnSync)(cmd, args, { stdio: "inherit" }).status !== 0) return false;
54394
+ return (0, import_node_child_process28.spawnSync)("systemctl", ["is-active", "--quiet", DAEMON_UNIT], { stdio: "pipe" }).status === 0;
52665
54395
  }
52666
54396
  function execQuiet(cmd) {
52667
54397
  try {
52668
- return (0, import_node_child_process26.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
54398
+ return (0, import_node_child_process28.execSync)(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
52669
54399
  } catch {
52670
54400
  return null;
52671
54401
  }
@@ -52717,6 +54447,10 @@ program2.command("monitor").description("Watch nginx, auth and syslog for attack
52717
54447
  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
54448
  await monitorCommand({ tui: true, demo: opts.demo });
52719
54449
  });
54450
+ program2.command("action-center").description("Fleet-wide terminal view of detections, server health, and queued actions").alias("actions").action(async () => {
54451
+ const { startActionCenter: startActionCenter2 } = await Promise.resolve().then(() => (init_action_center(), action_center_exports));
54452
+ await startActionCenter2();
54453
+ });
52720
54454
  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
54455
  Addresses from the daemon's live feed are placed with threatcrush.com/api/geo
52722
54456
  (DB-IP City Lite); this server is placed by the address it reaches us from.
@@ -52897,7 +54631,7 @@ program2.command("status").description("Show daemon status and loaded modules").
52897
54631
  program2.command("rules").description("Manage detection rules").argument("[action]", "list | show", "list").argument("[id]", "Rule ID (for show)").action(async (action, id) => {
52898
54632
  await rulesCommand({ action, id });
52899
54633
  });
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) => {
54634
+ 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
54635
  await hardenCommand(opts);
52902
54636
  });
52903
54637
  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 +54659,12 @@ reputationCmd.command("subscribe").description("Pay for Reputation Pro in crypto
52925
54659
  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
54660
  await privilegedCommand(opts);
52927
54661
  });
54662
+ 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) => {
54663
+ await integrityCommand(action, opts);
54664
+ });
54665
+ 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) => {
54666
+ await edrCommand(action, opts);
54667
+ });
52928
54668
  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
54669
  await blockCommand(ip, opts);
52930
54670
  });
@@ -52961,7 +54701,7 @@ program2.command("uninstall-service").description("Remove the threatcrushd syste
52961
54701
  program2.command("logs").description("Tail daemon logs").action(async () => {
52962
54702
  console.log(LOGO2);
52963
54703
  const logPath2 = PATHS.logFile;
52964
- if (!(0, import_node_fs61.existsSync)(logPath2)) {
54704
+ if (!(0, import_node_fs67.existsSync)(logPath2)) {
52965
54705
  console.log(source_default.yellow(` No log file found at ${logPath2}`));
52966
54706
  console.log(source_default.dim(" Start the daemon first with `threatcrush start`\n"));
52967
54707
  return;
@@ -52969,7 +54709,7 @@ program2.command("logs").description("Tail daemon logs").action(async () => {
52969
54709
  console.log(source_default.green(` Tailing ${logPath2}...
52970
54710
  `));
52971
54711
  console.log(source_default.gray(" Press Ctrl+C to stop\n"));
52972
- (0, import_node_child_process26.execSync)(`tail -f ${logPath2}`, { stdio: "inherit" });
54712
+ (0, import_node_child_process28.execSync)(`tail -f ${logPath2}`, { stdio: "inherit" });
52973
54713
  });
52974
54714
  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
54715
  console.log(LOGO2);
@@ -52981,7 +54721,7 @@ program2.command("update").description("Update ThreatCrush CLI and installed bun
52981
54721
  for (const cmd of commands2) {
52982
54722
  console.log(source_default.green(` \u2192 ${cmd}
52983
54723
  `));
52984
- (0, import_node_child_process26.execSync)(cmd, { stdio: "inherit" });
54724
+ (0, import_node_child_process28.execSync)(cmd, { stdio: "inherit" });
52985
54725
  }
52986
54726
  console.log(source_default.green("\n \u2713 Modules updated successfully!\n"));
52987
54727
  await reportIfStillStale();
@@ -53006,7 +54746,7 @@ program2.command("update").description("Update ThreatCrush CLI and installed bun
53006
54746
  for (const cmd of commands) {
53007
54747
  console.log(source_default.green(` \u2192 ${cmd}
53008
54748
  `));
53009
- (0, import_node_child_process26.execSync)(cmd, { stdio: "inherit" });
54749
+ (0, import_node_child_process28.execSync)(cmd, { stdio: "inherit" });
53010
54750
  }
53011
54751
  console.log(source_default.green("\n \u2713 ThreatCrush updated successfully!\n"));
53012
54752
  if (installMode === "desktop") {
@@ -53057,7 +54797,7 @@ program2.command("remove").description("Uninstall ThreatCrush and the installed
53057
54797
  for (const cmd of commands) {
53058
54798
  console.log(source_default.green(` \u2192 ${cmd}
53059
54799
  `));
53060
- (0, import_node_child_process26.execSync)(cmd, { stdio: "inherit" });
54800
+ (0, import_node_child_process28.execSync)(cmd, { stdio: "inherit" });
53061
54801
  }
53062
54802
  console.log(source_default.green("\n \u2713 ThreatCrush has been uninstalled.\n"));
53063
54803
  console.log(source_default.dim(" We're sorry to see you go! \u{1F44B}\n"));
@@ -53134,10 +54874,10 @@ storeCmd.command("search <query>").description("Search for modules in the store"
53134
54874
  });
53135
54875
  storeCmd.command("publish <url>").description("Publish a module from a git URL or web URL").action(async (url) => {
53136
54876
  console.log(LOGO2);
53137
- const configPath = (0, import_node_path47.join)((0, import_node_os18.homedir)(), ".threatcrush", "config.json");
54877
+ const configPath = (0, import_node_path51.join)((0, import_node_os19.homedir)(), ".threatcrush", "config.json");
53138
54878
  let email = "";
53139
54879
  try {
53140
- const config = JSON.parse((0, import_node_fs61.readFileSync)(configPath, "utf-8"));
54880
+ const config = JSON.parse((0, import_node_fs67.readFileSync)(configPath, "utf-8"));
53141
54881
  email = config.email || "";
53142
54882
  } catch {
53143
54883
  }
@@ -53154,9 +54894,9 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
53154
54894
  return;
53155
54895
  }
53156
54896
  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));
54897
+ const dir = (0, import_node_path51.join)((0, import_node_os19.homedir)(), ".threatcrush");
54898
+ if (!(0, import_node_fs67.existsSync)(dir)) (0, import_node_fs67.mkdirSync)(dir, { recursive: true });
54899
+ (0, import_node_fs67.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
53160
54900
  console.log(source_default.dim(` Saved email to ${configPath}`));
53161
54901
  } catch {
53162
54902
  }