@profullstack/threatcrush 0.13.7 → 0.13.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/daemon.js CHANGED
@@ -2022,8 +2022,8 @@ var require_toml = __commonJS({
2022
2022
  });
2023
2023
 
2024
2024
  // src/daemon/index.ts
2025
- var import_node_fs19 = require("fs");
2026
- var import_node_path14 = require("path");
2025
+ var import_node_fs20 = require("fs");
2026
+ var import_node_path15 = require("path");
2027
2027
 
2028
2028
  // src/daemon/paths.ts
2029
2029
  var import_node_fs = require("fs");
@@ -2459,12 +2459,27 @@ var IpcServer = class {
2459
2459
  });
2460
2460
  }
2461
2461
  async handleLine(client, line) {
2462
- let req;
2462
+ let frame;
2463
2463
  try {
2464
- req = JSON.parse(line);
2464
+ frame = JSON.parse(line);
2465
2465
  } catch {
2466
2466
  return this.send(client, { id: 0, ok: false, error: "invalid json" });
2467
2467
  }
2468
+ const { id, method } = frame ?? {};
2469
+ if (typeof id !== "number" || typeof method !== "string") {
2470
+ return this.send(client, {
2471
+ id: typeof id === "number" ? id : 0,
2472
+ ok: false,
2473
+ error: 'invalid request: expected {"id": number, "method": string}'
2474
+ });
2475
+ }
2476
+ try {
2477
+ await this.dispatch(client, frame);
2478
+ } catch (err) {
2479
+ this.send(client, { id, ok: false, error: String(err?.message || err) });
2480
+ }
2481
+ }
2482
+ async dispatch(client, req) {
2468
2483
  switch (req.method) {
2469
2484
  case "ping":
2470
2485
  return this.send(client, { id: req.id, ok: true, result: "pong" });
@@ -2572,6 +2587,10 @@ var IpcServer = class {
2572
2587
  this.send(client, { id: req.id, ok: true, result: "shutting down" });
2573
2588
  setTimeout(() => process.emit("SIGTERM"), 50);
2574
2589
  return;
2590
+ default: {
2591
+ const unknown = req;
2592
+ return this.send(client, { id: unknown.id, ok: false, error: `unknown method: ${unknown.method}` });
2593
+ }
2575
2594
  }
2576
2595
  }
2577
2596
  send(client, msg) {
@@ -2589,8 +2608,8 @@ var IpcServer = class {
2589
2608
  };
2590
2609
 
2591
2610
  // src/daemon/module-host.ts
2592
- var import_node_fs10 = require("fs");
2593
- var import_node_path5 = require("path");
2611
+ var import_node_fs11 = require("fs");
2612
+ var import_node_path6 = require("path");
2594
2613
  var import_node_url = require("url");
2595
2614
  var import_toml2 = __toESM(require_toml());
2596
2615
 
@@ -2716,7 +2735,7 @@ function verifyModuleTrust(name, modulePath) {
2716
2735
  }
2717
2736
 
2718
2737
  // src/daemon/watchers/log-watcher.ts
2719
- var import_node_fs6 = require("fs");
2738
+ var import_node_fs7 = require("fs");
2720
2739
  var import_node_readline = require("readline");
2721
2740
 
2722
2741
  // src/core/crs/rules.generated.ts
@@ -7014,6 +7033,31 @@ var CRS_RULES = [
7014
7033
  "negated": false
7015
7034
  }
7016
7035
  },
7036
+ {
7037
+ "id": 941100,
7038
+ "msg": "XSS Attack Detected via libinjection",
7039
+ "severity": "CRITICAL",
7040
+ "tags": [
7041
+ "attack-xss"
7042
+ ],
7043
+ "targets": [
7044
+ "REQUEST_HEADERS:User-Agent",
7045
+ "ARGS_NAMES",
7046
+ "ARGS"
7047
+ ],
7048
+ "transforms": [
7049
+ "utf8toUnicode",
7050
+ "urlDecodeUni",
7051
+ "htmlEntityDecode",
7052
+ "jsDecode",
7053
+ "cssDecode",
7054
+ "removeNulls"
7055
+ ],
7056
+ "op": {
7057
+ "type": "detectXSS",
7058
+ "negated": false
7059
+ }
7060
+ },
7017
7061
  {
7018
7062
  "id": 941110,
7019
7063
  "msg": "XSS Filter - Category 1: Script Tag Vector",
@@ -7700,6 +7744,30 @@ var CRS_RULES = [
7700
7744
  "negated": false
7701
7745
  }
7702
7746
  },
7747
+ {
7748
+ "id": 942100,
7749
+ "msg": "SQL Injection Attack Detected via libinjection",
7750
+ "severity": "CRITICAL",
7751
+ "tags": [
7752
+ "attack-sqli"
7753
+ ],
7754
+ "targets": [
7755
+ "REQUEST_HEADERS:User-Agent",
7756
+ "REQUEST_HEADERS:Referer",
7757
+ "ARGS_NAMES",
7758
+ "ARGS"
7759
+ ],
7760
+ "transforms": [
7761
+ "utf8toUnicode",
7762
+ "urlDecodeUni",
7763
+ "removeNulls"
7764
+ ],
7765
+ "multiMatch": true,
7766
+ "op": {
7767
+ "type": "detectSQLi",
7768
+ "negated": false
7769
+ }
7770
+ },
7703
7771
  {
7704
7772
  "id": 942140,
7705
7773
  "msg": "SQL Injection Attack: Common DB Names Detected",
@@ -8320,6 +8388,31 @@ var CRS_RULES = [
8320
8388
  }
8321
8389
  }
8322
8390
  ];
8391
+ var THREATCRUSH_RULES = [
8392
+ {
8393
+ "id": 10001,
8394
+ "msg": "OS File Access Attempt in the request path",
8395
+ "severity": "CRITICAL",
8396
+ "tags": [
8397
+ "attack-lfi",
8398
+ "threatcrush"
8399
+ ],
8400
+ "targets": [
8401
+ "REQUEST_FILENAME"
8402
+ ],
8403
+ "transforms": [
8404
+ "utf8toUnicode",
8405
+ "urlDecodeUni",
8406
+ "normalizePathWin"
8407
+ ],
8408
+ "op": {
8409
+ "type": "rx",
8410
+ "source": "^/?(?:[a-z]:/)?(?:\\.history(?![0-9a-z])|apache/access\\.conf(?![0-9a-z])|apache/apache\\.conf(?![0-9a-z])|apache/apache2\\.conf(?![0-9a-z])|apache/audit_log(?![0-9a-z])|apache/conf(?![0-9a-z])|apache/default-server\\.conf(?![0-9a-z])|apache/error_log(?![0-9a-z])|apache/httpd\\.conf(?![0-9a-z])|apache/log(?![0-9a-z])|apache2/apache\\.conf(?![0-9a-z])|apache2/apache2\\.conf(?![0-9a-z])|apache2/conf(?![0-9a-z])|apache2/default-server\\.conf(?![0-9a-z])|apache2/envvars(?![0-9a-z])|apache2/httpd\\.conf(?![0-9a-z])|apache2/httpd2\\.conf(?![0-9a-z])|apache2/logs(?![0-9a-z])|apache2/mods(?![0-9a-z])|apache2/ports\\.conf(?![0-9a-z])|apache2/sites(?![0-9a-z])|apache2/ssl-global\\.conf(?![0-9a-z])|apache2/vhosts\\.d(?![0-9a-z])|apache22/conf(?![0-9a-z])|apache22/httpd\\.conf(?![0-9a-z])|apache22/logs(?![0-9a-z])|apache24/conf(?![0-9a-z])|apache24/httpd\\.conf(?![0-9a-z])|apache24/logs(?![0-9a-z])|boot/grub/grub\\.cfg(?![0-9a-z])|boot/grub/menu\\.lst(?![0-9a-z])|config/app\\.php(?![0-9a-z])|config/custom\\.php(?![0-9a-z])|config/database\\.php(?![0-9a-z])|configuration\\.php(?![0-9a-z])|cpanel/logs(?![0-9a-z])|data/elasticsearch(?![0-9a-z])|data/kafka(?![0-9a-z])|etc/\\.java(?![0-9a-z])|etc/acpi(?![0-9a-z])|etc/adduser\\.conf(?![0-9a-z])|etc/alias(?![0-9a-z])|etc/alsa(?![0-9a-z])|etc/alternatives(?![0-9a-z])|etc/amavis(?![0-9a-z])|etc/anacrontab(?![0-9a-z])|etc/ansible(?![0-9a-z])|etc/apache/access\\.conf(?![0-9a-z])|etc/apache/apache\\.conf(?![0-9a-z])|etc/apache/default-server\\.conf(?![0-9a-z])|etc/apache/httpd\\.conf(?![0-9a-z])|etc/apache/vhosts\\.conf(?![0-9a-z])|etc/apache2(?![0-9a-z])|etc/apm(?![0-9a-z])|etc/apparmor(?![0-9a-z])|etc/apport(?![0-9a-z])|etc/apt(?![0-9a-z])|etc/asciidoc(?![0-9a-z])|etc/at\\.allow(?![0-9a-z])|etc/at\\.deny(?![0-9a-z])|etc/audit(?![0-9a-z])|etc/avahi(?![0-9a-z])|etc/bash_completion\\.d(?![0-9a-z])|etc/bashrc(?![0-9a-z])|etc/bind(?![0-9a-z])|etc/binfmt\\.d(?![0-9a-z])|etc/bluetooth(?![0-9a-z])|etc/bonobo-activation(?![0-9a-z])|etc/bootptab(?![0-9a-z])|etc/brltty(?![0-9a-z])|etc/byobu(?![0-9a-z])|etc/ca-certificates(?![0-9a-z])|etc/calendar(?![0-9a-z])|etc/casper\\.conf(?![0-9a-z])|etc/centos-release(?![0-9a-z])|etc/chatscripts(?![0-9a-z])|etc/chkrootkit\\.conf(?![0-9a-z])|etc/chromium-browser(?![0-9a-z])|etc/chrootusers(?![0-9a-z])|etc/chttp\\.conf(?![0-9a-z])|etc/clam\\.d(?![0-9a-z])|etc/clamav(?![0-9a-z])|etc/cni(?![0-9a-z])|etc/console-setup(?![0-9a-z])|etc/coraza-waf(?![0-9a-z])|etc/cracklib(?![0-9a-z])|etc/cron\\.allow(?![0-9a-z])|etc/cron\\.d(?![0-9a-z])|etc/cron\\.hourly(?![0-9a-z])|etc/cron\\.monthly(?![0-9a-z])|etc/cron\\.weekly(?![0-9a-z])|etc/cron\\.yearly(?![0-9a-z])|etc/crontab(?![0-9a-z])|etc/crowdsec(?![0-9a-z])|etc/crypttab(?![0-9a-z])|etc/cups(?![0-9a-z])|etc/cvs-cron\\.conf(?![0-9a-z])|etc/cvs-pserver\\.conf(?![0-9a-z])|etc/dbus-1(?![0-9a-z])|etc/dconf(?![0-9a-z])|etc/debconf\\.conf(?![0-9a-z])|etc/debian_version(?![0-9a-z])|etc/default(?![0-9a-z])|etc/deluser\\.conf(?![0-9a-z])|etc/depmod\\.d(?![0-9a-z])|etc/dhcp(?![0-9a-z])|etc/dictionaries-common(?![0-9a-z])|etc/dkms(?![0-9a-z])|etc/dns2tcpd\\.conf(?![0-9a-z])|etc/dnsmasq\\.d(?![0-9a-z])|etc/docker(?![0-9a-z])|etc/dockeretc/dpkg(?![0-9a-z])|etc/dovecot(?![0-9a-z])|etc/e2fsck\\.conf(?![0-9a-z])|etc/elasticsearch(?![0-9a-z])|etc/emacs(?![0-9a-z])|etc/environment\\.d(?![0-9a-z])|etc/esound/esd\\.conf(?![0-9a-z])|etc/etter\\.conf(?![0-9a-z])|etc/exports(?![0-9a-z])|etc/fail2ban(?![0-9a-z])|etc/fedora-release(?![0-9a-z])|etc/firebird(?![0-9a-z])|etc/firefox(?![0-9a-z])|etc/firewall(?![0-9a-z])|etc/fonts(?![0-9a-z])|etc/foremost\\.conf(?![0-9a-z])|etc/freshclam\\.conf(?![0-9a-z])|etc/fstab(?![0-9a-z])|etc/ftpaccess(?![0-9a-z])|etc/ftpchroot(?![0-9a-z])|etc/ftphosts(?![0-9a-z])|etc/ftpusers(?![0-9a-z])|etc/fuse\\.conf(?![0-9a-z])|etc/fwupd(?![0-9a-z])|etc/gconf(?![0-9a-z])|etc/gdb(?![0-9a-z])|etc/gdm3(?![0-9a-z])|etc/geoclue(?![0-9a-z])|etc/ghostscript(?![0-9a-z])|etc/gimp(?![0-9a-z])|etc/gitlab(?![0-9a-z])|etc/glvnd(?![0-9a-z])|etc/gnome(?![0-9a-z])|etc/gnucash(?![0-9a-z])|etc/gnustep(?![0-9a-z])|etc/groff(?![0-9a-z])|etc/group(?![0-9a-z])|etc/grub\\.conf(?![0-9a-z])|etc/grub\\.d(?![0-9a-z])|etc/gshadow(?![0-9a-z])|etc/gss(?![0-9a-z])|etc/gtk-2\\.0(?![0-9a-z])|etc/gtk-3\\.0(?![0-9a-z])|etc/hdparm\\.conf(?![0-9a-z])|etc/host\\.conf(?![0-9a-z])|etc/hostname(?![0-9a-z])|etc/hosts(?![0-9a-z])|etc/hp(?![0-9a-z])|etc/http/conf(?![0-9a-z])|etc/http/httpd\\.conf(?![0-9a-z])|etc/httpd(?![0-9a-z])|etc/ifplugd(?![0-9a-z])|etc/imagemagick-6(?![0-9a-z])|etc/inetd\\.conf(?![0-9a-z])|etc/init(?![0-9a-z])|etc/insserv\\.conf\\.d(?![0-9a-z])|etc/ipfw(?![0-9a-z])|etc/iproute2(?![0-9a-z])|etc/iptables(?![0-9a-z])|etc/issue(?![0-9a-z])|etc/java(?![0-9a-z])|etc/kafka(?![0-9a-z])|etc/kbd/config(?![0-9a-z])|etc/kernel(?![0-9a-z])|etc/kibana(?![0-9a-z])|etc/ld\\.so\\.conf(?![0-9a-z])|etc/ldap(?![0-9a-z])|etc/letsencrypt(?![0-9a-z])|etc/libblockdev(?![0-9a-z])|etc/libibverbs\\.d(?![0-9a-z])|etc/libnl-3(?![0-9a-z])|etc/libpaper\\.d(?![0-9a-z])|etc/libreoffice(?![0-9a-z])|etc/lighttpd(?![0-9a-z])|etc/lilo\\.conf(?![0-9a-z])|etc/logcheck(?![0-9a-z])|etc/login\\.defs(?![0-9a-z])|etc/logrotate\\.conf(?![0-9a-z])|etc/logrotate\\.d(?![0-9a-z])|etc/logstash(?![0-9a-z])|etc/logwatch(?![0-9a-z])|etc/lsb-release(?![0-9a-z])|etc/ltrace\\.conf(?![0-9a-z])|etc/lvm(?![0-9a-z])|etc/lynx(?![0-9a-z])|etc/mail(?![0-9a-z])|etc/mandrake-release(?![0-9a-z])|etc/manpath\\.config(?![0-9a-z])|etc/mc(?![0-9a-z])|etc/menu(?![0-9a-z])|etc/miredo-server\\.conf(?![0-9a-z])|etc/miredo\\.conf(?![0-9a-z])|etc/miredo/miredo-server\\.conf(?![0-9a-z])|etc/miredo/miredo\\.conf(?![0-9a-z])|etc/modprobe\\.d(?![0-9a-z])|etc/modsecurity(?![0-9a-z])|etc/modulesf(?![0-9a-z])|etc/mongod\\.conf(?![0-9a-z])|etc/monit(?![0-9a-z])|etc/mono(?![0-9a-z])|etc/motd(?![0-9a-z])|etc/mplayer(?![0-9a-z])|etc/mpv(?![0-9a-z])|etc/mtab(?![0-9a-z])|etc/mtools\\.conf(?![0-9a-z])|etc/muddleftpd(?![0-9a-z])|etc/muddleftpd\\.com(?![0-9a-z])|etc/muttrc\\.d(?![0-9a-z])|etc/my\\.conf(?![0-9a-z])|etc/mysql(?![0-9a-z])|etc/netplan(?![0-9a-z])|etc/network(?![0-9a-z])|etc/networkmanager(?![0-9a-z])|etc/newsyslog\\.conf(?![0-9a-z])|etc/newt(?![0-9a-z])|etc/nghttpx(?![0-9a-z])|etc/nginx(?![0-9a-z])|etc/nikto(?![0-9a-z])|etc/npasswd(?![0-9a-z])|etc/nsswitch\\.conf(?![0-9a-z])|etc/nuxeo\\.conf(?![0-9a-z])|etc/odbcdatasources(?![0-9a-z])|etc/openal(?![0-9a-z])|etc/opendkim(?![0-9a-z])|etc/opendmarc(?![0-9a-z])|etc/openldap/ldap\\.conf(?![0-9a-z])|etc/openmpi(?![0-9a-z])|etc/opt(?![0-9a-z])|etc/os-release(?![0-9a-z])|etc/osxhttpd(?![0-9a-z])|etc/osync(?![0-9a-z])|etc/packagekit(?![0-9a-z])|etc/pam\\.conf(?![0-9a-z])|etc/pam\\.d(?![0-9a-z])|etc/pam\\.d/proftpd(?![0-9a-z])|etc/passwd(?![0-9a-z])|etc/password(?![0-9a-z])|etc/pcmcia(?![0-9a-z])|etc/perl(?![0-9a-z])|etc/php(?![0-9a-z])|etc/pki(?![0-9a-z])|etc/pm(?![0-9a-z])|etc/polkit-1(?![0-9a-z])|etc/postfix(?![0-9a-z])|etc/postgresql(?![0-9a-z])|etc/ppp(?![0-9a-z])|etc/printcap(?![0-9a-z])|etc/profile(?![0-9a-z])|etc/proftp\\.conf(?![0-9a-z])|etc/proftpd(?![0-9a-z])|etc/pulse(?![0-9a-z])|etc/pure-ftpd(?![0-9a-z])|etc/pureftpd(?![0-9a-z])|etc/python(?![0-9a-z])|etc/qemu(?![0-9a-z])|etc/rc\\.conf(?![0-9a-z])|etc/rc\\.d/rc\\.httpd(?![0-9a-z])|etc/rc0\\.d(?![0-9a-z])|etc/rc1\\.d(?![0-9a-z])|etc/rc2\\.d(?![0-9a-z])|etc/rc3\\.d(?![0-9a-z])|etc/rc4\\.d(?![0-9a-z])|etc/rc5\\.d(?![0-9a-z])|etc/rc6\\.d(?![0-9a-z])|etc/rcs\\.d(?![0-9a-z])|etc/redhat-release(?![0-9a-z])|etc/redis-sentinel\\.conf(?![0-9a-z])|etc/redis\\.conf(?![0-9a-z])|etc/resolv\\.conf(?![0-9a-z])|etc/resolvconf(?![0-9a-z])|etc/rsyslog\\.d(?![0-9a-z])|etc/samba(?![0-9a-z])|etc/sane\\.d(?![0-9a-z])|etc/scw-release(?![0-9a-z])|etc/security(?![0-9a-z])|etc/selinux(?![0-9a-z])|etc/sensors\\.conf(?![0-9a-z])|etc/sensors\\.d(?![0-9a-z])|etc/sensors3\\.conf(?![0-9a-z])|etc/sgml(?![0-9a-z])|etc/shadow(?![0-9a-z])|etc/signon-ui(?![0-9a-z])|etc/skel(?![0-9a-z])|etc/slackware-release(?![0-9a-z])|etc/smb\\.conf(?![0-9a-z])|etc/smbpasswd(?![0-9a-z])|etc/smi\\.conf(?![0-9a-z])|etc/snmp(?![0-9a-z])|etc/sogo(?![0-9a-z])|etc/sound(?![0-9a-z])|etc/spamassassin(?![0-9a-z])|etc/speech-dispatcher(?![0-9a-z])|etc/squid(?![0-9a-z])|etc/squirrelmail(?![0-9a-z])|etc/ssh(?![0-9a-z])|etc/ssl(?![0-9a-z])|etc/sso(?![0-9a-z])|etc/stunnel(?![0-9a-z])|etc/subgid(?![0-9a-z])|etc/subuid(?![0-9a-z])|etc/subversion(?![0-9a-z])|etc/sudoers(?![0-9a-z])|etc/suse-release(?![0-9a-z])|etc/sw-cp-server/applications\\.d(?![0-9a-z])|etc/sysconfig(?![0-9a-z])|etc/sysctl\\.conf(?![0-9a-z])|etc/sysctl\\.d(?![0-9a-z])|etc/syslog\\.conf(?![0-9a-z])|etc/sysstat(?![0-9a-z])|etc/system-release-cpe(?![0-9a-z])|etc/systemd(?![0-9a-z])|etc/termcap(?![0-9a-z])|etc/terminfo(?![0-9a-z])|etc/texmf(?![0-9a-z])|etc/thermald(?![0-9a-z])|etc/thnuclnt(?![0-9a-z])|etc/thunderbird(?![0-9a-z])|etc/timezone(?![0-9a-z])|etc/timidity(?![0-9a-z])|etc/tinyproxy(?![0-9a-z])|etc/tmpfiles\\.d(?![0-9a-z])|etc/tor/tor-tsocks\\.conf(?![0-9a-z])|etc/tsocks\\.conf(?![0-9a-z])|etc/ubuntu-advantage(?![0-9a-z])|etc/udev(?![0-9a-z])|etc/udisks2(?![0-9a-z])|etc/ufw(?![0-9a-z])|etc/unbound(?![0-9a-z])|etc/update-manager(?![0-9a-z])|etc/update-motd\\.d(?![0-9a-z])|etc/update-notifier(?![0-9a-z])|etc/updatedb\\.conf(?![0-9a-z])|etc/upower(?![0-9a-z])|etc/urlview(?![0-9a-z])|etc/usb_modeswitch\\.d(?![0-9a-z])|etc/utmp(?![0-9a-z])|etc/vhcs2/proftpd/proftpd\\.conf(?![0-9a-z])|etc/vim(?![0-9a-z])|etc/vmware(?![0-9a-z])|etc/vsftpd\\.chroot_list(?![0-9a-z])|etc/vsftpd\\.conf(?![0-9a-z])|etc/vsftpd/vsftpd\\.conf(?![0-9a-z])|etc/vulkan(?![0-9a-z])|etc/w3m(?![0-9a-z])|etc/webmin(?![0-9a-z])|etc/wicd(?![0-9a-z])|etc/wireshark(?![0-9a-z])|etc/wpa_supplicant(?![0-9a-z])|etc/wu-ftpd(?![0-9a-z])|etc/x11(?![0-9a-z])|etc/xdg(?![0-9a-z])|etc/xml(?![0-9a-z])|home/postgres(?![0-9a-z])|http/httpd\\.conf(?![0-9a-z])|httpd/conf/httpd\\.conf(?![0-9a-z])|includes/configure\\.php(?![0-9a-z])|inetpub/wwwroot/global\\.asa(?![0-9a-z])|jakarta/dist/tomcat(?![0-9a-z])|jakarta/tomcat/conf(?![0-9a-z])|jakarta/tomcat/logs(?![0-9a-z])|library/webserver/documents(?![0-9a-z])|lighttpd/conf(?![0-9a-z])|lighttpd/lighttpd\\.conf(?![0-9a-z])|lighttpd/log(?![0-9a-z])|localsettings\\.php(?![0-9a-z])|logs/access\\.log(?![0-9a-z])|logs/access_log(?![0-9a-z])|logs/error_log(?![0-9a-z])|logs/pure-ftpd\\.log(?![0-9a-z])|logs/samba\\.log(?![0-9a-z])|logs/security_debug_log(?![0-9a-z])|logs/security_log(?![0-9a-z])|lsws/conf(?![0-9a-z])|lsws/logs(?![0-9a-z])|mysql/bin/my\\.ini(?![0-9a-z])|mysql/data(?![0-9a-z])|mysql/my\\.ini(?![0-9a-z])|nginx/conf/nginx\\.conf(?![0-9a-z])|opt/apache(?![0-9a-z])|opt/apache2(?![0-9a-z])|opt/httpd/apache\\.conf(?![0-9a-z])|opt/httpd/apache2\\.conf(?![0-9a-z])|opt/httpd/conf/|opt/jboss(?![0-9a-z])|opt/lampp(?![0-9a-z])|opt/nuxeo(?![0-9a-z])|opt/tomcat(?![0-9a-z])|opt/xampp(?![0-9a-z])|pgsql/bin/pg_passwd(?![0-9a-z])|pgsql/data(?![0-9a-z])|php/apache\\.conf(?![0-9a-z])|php/apache2\\.conf(?![0-9a-z])|php/httpd\\.conf(?![0-9a-z])|php5/apache\\.conf(?![0-9a-z])|php5/apache2\\.conf(?![0-9a-z])|php5/httpd\\.conf(?![0-9a-z])|postgresql/log/|program files(?![0-9a-z])|psa/admin(?![0-9a-z])|pureftpd/etc(?![0-9a-z])|root/anaconda-ks\\.cfg(?![0-9a-z])|samba/lib(?![0-9a-z])|sb/config(?![0-9a-z])|server/default/conf(?![0-9a-z])|server/default/deploy(?![0-9a-z])|server/default/log(?![0-9a-z])|squirrelmail/www(?![0-9a-z])|system/library/webobjects/adaptors(?![0-9a-z])|system32/config(?![0-9a-z])|system32/inetsrv/config(?![0-9a-z])|tmp/|tmp/access\\.log(?![0-9a-z])|tmp/kafka-logs(?![0-9a-z])|typo3conf/localconf\\.php(?![0-9a-z])|usr/etc/pure-ftpd\\.conf(?![0-9a-z])|usr/home/user/lighttpd(?![0-9a-z])|usr/lib/cron/log(?![0-9a-z])|usr/lib/php(?![0-9a-z])|usr/lib/rpm/rpm\\.log(?![0-9a-z])|usr/lib/security(?![0-9a-z])|usr/local/zeus/web(?![0-9a-z])|usr/pkg/etc/httpd(?![0-9a-z])|usr/pkgsrc/net/pureftpd(?![0-9a-z])|usr/ports/contrib/pure-ftpd(?![0-9a-z])|usr/ports/ftp/pure-ftpd(?![0-9a-z])|usr/sbin/mudlogd(?![0-9a-z])|usr/sbin/mudpasswd(?![0-9a-z])|usr/share/adduser(?![0-9a-z])|usr/share/logs(?![0-9a-z])|usr/share/squirrelmail(?![0-9a-z])|usr/share/tomcat(?![0-9a-z])|usr/spool/lp(?![0-9a-z])|usr/spool/mqueue(?![0-9a-z])|var/adm(?![0-9a-z])|var/apache/logs(?![0-9a-z])|var/apache2/config\\.inc(?![0-9a-z])|var/cpanel(?![0-9a-z])|var/cron/log(?![0-9a-z])|var/data/elasticsearch(?![0-9a-z])|var/data/mysql-bin(?![0-9a-z])|var/htmp(?![0-9a-z])|var/lib/elasticsearch(?![0-9a-z])|var/lib/mysql(?![0-9a-z])|var/lib/pgsql(?![0-9a-z])|var/lib/squirrelmail(?![0-9a-z])|var/lighttpd(?![0-9a-z])|var/local/www/conf(?![0-9a-z])|var/log(?![0-9a-z])|var/lp/logs(?![0-9a-z])|var/mail(?![0-9a-z])|var/mysql-bin(?![0-9a-z])|var/mysql\\.log(?![0-9a-z])|var/nm2/postgresql\\.conf(?![0-9a-z])|var/postgresql(?![0-9a-z])|var/run/utmp(?![0-9a-z])|var/saf/_log(?![0-9a-z])|var/saf/port/log(?![0-9a-z])|var/spool(?![0-9a-z])|var/webmin(?![0-9a-z])|var/www(?![0-9a-z])|volumes/macintosh_hd(?![0-9a-z])|volumes/webbackup(?![0-9a-z])|wamp/bin/apache(?![0-9a-z])|wamp/bin/mysql(?![0-9a-z])|wamp/bin/php(?![0-9a-z])|wamp/logs(?![0-9a-z])|windows/comsetup\\.log(?![0-9a-z])|windows/debug/netsetup\\.log(?![0-9a-z])|windows/odbc\\.ini(?![0-9a-z])|windows/repair/setup\\.log(?![0-9a-z])|windows/setupact\\.log(?![0-9a-z])|windows/setupapi\\.log(?![0-9a-z])|windows/setuperr\\.log(?![0-9a-z])|windows/system32(?![0-9a-z])|windows/syswow64(?![0-9a-z])|windows/updspapi\\.log(?![0-9a-z])|windows/windowsupdate\\.log(?![0-9a-z])|windows/wmsetup\\.log(?![0-9a-z])|winnt/repair(?![0-9a-z])|winnt/system32/logfiles(?![0-9a-z])|wp-cli\\.|www/conf/httpd\\.conf(?![0-9a-z])|www/logs(?![0-9a-z])|xampp/apache/logs(?![0-9a-z])|xampp/filezillaftp(?![0-9a-z])|xampp/htdocs(?![0-9a-z])|xampp/mercurymail(?![0-9a-z])|xampp/mysql/data(?![0-9a-z])|xampp/php(?![0-9a-z])|xampp/sendmail(?![0-9a-z])|xampp/webalizer/webalizer\\.conf(?![0-9a-z]))",
8411
+ "flags": "i",
8412
+ "negated": false
8413
+ }
8414
+ }
8415
+ ];
8323
8416
 
8324
8417
  // src/core/crs/transforms.ts
8325
8418
  var NBSP = 160;
@@ -8832,9 +8925,44 @@ var TRANSFORMS = {
8832
8925
  base64Decode
8833
8926
  };
8834
8927
 
8928
+ // src/core/crs/libinjection.ts
8929
+ var import_node_fs6 = require("fs");
8930
+ var import_node_path4 = require("path");
8931
+ var wasm;
8932
+ function loadLibinjection() {
8933
+ if (!wasm) {
8934
+ const bytes = (0, import_node_fs6.readFileSync)((0, import_node_path4.join)(__dirname, "libinjection", "libinjection.wasm"));
8935
+ wasm = new WebAssembly.Instance(new WebAssembly.Module(bytes), {}).exports;
8936
+ wasm._initialize();
8937
+ }
8938
+ return wasm;
8939
+ }
8940
+ var view;
8941
+ function put(w, bytes) {
8942
+ const ptr = w.tc_input(bytes.length);
8943
+ if (ptr === 0) throw new Error(`libinjection: cannot allocate ${bytes.length} bytes`);
8944
+ if (view?.buffer !== w.memory.buffer) view = Buffer.from(w.memory.buffer);
8945
+ view.write(bytes, ptr, bytes.length, "latin1");
8946
+ }
8947
+ function detectSQLi(bytes) {
8948
+ const w = loadLibinjection();
8949
+ put(w, bytes);
8950
+ const result = w.tc_sqli(bytes.length);
8951
+ if (result !== 1) return { result, fingerprint: "" };
8952
+ const start = w.tc_fingerprint();
8953
+ if (view?.buffer !== w.memory.buffer) view = Buffer.from(w.memory.buffer);
8954
+ return { result, fingerprint: view.toString("latin1", start, view.indexOf(0, start)) };
8955
+ }
8956
+ function detectXSS(bytes) {
8957
+ const w = loadLibinjection();
8958
+ put(w, bytes);
8959
+ return w.tc_xss(bytes.length);
8960
+ }
8961
+
8835
8962
  // src/core/crs/engine.ts
8836
8963
  var SEVERITY_POINTS = { CRITICAL: 5, ERROR: 4, WARNING: 3, NOTICE: 2 };
8837
8964
  var DEFAULT_ANOMALY_THRESHOLD = 5;
8965
+ var DEFAULT_EXCLUDED_RULE_IDS = [941130];
8838
8966
  var ATTACK_TYPES = {
8839
8967
  "attack-sqli": "sqli",
8840
8968
  "attack-xss": "xss",
@@ -8847,6 +8975,9 @@ var ATTACK_TYPES = {
8847
8975
  "attack-reputation-scanner": "scanner",
8848
8976
  "attack-injection-generic": "injection"
8849
8977
  };
8978
+ function crsAttackType(rule) {
8979
+ return rule.tags.map((t) => ATTACK_TYPES[t]).find((t) => t !== void 0) ?? null;
8980
+ }
8850
8981
  var PhraseMatcher = class {
8851
8982
  next = [/* @__PURE__ */ new Map()];
8852
8983
  fail = [0];
@@ -8926,6 +9057,16 @@ function compileOperator(op) {
8926
9057
  case "within":
8927
9058
  test = (v) => op.arg.includes(v);
8928
9059
  break;
9060
+ // ModSecurity v3 counts libinjection's ERROR (parser in an invalid state) as
9061
+ // a match, fail-safe, like TRUE.
9062
+ case "detectSQLi":
9063
+ loadLibinjection();
9064
+ test = (v) => detectSQLi(v).result !== 0;
9065
+ break;
9066
+ case "detectXSS":
9067
+ loadLibinjection();
9068
+ test = (v) => detectXSS(v) !== 0;
9069
+ break;
8929
9070
  }
8930
9071
  return op.negated ? (v) => !test(v) : test;
8931
9072
  }
@@ -9044,6 +9185,8 @@ var MEMO_ENTRIES = 1e4;
9044
9185
  var MEMO_MAX_VALUE = 512;
9045
9186
  var CrsEngine = class {
9046
9187
  threshold;
9188
+ /** How many rules are loaded, by origin: ported OWASP CRS, and ThreatCrush's own. */
9189
+ ruleCounts;
9047
9190
  rules;
9048
9191
  /** Unchained rules by the targets they read. */
9049
9192
  byTarget = /* @__PURE__ */ new Map();
@@ -9053,14 +9196,17 @@ var CrsEngine = class {
9053
9196
  memoSize = 0;
9054
9197
  constructor(options = {}) {
9055
9198
  this.threshold = options.threshold ?? DEFAULT_ANOMALY_THRESHOLD;
9056
- const excluded = new Set(options.excludeRuleIds ?? []);
9057
- this.rules = CRS_RULES.filter((r) => !excluded.has(r.id)).map((rule, index) => ({
9199
+ const excluded = new Set(options.excludeRuleIds ?? DEFAULT_EXCLUDED_RULE_IDS);
9200
+ const crs = CRS_RULES.filter((r) => !excluded.has(r.id));
9201
+ const threatcrush = THREATCRUSH_RULES.filter((r) => !excluded.has(r.id));
9202
+ this.ruleCounts = { crs: crs.length, threatcrush: threatcrush.length };
9203
+ this.rules = [...crs, ...threatcrush].map((rule, index) => ({
9058
9204
  index,
9059
9205
  rule,
9060
9206
  test: compileOperator(rule.op),
9061
9207
  stepKeys: rule.transforms.map((_, k) => rule.transforms.slice(0, k + 1).join(",")),
9062
9208
  chain: (rule.chain ?? []).map((link) => ({ link, test: compileOperator(link.op) })),
9063
- attackType: rule.tags.map((t) => ATTACK_TYPES[t]).find((t) => t !== void 0) ?? null
9209
+ attackType: crsAttackType(rule)
9064
9210
  }));
9065
9211
  for (const compiled of this.rules) {
9066
9212
  if (compiled.chain.length > 0) {
@@ -9074,9 +9220,6 @@ var CrsEngine = class {
9074
9220
  }
9075
9221
  }
9076
9222
  }
9077
- get ruleCount() {
9078
- return this.rules.length;
9079
- }
9080
9223
  slotMatches(target, rules, slot) {
9081
9224
  const memoize = slot.value.length <= MEMO_MAX_VALUE;
9082
9225
  let memo = this.memo.get(target);
@@ -9177,20 +9320,36 @@ function parseNginxLog(line) {
9177
9320
  function parseAuthLog(line) {
9178
9321
  const match = line.match(AUTH_REGEX);
9179
9322
  if (!match) return null;
9180
- const ipMatch = match[3].match(IP_REGEX);
9181
- const userMatch = match[3].match(INVALID_USER_REGEX) || match[3].match(USER_REGEX);
9323
+ return parseAuthMessage(match[2], match[3], parseSyslogTimestamp(match[1]), line);
9324
+ }
9325
+ function parseAuthMessage(process3, message, timestamp, raw = message) {
9326
+ const ipMatch = message.match(IP_REGEX);
9327
+ const userMatch = message.match(INVALID_USER_REGEX) || message.match(USER_REGEX);
9182
9328
  return {
9183
- timestamp: parseSyslogTimestamp(match[1]),
9184
- raw: line,
9329
+ timestamp,
9330
+ raw,
9185
9331
  source: "auth",
9186
9332
  fields: {
9187
- process: match[2],
9188
- message: match[3],
9333
+ process: process3,
9334
+ message,
9189
9335
  ip: ipMatch?.[1],
9190
9336
  user: userMatch?.[1]
9191
9337
  }
9192
9338
  };
9193
9339
  }
9340
+ function classifySshAuth(entry) {
9341
+ const { ip, user, message } = entry.fields;
9342
+ if (/failed password/i.test(message)) {
9343
+ return { severity: "high", message: `Failed SSH login for ${user || "unknown"} from ${ip || "unknown"}`, source_ip: ip };
9344
+ }
9345
+ if (/invalid user/i.test(message)) {
9346
+ return { severity: "high", message: `Invalid SSH user: ${user || "unknown"} from ${ip || "unknown"}`, source_ip: ip };
9347
+ }
9348
+ if (/accepted/i.test(message)) {
9349
+ return { severity: "info", message: `SSH login accepted for ${user || "unknown"}`, source_ip: ip };
9350
+ }
9351
+ return null;
9352
+ }
9194
9353
  function parseSyslog(line) {
9195
9354
  const match = line.match(SYSLOG_REGEX);
9196
9355
  if (!match) return null;
@@ -9208,9 +9367,13 @@ function parseSyslog(line) {
9208
9367
  var crsEngine;
9209
9368
  function configureAttackDetection(section) {
9210
9369
  const threshold = section?.anomaly_threshold;
9370
+ const included = Array.isArray(section?.include_rules) ? section.include_rules.map(Number) : [];
9211
9371
  crsEngine = new CrsEngine({
9212
9372
  threshold: typeof threshold === "number" && threshold > 0 ? threshold : void 0,
9213
- excludeRuleIds: Array.isArray(section?.exclude_rules) ? section.exclude_rules.map(Number) : void 0
9373
+ excludeRuleIds: [
9374
+ ...DEFAULT_EXCLUDED_RULE_IDS.filter((id) => !included.includes(id)),
9375
+ ...Array.isArray(section?.exclude_rules) ? section.exclude_rules.map(Number) : []
9376
+ ]
9214
9377
  });
9215
9378
  }
9216
9379
  function engine() {
@@ -9284,9 +9447,9 @@ var LogWatcher = class {
9284
9447
  start() {
9285
9448
  const started = [];
9286
9449
  for (const src of this.sources) {
9287
- if (!(0, import_node_fs6.existsSync)(src.path)) continue;
9450
+ if (!(0, import_node_fs7.existsSync)(src.path)) continue;
9288
9451
  try {
9289
- (0, import_node_fs6.accessSync)(src.path, import_node_fs6.constants.R_OK);
9452
+ (0, import_node_fs7.accessSync)(src.path, import_node_fs7.constants.R_OK);
9290
9453
  } catch {
9291
9454
  continue;
9292
9455
  }
@@ -9304,9 +9467,17 @@ var LogWatcher = class {
9304
9467
  activeModules() {
9305
9468
  return [...this.active];
9306
9469
  }
9470
+ /**
9471
+ * The auth logs being tailed. While there is one, it is the only source of
9472
+ * SSH events: sshd's journald records carry the same lines, and counting
9473
+ * both would halve every SSH threshold.
9474
+ */
9475
+ authLogs() {
9476
+ return this.sources.filter((s) => s.category === "auth" && this.timers.has(s.path)).map((s) => s.path);
9477
+ }
9307
9478
  tail(src) {
9308
9479
  try {
9309
- this.positions.set(src.path, (0, import_node_fs6.statSync)(src.path).size);
9480
+ this.positions.set(src.path, (0, import_node_fs7.statSync)(src.path).size);
9310
9481
  } catch {
9311
9482
  this.positions.set(src.path, 0);
9312
9483
  }
@@ -9317,7 +9488,7 @@ var LogWatcher = class {
9317
9488
  poll(src) {
9318
9489
  let stat;
9319
9490
  try {
9320
- stat = (0, import_node_fs6.statSync)(src.path);
9491
+ stat = (0, import_node_fs7.statSync)(src.path);
9321
9492
  } catch {
9322
9493
  return;
9323
9494
  }
@@ -9327,7 +9498,7 @@ var LogWatcher = class {
9327
9498
  return;
9328
9499
  }
9329
9500
  if (stat.size === prev) return;
9330
- const stream = (0, import_node_fs6.createReadStream)(src.path, { start: prev, encoding: "utf-8" });
9501
+ const stream = (0, import_node_fs7.createReadStream)(src.path, { start: prev, encoding: "utf-8" });
9331
9502
  stream.on("error", () => this.positions.set(src.path, stat.size));
9332
9503
  const rl = (0, import_node_readline.createInterface)({ input: stream });
9333
9504
  rl.on("error", () => {
@@ -9348,20 +9519,9 @@ var LogWatcher = class {
9348
9519
  if (parsed.source === "auth") {
9349
9520
  const entry = parseAuthLog(line);
9350
9521
  if (!entry) return;
9351
- sourceIp = entry.fields.ip;
9352
- const msg = entry.fields.message;
9353
- if (/failed password/i.test(msg)) {
9354
- severity = "high";
9355
- message = `Failed SSH login for ${entry.fields.user || "unknown"} from ${entry.fields.ip || "unknown"}`;
9356
- } else if (/invalid user/i.test(msg)) {
9357
- severity = "high";
9358
- message = `Invalid SSH user: ${entry.fields.user || "unknown"} from ${entry.fields.ip || "unknown"}`;
9359
- } else if (/accepted/i.test(msg)) {
9360
- severity = "info";
9361
- message = `SSH login accepted for ${entry.fields.user || "unknown"}`;
9362
- } else {
9363
- return;
9364
- }
9522
+ const verdict = classifySshAuth(entry);
9523
+ if (!verdict) return;
9524
+ ({ severity, message, source_ip: sourceIp } = verdict);
9365
9525
  } else if (parsed.source === "nginx") {
9366
9526
  const entry = parseNginxLog(line);
9367
9527
  if (!entry) return;
@@ -9419,13 +9579,33 @@ var LogWatcher = class {
9419
9579
 
9420
9580
  // src/daemon/watchers/journal-watcher.ts
9421
9581
  var import_node_child_process = require("child_process");
9582
+ var SSHD_COMMS = ["sshd", "sshd-session"];
9583
+ function isSshdRecord(entry) {
9584
+ return entry._UID === "0" && SSHD_COMMS.includes(entry._COMM);
9585
+ }
9586
+ function sshEventFromJournal(entry) {
9587
+ if (!isSshdRecord(entry) || typeof entry.MESSAGE !== "string") return null;
9588
+ const timestamp = realtimeToDate(entry.__REALTIME_TIMESTAMP) || /* @__PURE__ */ new Date();
9589
+ const verdict = classifySshAuth(parseAuthMessage(entry._COMM, entry.MESSAGE, timestamp));
9590
+ if (!verdict) return null;
9591
+ return {
9592
+ timestamp,
9593
+ module: "ssh-guard",
9594
+ category: "auth",
9595
+ severity: verdict.severity,
9596
+ message: verdict.message,
9597
+ source_ip: verdict.source_ip
9598
+ };
9599
+ }
9422
9600
  var JournalWatcher = class _JournalWatcher {
9423
9601
  constructor(bus2) {
9424
9602
  this.bus = bus2;
9425
9603
  }
9426
9604
  bus;
9427
9605
  proc = null;
9606
+ sshdProc = null;
9428
9607
  buffer = "";
9608
+ sshdBuffer = "";
9429
9609
  moduleName = "user-journal";
9430
9610
  active = false;
9431
9611
  // When the daemon runs as root (system mode), tail the SYSTEM journal so
@@ -9451,7 +9631,9 @@ var JournalWatcher = class _JournalWatcher {
9451
9631
  );
9452
9632
  if (!child.stdout) return false;
9453
9633
  child.stdout.setEncoding("utf-8");
9454
- child.stdout.on("data", (chunk) => this.onData(chunk));
9634
+ child.stdout.on("data", (chunk) => {
9635
+ this.buffer = this.drain(this.buffer + chunk, (entry) => this.handleEntry(entry));
9636
+ });
9455
9637
  child.on("exit", () => {
9456
9638
  this.proc = null;
9457
9639
  this.active = false;
@@ -9460,14 +9642,49 @@ var JournalWatcher = class _JournalWatcher {
9460
9642
  this.active = true;
9461
9643
  return true;
9462
9644
  }
9645
+ /**
9646
+ * Follows sshd in the system journal. Unprivileged, that needs the adm,
9647
+ * systemd-journal or wheel group; without it journalctl shows only the
9648
+ * user's own records, so this reports `unreadable` rather than tailing
9649
+ * nothing and looking like protection.
9650
+ */
9651
+ startSshd() {
9652
+ const probe = (0, import_node_child_process.spawnSync)("journalctl", ["-q", "-n", "1", "-o", "cat", "--no-pager", "_UID=0"], {
9653
+ stdio: ["ignore", "pipe", "ignore"],
9654
+ encoding: "utf-8"
9655
+ });
9656
+ if (probe.error || probe.status !== 0) return "unavailable";
9657
+ if (!probe.stdout.trim()) return "unreadable";
9658
+ const matches = ["_UID=0", ...SSHD_COMMS.map((comm) => `_COMM=${comm}`)];
9659
+ const child = (0, import_node_child_process.spawn)("journalctl", ["-o", "json", "-f", "--since", "now", ...matches], {
9660
+ stdio: ["ignore", "pipe", "ignore"]
9661
+ });
9662
+ if (!child.stdout) return "unavailable";
9663
+ child.stdout.setEncoding("utf-8");
9664
+ child.stdout.on("data", (chunk) => {
9665
+ this.sshdBuffer = this.drain(this.sshdBuffer + chunk, (entry) => {
9666
+ const event = sshEventFromJournal(entry);
9667
+ if (event) this.emit(event);
9668
+ });
9669
+ });
9670
+ child.on("error", () => {
9671
+ this.sshdProc = null;
9672
+ });
9673
+ child.on("exit", () => {
9674
+ this.sshdProc = null;
9675
+ });
9676
+ this.sshdProc = child;
9677
+ return "running";
9678
+ }
9463
9679
  stop() {
9464
- if (this.proc) {
9680
+ for (const child of [this.proc, this.sshdProc]) {
9465
9681
  try {
9466
- this.proc.kill("SIGTERM");
9682
+ child?.kill("SIGTERM");
9467
9683
  } catch {
9468
9684
  }
9469
- this.proc = null;
9470
9685
  }
9686
+ this.proc = null;
9687
+ this.sshdProc = null;
9471
9688
  this.active = false;
9472
9689
  }
9473
9690
  isActive() {
@@ -9476,36 +9693,40 @@ var JournalWatcher = class _JournalWatcher {
9476
9693
  moduleNameValue() {
9477
9694
  return this.moduleName;
9478
9695
  }
9479
- onData(chunk) {
9480
- this.buffer += chunk;
9696
+ /** Hands each complete JSON line to `onEntry`; returns the unterminated rest. */
9697
+ drain(buffer, onEntry) {
9481
9698
  let idx;
9482
- while ((idx = this.buffer.indexOf("\n")) >= 0) {
9483
- const line = this.buffer.slice(0, idx);
9484
- this.buffer = this.buffer.slice(idx + 1);
9699
+ while ((idx = buffer.indexOf("\n")) >= 0) {
9700
+ const line = buffer.slice(0, idx);
9701
+ buffer = buffer.slice(idx + 1);
9485
9702
  if (!line.trim()) continue;
9486
- this.handleLine(line);
9703
+ let entry;
9704
+ try {
9705
+ entry = JSON.parse(line);
9706
+ } catch {
9707
+ continue;
9708
+ }
9709
+ onEntry(entry);
9487
9710
  }
9711
+ return buffer;
9488
9712
  }
9489
- handleLine(line) {
9490
- let entry;
9491
- try {
9492
- entry = JSON.parse(line);
9493
- } catch {
9494
- return;
9495
- }
9713
+ handleEntry(entry) {
9714
+ if (this.sshdProc && isSshdRecord(entry)) return;
9496
9715
  const message = entry.MESSAGE;
9497
9716
  if (!message) return;
9498
9717
  const priority = parseInt(entry.PRIORITY ?? "6", 10);
9499
9718
  const severity = priorityToSeverity(priority);
9500
9719
  const ident = entry.SYSLOG_IDENTIFIER || entry._COMM || "journal";
9501
9720
  const bumpedSeverity = bumpForIdent(ident, message, severity);
9502
- const event = {
9721
+ this.emit({
9503
9722
  timestamp: realtimeToDate(entry.__REALTIME_TIMESTAMP) || /* @__PURE__ */ new Date(),
9504
9723
  module: this.moduleName,
9505
9724
  category: "system",
9506
9725
  severity: bumpedSeverity,
9507
9726
  message: `[${ident}] ${message}`.slice(0, 500)
9508
- };
9727
+ });
9728
+ }
9729
+ emit(event) {
9509
9730
  try {
9510
9731
  insertEvent(event);
9511
9732
  } catch {
@@ -9538,7 +9759,7 @@ function realtimeToDate(rt) {
9538
9759
 
9539
9760
  // src/modules/network-monitor/index.ts
9540
9761
  var import_node_child_process2 = require("child_process");
9541
- var import_node_fs7 = require("fs");
9762
+ var import_node_fs8 = require("fs");
9542
9763
  var NetworkMonitor = class {
9543
9764
  constructor(bus2) {
9544
9765
  this.bus = bus2;
@@ -9546,13 +9767,22 @@ var NetworkMonitor = class {
9546
9767
  bus;
9547
9768
  active = false;
9548
9769
  pollTimer = null;
9770
+ heartbeatTimer = null;
9549
9771
  scanTrackers = /* @__PURE__ */ new Map();
9550
9772
  halfOpenTrackers = /* @__PURE__ */ new Map();
9551
9773
  lastConnections = /* @__PURE__ */ new Set();
9774
+ // Proof-of-life accounting, reset each heartbeat.
9775
+ obsConnections = 0;
9776
+ obsSources = /* @__PURE__ */ new Set();
9777
+ noticed = /* @__PURE__ */ new Set();
9552
9778
  // Config
9553
9779
  pollIntervalMs = 5e3;
9780
+ heartbeatMs = 9e5;
9781
+ // 15 min: proof of life, low volume
9554
9782
  portScanThreshold = 10;
9555
- // unique ports in window
9783
+ // unique listening ports -> high (bannable)
9784
+ portScanNoticeThreshold = 5;
9785
+ // 5-9 -> medium notice (never bans)
9556
9786
  portScanWindowMs = 3e4;
9557
9787
  synFloodThreshold = 50;
9558
9788
  // half-open connections
@@ -9563,20 +9793,37 @@ var NetworkMonitor = class {
9563
9793
  }
9564
9794
  this.active = true;
9565
9795
  this.pollTimer = setInterval(() => this.poll(), this.pollIntervalMs);
9796
+ this.heartbeatTimer = setInterval(() => this.heartbeat(), this.heartbeatMs);
9566
9797
  return true;
9567
9798
  }
9568
9799
  stop() {
9569
9800
  if (this.pollTimer) clearInterval(this.pollTimer);
9801
+ if (this.heartbeatTimer) clearInterval(this.heartbeatTimer);
9570
9802
  this.pollTimer = null;
9803
+ this.heartbeatTimer = null;
9571
9804
  this.active = false;
9572
9805
  }
9806
+ heartbeat() {
9807
+ const conns = this.obsConnections;
9808
+ const srcs = this.obsSources.size;
9809
+ this.obsConnections = 0;
9810
+ this.obsSources.clear();
9811
+ this.noticed.clear();
9812
+ const listening = this.listeningPorts().size;
9813
+ this.emitEvent(
9814
+ "info",
9815
+ `network-monitor alive: ${conns} inbound connection(s) from ${srcs} source(s) across ${listening} listening port(s) in the last ${Math.round(this.heartbeatMs / 6e4)}m`,
9816
+ void 0,
9817
+ { heartbeat: true, inbound: conns, sources: srcs, listening_ports: listening }
9818
+ );
9819
+ }
9573
9820
  isActive() {
9574
9821
  return this.active;
9575
9822
  }
9576
9823
  hasConntrackOrSs() {
9577
9824
  const ss = (0, import_node_child_process2.spawnSync)("ss", ["--version"], { stdio: "pipe" });
9578
9825
  if (ss.status === 0) return true;
9579
- return (0, import_node_fs7.existsSync)("/proc/net/tcp");
9826
+ return (0, import_node_fs8.existsSync)("/proc/net/tcp");
9580
9827
  }
9581
9828
  /**
9582
9829
  * The TCP ports this host actually listens on.
@@ -9608,6 +9855,8 @@ var NetworkMonitor = class {
9608
9855
  poll() {
9609
9856
  try {
9610
9857
  const connections = this.getConnections();
9858
+ this.obsConnections += connections.length;
9859
+ for (const c of connections) this.obsSources.add(c.source_ip);
9611
9860
  this.analyzePortScans(connections);
9612
9861
  this.analyzeSynFlood(connections);
9613
9862
  this.cleanupTrackers();
@@ -9676,7 +9925,8 @@ var NetworkMonitor = class {
9676
9925
  tracker.ports.add(conn.dest_port);
9677
9926
  tracker.lastSeen = now;
9678
9927
  tracker.count++;
9679
- if (tracker.ports.size >= this.portScanThreshold && now - tracker.firstSeen <= this.portScanWindowMs) {
9928
+ const withinWindow = now - tracker.firstSeen <= this.portScanWindowMs;
9929
+ if (tracker.ports.size >= this.portScanThreshold && withinWindow) {
9680
9930
  this.emitEvent(
9681
9931
  "high",
9682
9932
  `Port scan detected: ${conn.source_ip} probed ${tracker.ports.size} ports in ${Math.round((now - tracker.firstSeen) / 1e3)}s`,
@@ -9684,6 +9934,20 @@ var NetworkMonitor = class {
9684
9934
  { ports_scanned: tracker.ports.size, window_seconds: Math.round((now - tracker.firstSeen) / 1e3) }
9685
9935
  );
9686
9936
  this.scanTrackers.delete(key);
9937
+ } else if (
9938
+ // A smaller spread across our listening ports is worth surfacing, but
9939
+ // at `medium` so it is logged and never banned (auto-defence bans at
9940
+ // `high`). These are inbound-to-listening only, so the ephemeral
9941
+ // outbound-port bug that once banned our upstreams cannot recur here.
9942
+ tracker.ports.size >= this.portScanNoticeThreshold && withinWindow && !this.noticed.has(key)
9943
+ ) {
9944
+ this.noticed.add(key);
9945
+ this.emitEvent(
9946
+ "medium",
9947
+ `Possible port scan: ${conn.source_ip} touched ${tracker.ports.size} listening ports in ${Math.round((now - tracker.firstSeen) / 1e3)}s`,
9948
+ conn.source_ip,
9949
+ { ports_scanned: tracker.ports.size, window_seconds: Math.round((now - tracker.firstSeen) / 1e3), notice: true }
9950
+ );
9687
9951
  }
9688
9952
  }
9689
9953
  }
@@ -9746,7 +10010,7 @@ var NetworkMonitor = class {
9746
10010
  };
9747
10011
 
9748
10012
  // src/modules/dns-monitor/index.ts
9749
- var import_node_fs8 = require("fs");
10013
+ var import_node_fs9 = require("fs");
9750
10014
  var import_node_child_process3 = require("child_process");
9751
10015
  var import_node_readline2 = require("readline");
9752
10016
  var DNS_LOG_SOURCES = [
@@ -9759,6 +10023,7 @@ var DNS_LOG_SOURCES = [
9759
10023
  "/var/log/pihole.log"
9760
10024
  // Pi-hole
9761
10025
  ];
10026
+ var DEFAULT_DNS_JOURNAL_UNITS = ["moshpit-dns", "dnsmasq", "named", "unbound", "pdns-recursor"];
9762
10027
  function qtypeName(qtype) {
9763
10028
  const names = {
9764
10029
  1: "A",
@@ -9779,10 +10044,11 @@ function qtypeName(qtype) {
9779
10044
  return names[qtype] ?? `TYPE${qtype}`;
9780
10045
  }
9781
10046
  var DnsMonitor = class {
10047
+ // 15 min: enough to prove life, low volume
9782
10048
  constructor(bus2, options = {}) {
9783
10049
  this.bus = bus2;
9784
10050
  this.extraPaths = options.log_paths ?? [];
9785
- this.journalUnits = options.journal_units ?? [];
10051
+ this.journalUnits = options.journal_units ?? DEFAULT_DNS_JOURNAL_UNITS;
9786
10052
  }
9787
10053
  bus;
9788
10054
  active = false;
@@ -9804,28 +10070,77 @@ var DnsMonitor = class {
9804
10070
  extraPaths = [];
9805
10071
  journalUnits = [];
9806
10072
  journalTails = [];
10073
+ /** What we ended up tailing, for an honest status line. */
10074
+ activeSources = [];
10075
+ /** Queries seen since the last heartbeat, for a proof-of-life event. */
10076
+ observed = 0;
10077
+ analyzeTimer = null;
10078
+ heartbeatTimer = null;
10079
+ heartbeatMs = 9e5;
10080
+ /** True if a systemd unit is loaded on this host (so we do not tail nothing). */
10081
+ unitExists(unit) {
10082
+ try {
10083
+ const r = (0, import_node_child_process3.spawnSync)("systemctl", ["show", unit, "--property=LoadState", "--value"], {
10084
+ encoding: "utf-8",
10085
+ stdio: ["ignore", "pipe", "ignore"],
10086
+ timeout: 3e3
10087
+ });
10088
+ return r.status === 0 && (r.stdout || "").trim() === "loaded";
10089
+ } catch {
10090
+ return false;
10091
+ }
10092
+ }
9807
10093
  start() {
9808
10094
  const sources = [...DNS_LOG_SOURCES, ...this.extraPaths].filter((p) => {
9809
- if (!(0, import_node_fs8.existsSync)(p)) return false;
10095
+ if (!(0, import_node_fs9.existsSync)(p)) return false;
9810
10096
  try {
9811
- (0, import_node_fs8.accessSync)(p, import_node_fs8.constants.R_OK);
10097
+ (0, import_node_fs9.accessSync)(p, import_node_fs9.constants.R_OK);
9812
10098
  return true;
9813
10099
  } catch {
9814
10100
  return false;
9815
10101
  }
9816
10102
  });
9817
- for (const unit of this.journalUnits) this.tailJournalUnit(unit);
10103
+ for (const unit of this.journalUnits) {
10104
+ if (this.unitExists(unit)) {
10105
+ this.tailJournalUnit(unit);
10106
+ this.activeSources.push(`journal:${unit}`);
10107
+ }
10108
+ }
10109
+ this.activeSources.push(...sources);
9818
10110
  if (sources.length === 0 && this.journalTails.length === 0) return false;
9819
10111
  this.active = true;
9820
10112
  for (const src of sources) {
9821
10113
  this.tailLog(src);
9822
10114
  }
9823
- setInterval(() => this.analyzeBuffer(), 1e4);
10115
+ this.analyzeTimer = setInterval(() => this.analyzeBuffer(), 1e4);
10116
+ this.heartbeatTimer = setInterval(() => this.heartbeat(), this.heartbeatMs);
9824
10117
  return true;
9825
10118
  }
10119
+ /** What the module is tailing, for the host's status line. */
10120
+ sources() {
10121
+ return [...this.activeSources];
10122
+ }
10123
+ heartbeat() {
10124
+ const seen = this.observed;
10125
+ this.observed = 0;
10126
+ this.emitEvent(
10127
+ "info",
10128
+ `dns-monitor alive: ${seen} DNS quer${seen === 1 ? "y" : "ies"} in the last ${Math.round(this.heartbeatMs / 6e4)}m (sources: ${this.activeSources.join(", ") || "none"})`,
10129
+ void 0,
10130
+ { heartbeat: true, observed: seen, sources: this.activeSources }
10131
+ );
10132
+ }
9826
10133
  stop() {
9827
10134
  for (const t of this.timers.values()) clearInterval(t);
9828
10135
  this.timers.clear();
10136
+ if (this.analyzeTimer) {
10137
+ clearInterval(this.analyzeTimer);
10138
+ this.analyzeTimer = null;
10139
+ }
10140
+ if (this.heartbeatTimer) {
10141
+ clearInterval(this.heartbeatTimer);
10142
+ this.heartbeatTimer = null;
10143
+ }
9829
10144
  for (const child of this.journalTails) {
9830
10145
  try {
9831
10146
  child.kill("SIGTERM");
@@ -9855,7 +10170,7 @@ var DnsMonitor = class {
9855
10170
  }
9856
10171
  tailLog(path) {
9857
10172
  try {
9858
- this.positions.set(path, (0, import_node_fs8.statSync)(path).size);
10173
+ this.positions.set(path, (0, import_node_fs9.statSync)(path).size);
9859
10174
  } catch {
9860
10175
  this.positions.set(path, 0);
9861
10176
  }
@@ -9865,7 +10180,7 @@ var DnsMonitor = class {
9865
10180
  pollLog(path) {
9866
10181
  let stat;
9867
10182
  try {
9868
- stat = (0, import_node_fs8.statSync)(path);
10183
+ stat = (0, import_node_fs9.statSync)(path);
9869
10184
  } catch {
9870
10185
  return;
9871
10186
  }
@@ -9875,7 +10190,7 @@ var DnsMonitor = class {
9875
10190
  return;
9876
10191
  }
9877
10192
  if (stat.size === prev) return;
9878
- const stream = (0, import_node_fs8.createReadStream)(path, { start: prev, encoding: "utf-8" });
10193
+ const stream = (0, import_node_fs9.createReadStream)(path, { start: prev, encoding: "utf-8" });
9879
10194
  stream.on("error", () => this.positions.set(path, stat.size));
9880
10195
  const rl = (0, import_node_readline2.createInterface)({ input: stream });
9881
10196
  rl.on("line", (line) => this.parseDnsLine(line));
@@ -9886,7 +10201,7 @@ var DnsMonitor = class {
9886
10201
  /\[dns\]\s+(?:udp|tcp|doh)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\w+)/i
9887
10202
  );
9888
10203
  if (moshpit) {
9889
- this.domainBuffer.push({
10204
+ this.record({
9890
10205
  type: qtypeName(Number.parseInt(moshpit[3], 10)),
9891
10206
  domain: moshpit[2],
9892
10207
  source_ip: moshpit[1],
@@ -9896,7 +10211,7 @@ var DnsMonitor = class {
9896
10211
  }
9897
10212
  const resolvedMatch = line.match(/query\[(\w+)\]\s+(\S+)\s+from\s+(\S+)/i);
9898
10213
  if (resolvedMatch) {
9899
- this.domainBuffer.push({
10214
+ this.record({
9900
10215
  type: resolvedMatch[1],
9901
10216
  domain: resolvedMatch[2],
9902
10217
  source_ip: resolvedMatch[3],
@@ -9906,7 +10221,7 @@ var DnsMonitor = class {
9906
10221
  }
9907
10222
  const dnsmasqMatch = line.match(/query\[(\w+)\]\s+(\S+)\s+from\s+(\S+)/i);
9908
10223
  if (dnsmasqMatch) {
9909
- this.domainBuffer.push({
10224
+ this.record({
9910
10225
  type: dnsmasqMatch[1],
9911
10226
  domain: dnsmasqMatch[2],
9912
10227
  source_ip: dnsmasqMatch[3],
@@ -9917,7 +10232,7 @@ var DnsMonitor = class {
9917
10232
  const genericMatch = line.match(/(?:query|lookup|resolve)[:\s]+(\S+)/i);
9918
10233
  if (genericMatch) {
9919
10234
  const typeMatch = line.match(/type[:\s]+(\w+)/i);
9920
- this.domainBuffer.push({
10235
+ this.record({
9921
10236
  type: typeMatch?.[1] || "A",
9922
10237
  domain: genericMatch[1],
9923
10238
  timestamp: Date.now()
@@ -9997,6 +10312,11 @@ var DnsMonitor = class {
9997
10312
  }
9998
10313
  return entropy;
9999
10314
  }
10315
+ /** Buffer a parsed query and count it toward the proof-of-life heartbeat. */
10316
+ record(q) {
10317
+ this.domainBuffer.push(q);
10318
+ this.observed++;
10319
+ }
10000
10320
  emitEvent(severity, message, sourceIp, details) {
10001
10321
  const event = {
10002
10322
  timestamp: /* @__PURE__ */ new Date(),
@@ -10016,8 +10336,8 @@ var DnsMonitor = class {
10016
10336
  };
10017
10337
 
10018
10338
  // src/core/config.ts
10019
- var import_node_fs9 = require("fs");
10020
- var import_node_path4 = require("path");
10339
+ var import_node_fs10 = require("fs");
10340
+ var import_node_path5 = require("path");
10021
10341
  var import_toml = __toESM(require_toml());
10022
10342
  var DEFAULT_CONFIG_PATH = "/etc/threatcrush/threatcrushd.conf";
10023
10343
  var DEFAULT_CONFDIR = "/etc/threatcrush/threatcrushd.conf.d";
@@ -10043,11 +10363,11 @@ var DEFAULT_CONFIG = {
10043
10363
  };
10044
10364
  function loadConfig(configPath) {
10045
10365
  const path = configPath || DEFAULT_CONFIG_PATH;
10046
- if (!(0, import_node_fs9.existsSync)(path)) {
10366
+ if (!(0, import_node_fs10.existsSync)(path)) {
10047
10367
  return { ...DEFAULT_CONFIG };
10048
10368
  }
10049
10369
  try {
10050
- const raw = (0, import_node_fs9.readFileSync)(path, "utf-8");
10370
+ const raw = (0, import_node_fs10.readFileSync)(path, "utf-8");
10051
10371
  const parsed = import_toml.default.parse(raw);
10052
10372
  return {
10053
10373
  daemon: { ...DEFAULT_CONFIG.daemon, ...parsed.daemon },
@@ -10065,13 +10385,13 @@ function loadConfig(configPath) {
10065
10385
  function loadModuleConfigs(confDir) {
10066
10386
  const dir = confDir || DEFAULT_CONFDIR;
10067
10387
  const configs = /* @__PURE__ */ new Map();
10068
- if (!(0, import_node_fs9.existsSync)(dir)) {
10388
+ if (!(0, import_node_fs10.existsSync)(dir)) {
10069
10389
  return configs;
10070
10390
  }
10071
- const files = (0, import_node_fs9.readdirSync)(dir).filter((f) => f.endsWith(".conf"));
10391
+ const files = (0, import_node_fs10.readdirSync)(dir).filter((f) => f.endsWith(".conf"));
10072
10392
  for (const file of files) {
10073
10393
  try {
10074
- const raw = (0, import_node_fs9.readFileSync)((0, import_node_path4.join)(dir, file), "utf-8");
10394
+ const raw = (0, import_node_fs10.readFileSync)((0, import_node_path5.join)(dir, file), "utf-8");
10075
10395
  const parsed = import_toml.default.parse(raw);
10076
10396
  for (const [name, config] of Object.entries(parsed)) {
10077
10397
  configs.set(name, config);
@@ -10127,6 +10447,18 @@ var ModuleHost = class {
10127
10447
  this.bus.announceModule("user-journal", "running", mod.detail);
10128
10448
  }
10129
10449
  }
10450
+ if (this.logWatcher.authLogs().length === 0) {
10451
+ const sshd = this.journalWatcher.startSshd();
10452
+ const mod = this.modules.get("ssh-guard");
10453
+ if (mod && sshd === "running") {
10454
+ mod.status = "running";
10455
+ mod.detail = "no auth log; following sshd in the system journal";
10456
+ this.bus.announceModule("ssh-guard", "running", mod.detail);
10457
+ } else if (mod && sshd === "unreadable") {
10458
+ mod.detail = "no auth log, and the system journal is unreadable: add this user to the adm, systemd-journal or wheel group";
10459
+ this.bus.announceModule("ssh-guard", mod.status, mod.detail);
10460
+ }
10461
+ }
10130
10462
  this.networkMonitor = new NetworkMonitor(this.bus);
10131
10463
  if (this.networkMonitor.start()) {
10132
10464
  const nmod = this.modules.get("network-monitor");
@@ -10145,7 +10477,7 @@ var ModuleHost = class {
10145
10477
  const dmod = this.modules.get("dns-monitor");
10146
10478
  if (dmod) {
10147
10479
  dmod.status = "running";
10148
- dmod.detail = "monitoring DNS queries";
10480
+ dmod.detail = `monitoring DNS: ${this.dnsMonitor.sources().join(", ") || "no source"}`;
10149
10481
  this.bus.announceModule("dns-monitor", "running", dmod.detail);
10150
10482
  }
10151
10483
  }
@@ -10189,15 +10521,15 @@ var ModuleHost = class {
10189
10521
  for (const m of builtins) this.modules.set(m.name, m);
10190
10522
  }
10191
10523
  async discoverAndStartInstalled() {
10192
- if (!(0, import_node_fs10.existsSync)(PATHS.moduleDir)) return;
10524
+ if (!(0, import_node_fs11.existsSync)(PATHS.moduleDir)) return;
10193
10525
  const configs = loadModuleConfigs(PATHS.confD);
10194
- const entries = (0, import_node_fs10.readdirSync)(PATHS.moduleDir, { withFileTypes: true });
10526
+ const entries = (0, import_node_fs11.readdirSync)(PATHS.moduleDir, { withFileTypes: true });
10195
10527
  for (const entry of entries) {
10196
10528
  if (!entry.isDirectory()) continue;
10197
- const manifestPath = (0, import_node_path5.join)(PATHS.moduleDir, entry.name, "mod.toml");
10198
- if (!(0, import_node_fs10.existsSync)(manifestPath)) continue;
10529
+ const manifestPath = (0, import_node_path6.join)(PATHS.moduleDir, entry.name, "mod.toml");
10530
+ if (!(0, import_node_fs11.existsSync)(manifestPath)) continue;
10199
10531
  try {
10200
- const manifest = import_toml2.default.parse((0, import_node_fs10.readFileSync)(manifestPath, "utf-8"));
10532
+ const manifest = import_toml2.default.parse((0, import_node_fs11.readFileSync)(manifestPath, "utf-8"));
10201
10533
  const name = manifest.module?.name || entry.name;
10202
10534
  const defaults = manifest.module?.config?.defaults || {};
10203
10535
  const config = {
@@ -10211,7 +10543,7 @@ var ModuleHost = class {
10211
10543
  source: "installed",
10212
10544
  status: config.enabled === false ? "disabled" : "loaded",
10213
10545
  events: 0,
10214
- path: (0, import_node_path5.join)(PATHS.moduleDir, entry.name),
10546
+ path: (0, import_node_path6.join)(PATHS.moduleDir, entry.name),
10215
10547
  config
10216
10548
  };
10217
10549
  this.modules.set(name, hosted);
@@ -10226,7 +10558,7 @@ var ModuleHost = class {
10226
10558
  status: "error",
10227
10559
  events: 0,
10228
10560
  detail: `manifest load failed: ${String(err.message || err)}`,
10229
- path: (0, import_node_path5.join)(PATHS.moduleDir, entry.name)
10561
+ path: (0, import_node_path6.join)(PATHS.moduleDir, entry.name)
10230
10562
  });
10231
10563
  }
10232
10564
  }
@@ -10265,17 +10597,17 @@ var ModuleHost = class {
10265
10597
  }
10266
10598
  }
10267
10599
  installedEntrypoint(modulePath) {
10268
- const packageJson = (0, import_node_path5.join)(modulePath, "package.json");
10600
+ const packageJson = (0, import_node_path6.join)(modulePath, "package.json");
10269
10601
  const candidates = [];
10270
- if ((0, import_node_fs10.existsSync)(packageJson)) {
10602
+ if ((0, import_node_fs11.existsSync)(packageJson)) {
10271
10603
  try {
10272
- const pkg = JSON.parse((0, import_node_fs10.readFileSync)(packageJson, "utf-8"));
10273
- if (pkg.main) candidates.push((0, import_node_path5.join)(modulePath, pkg.main));
10604
+ const pkg = JSON.parse((0, import_node_fs11.readFileSync)(packageJson, "utf-8"));
10605
+ if (pkg.main) candidates.push((0, import_node_path6.join)(modulePath, pkg.main));
10274
10606
  } catch {
10275
10607
  }
10276
10608
  }
10277
- candidates.push((0, import_node_path5.join)(modulePath, "dist", "index.js"), (0, import_node_path5.join)(modulePath, "index.js"));
10278
- return candidates.find((candidate) => (0, import_node_fs10.existsSync)(candidate)) || null;
10609
+ candidates.push((0, import_node_path6.join)(modulePath, "dist", "index.js"), (0, import_node_path6.join)(modulePath, "index.js"));
10610
+ return candidates.find((candidate) => (0, import_node_fs11.existsSync)(candidate)) || null;
10279
10611
  }
10280
10612
  isThreatCrushModule(value) {
10281
10613
  return Boolean(
@@ -10547,14 +10879,14 @@ function slackChannel(webhookUrl) {
10547
10879
  }
10548
10880
 
10549
10881
  // src/core/cli-config.ts
10550
- var import_node_fs11 = require("fs");
10551
- var import_node_path6 = require("path");
10882
+ var import_node_fs12 = require("fs");
10883
+ var import_node_path7 = require("path");
10552
10884
  var import_node_os2 = require("os");
10553
- var CLI_CONFIG_DIR = (0, import_node_path6.join)((0, import_node_os2.homedir)(), ".threatcrush");
10554
- var CLI_CONFIG_PATH = (0, import_node_path6.join)(CLI_CONFIG_DIR, "config.json");
10885
+ var CLI_CONFIG_DIR = (0, import_node_path7.join)((0, import_node_os2.homedir)(), ".threatcrush");
10886
+ var CLI_CONFIG_PATH = (0, import_node_path7.join)(CLI_CONFIG_DIR, "config.json");
10555
10887
  function readCliConfig() {
10556
10888
  try {
10557
- return JSON.parse((0, import_node_fs11.readFileSync)(CLI_CONFIG_PATH, "utf-8"));
10889
+ return JSON.parse((0, import_node_fs12.readFileSync)(CLI_CONFIG_PATH, "utf-8"));
10558
10890
  } catch {
10559
10891
  return {};
10560
10892
  }
@@ -10573,8 +10905,8 @@ function authHeaders() {
10573
10905
  }
10574
10906
 
10575
10907
  // src/commands/scan.ts
10576
- var import_node_fs15 = require("fs");
10577
- var import_node_path11 = require("path");
10908
+ var import_node_fs16 = require("fs");
10909
+ var import_node_path12 = require("path");
10578
10910
 
10579
10911
  // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
10580
10912
  var ANSI_BACKGROUND_OFFSET = 10;
@@ -11072,13 +11404,13 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
11072
11404
  var source_default = chalk;
11073
11405
 
11074
11406
  // src/core/version.ts
11075
- var import_node_fs12 = require("fs");
11076
- var import_node_path7 = require("path");
11407
+ var import_node_fs13 = require("fs");
11408
+ var import_node_path8 = require("path");
11077
11409
  var FALLBACK_VERSION = "0.0.0";
11078
11410
  function readPackageVersion() {
11079
11411
  try {
11080
11412
  const pkg = JSON.parse(
11081
- (0, import_node_fs12.readFileSync)((0, import_node_path7.join)(__dirname, "..", "package.json"), "utf-8")
11413
+ (0, import_node_fs13.readFileSync)((0, import_node_path8.join)(__dirname, "..", "package.json"), "utf-8")
11082
11414
  );
11083
11415
  return pkg.version || FALLBACK_VERSION;
11084
11416
  } catch {
@@ -14085,8 +14417,8 @@ function scanManifest(relativePath, filename, text) {
14085
14417
  }
14086
14418
 
14087
14419
  // ../../packages/scan/src/node/walk.ts
14088
- var import_node_fs13 = require("fs");
14089
- var import_node_path8 = require("path");
14420
+ var import_node_fs14 = require("fs");
14421
+ var import_node_path9 = require("path");
14090
14422
  function compileExcludes(patterns) {
14091
14423
  const matchers = patterns.map((p) => p.trim()).filter((p) => p.length > 0 && !p.startsWith("#")).map(compilePattern);
14092
14424
  if (matchers.length === 0) return () => false;
@@ -14157,7 +14489,7 @@ function matchPrefix(parts, segs) {
14157
14489
  }
14158
14490
  function readIgnoreFile(root) {
14159
14491
  try {
14160
- return (0, import_node_fs13.readFileSync)((0, import_node_path8.join)(root, ".threatcrushignore"), "utf-8").split("\n");
14492
+ return (0, import_node_fs14.readFileSync)((0, import_node_path9.join)(root, ".threatcrushignore"), "utf-8").split("\n");
14161
14493
  } catch {
14162
14494
  return [];
14163
14495
  }
@@ -14173,16 +14505,16 @@ function scanPath(targetPath, options = {}) {
14173
14505
  let excluded = 0;
14174
14506
  const rootIsDirectory = (() => {
14175
14507
  try {
14176
- return (0, import_node_fs13.statSync)(targetPath).isDirectory();
14508
+ return (0, import_node_fs14.statSync)(targetPath).isDirectory();
14177
14509
  } catch {
14178
14510
  return true;
14179
14511
  }
14180
14512
  })();
14181
- const walkRoot = rootIsDirectory ? targetPath : (0, import_node_path8.dirname)(targetPath);
14513
+ const walkRoot = rootIsDirectory ? targetPath : (0, import_node_path9.dirname)(targetPath);
14182
14514
  const isExcluded = compileExcludes([...options.exclude ?? [], ...readIgnoreFile(walkRoot)]);
14183
14515
  const scanFile = (fullPath, filename) => {
14184
14516
  const relativePath = toRelative(walkRoot, fullPath);
14185
- const extension = (0, import_node_path8.extname)(filename).toLowerCase();
14517
+ const extension = (0, import_node_path9.extname)(filename).toLowerCase();
14186
14518
  const isManifest = filename === "package.json" || filename === "requirements.txt";
14187
14519
  const scannable = SCAN_EXTENSIONS.has(extension) || filename.startsWith(".env");
14188
14520
  const mayDeclareInterpreter = !scannable && !isManifest && extension === "";
@@ -14194,26 +14526,26 @@ function scanPath(targetPath, options = {}) {
14194
14526
  let handle;
14195
14527
  let declared = null;
14196
14528
  try {
14197
- handle = (0, import_node_fs13.openSync)(fullPath, "r");
14529
+ handle = (0, import_node_fs14.openSync)(fullPath, "r");
14198
14530
  } catch {
14199
14531
  unreadable.push(relativePath);
14200
14532
  return;
14201
14533
  }
14202
14534
  try {
14203
- if ((0, import_node_fs13.fstatSync)(handle).size > maxFileBytes) return;
14535
+ if ((0, import_node_fs14.fstatSync)(handle).size > maxFileBytes) return;
14204
14536
  if (mayDeclareInterpreter) {
14205
14537
  const prefix = Buffer.alloc(128);
14206
- const read = (0, import_node_fs13.readSync)(handle, prefix, 0, prefix.length, 0);
14538
+ const read = (0, import_node_fs14.readSync)(handle, prefix, 0, prefix.length, 0);
14207
14539
  declared = languageOfShebang(prefix.subarray(0, read).toString("utf-8").split("\n", 1)[0] ?? "");
14208
14540
  if (!declared) return;
14209
14541
  }
14210
- text = (0, import_node_fs13.readFileSync)(handle, "utf-8");
14542
+ text = (0, import_node_fs14.readFileSync)(handle, "utf-8");
14211
14543
  } catch {
14212
14544
  unreadable.push(relativePath);
14213
14545
  return;
14214
14546
  } finally {
14215
14547
  try {
14216
- (0, import_node_fs13.closeSync)(handle);
14548
+ (0, import_node_fs14.closeSync)(handle);
14217
14549
  } catch {
14218
14550
  }
14219
14551
  }
@@ -14231,13 +14563,13 @@ function scanPath(targetPath, options = {}) {
14231
14563
  const walk = (currentPath) => {
14232
14564
  let entries;
14233
14565
  try {
14234
- entries = (0, import_node_fs13.readdirSync)(currentPath, { withFileTypes: true });
14566
+ entries = (0, import_node_fs14.readdirSync)(currentPath, { withFileTypes: true });
14235
14567
  } catch {
14236
14568
  unreadable.push(toRelative(walkRoot, currentPath));
14237
14569
  return;
14238
14570
  }
14239
14571
  for (const entry of entries) {
14240
- const fullPath = (0, import_node_path8.join)(currentPath, entry.name);
14572
+ const fullPath = (0, import_node_path9.join)(currentPath, entry.name);
14241
14573
  const relativePath = toRelative(walkRoot, fullPath);
14242
14574
  if (entry.isDirectory()) {
14243
14575
  if (SKIP_DIRS.has(entry.name)) continue;
@@ -14261,7 +14593,7 @@ function scanPath(targetPath, options = {}) {
14261
14593
  } else if (isExcluded(toRelative(walkRoot, targetPath))) {
14262
14594
  excluded += 1;
14263
14595
  } else {
14264
- scanFile(targetPath, (0, import_node_path8.basename)(targetPath));
14596
+ scanFile(targetPath, (0, import_node_path9.basename)(targetPath));
14265
14597
  }
14266
14598
  if (options.missingControls) findings.push(...controls.findings());
14267
14599
  const filtered = allowed ? findings.filter((f) => allowed.has(f.category)) : findings;
@@ -14293,22 +14625,22 @@ function recordSensitiveFile(filename, relativePath, sink, fileFindings) {
14293
14625
  }
14294
14626
  }
14295
14627
  function toRelative(base, target) {
14296
- const rel = (0, import_node_path8.relative)(base, target);
14297
- return (rel === "" ? target : rel).split(import_node_path8.sep).join("/");
14628
+ const rel = (0, import_node_path9.relative)(base, target);
14629
+ return (rel === "" ? target : rel).split(import_node_path9.sep).join("/");
14298
14630
  }
14299
14631
 
14300
14632
  // ../../packages/scan/src/node/dependencies.ts
14301
- var import_node_fs14 = require("fs");
14302
- var import_node_path9 = require("path");
14633
+ var import_node_fs15 = require("fs");
14634
+ var import_node_path10 = require("path");
14303
14635
  var MAX_DEPS_PER_LOCKFILE = 50;
14304
14636
  async function scanDependencies(targetPath) {
14305
14637
  const findings = [];
14306
14638
  for (const { file, ecosystem, parse } of LOCKFILES) {
14307
- const lockPath = (0, import_node_path9.join)(targetPath, file);
14308
- if (!(0, import_node_fs14.existsSync)(lockPath)) continue;
14639
+ const lockPath = (0, import_node_path10.join)(targetPath, file);
14640
+ if (!(0, import_node_fs15.existsSync)(lockPath)) continue;
14309
14641
  let deps;
14310
14642
  try {
14311
- deps = dedupe(parse((0, import_node_fs14.readFileSync)(lockPath, "utf-8")));
14643
+ deps = dedupe(parse((0, import_node_fs15.readFileSync)(lockPath, "utf-8")));
14312
14644
  } catch {
14313
14645
  continue;
14314
14646
  }
@@ -14523,16 +14855,16 @@ async function queryOsv(name, version, ecosystem) {
14523
14855
 
14524
14856
  // ../../packages/scan/src/node/sarif.ts
14525
14857
  var import_node_crypto3 = require("crypto");
14526
- var import_node_path10 = require("path");
14858
+ var import_node_path11 = require("path");
14527
14859
 
14528
14860
  // src/commands/scan.ts
14529
14861
  function readVersion() {
14530
14862
  for (const candidate of [
14531
- (0, import_node_path11.join)(__dirname, "..", "package.json"),
14532
- (0, import_node_path11.join)(__dirname, "..", "..", "package.json")
14863
+ (0, import_node_path12.join)(__dirname, "..", "package.json"),
14864
+ (0, import_node_path12.join)(__dirname, "..", "..", "package.json")
14533
14865
  ]) {
14534
14866
  try {
14535
- return JSON.parse((0, import_node_fs15.readFileSync)(candidate, "utf-8")).version ?? "0.0.0";
14867
+ return JSON.parse((0, import_node_fs16.readFileSync)(candidate, "utf-8")).version ?? "0.0.0";
14536
14868
  } catch {
14537
14869
  }
14538
14870
  }
@@ -15002,10 +15334,11 @@ var RuleEngine = class {
15002
15334
  };
15003
15335
 
15004
15336
  // src/daemon/rules/loader.ts
15005
- var import_node_fs16 = require("fs");
15006
- var import_node_path12 = require("path");
15337
+ var import_node_fs17 = require("fs");
15338
+ var import_node_path13 = require("path");
15007
15339
 
15008
15340
  // src/daemon/rules/default-rules.ts
15341
+ var AT_CRS_THRESHOLD = { field: "severity", operator: "regex", value: "^(high|critical)$" };
15009
15342
  var DEFAULT_RULES = [
15010
15343
  {
15011
15344
  id: "ssh-brute-force",
@@ -15026,8 +15359,7 @@ var DEFAULT_RULES = [
15026
15359
  tags: ["ssh", "brute-force", "credential-stuffing"],
15027
15360
  remediation: {
15028
15361
  action: "block",
15029
- ttl_seconds: 3600,
15030
- description: "Block source IP for 1 hour"
15362
+ description: "Block source IP"
15031
15363
  },
15032
15364
  enabled: true
15033
15365
  },
@@ -15075,7 +15407,6 @@ var DEFAULT_RULES = [
15075
15407
  tags: ["ssh", "root-access"],
15076
15408
  remediation: {
15077
15409
  action: "block",
15078
- ttl_seconds: 7200,
15079
15410
  description: "Block source IP attempting root login"
15080
15411
  },
15081
15412
  enabled: true
@@ -15099,7 +15430,6 @@ var DEFAULT_RULES = [
15099
15430
  tags: ["ssh", "enumeration", "reconnaissance"],
15100
15431
  remediation: {
15101
15432
  action: "block",
15102
- ttl_seconds: 3600,
15103
15433
  description: "Block source IP performing user enumeration"
15104
15434
  },
15105
15435
  enabled: true
@@ -15129,20 +15459,15 @@ var DEFAULT_RULES = [
15129
15459
  description: "HTTP request with SQL injection patterns",
15130
15460
  version: "1.0.0",
15131
15461
  category: "web",
15132
- severity: "critical",
15462
+ severity: "high",
15133
15463
  source_types: ["log-watcher", "web"],
15134
- match: {
15135
- field: "message",
15136
- operator: "contains",
15137
- value: "Attack detected [SQLI]"
15138
- },
15464
+ match: { field: "attack_type", operator: "equals", value: "sqli", and: [AT_CRS_THRESHOLD] },
15139
15465
  threshold: 1,
15140
15466
  window_seconds: 60,
15141
15467
  cooldown_seconds: 300,
15142
15468
  tags: ["web", "sqli", "injection"],
15143
15469
  remediation: {
15144
15470
  action: "block",
15145
- ttl_seconds: 3600,
15146
15471
  description: "Block source IP performing SQL injection"
15147
15472
  },
15148
15473
  enabled: true
@@ -15153,20 +15478,15 @@ var DEFAULT_RULES = [
15153
15478
  description: "HTTP request with path traversal patterns",
15154
15479
  version: "1.0.0",
15155
15480
  category: "web",
15156
- severity: "critical",
15481
+ severity: "high",
15157
15482
  source_types: ["log-watcher", "web"],
15158
- match: {
15159
- field: "message",
15160
- operator: "contains",
15161
- value: "Attack detected [PATH_TRAVERSAL]"
15162
- },
15483
+ match: { field: "attack_type", operator: "equals", value: "path_traversal", and: [AT_CRS_THRESHOLD] },
15163
15484
  threshold: 1,
15164
15485
  window_seconds: 60,
15165
15486
  cooldown_seconds: 300,
15166
15487
  tags: ["web", "path-traversal", "lfi"],
15167
15488
  remediation: {
15168
15489
  action: "block",
15169
- ttl_seconds: 3600,
15170
15490
  description: "Block source IP performing path traversal"
15171
15491
  },
15172
15492
  enabled: true
@@ -15179,22 +15499,39 @@ var DEFAULT_RULES = [
15179
15499
  category: "web",
15180
15500
  severity: "high",
15181
15501
  source_types: ["log-watcher", "web"],
15182
- match: {
15183
- field: "message",
15184
- operator: "regex",
15185
- value: "Attack detected \\[XSS\\]"
15186
- },
15502
+ match: { field: "attack_type", operator: "equals", value: "xss", and: [AT_CRS_THRESHOLD] },
15187
15503
  threshold: 1,
15188
15504
  window_seconds: 60,
15189
15505
  cooldown_seconds: 300,
15190
15506
  tags: ["web", "xss", "injection"],
15191
15507
  remediation: {
15192
15508
  action: "block",
15193
- ttl_seconds: 3600,
15194
15509
  description: "Block source IP performing XSS attack"
15195
15510
  },
15196
15511
  enabled: true
15197
15512
  },
15513
+ {
15514
+ // CRS 913100: the User-Agent names a security scanner or attack tool
15515
+ // (sqlmap, nikto, nuclei, …). One request is enough, like the rules above;
15516
+ // `web-scanner-detection` is the volume rule for scanners that hide theirs.
15517
+ id: "web-scanner-user-agent",
15518
+ title: "Attack Tool User-Agent Detected",
15519
+ description: "HTTP request from a known vulnerability scanner or attack tool",
15520
+ version: "1.0.0",
15521
+ category: "web",
15522
+ severity: "high",
15523
+ source_types: ["log-watcher", "web"],
15524
+ match: { field: "attack_type", operator: "equals", value: "scanner", and: [AT_CRS_THRESHOLD] },
15525
+ threshold: 1,
15526
+ window_seconds: 60,
15527
+ cooldown_seconds: 300,
15528
+ tags: ["web", "scanner", "reconnaissance"],
15529
+ remediation: {
15530
+ action: "block",
15531
+ description: "Block source IP running a known attack tool"
15532
+ },
15533
+ enabled: true
15534
+ },
15198
15535
  {
15199
15536
  id: "web-scanner-detection",
15200
15537
  title: "Web Vulnerability Scanner Detected",
@@ -15214,7 +15551,6 @@ var DEFAULT_RULES = [
15214
15551
  tags: ["web", "scanner", "reconnaissance"],
15215
15552
  remediation: {
15216
15553
  action: "block",
15217
- ttl_seconds: 1800,
15218
15554
  description: "Block automated scanner"
15219
15555
  },
15220
15556
  enabled: true
@@ -15304,7 +15640,6 @@ var DEFAULT_RULES = [
15304
15640
  tags: ["network", "port-scan", "reconnaissance"],
15305
15641
  remediation: {
15306
15642
  action: "block",
15307
- ttl_seconds: 3600,
15308
15643
  description: "Block port scanner"
15309
15644
  },
15310
15645
  enabled: true
@@ -15336,10 +15671,13 @@ var DEFAULT_RULES = [
15336
15671
  category: "web",
15337
15672
  severity: "high",
15338
15673
  source_types: ["log-watcher", "web"],
15674
+ // CRS files command injection under `rce`. There is no XXE type: an
15675
+ // access log never shows the request body an XXE payload lives in.
15339
15676
  match: {
15340
- field: "message",
15677
+ field: "attack_type",
15341
15678
  operator: "regex",
15342
- value: "Attack detected \\[(CMD_INJECTION|RCE|SSRF|XXE)\\]"
15679
+ value: "^(rce|ssrf|rfi|php_injection|ssti)$",
15680
+ and: [AT_CRS_THRESHOLD]
15343
15681
  },
15344
15682
  threshold: 1,
15345
15683
  window_seconds: 60,
@@ -15347,7 +15685,6 @@ var DEFAULT_RULES = [
15347
15685
  tags: ["web", "exploit", "probe"],
15348
15686
  remediation: {
15349
15687
  action: "block",
15350
- ttl_seconds: 7200,
15351
15688
  description: "Block source IP performing exploit probes"
15352
15689
  },
15353
15690
  enabled: true
@@ -15359,11 +15696,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
15359
15696
  function loadAllRules(customDir) {
15360
15697
  const rules = [...DEFAULT_RULES];
15361
15698
  const dir = customDir || RULES_DIR;
15362
- if ((0, import_node_fs16.existsSync)(dir)) {
15363
- const files = (0, import_node_fs16.readdirSync)(dir).filter((f) => f.endsWith(".json"));
15699
+ if ((0, import_node_fs17.existsSync)(dir)) {
15700
+ const files = (0, import_node_fs17.readdirSync)(dir).filter((f) => f.endsWith(".json"));
15364
15701
  for (const file of files) {
15365
15702
  try {
15366
- const raw = (0, import_node_fs16.readFileSync)((0, import_node_path12.join)(dir, file), "utf-8");
15703
+ const raw = (0, import_node_fs17.readFileSync)((0, import_node_path13.join)(dir, file), "utf-8");
15367
15704
  const parsed = JSON.parse(raw);
15368
15705
  const customRules = Array.isArray(parsed) ? parsed : [parsed];
15369
15706
  for (const rule of customRules) {
@@ -15371,6 +15708,13 @@ function loadAllRules(customDir) {
15371
15708
  console.warn(`[rules] skipping invalid rule in ${file}: missing required fields`);
15372
15709
  continue;
15373
15710
  }
15711
+ if (rule.remediation && typeof rule.remediation === "object" && "ttl_seconds" in rule.remediation) {
15712
+ console.warn(
15713
+ `[rules] ${rule.id} (${file}): remediation.ttl_seconds is ignored; ban length follows the escalation ladder, see auto-defence.md`
15714
+ );
15715
+ const { ttl_seconds: _ignored, ...remediation } = rule.remediation;
15716
+ rule.remediation = remediation;
15717
+ }
15374
15718
  const existingIdx = rules.findIndex((r) => r.id === rule.id);
15375
15719
  if (existingIdx >= 0) {
15376
15720
  rules[existingIdx] = { ...rules[existingIdx], ...rule };
@@ -15388,8 +15732,8 @@ function loadAllRules(customDir) {
15388
15732
 
15389
15733
  // src/daemon/firewall/adapters.ts
15390
15734
  var import_node_child_process4 = require("child_process");
15391
- var import_node_fs17 = require("fs");
15392
- var import_node_path13 = require("path");
15735
+ var import_node_fs18 = require("fs");
15736
+ var import_node_path14 = require("path");
15393
15737
  var import_node_net2 = require("net");
15394
15738
  function assertValidFirewallIp(ip) {
15395
15739
  if ((0, import_node_net2.isIP)(ip) !== 4) {
@@ -15402,9 +15746,9 @@ function assertBannableIp(ip) {
15402
15746
  }
15403
15747
  }
15404
15748
  function writeIfAbsent(path, contents) {
15405
- (0, import_node_fs17.mkdirSync)((0, import_node_path13.dirname)(path), { recursive: true });
15749
+ (0, import_node_fs18.mkdirSync)((0, import_node_path14.dirname)(path), { recursive: true });
15406
15750
  try {
15407
- (0, import_node_fs17.writeFileSync)(path, contents, { flag: "wx" });
15751
+ (0, import_node_fs18.writeFileSync)(path, contents, { flag: "wx" });
15408
15752
  } catch (err) {
15409
15753
  if (err.code !== "EEXIST") throw err;
15410
15754
  }
@@ -15659,7 +16003,7 @@ function detectFirewallAdapter(backend = "auto") {
15659
16003
  }
15660
16004
 
15661
16005
  // src/daemon/firewall/remediation.ts
15662
- var import_node_fs18 = require("fs");
16006
+ var import_node_fs19 = require("fs");
15663
16007
  var import_node_net4 = require("net");
15664
16008
 
15665
16009
  // src/daemon/firewall/protected.ts
@@ -16175,7 +16519,7 @@ var RemediationManager = class {
16175
16519
  }
16176
16520
  logLine(line) {
16177
16521
  try {
16178
- (0, import_node_fs18.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
16522
+ (0, import_node_fs19.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
16179
16523
  `);
16180
16524
  } catch {
16181
16525
  }
@@ -16255,7 +16599,7 @@ async function flushTelemetry(timeoutMs = 2e3) {
16255
16599
  // src/daemon/index.ts
16256
16600
  function readVersion2() {
16257
16601
  try {
16258
- const pkg = JSON.parse((0, import_node_fs19.readFileSync)((0, import_node_path14.join)(__dirname, "..", "package.json"), "utf-8"));
16602
+ const pkg = JSON.parse((0, import_node_fs20.readFileSync)((0, import_node_path15.join)(__dirname, "..", "package.json"), "utf-8"));
16259
16603
  return pkg.version || "0.0.0";
16260
16604
  } catch {
16261
16605
  return "0.0.0";
@@ -16263,7 +16607,7 @@ function readVersion2() {
16263
16607
  }
16264
16608
  function logLine(line) {
16265
16609
  try {
16266
- (0, import_node_fs19.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
16610
+ (0, import_node_fs20.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
16267
16611
  `);
16268
16612
  } catch {
16269
16613
  }
@@ -16291,7 +16635,7 @@ async function runDaemon() {
16291
16635
  } catch (err) {
16292
16636
  logLine(`[daemon] state db unavailable: ${err.message}`);
16293
16637
  }
16294
- const config = loadConfig((0, import_node_fs19.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
16638
+ const config = loadConfig((0, import_node_fs20.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
16295
16639
  configureAttackDetection(config.detection);
16296
16640
  bus.on("event", (event) => {
16297
16641
  logLine(`[event] ${event.severity} ${event.module} ${event.message}`);