@profullstack/threatcrush 0.18.0 → 0.18.1

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
@@ -62024,6 +62024,7 @@ function probeHost(configured) {
62024
62024
  platform: process.platform
62025
62025
  };
62026
62026
  }
62027
+ var BPFTRACE_ENV = { PATH: "/usr/sbin:/usr/bin:/sbin:/bin", LANG: "C" };
62027
62028
  var STDERR_TAIL = 2048;
62028
62029
  var HEALTHY_AFTER_MS = 3e4;
62029
62030
  var KILL_GRACE_MS = 3e3;
@@ -62134,7 +62135,7 @@ var BpftraceSource = class {
62134
62135
  child = this.spawnFn(this.opts.bpftracePath, bpftraceArgs({ network: this.opts.network, peers: this.opts.peers }), {
62135
62136
  stdio: ["ignore", "pipe", "pipe"],
62136
62137
  shell: false,
62137
- env: { PATH: "/usr/sbin:/usr/bin:/sbin:/bin", LANG: "C" }
62138
+ env: BPFTRACE_ENV
62138
62139
  });
62139
62140
  } catch (error2) {
62140
62141
  this.onExit(null, null, error2.message);
@@ -62386,6 +62387,9 @@ var EdrWatch = class {
62386
62387
  onFatal: (failure) => {
62387
62388
  this.bpftrace = null;
62388
62389
  this.opts.log(`[edr] ${failure}; falling back to auditd`);
62390
+ if (/Missing CAP_(BPF|PERFMON)/.test(failure)) {
62391
+ this.opts.log("[edr] the service unit does not grant CAP_BPF and CAP_PERFMON: re-run `threatcrush install-service` with [edr] enabled, then restart the daemon");
62392
+ }
62389
62393
  this.startAuditd(`eBPF failed: ${failure}`);
62390
62394
  },
62391
62395
  log: this.opts.log
@@ -67727,6 +67731,12 @@ function renderUnit(template, opts) {
67727
67731
  const extraCaps = (opts.extraCapabilities ?? []).filter((cap) => /^CAP_[A-Z_]+$/.test(cap));
67728
67732
  return template.replaceAll("{{EXTRA_CAPS}}", extraCaps.map((cap) => ` ${cap}`).join("")).replaceAll("{{BIN_PATH}} daemon", opts.exec).replaceAll("{{BIN_PATH}}", opts.binPath).replaceAll("{{CONFIG_DIR}}", opts.configDir).replaceAll("{{HISTORY_PATHS}}", (opts.historyPaths ?? []).map((path2) => `-${path2}`).join(" ")).replace(/ReadWritePaths=([^\n]*)/, (_line, paths) => `ReadWritePaths=${paths.split(/\s+/).filter(Boolean).join(" ")}`);
67729
67733
  }
67734
+ function unitExtraCapabilities(opts) {
67735
+ return [
67736
+ ...opts.containWriter ? ["CAP_SYS_PTRACE"] : [],
67737
+ ...opts.edrEbpf ? ["CAP_BPF", "CAP_PERFMON"] : []
67738
+ ];
67739
+ }
67730
67740
  function nodeVersionDir(path2) {
67731
67741
  const m = path2.match(
67732
67742
  /^(.*?\/(?:installs\/node(?:js)?|\.nvm\/versions\/node|node-versions|tools\/image\/node|n\/versions\/node)\/[^/]+)\//
@@ -67839,12 +67849,15 @@ async function installServiceCommand() {
67839
67849
  const commandHistoryEnabled = commandHistorySettings(loadConfig().command_history).enabled;
67840
67850
  const historyPaths = commandHistoryEnabled ? historyWritableHomes() : [];
67841
67851
  const containWriter = containWriterSettings(loadConfig().file_integrity).mode !== "off";
67842
- const extraCapabilities = containWriter ? ["CAP_SYS_PTRACE"] : [];
67852
+ const edr = edrSettings(loadConfig().edr);
67853
+ const edrEbpf = edr.enabled && edr.source !== "auditd";
67854
+ const extraCapabilities = unitExtraCapabilities({ containWriter, edrEbpf });
67843
67855
  const unit = renderUnit(resolveTemplate(), { exec, binPath, configDir, historyPaths, extraCapabilities });
67844
67856
  (0, import_node_fs73.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
67845
67857
  console.log(source_default.green(` \u2713 Installed unit file: ${UNIT_PATH}`));
67846
67858
  console.log(source_default.dim(` ExecStart=${exec}`));
67847
67859
  if (containWriter) console.log(source_default.dim(" CAP_SYS_PTRACE granted for [file_integrity] contain_writer (reads /proc/<pid>/fd)"));
67860
+ if (edrEbpf) console.log(source_default.dim(' CAP_BPF and CAP_PERFMON granted for [edr] source = "ebpf" (bpftrace loads a tracing program)'));
67848
67861
  const nodeDir = nodeVersionDir(nodePath);
67849
67862
  const pinnedTo = nodeVersionDir(binPath) ?? (isNodeScript && nodeDir && !nodeDir.endsWith("/latest") ? nodeDir : null);
67850
67863
  if (pinnedTo) {