@profullstack/threatcrush 0.13.35 → 0.13.37
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 +412 -119
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +637 -220
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -2022,10 +2022,10 @@ var require_toml = __commonJS({
|
|
|
2022
2022
|
});
|
|
2023
2023
|
|
|
2024
2024
|
// src/daemon/index.ts
|
|
2025
|
-
var
|
|
2026
|
-
var
|
|
2025
|
+
var import_node_fs29 = require("fs");
|
|
2026
|
+
var import_node_child_process11 = require("child_process");
|
|
2027
2027
|
var import_node_os5 = require("os");
|
|
2028
|
-
var
|
|
2028
|
+
var import_node_path22 = require("path");
|
|
2029
2029
|
var import_node_util = require("util");
|
|
2030
2030
|
|
|
2031
2031
|
// src/daemon/paths.ts
|
|
@@ -2674,7 +2674,7 @@ function admGid(readGroup = () => (0, import_node_fs4.readFileSync)("/etc/group"
|
|
|
2674
2674
|
}
|
|
2675
2675
|
|
|
2676
2676
|
// src/daemon/module-host.ts
|
|
2677
|
-
var
|
|
2677
|
+
var import_node_fs14 = require("fs");
|
|
2678
2678
|
var import_node_path7 = require("path");
|
|
2679
2679
|
var import_node_url = require("url");
|
|
2680
2680
|
var import_toml2 = __toESM(require_toml());
|
|
@@ -10149,17 +10149,18 @@ var NetworkMonitor = class {
|
|
|
10149
10149
|
};
|
|
10150
10150
|
|
|
10151
10151
|
// src/modules/dns-monitor/index.ts
|
|
10152
|
-
var
|
|
10152
|
+
var import_node_fs12 = require("fs");
|
|
10153
10153
|
var import_node_child_process4 = require("child_process");
|
|
10154
10154
|
var import_node_readline = require("readline");
|
|
10155
10155
|
|
|
10156
10156
|
// src/core/threat-feeds/index.ts
|
|
10157
|
-
var
|
|
10157
|
+
var import_node_fs11 = require("fs");
|
|
10158
10158
|
var import_node_path5 = require("path");
|
|
10159
10159
|
var import_node_net3 = require("net");
|
|
10160
10160
|
|
|
10161
10161
|
// src/daemon/firewall/protected.ts
|
|
10162
10162
|
var import_node_child_process3 = require("child_process");
|
|
10163
|
+
var import_node_fs10 = require("fs");
|
|
10163
10164
|
var import_node_net2 = require("net");
|
|
10164
10165
|
var DEFAULT_PROTECTED = [
|
|
10165
10166
|
"127.0.0.0/8",
|
|
@@ -10272,6 +10273,45 @@ function establishedSshPeers() {
|
|
|
10272
10273
|
}
|
|
10273
10274
|
return [...peers];
|
|
10274
10275
|
}
|
|
10276
|
+
function sshClientFromEnviron(environ) {
|
|
10277
|
+
for (const entry of environ.split("\0")) {
|
|
10278
|
+
const m = /^SSH_(?:CONNECTION|CLIENT)=(\S+)/.exec(entry);
|
|
10279
|
+
if (m && (0, import_node_net2.isIP)(m[1])) return m[1];
|
|
10280
|
+
}
|
|
10281
|
+
return null;
|
|
10282
|
+
}
|
|
10283
|
+
function moshClients(procDir = "/proc") {
|
|
10284
|
+
const found = /* @__PURE__ */ new Set();
|
|
10285
|
+
let pids = [];
|
|
10286
|
+
try {
|
|
10287
|
+
pids = (0, import_node_fs10.readdirSync)(procDir).filter((p) => /^\d+$/.test(p));
|
|
10288
|
+
} catch {
|
|
10289
|
+
return [];
|
|
10290
|
+
}
|
|
10291
|
+
for (const pid of pids) {
|
|
10292
|
+
try {
|
|
10293
|
+
if ((0, import_node_fs10.readFileSync)(`${procDir}/${pid}/comm`, "utf-8").trim() !== "mosh-server") continue;
|
|
10294
|
+
const ip = sshClientFromEnviron((0, import_node_fs10.readFileSync)(`${procDir}/${pid}/environ`, "latin1"));
|
|
10295
|
+
if (ip) found.add(ip);
|
|
10296
|
+
} catch {
|
|
10297
|
+
}
|
|
10298
|
+
}
|
|
10299
|
+
return [...found];
|
|
10300
|
+
}
|
|
10301
|
+
function parseKeyLogins(text, skip = () => false) {
|
|
10302
|
+
const out = /* @__PURE__ */ new Map();
|
|
10303
|
+
for (const line of text.split("\n")) {
|
|
10304
|
+
const m = /^(\d+(?:\.\d+)?)\s.*Accepted publickey for \S+ from (\S+) port \d+ [^\s:]+(?:: \S+ (SHA256:\S+))?/.exec(line);
|
|
10305
|
+
if (!m || !(0, import_node_net2.isIP)(m[2])) continue;
|
|
10306
|
+
if (m[3] && skip(m[3])) continue;
|
|
10307
|
+
const at = Math.round(Number(m[1]) * 1e3);
|
|
10308
|
+
if (at > (out.get(m[2]) ?? 0)) out.set(m[2], at);
|
|
10309
|
+
}
|
|
10310
|
+
return out;
|
|
10311
|
+
}
|
|
10312
|
+
function isAutomationKeyComment(comment) {
|
|
10313
|
+
return /github-actions|gitlab|jenkins|buildkite|circleci|drone|\bci\b|runner|deploy|backup|automation|\bbot\b/i.test(comment);
|
|
10314
|
+
}
|
|
10275
10315
|
function defaultGateways() {
|
|
10276
10316
|
const found = /* @__PURE__ */ new Set();
|
|
10277
10317
|
for (const args of [["-4", "route", "show", "default"], ["-6", "route", "show", "default"]]) {
|
|
@@ -10457,17 +10497,38 @@ async function fetchFeeds(settings, fetchImpl = fetch) {
|
|
|
10457
10497
|
}
|
|
10458
10498
|
function readFeedCache(path) {
|
|
10459
10499
|
try {
|
|
10460
|
-
const set = JSON.parse((0,
|
|
10500
|
+
const set = JSON.parse((0, import_node_fs11.readFileSync)(path, "utf-8"));
|
|
10461
10501
|
return set && typeof set.ips === "object" && typeof set.domains === "object" ? set : null;
|
|
10462
10502
|
} catch {
|
|
10463
10503
|
return null;
|
|
10464
10504
|
}
|
|
10465
10505
|
}
|
|
10466
10506
|
function writeFeedCache(path, set) {
|
|
10467
|
-
(0,
|
|
10507
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path5.dirname)(path), { recursive: true });
|
|
10468
10508
|
const tmp = `${path}.tmp`;
|
|
10469
|
-
(0,
|
|
10470
|
-
(0,
|
|
10509
|
+
(0, import_node_fs11.writeFileSync)(tmp, JSON.stringify(set));
|
|
10510
|
+
(0, import_node_fs11.renameSync)(tmp, path);
|
|
10511
|
+
}
|
|
10512
|
+
var RESOLVER_FILES = {
|
|
10513
|
+
hosts: "blocked-domains.hosts",
|
|
10514
|
+
unbound: "blocked-domains.unbound.conf"
|
|
10515
|
+
};
|
|
10516
|
+
var RESOLVER_HOOKS = {
|
|
10517
|
+
dnsmasq: "/etc/dnsmasq.d/threatcrush.conf",
|
|
10518
|
+
unbound: "/etc/unbound/unbound.conf.d/threatcrush.conf"
|
|
10519
|
+
};
|
|
10520
|
+
var GENERATED = "# Written by threatcrushd from abuse.ch feeds; rewritten every refresh. Do not edit.";
|
|
10521
|
+
function hostsBlocklist(domains) {
|
|
10522
|
+
const lines = [GENERATED];
|
|
10523
|
+
for (const d of domains) lines.push(`0.0.0.0 ${d}`, `:: ${d}`);
|
|
10524
|
+
return `${lines.join("\n")}
|
|
10525
|
+
`;
|
|
10526
|
+
}
|
|
10527
|
+
function unboundBlocklist(domains) {
|
|
10528
|
+
const lines = [GENERATED, "server:"];
|
|
10529
|
+
for (const d of domains) lines.push(` local-zone: "${d}." always_nxdomain`);
|
|
10530
|
+
return `${lines.join("\n")}
|
|
10531
|
+
`;
|
|
10471
10532
|
}
|
|
10472
10533
|
var active = null;
|
|
10473
10534
|
function setActiveFeeds(set) {
|
|
@@ -10571,9 +10632,9 @@ var DnsMonitor = class {
|
|
|
10571
10632
|
}
|
|
10572
10633
|
start() {
|
|
10573
10634
|
const sources = [...DNS_LOG_SOURCES, ...this.extraPaths].filter((p) => {
|
|
10574
|
-
if (!(0,
|
|
10635
|
+
if (!(0, import_node_fs12.existsSync)(p)) return false;
|
|
10575
10636
|
try {
|
|
10576
|
-
(0,
|
|
10637
|
+
(0, import_node_fs12.accessSync)(p, import_node_fs12.constants.R_OK);
|
|
10577
10638
|
return true;
|
|
10578
10639
|
} catch {
|
|
10579
10640
|
return false;
|
|
@@ -10817,7 +10878,7 @@ var DnsMonitor = class {
|
|
|
10817
10878
|
};
|
|
10818
10879
|
|
|
10819
10880
|
// src/core/config.ts
|
|
10820
|
-
var
|
|
10881
|
+
var import_node_fs13 = require("fs");
|
|
10821
10882
|
var import_node_path6 = require("path");
|
|
10822
10883
|
var import_toml = __toESM(require_toml());
|
|
10823
10884
|
var DEFAULT_CONFIG_PATH = "/etc/threatcrush/threatcrushd.conf";
|
|
@@ -10844,11 +10905,11 @@ var DEFAULT_CONFIG = {
|
|
|
10844
10905
|
};
|
|
10845
10906
|
function loadConfig(configPath) {
|
|
10846
10907
|
const path = configPath || DEFAULT_CONFIG_PATH;
|
|
10847
|
-
if (!(0,
|
|
10908
|
+
if (!(0, import_node_fs13.existsSync)(path)) {
|
|
10848
10909
|
return { ...DEFAULT_CONFIG };
|
|
10849
10910
|
}
|
|
10850
10911
|
try {
|
|
10851
|
-
const raw = (0,
|
|
10912
|
+
const raw = (0, import_node_fs13.readFileSync)(path, "utf-8");
|
|
10852
10913
|
const parsed = import_toml.default.parse(raw);
|
|
10853
10914
|
return {
|
|
10854
10915
|
daemon: { ...DEFAULT_CONFIG.daemon, ...parsed.daemon },
|
|
@@ -10872,13 +10933,13 @@ function loadConfig(configPath) {
|
|
|
10872
10933
|
function loadModuleConfigs(confDir) {
|
|
10873
10934
|
const dir = confDir || DEFAULT_CONFDIR;
|
|
10874
10935
|
const configs = /* @__PURE__ */ new Map();
|
|
10875
|
-
if (!(0,
|
|
10936
|
+
if (!(0, import_node_fs13.existsSync)(dir)) {
|
|
10876
10937
|
return configs;
|
|
10877
10938
|
}
|
|
10878
|
-
const files = (0,
|
|
10939
|
+
const files = (0, import_node_fs13.readdirSync)(dir).filter((f) => f.endsWith(".conf"));
|
|
10879
10940
|
for (const file of files) {
|
|
10880
10941
|
try {
|
|
10881
|
-
const raw = (0,
|
|
10942
|
+
const raw = (0, import_node_fs13.readFileSync)((0, import_node_path6.join)(dir, file), "utf-8");
|
|
10882
10943
|
const parsed = import_toml.default.parse(raw);
|
|
10883
10944
|
for (const [name, config] of Object.entries(parsed)) {
|
|
10884
10945
|
configs.set(name, config);
|
|
@@ -11012,15 +11073,15 @@ var ModuleHost = class {
|
|
|
11012
11073
|
}
|
|
11013
11074
|
}
|
|
11014
11075
|
async discoverAndStartInstalled() {
|
|
11015
|
-
if (!(0,
|
|
11076
|
+
if (!(0, import_node_fs14.existsSync)(PATHS.moduleDir)) return;
|
|
11016
11077
|
const configs = loadModuleConfigs(PATHS.confD);
|
|
11017
|
-
const entries = (0,
|
|
11078
|
+
const entries = (0, import_node_fs14.readdirSync)(PATHS.moduleDir, { withFileTypes: true });
|
|
11018
11079
|
for (const entry of entries) {
|
|
11019
11080
|
if (!entry.isDirectory()) continue;
|
|
11020
11081
|
const manifestPath = (0, import_node_path7.join)(PATHS.moduleDir, entry.name, "mod.toml");
|
|
11021
|
-
if (!(0,
|
|
11082
|
+
if (!(0, import_node_fs14.existsSync)(manifestPath)) continue;
|
|
11022
11083
|
try {
|
|
11023
|
-
const manifest = import_toml2.default.parse((0,
|
|
11084
|
+
const manifest = import_toml2.default.parse((0, import_node_fs14.readFileSync)(manifestPath, "utf-8"));
|
|
11024
11085
|
const name = manifest.module?.name || entry.name;
|
|
11025
11086
|
const defaults = manifest.module?.config?.defaults || {};
|
|
11026
11087
|
const config = {
|
|
@@ -11090,15 +11151,15 @@ var ModuleHost = class {
|
|
|
11090
11151
|
installedEntrypoint(modulePath) {
|
|
11091
11152
|
const packageJson = (0, import_node_path7.join)(modulePath, "package.json");
|
|
11092
11153
|
const candidates = [];
|
|
11093
|
-
if ((0,
|
|
11154
|
+
if ((0, import_node_fs14.existsSync)(packageJson)) {
|
|
11094
11155
|
try {
|
|
11095
|
-
const pkg = JSON.parse((0,
|
|
11156
|
+
const pkg = JSON.parse((0, import_node_fs14.readFileSync)(packageJson, "utf-8"));
|
|
11096
11157
|
if (pkg.main) candidates.push((0, import_node_path7.join)(modulePath, pkg.main));
|
|
11097
11158
|
} catch {
|
|
11098
11159
|
}
|
|
11099
11160
|
}
|
|
11100
11161
|
candidates.push((0, import_node_path7.join)(modulePath, "dist", "index.js"), (0, import_node_path7.join)(modulePath, "index.js"));
|
|
11101
|
-
return candidates.find((candidate) => (0,
|
|
11162
|
+
return candidates.find((candidate) => (0, import_node_fs14.existsSync)(candidate)) || null;
|
|
11102
11163
|
}
|
|
11103
11164
|
isThreatCrushModule(value) {
|
|
11104
11165
|
return Boolean(
|
|
@@ -11370,7 +11431,7 @@ function slackChannel(webhookUrl) {
|
|
|
11370
11431
|
}
|
|
11371
11432
|
|
|
11372
11433
|
// src/core/cli-config.ts
|
|
11373
|
-
var
|
|
11434
|
+
var import_node_fs15 = require("fs");
|
|
11374
11435
|
var import_node_path8 = require("path");
|
|
11375
11436
|
var import_node_os2 = require("os");
|
|
11376
11437
|
var CLI_CONFIG_DIR = (0, import_node_path8.join)((0, import_node_os2.homedir)(), ".threatcrush");
|
|
@@ -11380,16 +11441,16 @@ function apiUrl() {
|
|
|
11380
11441
|
}
|
|
11381
11442
|
function readCliConfig() {
|
|
11382
11443
|
try {
|
|
11383
|
-
return JSON.parse((0,
|
|
11444
|
+
return JSON.parse((0, import_node_fs15.readFileSync)(CLI_CONFIG_PATH, "utf-8"));
|
|
11384
11445
|
} catch {
|
|
11385
11446
|
return {};
|
|
11386
11447
|
}
|
|
11387
11448
|
}
|
|
11388
11449
|
function writeCliConfig(config) {
|
|
11389
|
-
if (!(0,
|
|
11390
|
-
(0,
|
|
11450
|
+
if (!(0, import_node_fs15.existsSync)(CLI_CONFIG_DIR)) (0, import_node_fs15.mkdirSync)(CLI_CONFIG_DIR, { recursive: true });
|
|
11451
|
+
(0, import_node_fs15.writeFileSync)(CLI_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
11391
11452
|
try {
|
|
11392
|
-
(0,
|
|
11453
|
+
(0, import_node_fs15.chmodSync)(CLI_CONFIG_PATH, 384);
|
|
11393
11454
|
} catch {
|
|
11394
11455
|
}
|
|
11395
11456
|
}
|
|
@@ -11465,7 +11526,7 @@ async function cloudFetch(path, init = {}) {
|
|
|
11465
11526
|
}
|
|
11466
11527
|
|
|
11467
11528
|
// src/commands/scan.ts
|
|
11468
|
-
var
|
|
11529
|
+
var import_node_fs19 = require("fs");
|
|
11469
11530
|
var import_node_path13 = require("path");
|
|
11470
11531
|
|
|
11471
11532
|
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
@@ -11964,13 +12025,13 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
|
11964
12025
|
var source_default = chalk;
|
|
11965
12026
|
|
|
11966
12027
|
// src/core/version.ts
|
|
11967
|
-
var
|
|
12028
|
+
var import_node_fs16 = require("fs");
|
|
11968
12029
|
var import_node_path9 = require("path");
|
|
11969
12030
|
var FALLBACK_VERSION = "0.0.0";
|
|
11970
12031
|
function readPackageVersion() {
|
|
11971
12032
|
try {
|
|
11972
12033
|
const pkg = JSON.parse(
|
|
11973
|
-
(0,
|
|
12034
|
+
(0, import_node_fs16.readFileSync)((0, import_node_path9.join)(__dirname, "..", "package.json"), "utf-8")
|
|
11974
12035
|
);
|
|
11975
12036
|
return pkg.version || FALLBACK_VERSION;
|
|
11976
12037
|
} catch {
|
|
@@ -15000,7 +15061,7 @@ function scanManifest(relativePath, filename, text) {
|
|
|
15000
15061
|
}
|
|
15001
15062
|
|
|
15002
15063
|
// ../../packages/scan/src/node/walk.ts
|
|
15003
|
-
var
|
|
15064
|
+
var import_node_fs17 = require("fs");
|
|
15004
15065
|
var import_node_path10 = require("path");
|
|
15005
15066
|
function compileExcludes(patterns) {
|
|
15006
15067
|
const matchers = patterns.map((p) => p.trim()).filter((p) => p.length > 0 && !p.startsWith("#")).map(compilePattern);
|
|
@@ -15072,7 +15133,7 @@ function matchPrefix(parts, segs) {
|
|
|
15072
15133
|
}
|
|
15073
15134
|
function readIgnoreFile(root) {
|
|
15074
15135
|
try {
|
|
15075
|
-
return (0,
|
|
15136
|
+
return (0, import_node_fs17.readFileSync)((0, import_node_path10.join)(root, ".threatcrushignore"), "utf-8").split("\n");
|
|
15076
15137
|
} catch {
|
|
15077
15138
|
return [];
|
|
15078
15139
|
}
|
|
@@ -15088,7 +15149,7 @@ function scanPath(targetPath, options = {}) {
|
|
|
15088
15149
|
let excluded = 0;
|
|
15089
15150
|
const rootIsDirectory = (() => {
|
|
15090
15151
|
try {
|
|
15091
|
-
return (0,
|
|
15152
|
+
return (0, import_node_fs17.statSync)(targetPath).isDirectory();
|
|
15092
15153
|
} catch {
|
|
15093
15154
|
return true;
|
|
15094
15155
|
}
|
|
@@ -15109,26 +15170,26 @@ function scanPath(targetPath, options = {}) {
|
|
|
15109
15170
|
let handle;
|
|
15110
15171
|
let declared = null;
|
|
15111
15172
|
try {
|
|
15112
|
-
handle = (0,
|
|
15173
|
+
handle = (0, import_node_fs17.openSync)(fullPath, "r");
|
|
15113
15174
|
} catch {
|
|
15114
15175
|
unreadable.push(relativePath);
|
|
15115
15176
|
return;
|
|
15116
15177
|
}
|
|
15117
15178
|
try {
|
|
15118
|
-
if ((0,
|
|
15179
|
+
if ((0, import_node_fs17.fstatSync)(handle).size > maxFileBytes) return;
|
|
15119
15180
|
if (mayDeclareInterpreter) {
|
|
15120
15181
|
const prefix = Buffer.alloc(128);
|
|
15121
|
-
const read = (0,
|
|
15182
|
+
const read = (0, import_node_fs17.readSync)(handle, prefix, 0, prefix.length, 0);
|
|
15122
15183
|
declared = languageOfShebang(prefix.subarray(0, read).toString("utf-8").split("\n", 1)[0] ?? "");
|
|
15123
15184
|
if (!declared) return;
|
|
15124
15185
|
}
|
|
15125
|
-
text = (0,
|
|
15186
|
+
text = (0, import_node_fs17.readFileSync)(handle, "utf-8");
|
|
15126
15187
|
} catch {
|
|
15127
15188
|
unreadable.push(relativePath);
|
|
15128
15189
|
return;
|
|
15129
15190
|
} finally {
|
|
15130
15191
|
try {
|
|
15131
|
-
(0,
|
|
15192
|
+
(0, import_node_fs17.closeSync)(handle);
|
|
15132
15193
|
} catch {
|
|
15133
15194
|
}
|
|
15134
15195
|
}
|
|
@@ -15146,7 +15207,7 @@ function scanPath(targetPath, options = {}) {
|
|
|
15146
15207
|
const walk = (currentPath) => {
|
|
15147
15208
|
let entries;
|
|
15148
15209
|
try {
|
|
15149
|
-
entries = (0,
|
|
15210
|
+
entries = (0, import_node_fs17.readdirSync)(currentPath, { withFileTypes: true });
|
|
15150
15211
|
} catch {
|
|
15151
15212
|
unreadable.push(toRelative(walkRoot, currentPath));
|
|
15152
15213
|
return;
|
|
@@ -15213,17 +15274,17 @@ function toRelative(base, target) {
|
|
|
15213
15274
|
}
|
|
15214
15275
|
|
|
15215
15276
|
// ../../packages/scan/src/node/dependencies.ts
|
|
15216
|
-
var
|
|
15277
|
+
var import_node_fs18 = require("fs");
|
|
15217
15278
|
var import_node_path11 = require("path");
|
|
15218
15279
|
var MAX_DEPS_PER_LOCKFILE = 50;
|
|
15219
15280
|
async function scanDependencies(targetPath) {
|
|
15220
15281
|
const findings = [];
|
|
15221
15282
|
for (const { file, ecosystem, parse } of LOCKFILES) {
|
|
15222
15283
|
const lockPath = (0, import_node_path11.join)(targetPath, file);
|
|
15223
|
-
if (!(0,
|
|
15284
|
+
if (!(0, import_node_fs18.existsSync)(lockPath)) continue;
|
|
15224
15285
|
let deps;
|
|
15225
15286
|
try {
|
|
15226
|
-
deps = dedupe(parse((0,
|
|
15287
|
+
deps = dedupe(parse((0, import_node_fs18.readFileSync)(lockPath, "utf-8")));
|
|
15227
15288
|
} catch {
|
|
15228
15289
|
continue;
|
|
15229
15290
|
}
|
|
@@ -15447,7 +15508,7 @@ function readVersion() {
|
|
|
15447
15508
|
(0, import_node_path13.join)(__dirname, "..", "..", "package.json")
|
|
15448
15509
|
]) {
|
|
15449
15510
|
try {
|
|
15450
|
-
return JSON.parse((0,
|
|
15511
|
+
return JSON.parse((0, import_node_fs19.readFileSync)(candidate, "utf-8")).version ?? "0.0.0";
|
|
15451
15512
|
} catch {
|
|
15452
15513
|
}
|
|
15453
15514
|
}
|
|
@@ -15891,7 +15952,7 @@ function findingEvents(serverId, results, observedAt = /* @__PURE__ */ new Date(
|
|
|
15891
15952
|
}
|
|
15892
15953
|
|
|
15893
15954
|
// src/daemon/workers/cloud-spool.ts
|
|
15894
|
-
var
|
|
15955
|
+
var import_node_fs20 = require("fs");
|
|
15895
15956
|
var import_promises = require("fs/promises");
|
|
15896
15957
|
var import_node_path14 = require("path");
|
|
15897
15958
|
var DEFAULT_SPOOL_LIMITS = { maxEvents: 1e4, maxBytes: 20 * 1024 * 1024 };
|
|
@@ -15900,7 +15961,7 @@ var CloudSpool = class {
|
|
|
15900
15961
|
this.path = path;
|
|
15901
15962
|
this.limits = limits;
|
|
15902
15963
|
try {
|
|
15903
|
-
(0,
|
|
15964
|
+
(0, import_node_fs20.mkdirSync)((0, import_node_path14.dirname)(path), { recursive: true });
|
|
15904
15965
|
} catch {
|
|
15905
15966
|
}
|
|
15906
15967
|
this.load();
|
|
@@ -15969,7 +16030,7 @@ var CloudSpool = class {
|
|
|
15969
16030
|
load() {
|
|
15970
16031
|
let raw;
|
|
15971
16032
|
try {
|
|
15972
|
-
raw = (0,
|
|
16033
|
+
raw = (0, import_node_fs20.readFileSync)(this.path, "utf-8");
|
|
15973
16034
|
} catch {
|
|
15974
16035
|
return;
|
|
15975
16036
|
}
|
|
@@ -16426,7 +16487,7 @@ var RemediationConsumer = class {
|
|
|
16426
16487
|
|
|
16427
16488
|
// src/daemon/workers/auto-update.ts
|
|
16428
16489
|
var import_node_child_process5 = require("child_process");
|
|
16429
|
-
var
|
|
16490
|
+
var import_node_fs21 = require("fs");
|
|
16430
16491
|
var import_node_path15 = require("path");
|
|
16431
16492
|
var PKG_NAME = "@profullstack/threatcrush";
|
|
16432
16493
|
var REGISTRY = `https://registry.npmjs.org/${PKG_NAME}`;
|
|
@@ -16501,10 +16562,10 @@ function installPlan(opts) {
|
|
|
16501
16562
|
}
|
|
16502
16563
|
function ownerOf(path, passwd = "/etc/passwd") {
|
|
16503
16564
|
try {
|
|
16504
|
-
const st = (0,
|
|
16565
|
+
const st = (0, import_node_fs21.statSync)(path);
|
|
16505
16566
|
let home = st.uid === 0 ? "/root" : "";
|
|
16506
16567
|
try {
|
|
16507
|
-
for (const line of (0,
|
|
16568
|
+
for (const line of (0, import_node_fs21.readFileSync)(passwd, "utf8").split("\n")) {
|
|
16508
16569
|
const f = line.split(":");
|
|
16509
16570
|
if (Number(f[2]) === st.uid && f[5]) home = f[5];
|
|
16510
16571
|
}
|
|
@@ -16609,7 +16670,7 @@ var AutoUpdate = class {
|
|
|
16609
16670
|
uid: process.getuid?.() ?? -1,
|
|
16610
16671
|
owner: ownerOf(this.opts.pkgRoot),
|
|
16611
16672
|
underSystemd: this.opts.underSystemd ?? Boolean(process.env.INVOCATION_ID),
|
|
16612
|
-
npmExists:
|
|
16673
|
+
npmExists: import_node_fs21.existsSync
|
|
16613
16674
|
});
|
|
16614
16675
|
if (plan.kind === "unsupported") return this.note(`${target} is available but cannot self-install: ${plan.reason}`);
|
|
16615
16676
|
this.recordAttempt(target);
|
|
@@ -16644,7 +16705,7 @@ var AutoUpdate = class {
|
|
|
16644
16705
|
}
|
|
16645
16706
|
lastAttempt() {
|
|
16646
16707
|
try {
|
|
16647
|
-
const v = JSON.parse((0,
|
|
16708
|
+
const v = JSON.parse((0, import_node_fs21.readFileSync)(this.opts.statePath, "utf8"));
|
|
16648
16709
|
return v.version && typeof v.at === "number" ? { version: v.version, at: v.at } : null;
|
|
16649
16710
|
} catch {
|
|
16650
16711
|
return null;
|
|
@@ -16652,7 +16713,7 @@ var AutoUpdate = class {
|
|
|
16652
16713
|
}
|
|
16653
16714
|
recordAttempt(version) {
|
|
16654
16715
|
try {
|
|
16655
|
-
(0,
|
|
16716
|
+
(0, import_node_fs21.writeFileSync)(this.opts.statePath, JSON.stringify({ version, at: this.now() }));
|
|
16656
16717
|
} catch (err) {
|
|
16657
16718
|
this.opts.log(`[update] could not record attempt: ${err.message}`);
|
|
16658
16719
|
}
|
|
@@ -16661,6 +16722,8 @@ var AutoUpdate = class {
|
|
|
16661
16722
|
|
|
16662
16723
|
// src/daemon/workers/threat-feeds.ts
|
|
16663
16724
|
var import_node_child_process6 = require("child_process");
|
|
16725
|
+
var import_node_fs22 = require("fs");
|
|
16726
|
+
var import_node_path16 = require("path");
|
|
16664
16727
|
var import_node_net7 = require("net");
|
|
16665
16728
|
var EGRESS_TABLE = "threatcrush_egress";
|
|
16666
16729
|
var DEFAULT_REFRESH_MS = 36e5;
|
|
@@ -16671,6 +16734,7 @@ function threatFeedSettings(section) {
|
|
|
16671
16734
|
return {
|
|
16672
16735
|
enabled: section?.enabled !== false,
|
|
16673
16736
|
block: section?.block === true,
|
|
16737
|
+
blockDomains: section?.block_domains === true,
|
|
16674
16738
|
// abuse.ch asks for no more than one fetch per 5 minutes; hourly is plenty.
|
|
16675
16739
|
refreshMs: refresh ? Math.max(900, refresh) * 1e3 : DEFAULT_REFRESH_MS,
|
|
16676
16740
|
minConfidence: typeof section?.min_confidence === "number" ? section.min_confidence : 75,
|
|
@@ -16750,6 +16814,8 @@ var ThreatFeeds = class {
|
|
|
16750
16814
|
set = null;
|
|
16751
16815
|
alerted = /* @__PURE__ */ new Map();
|
|
16752
16816
|
blocking = false;
|
|
16817
|
+
/** Resolver blocklist content last written, by file name (see writeResolverFiles). */
|
|
16818
|
+
resolverWritten = /* @__PURE__ */ new Map();
|
|
16753
16819
|
run;
|
|
16754
16820
|
now;
|
|
16755
16821
|
get wantsBlock() {
|
|
@@ -16811,10 +16877,55 @@ var ThreatFeeds = class {
|
|
|
16811
16877
|
this.blocking = ok;
|
|
16812
16878
|
mode = ok ? "blocking egress" : "detecting (nft load failed)";
|
|
16813
16879
|
}
|
|
16814
|
-
const detail = `${ips.length} IPs, ${domains} domains, ${mode}`;
|
|
16880
|
+
const detail = `${ips.length} IPs, ${domains} domains, ${mode}${this.writeResolverFiles(set)}`;
|
|
16815
16881
|
this.opts.log(`[threat-feeds] ${from === "cache" ? "loaded cached" : "refreshed"} list: ${detail} (${set.skipped_shared} shared/protected entries skipped)`);
|
|
16816
16882
|
this.opts.bus.announceModule("threat-feeds", "running", detail);
|
|
16817
16883
|
}
|
|
16884
|
+
/** Whether listed domains are refused at the resolver: opted in and enforcing. */
|
|
16885
|
+
get wantsDomainBlock() {
|
|
16886
|
+
return this.opts.settings.blockDomains && this.opts.enforcing;
|
|
16887
|
+
}
|
|
16888
|
+
/**
|
|
16889
|
+
* Rewrite the resolver blocklists in the state dir and reload any resolver
|
|
16890
|
+
* whose hook is installed — only when the content changed, so an hourly
|
|
16891
|
+
* refresh with nothing new costs no reload. With domain blocking off the
|
|
16892
|
+
* files are emptied, so an installed hook blocks nothing and the config
|
|
16893
|
+
* stays the one switch. Returns a status suffix for the log line.
|
|
16894
|
+
*/
|
|
16895
|
+
writeResolverFiles(set) {
|
|
16896
|
+
const domains = this.wantsDomainBlock ? Object.keys(set.domains).sort() : [];
|
|
16897
|
+
const dir = this.opts.resolverDir ?? (0, import_node_path16.dirname)(this.opts.cachePath);
|
|
16898
|
+
const hooks = this.opts.resolverHooks ?? RESOLVER_HOOKS;
|
|
16899
|
+
const write = (name, content) => {
|
|
16900
|
+
const path = (0, import_node_path16.join)(dir, name);
|
|
16901
|
+
if (this.resolverWritten.get(name) === content) return false;
|
|
16902
|
+
try {
|
|
16903
|
+
(0, import_node_fs22.writeFileSync)(`${path}.tmp`, content);
|
|
16904
|
+
(0, import_node_fs22.renameSync)(`${path}.tmp`, path);
|
|
16905
|
+
this.resolverWritten.set(name, content);
|
|
16906
|
+
return true;
|
|
16907
|
+
} catch (err) {
|
|
16908
|
+
this.opts.log(`[threat-feeds] could not write ${path}: ${err.message}`);
|
|
16909
|
+
return false;
|
|
16910
|
+
}
|
|
16911
|
+
};
|
|
16912
|
+
const hostsChanged = write(RESOLVER_FILES.hosts, hostsBlocklist(domains));
|
|
16913
|
+
const unboundChanged = write(RESOLVER_FILES.unbound, unboundBlocklist(domains));
|
|
16914
|
+
const via = [];
|
|
16915
|
+
if ((0, import_node_fs22.existsSync)(hooks.dnsmasq)) {
|
|
16916
|
+
via.push("dnsmasq");
|
|
16917
|
+
if (hostsChanged) this.run("systemctl", ["kill", "-s", "HUP", "dnsmasq.service"]);
|
|
16918
|
+
}
|
|
16919
|
+
if ((0, import_node_fs22.existsSync)(hooks.unbound)) {
|
|
16920
|
+
via.push("unbound");
|
|
16921
|
+
if (unboundChanged && this.run("unbound-control", ["reload"]) === null) {
|
|
16922
|
+
this.run("systemctl", ["reload", "unbound.service"]);
|
|
16923
|
+
}
|
|
16924
|
+
}
|
|
16925
|
+
if (!this.opts.settings.blockDomains) return "";
|
|
16926
|
+
if (!this.opts.enforcing) return "; domain blocking set but remediation is dry_run";
|
|
16927
|
+
return via.length ? `; ${domains.length} domains refused via ${via.join(" + ")}` : "; domain blocking set but no resolver hook (run `threatcrush feeds resolver install`)";
|
|
16928
|
+
}
|
|
16818
16929
|
removeBlocking() {
|
|
16819
16930
|
if (this.run("nft", ["list", "table", "inet", EGRESS_TABLE]) !== null) {
|
|
16820
16931
|
this.run("nft", ["delete", "table", "inet", EGRESS_TABLE]);
|
|
@@ -16866,8 +16977,8 @@ var ThreatFeeds = class {
|
|
|
16866
16977
|
};
|
|
16867
16978
|
|
|
16868
16979
|
// src/daemon/workers/privilege-watch.ts
|
|
16869
|
-
var
|
|
16870
|
-
var
|
|
16980
|
+
var import_node_fs23 = require("fs");
|
|
16981
|
+
var import_node_path17 = require("path");
|
|
16871
16982
|
var import_node_child_process7 = require("child_process");
|
|
16872
16983
|
|
|
16873
16984
|
// src/core/privileges/index.ts
|
|
@@ -17058,31 +17169,31 @@ function countryName(code) {
|
|
|
17058
17169
|
var fsIO = {
|
|
17059
17170
|
readFile: (p) => {
|
|
17060
17171
|
try {
|
|
17061
|
-
return (0,
|
|
17172
|
+
return (0, import_node_fs23.readFileSync)(p, "utf-8");
|
|
17062
17173
|
} catch {
|
|
17063
17174
|
return null;
|
|
17064
17175
|
}
|
|
17065
17176
|
},
|
|
17066
17177
|
readDir: (p) => {
|
|
17067
17178
|
try {
|
|
17068
|
-
return (0,
|
|
17179
|
+
return (0, import_node_fs23.readdirSync)(p);
|
|
17069
17180
|
} catch {
|
|
17070
17181
|
return null;
|
|
17071
17182
|
}
|
|
17072
17183
|
},
|
|
17073
|
-
exists: (p) => (0,
|
|
17184
|
+
exists: (p) => (0, import_node_fs23.existsSync)(p)
|
|
17074
17185
|
};
|
|
17075
17186
|
function readJson(path) {
|
|
17076
17187
|
try {
|
|
17077
|
-
return JSON.parse((0,
|
|
17188
|
+
return JSON.parse((0, import_node_fs23.readFileSync)(path, "utf-8"));
|
|
17078
17189
|
} catch {
|
|
17079
17190
|
return null;
|
|
17080
17191
|
}
|
|
17081
17192
|
}
|
|
17082
17193
|
function writeJson(path, value) {
|
|
17083
|
-
(0,
|
|
17084
|
-
(0,
|
|
17085
|
-
(0,
|
|
17194
|
+
(0, import_node_fs23.mkdirSync)((0, import_node_path17.dirname)(path), { recursive: true });
|
|
17195
|
+
(0, import_node_fs23.writeFileSync)(`${path}.tmp`, JSON.stringify(value));
|
|
17196
|
+
(0, import_node_fs23.renameSync)(`${path}.tmp`, path);
|
|
17086
17197
|
}
|
|
17087
17198
|
function defaultRun3(cmd, args) {
|
|
17088
17199
|
const res = (0, import_node_child_process7.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 2e4, maxBuffer: 16 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
|
|
@@ -17100,6 +17211,36 @@ async function geolocateViaThreatcrush(ip, fetchImpl = fetch) {
|
|
|
17100
17211
|
const code = body.results?.[ip]?.countryCode;
|
|
17101
17212
|
return typeof code === "string" && /^[A-Z]{2}$/.test(code) ? { countryCode: code } : null;
|
|
17102
17213
|
}
|
|
17214
|
+
async function geolocateManyViaThreatcrush(ips, fetchImpl = fetch) {
|
|
17215
|
+
const out = /* @__PURE__ */ new Map();
|
|
17216
|
+
for (let i = 0; i < ips.length; i += 200) {
|
|
17217
|
+
const chunk = ips.slice(i, i + 200);
|
|
17218
|
+
const res = await fetchImpl("https://threatcrush.com/api/geo", {
|
|
17219
|
+
method: "POST",
|
|
17220
|
+
headers: { "Content-Type": "application/json" },
|
|
17221
|
+
body: JSON.stringify({ ips: chunk }),
|
|
17222
|
+
signal: AbortSignal.timeout(15e3)
|
|
17223
|
+
});
|
|
17224
|
+
if (!res.ok) throw new Error(`geo lookup failed: HTTP ${res.status}`);
|
|
17225
|
+
const body = await res.json();
|
|
17226
|
+
for (const ip of chunk) {
|
|
17227
|
+
const code = body.results?.[ip]?.countryCode;
|
|
17228
|
+
if (typeof code === "string" && /^[A-Z]{2}$/.test(code)) out.set(ip, code);
|
|
17229
|
+
}
|
|
17230
|
+
}
|
|
17231
|
+
return out;
|
|
17232
|
+
}
|
|
17233
|
+
function parseAcceptedLogins(text) {
|
|
17234
|
+
const out = /* @__PURE__ */ new Map();
|
|
17235
|
+
for (const m of text.matchAll(/Accepted \S+ for (\S+) from (\S+) port/g)) {
|
|
17236
|
+
const [, user, ip] = m;
|
|
17237
|
+
if (isProtected(ip, DEFAULT_PROTECTED)) continue;
|
|
17238
|
+
const ips = out.get(user) ?? /* @__PURE__ */ new Set();
|
|
17239
|
+
ips.add(ip);
|
|
17240
|
+
out.set(user, ips);
|
|
17241
|
+
}
|
|
17242
|
+
return out;
|
|
17243
|
+
}
|
|
17103
17244
|
var PrivilegeWatch = class {
|
|
17104
17245
|
constructor(opts) {
|
|
17105
17246
|
this.opts = opts;
|
|
@@ -17123,7 +17264,10 @@ var PrivilegeWatch = class {
|
|
|
17123
17264
|
}
|
|
17124
17265
|
this.checkSnapshot();
|
|
17125
17266
|
this.readSudoLedger();
|
|
17126
|
-
if (this.opts.settings.geo)
|
|
17267
|
+
if (this.opts.settings.geo) {
|
|
17268
|
+
this.opts.bus.on("event", this.onEvent);
|
|
17269
|
+
void this.backfillLogins();
|
|
17270
|
+
}
|
|
17127
17271
|
const timer = setInterval(() => {
|
|
17128
17272
|
this.checkSnapshot();
|
|
17129
17273
|
this.readSudoLedger();
|
|
@@ -17198,6 +17342,42 @@ var PrivilegeWatch = class {
|
|
|
17198
17342
|
}
|
|
17199
17343
|
}
|
|
17200
17344
|
}
|
|
17345
|
+
/**
|
|
17346
|
+
* Seed the login history from the last 30 days of sshd logins, once, when
|
|
17347
|
+
* there is none. Learning only from logins after install meant regular
|
|
17348
|
+
* automation from another country (a backup box pulling every four hours)
|
|
17349
|
+
* raised a "new country" alert on its first run; on dev2 it did, at once.
|
|
17350
|
+
*/
|
|
17351
|
+
async backfillLogins() {
|
|
17352
|
+
if ((0, import_node_fs23.existsSync)(this.opts.loginsPath)) return;
|
|
17353
|
+
const out = this.run("journalctl", ["_COMM=sshd", "_COMM=sshd-session", "--since=-30d", "-o", "cat", "--no-pager"]);
|
|
17354
|
+
const byUser = parseAcceptedLogins(out ?? "");
|
|
17355
|
+
const ips = [...new Set([...byUser.values()].flatMap((s) => [...s]))];
|
|
17356
|
+
let codes = /* @__PURE__ */ new Map();
|
|
17357
|
+
if (ips.length > 0) {
|
|
17358
|
+
try {
|
|
17359
|
+
codes = await (this.opts.geolocateMany ?? geolocateManyViaThreatcrush)(ips);
|
|
17360
|
+
} catch (err) {
|
|
17361
|
+
this.opts.log(`[privileged] login backfill geolocation failed: ${err.message}`);
|
|
17362
|
+
return;
|
|
17363
|
+
}
|
|
17364
|
+
}
|
|
17365
|
+
if ((0, import_node_fs23.existsSync)(this.opts.loginsPath)) return;
|
|
17366
|
+
const at = this.now().toISOString();
|
|
17367
|
+
const history = {};
|
|
17368
|
+
for (const [user, userIps] of byUser) {
|
|
17369
|
+
for (const ip of userIps) {
|
|
17370
|
+
const code = codes.get(ip);
|
|
17371
|
+
if (code) (history[user] ??= {})[code] = { first: at, last: at };
|
|
17372
|
+
}
|
|
17373
|
+
}
|
|
17374
|
+
try {
|
|
17375
|
+
writeJson(this.opts.loginsPath, history);
|
|
17376
|
+
} catch {
|
|
17377
|
+
}
|
|
17378
|
+
const summary = Object.entries(history).map(([u, c]) => `${u}: ${Object.keys(c).join("/")}`).join(", ");
|
|
17379
|
+
this.opts.log(`[privileged] login baseline from the last 30 days: ${summary || "no public SSH logins"}`);
|
|
17380
|
+
}
|
|
17201
17381
|
/** An accepted SSH login from a country new for that user. */
|
|
17202
17382
|
async checkLogin(event) {
|
|
17203
17383
|
if (event.module !== "ssh-guard" || !event.source_ip) return;
|
|
@@ -17394,8 +17574,8 @@ var RuleEngine = class {
|
|
|
17394
17574
|
};
|
|
17395
17575
|
|
|
17396
17576
|
// src/daemon/rules/loader.ts
|
|
17397
|
-
var
|
|
17398
|
-
var
|
|
17577
|
+
var import_node_fs24 = require("fs");
|
|
17578
|
+
var import_node_path18 = require("path");
|
|
17399
17579
|
|
|
17400
17580
|
// src/daemon/rules/default-rules.ts
|
|
17401
17581
|
var AT_CRS_THRESHOLD = { field: "severity", operator: "regex", value: "^(high|critical)$" };
|
|
@@ -17796,11 +17976,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
|
|
|
17796
17976
|
function loadAllRules(customDir) {
|
|
17797
17977
|
const rules = [...DEFAULT_RULES];
|
|
17798
17978
|
const dir = customDir || RULES_DIR;
|
|
17799
|
-
if ((0,
|
|
17800
|
-
const files = (0,
|
|
17979
|
+
if ((0, import_node_fs24.existsSync)(dir)) {
|
|
17980
|
+
const files = (0, import_node_fs24.readdirSync)(dir).filter((f) => f.endsWith(".json"));
|
|
17801
17981
|
for (const file of files) {
|
|
17802
17982
|
try {
|
|
17803
|
-
const raw = (0,
|
|
17983
|
+
const raw = (0, import_node_fs24.readFileSync)((0, import_node_path18.join)(dir, file), "utf-8");
|
|
17804
17984
|
const parsed = JSON.parse(raw);
|
|
17805
17985
|
const customRules = Array.isArray(parsed) ? parsed : [parsed];
|
|
17806
17986
|
for (const rule of customRules) {
|
|
@@ -17832,8 +18012,8 @@ function loadAllRules(customDir) {
|
|
|
17832
18012
|
|
|
17833
18013
|
// src/daemon/firewall/adapters.ts
|
|
17834
18014
|
var import_node_child_process8 = require("child_process");
|
|
17835
|
-
var
|
|
17836
|
-
var
|
|
18015
|
+
var import_node_fs25 = require("fs");
|
|
18016
|
+
var import_node_path19 = require("path");
|
|
17837
18017
|
var import_node_net8 = require("net");
|
|
17838
18018
|
function assertValidFirewallIp(ip) {
|
|
17839
18019
|
if ((0, import_node_net8.isIP)(ip) !== 4) {
|
|
@@ -17846,9 +18026,9 @@ function assertBannableIp(ip) {
|
|
|
17846
18026
|
}
|
|
17847
18027
|
}
|
|
17848
18028
|
function writeIfAbsent(path, contents) {
|
|
17849
|
-
(0,
|
|
18029
|
+
(0, import_node_fs25.mkdirSync)((0, import_node_path19.dirname)(path), { recursive: true });
|
|
17850
18030
|
try {
|
|
17851
|
-
(0,
|
|
18031
|
+
(0, import_node_fs25.writeFileSync)(path, contents, { flag: "wx" });
|
|
17852
18032
|
} catch (err) {
|
|
17853
18033
|
if (err.code !== "EEXIST") throw err;
|
|
17854
18034
|
}
|
|
@@ -18107,7 +18287,8 @@ function detectFirewallAdapter(backend = "auto") {
|
|
|
18107
18287
|
}
|
|
18108
18288
|
|
|
18109
18289
|
// src/daemon/firewall/remediation.ts
|
|
18110
|
-
var
|
|
18290
|
+
var import_node_fs26 = require("fs");
|
|
18291
|
+
var import_node_child_process9 = require("child_process");
|
|
18111
18292
|
var import_node_net9 = require("net");
|
|
18112
18293
|
|
|
18113
18294
|
// src/daemon/firewall/crawlers.ts
|
|
@@ -18164,8 +18345,46 @@ var DEFAULT_CONFIG2 = {
|
|
|
18164
18345
|
strike_memory_seconds: 30 * 86400,
|
|
18165
18346
|
allowlist: [],
|
|
18166
18347
|
protect_current_ssh_client: true,
|
|
18348
|
+
protect_recent_operators: true,
|
|
18349
|
+
operator_memory_seconds: 30 * 86400,
|
|
18167
18350
|
spare_verified_crawlers: true
|
|
18168
18351
|
};
|
|
18352
|
+
var defaultDiscovery = {
|
|
18353
|
+
sshPeers: () => [currentSshClient(), ...establishedSshPeers()].filter((ip) => Boolean(ip)),
|
|
18354
|
+
moshClients: () => moshClients(),
|
|
18355
|
+
automationKeys: () => {
|
|
18356
|
+
const snapshot = takeSnapshot({
|
|
18357
|
+
readFile: (p) => {
|
|
18358
|
+
try {
|
|
18359
|
+
return (0, import_node_fs26.readFileSync)(p, "utf-8");
|
|
18360
|
+
} catch {
|
|
18361
|
+
return null;
|
|
18362
|
+
}
|
|
18363
|
+
},
|
|
18364
|
+
readDir: (p) => {
|
|
18365
|
+
try {
|
|
18366
|
+
return (0, import_node_fs26.readdirSync)(p);
|
|
18367
|
+
} catch {
|
|
18368
|
+
return null;
|
|
18369
|
+
}
|
|
18370
|
+
},
|
|
18371
|
+
exists: (p) => (0, import_node_fs26.existsSync)(p)
|
|
18372
|
+
});
|
|
18373
|
+
const out = /* @__PURE__ */ new Set();
|
|
18374
|
+
for (const keys of Object.values(snapshot.keys)) {
|
|
18375
|
+
for (const [fp, k] of Object.entries(keys)) if (isAutomationKeyComment(k.comment)) out.add(fp);
|
|
18376
|
+
}
|
|
18377
|
+
return out;
|
|
18378
|
+
},
|
|
18379
|
+
keyLoginJournal: (sinceSeconds) => new Promise((resolve3) => {
|
|
18380
|
+
(0, import_node_child_process9.execFile)(
|
|
18381
|
+
"journalctl",
|
|
18382
|
+
["_COMM=sshd", "_COMM=sshd-session", `--since=-${Math.ceil(sinceSeconds / 86400)}d`, "-o", "short-unix", "--no-pager", "--grep", "Accepted publickey"],
|
|
18383
|
+
{ maxBuffer: 32 * 1024 * 1024, timeout: 6e4 },
|
|
18384
|
+
(_err, stdout) => resolve3(stdout ?? "")
|
|
18385
|
+
);
|
|
18386
|
+
})
|
|
18387
|
+
};
|
|
18169
18388
|
var SEVERITY_RANK5 = {
|
|
18170
18389
|
info: 0,
|
|
18171
18390
|
low: 1,
|
|
@@ -18188,28 +18407,70 @@ function explainBlockFailure(err, backend) {
|
|
|
18188
18407
|
return `threatcrushd is running ${who} and cannot manage ${backend}. A ban is written by the daemon, not by whoever asked for it. Fix it with one command, which asks for root itself: threatcrush install-service`;
|
|
18189
18408
|
}
|
|
18190
18409
|
var RemediationManager = class {
|
|
18191
|
-
constructor(adapter, bus2, config, verifyCrawler = crawlerVerifier()) {
|
|
18410
|
+
constructor(adapter, bus2, config, verifyCrawler = crawlerVerifier(), discovery = defaultDiscovery) {
|
|
18192
18411
|
this.adapter = adapter;
|
|
18193
18412
|
this.bus = bus2;
|
|
18194
18413
|
this.verifyCrawler = verifyCrawler;
|
|
18414
|
+
this.discovery = discovery;
|
|
18195
18415
|
this.config = { ...DEFAULT_CONFIG2, ...config };
|
|
18196
18416
|
this.config.allowlist = [...this.config.allowlist];
|
|
18197
18417
|
this.protectedList = [...DEFAULT_PROTECTED, ...this.config.allowlist];
|
|
18198
18418
|
for (const gateway of defaultGateways()) this.protectedList.push(gateway);
|
|
18199
|
-
this.refreshSshProtection();
|
|
18200
18419
|
if (this.adapter.enforces === false) this.config.dry_run = true;
|
|
18201
18420
|
this.loadState();
|
|
18421
|
+
this.refreshSshProtection();
|
|
18202
18422
|
void this.reconcile();
|
|
18203
18423
|
this.startExpiryWorker();
|
|
18424
|
+
if (this.config.protect_recent_operators) void this.seedOperatorsFromJournal();
|
|
18204
18425
|
}
|
|
18205
18426
|
adapter;
|
|
18206
18427
|
bus;
|
|
18207
18428
|
verifyCrawler;
|
|
18429
|
+
discovery;
|
|
18208
18430
|
config;
|
|
18209
18431
|
blocklist = [];
|
|
18210
18432
|
strikes = {};
|
|
18211
18433
|
protectedList = [];
|
|
18434
|
+
/** Operator address → last time seen (ms), persisted. */
|
|
18435
|
+
operators = {};
|
|
18212
18436
|
expiryTimer = null;
|
|
18437
|
+
operatorTimer = null;
|
|
18438
|
+
/** Remembered operator addresses and when each was last seen. */
|
|
18439
|
+
getOperators() {
|
|
18440
|
+
return { ...this.operators };
|
|
18441
|
+
}
|
|
18442
|
+
/**
|
|
18443
|
+
* An address an operator really came from: never ban it, remember it, and
|
|
18444
|
+
* lift a ban that is already on it — the operator is the one who needs in.
|
|
18445
|
+
*/
|
|
18446
|
+
noteOperator(ip, at, remember = true) {
|
|
18447
|
+
if (Date.now() - at > this.config.operator_memory_seconds * 1e3) return;
|
|
18448
|
+
if (!this.protectedList.includes(ip)) this.protectedList.push(ip);
|
|
18449
|
+
if (!remember || !this.config.protect_recent_operators || isProtected(ip, DEFAULT_PROTECTED)) return;
|
|
18450
|
+
const known = this.operators[ip] ?? 0;
|
|
18451
|
+
if (at > known) {
|
|
18452
|
+
this.operators[ip] = at;
|
|
18453
|
+
if (!known) this.logLine(`[firewall] operator address remembered: ${ip}`);
|
|
18454
|
+
this.saveState();
|
|
18455
|
+
}
|
|
18456
|
+
if (this.blocklist.some((b) => b.ip === ip)) {
|
|
18457
|
+
void this.unban(ip, { forget: true, reason: "operator address (key login or live session)" });
|
|
18458
|
+
}
|
|
18459
|
+
}
|
|
18460
|
+
/**
|
|
18461
|
+
* Key-based SSH logins in the memory window, by keys that belong to people:
|
|
18462
|
+
* a key whose comment marks automation (a CI deploy key) logs in from
|
|
18463
|
+
* shared cloud runners, and remembering those would allowlist hundreds of
|
|
18464
|
+
* strangers' addresses — dev2 saw 308 distinct key-login IPs in 30 days.
|
|
18465
|
+
*/
|
|
18466
|
+
async seedOperatorsFromJournal() {
|
|
18467
|
+
try {
|
|
18468
|
+
const automation = this.discovery.automationKeys();
|
|
18469
|
+
const journal = await this.discovery.keyLoginJournal(this.config.operator_memory_seconds);
|
|
18470
|
+
for (const [ip, at] of parseKeyLogins(journal, (fp) => automation.has(fp))) this.noteOperator(ip, at);
|
|
18471
|
+
} catch {
|
|
18472
|
+
}
|
|
18473
|
+
}
|
|
18213
18474
|
/** Every address that can never be blocked, built-ins included. */
|
|
18214
18475
|
getProtected() {
|
|
18215
18476
|
return [...this.protectedList];
|
|
@@ -18224,10 +18485,9 @@ var RemediationManager = class {
|
|
|
18224
18485
|
*/
|
|
18225
18486
|
refreshSshProtection() {
|
|
18226
18487
|
if (!this.config.protect_current_ssh_client) return;
|
|
18227
|
-
const
|
|
18228
|
-
for (const ip of
|
|
18229
|
-
|
|
18230
|
-
}
|
|
18488
|
+
const now = Date.now();
|
|
18489
|
+
for (const ip of this.discovery.sshPeers()) this.noteOperator(ip, now, false);
|
|
18490
|
+
for (const ip of this.discovery.moshClients()) this.noteOperator(ip, now);
|
|
18231
18491
|
}
|
|
18232
18492
|
isAllowlisted(ip) {
|
|
18233
18493
|
return isProtected(ip, this.protectedList);
|
|
@@ -18426,7 +18686,9 @@ var RemediationManager = class {
|
|
|
18426
18686
|
}
|
|
18427
18687
|
stop() {
|
|
18428
18688
|
if (this.expiryTimer) clearInterval(this.expiryTimer);
|
|
18689
|
+
if (this.operatorTimer) clearInterval(this.operatorTimer);
|
|
18429
18690
|
this.expiryTimer = null;
|
|
18691
|
+
this.operatorTimer = null;
|
|
18430
18692
|
}
|
|
18431
18693
|
/**
|
|
18432
18694
|
* R5: bans survive a restart, their TTLs do not. Anything that expired while
|
|
@@ -18475,6 +18737,10 @@ var RemediationManager = class {
|
|
|
18475
18737
|
startExpiryWorker() {
|
|
18476
18738
|
this.expiryTimer = setInterval(() => void this.processExpiries(), 1e4);
|
|
18477
18739
|
this.expiryTimer.unref?.();
|
|
18740
|
+
if (this.config.protect_recent_operators) {
|
|
18741
|
+
this.operatorTimer = setInterval(() => void this.seedOperatorsFromJournal(), 36e5);
|
|
18742
|
+
this.operatorTimer.unref?.();
|
|
18743
|
+
}
|
|
18478
18744
|
}
|
|
18479
18745
|
async processExpiries() {
|
|
18480
18746
|
const now = Date.now();
|
|
@@ -18487,6 +18753,12 @@ var RemediationManager = class {
|
|
|
18487
18753
|
this.strikes = pruned;
|
|
18488
18754
|
this.saveState();
|
|
18489
18755
|
}
|
|
18756
|
+
const cutoff = now - this.config.operator_memory_seconds * 1e3;
|
|
18757
|
+
const stale = Object.keys(this.operators).filter((ip) => this.operators[ip] < cutoff);
|
|
18758
|
+
if (stale.length > 0) {
|
|
18759
|
+
for (const ip of stale) delete this.operators[ip];
|
|
18760
|
+
this.saveState();
|
|
18761
|
+
}
|
|
18490
18762
|
}
|
|
18491
18763
|
loadState() {
|
|
18492
18764
|
try {
|
|
@@ -18506,6 +18778,18 @@ var RemediationManager = class {
|
|
|
18506
18778
|
if (saved && typeof saved === "object") this.strikes = saved;
|
|
18507
18779
|
} catch {
|
|
18508
18780
|
}
|
|
18781
|
+
try {
|
|
18782
|
+
const saved = getModuleState("firewall-rules", "operators");
|
|
18783
|
+
if (saved && typeof saved === "object" && this.config.protect_recent_operators) {
|
|
18784
|
+
const cutoff = Date.now() - this.config.operator_memory_seconds * 1e3;
|
|
18785
|
+
for (const [ip, at] of Object.entries(saved)) {
|
|
18786
|
+
if (typeof at !== "number" || at < cutoff || !(0, import_node_net9.isIP)(ip)) continue;
|
|
18787
|
+
this.operators[ip] = at;
|
|
18788
|
+
if (!this.protectedList.includes(ip)) this.protectedList.push(ip);
|
|
18789
|
+
}
|
|
18790
|
+
}
|
|
18791
|
+
} catch {
|
|
18792
|
+
}
|
|
18509
18793
|
}
|
|
18510
18794
|
saveState() {
|
|
18511
18795
|
try {
|
|
@@ -18516,10 +18800,14 @@ var RemediationManager = class {
|
|
|
18516
18800
|
setModuleState("firewall-rules", "strikes", this.strikes);
|
|
18517
18801
|
} catch {
|
|
18518
18802
|
}
|
|
18803
|
+
try {
|
|
18804
|
+
setModuleState("firewall-rules", "operators", this.operators);
|
|
18805
|
+
} catch {
|
|
18806
|
+
}
|
|
18519
18807
|
}
|
|
18520
18808
|
logLine(line) {
|
|
18521
18809
|
try {
|
|
18522
|
-
(0,
|
|
18810
|
+
(0, import_node_fs26.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
18523
18811
|
`);
|
|
18524
18812
|
} catch {
|
|
18525
18813
|
}
|
|
@@ -18546,6 +18834,11 @@ function remediationSettings(section) {
|
|
|
18546
18834
|
if (typeof section.protect_current_ssh_client === "boolean") {
|
|
18547
18835
|
settings.protect_current_ssh_client = section.protect_current_ssh_client;
|
|
18548
18836
|
}
|
|
18837
|
+
if (typeof section.protect_recent_operators === "boolean") {
|
|
18838
|
+
settings.protect_recent_operators = section.protect_recent_operators;
|
|
18839
|
+
}
|
|
18840
|
+
const operatorMemory = parseDuration(section.operator_memory);
|
|
18841
|
+
if (operatorMemory) settings.operator_memory_seconds = operatorMemory;
|
|
18549
18842
|
if (typeof section.spare_verified_crawlers === "boolean") {
|
|
18550
18843
|
settings.spare_verified_crawlers = section.spare_verified_crawlers;
|
|
18551
18844
|
}
|
|
@@ -18553,13 +18846,13 @@ function remediationSettings(section) {
|
|
|
18553
18846
|
}
|
|
18554
18847
|
|
|
18555
18848
|
// src/daemon/watchdog-service.ts
|
|
18556
|
-
var
|
|
18557
|
-
var
|
|
18849
|
+
var import_node_fs28 = require("fs");
|
|
18850
|
+
var import_node_path21 = require("path");
|
|
18558
18851
|
|
|
18559
18852
|
// src/core/watchdog.ts
|
|
18560
|
-
var
|
|
18853
|
+
var import_node_fs27 = require("fs");
|
|
18561
18854
|
var import_node_crypto6 = require("crypto");
|
|
18562
|
-
var
|
|
18855
|
+
var import_node_path20 = require("path");
|
|
18563
18856
|
var WATCHDOG_DIRNAME = "watchdog";
|
|
18564
18857
|
var LOG_FILE = "attacks.jsonl";
|
|
18565
18858
|
var ROTATED_FILE = "attacks.1.jsonl";
|
|
@@ -18648,12 +18941,12 @@ var WatchdogLog = class {
|
|
|
18648
18941
|
stats = { logged: 0, answered: 0, errored: 0 };
|
|
18649
18942
|
constructor(dir, options = {}) {
|
|
18650
18943
|
this.dir = dir;
|
|
18651
|
-
this.file = (0,
|
|
18944
|
+
this.file = (0, import_node_path20.join)(dir, LOG_FILE);
|
|
18652
18945
|
this.shareGid = options.shareGid;
|
|
18653
|
-
(0,
|
|
18946
|
+
(0, import_node_fs27.mkdirSync)(dir, { recursive: true, mode: this.shareGid === void 0 ? 448 : 1528 });
|
|
18654
18947
|
if (this.shareGid !== void 0) {
|
|
18655
|
-
(0,
|
|
18656
|
-
(0,
|
|
18948
|
+
(0, import_node_fs27.chownSync)(dir, process.getuid?.() ?? 0, this.shareGid);
|
|
18949
|
+
(0, import_node_fs27.chmodSync)(dir, 1528);
|
|
18657
18950
|
}
|
|
18658
18951
|
for (const r of readTail(this.file, 512 * 1024)) this.remember(dedupeKey(r));
|
|
18659
18952
|
}
|
|
@@ -18682,16 +18975,16 @@ var WatchdogLog = class {
|
|
|
18682
18975
|
const chunk = this.buffer.join("\n") + "\n";
|
|
18683
18976
|
this.buffer = [];
|
|
18684
18977
|
try {
|
|
18685
|
-
if ((0,
|
|
18686
|
-
(0,
|
|
18978
|
+
if ((0, import_node_fs27.statSync)(this.file).size > ROTATE_BYTES) {
|
|
18979
|
+
(0, import_node_fs27.renameSync)(this.file, (0, import_node_path20.join)(this.dir, ROTATED_FILE));
|
|
18687
18980
|
}
|
|
18688
18981
|
} catch {
|
|
18689
18982
|
}
|
|
18690
|
-
(0,
|
|
18983
|
+
(0, import_node_fs27.appendFileSync)(this.file, chunk, { mode: this.shareGid === void 0 ? 384 : 432 });
|
|
18691
18984
|
if (this.shareGid !== void 0) {
|
|
18692
18985
|
try {
|
|
18693
|
-
(0,
|
|
18694
|
-
(0,
|
|
18986
|
+
(0, import_node_fs27.chownSync)(this.file, process.getuid?.() ?? 0, this.shareGid);
|
|
18987
|
+
(0, import_node_fs27.chmodSync)(this.file, 432);
|
|
18695
18988
|
} catch {
|
|
18696
18989
|
}
|
|
18697
18990
|
}
|
|
@@ -18712,21 +19005,21 @@ function parseLines(text) {
|
|
|
18712
19005
|
function readTail(file, bytes) {
|
|
18713
19006
|
let fd;
|
|
18714
19007
|
try {
|
|
18715
|
-
fd = (0,
|
|
19008
|
+
fd = (0, import_node_fs27.openSync)(file, "r");
|
|
18716
19009
|
} catch (err) {
|
|
18717
19010
|
if (err.code === "ENOENT") return [];
|
|
18718
19011
|
throw err;
|
|
18719
19012
|
}
|
|
18720
19013
|
try {
|
|
18721
|
-
const size = (0,
|
|
19014
|
+
const size = (0, import_node_fs27.fstatSync)(fd).size;
|
|
18722
19015
|
const start = Math.max(0, size - bytes);
|
|
18723
19016
|
const buf = Buffer.alloc(size - start);
|
|
18724
|
-
(0,
|
|
19017
|
+
(0, import_node_fs27.readSync)(fd, buf, 0, buf.length, start);
|
|
18725
19018
|
let text = buf.toString("utf8");
|
|
18726
19019
|
if (start > 0) text = text.slice(text.indexOf("\n") + 1);
|
|
18727
19020
|
return parseLines(text);
|
|
18728
19021
|
} finally {
|
|
18729
|
-
(0,
|
|
19022
|
+
(0, import_node_fs27.closeSync)(fd);
|
|
18730
19023
|
}
|
|
18731
19024
|
}
|
|
18732
19025
|
|
|
@@ -18735,13 +19028,13 @@ function defaultShareGid() {
|
|
|
18735
19028
|
const isRoot2 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
18736
19029
|
if (!isRoot2) return void 0;
|
|
18737
19030
|
try {
|
|
18738
|
-
return (0,
|
|
19031
|
+
return (0, import_node_fs28.statSync)("/var/log/auth.log").gid;
|
|
18739
19032
|
} catch {
|
|
18740
19033
|
return void 0;
|
|
18741
19034
|
}
|
|
18742
19035
|
}
|
|
18743
19036
|
function startWatchdog(opts) {
|
|
18744
|
-
const dir = opts.config?.dir ?? (0,
|
|
19037
|
+
const dir = opts.config?.dir ?? (0, import_node_path21.join)(opts.stateDir, WATCHDOG_DIRNAME);
|
|
18745
19038
|
const base = { dir, logged: 0, answered: 0, errored: 0 };
|
|
18746
19039
|
if (opts.config?.enabled === false) {
|
|
18747
19040
|
opts.log("[watchdog] off ([watchdog] enabled = false)");
|
|
@@ -18832,7 +19125,7 @@ async function flushTelemetry(timeoutMs = 2e3) {
|
|
|
18832
19125
|
}
|
|
18833
19126
|
|
|
18834
19127
|
// src/core/node-runtime.ts
|
|
18835
|
-
var
|
|
19128
|
+
var import_node_child_process10 = require("child_process");
|
|
18836
19129
|
var MIN_DAEMON_NODE_MAJOR = 22;
|
|
18837
19130
|
function nodeMajor(version) {
|
|
18838
19131
|
const m = String(version ?? "").trim().replace(/^v/, "").match(/^(\d+)\./);
|
|
@@ -18848,16 +19141,16 @@ function daemonNodeProblem(version) {
|
|
|
18848
19141
|
// src/daemon/index.ts
|
|
18849
19142
|
function readVersion2() {
|
|
18850
19143
|
try {
|
|
18851
|
-
const pkg = JSON.parse((0,
|
|
19144
|
+
const pkg = JSON.parse((0, import_node_fs29.readFileSync)((0, import_node_path22.join)(__dirname, "..", "package.json"), "utf-8"));
|
|
18852
19145
|
return pkg.version || "0.0.0";
|
|
18853
19146
|
} catch {
|
|
18854
19147
|
return "0.0.0";
|
|
18855
19148
|
}
|
|
18856
19149
|
}
|
|
18857
19150
|
async function runHardeningChecks() {
|
|
18858
|
-
const { stdout } = await (0, import_node_util.promisify)(
|
|
19151
|
+
const { stdout } = await (0, import_node_util.promisify)(import_node_child_process11.execFile)(
|
|
18859
19152
|
process.execPath,
|
|
18860
|
-
[(0,
|
|
19153
|
+
[(0, import_node_path22.join)(__dirname, "index.js"), "harden", "--json", "--no-upload"],
|
|
18861
19154
|
{ timeout: 12e4, maxBuffer: 4 * 1024 * 1024 }
|
|
18862
19155
|
);
|
|
18863
19156
|
const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
|
|
@@ -18869,9 +19162,9 @@ async function runHardeningChecks() {
|
|
|
18869
19162
|
return patches ? [...findings, patches] : findings;
|
|
18870
19163
|
}
|
|
18871
19164
|
async function runPatchCheck() {
|
|
18872
|
-
const { stdout } = await (0, import_node_util.promisify)(
|
|
19165
|
+
const { stdout } = await (0, import_node_util.promisify)(import_node_child_process11.execFile)(
|
|
18873
19166
|
process.execPath,
|
|
18874
|
-
[(0,
|
|
19167
|
+
[(0, import_node_path22.join)(__dirname, "index.js"), "patches", "--json", "--no-upload"],
|
|
18875
19168
|
{ timeout: 3e5, maxBuffer: 16 * 1024 * 1024 }
|
|
18876
19169
|
);
|
|
18877
19170
|
const parsed = JSON.parse(stdout.slice(stdout.indexOf("{")));
|
|
@@ -18879,7 +19172,7 @@ async function runPatchCheck() {
|
|
|
18879
19172
|
}
|
|
18880
19173
|
function logLine(line) {
|
|
18881
19174
|
try {
|
|
18882
|
-
(0,
|
|
19175
|
+
(0, import_node_fs29.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
18883
19176
|
`);
|
|
18884
19177
|
} catch {
|
|
18885
19178
|
}
|
|
@@ -18904,9 +19197,9 @@ async function runDaemon() {
|
|
|
18904
19197
|
logLine(`[daemon] starting threatcrushd v${version} mode=${PATHS.mode}`);
|
|
18905
19198
|
const restartDaemon = () => {
|
|
18906
19199
|
if (PATHS.mode === "system") {
|
|
18907
|
-
(0,
|
|
19200
|
+
(0, import_node_child_process11.spawn)("systemctl", ["restart", "threatcrushd"], { detached: true, stdio: "ignore" }).unref();
|
|
18908
19201
|
} else {
|
|
18909
|
-
(0,
|
|
19202
|
+
(0, import_node_child_process11.spawn)(process.execPath, process.argv.slice(1), { detached: true, stdio: "ignore" }).unref();
|
|
18910
19203
|
setTimeout(() => process.exit(0), 500).unref();
|
|
18911
19204
|
}
|
|
18912
19205
|
};
|
|
@@ -18921,7 +19214,7 @@ async function runDaemon() {
|
|
|
18921
19214
|
} catch (err) {
|
|
18922
19215
|
logLine(`[daemon] state db unavailable: ${err.message}`);
|
|
18923
19216
|
}
|
|
18924
|
-
const config = loadConfig((0,
|
|
19217
|
+
const config = loadConfig((0, import_node_fs29.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
|
|
18925
19218
|
configureAttackDetection(config.detection);
|
|
18926
19219
|
const retentionSeconds = parseDuration(config.storage?.event_retention) ?? DEFAULT_EVENT_RETENTION_SECONDS;
|
|
18927
19220
|
const maxEvents = config.storage?.max_events ?? DEFAULT_MAX_EVENTS;
|
|
@@ -18985,7 +19278,7 @@ async function runDaemon() {
|
|
|
18985
19278
|
const threatFeeds = new ThreatFeeds({
|
|
18986
19279
|
settings: { ...feedSettings, allow: [...feedSettings.allow, ...remediation.getAllowlist()] },
|
|
18987
19280
|
enforcing: !remediationStatus.dry_run && firewallAdapter.enforces !== false,
|
|
18988
|
-
cachePath: (0,
|
|
19281
|
+
cachePath: (0, import_node_path22.join)(PATHS.stateDir, "threat-feeds.json"),
|
|
18989
19282
|
bus,
|
|
18990
19283
|
log: logLine
|
|
18991
19284
|
});
|
|
@@ -18993,9 +19286,9 @@ async function runDaemon() {
|
|
|
18993
19286
|
const privilegeWatch = new PrivilegeWatch({
|
|
18994
19287
|
settings: privilegeSettings(config.privileged),
|
|
18995
19288
|
bus,
|
|
18996
|
-
snapshotPath: (0,
|
|
18997
|
-
loginsPath: (0,
|
|
18998
|
-
cursorPath: (0,
|
|
19289
|
+
snapshotPath: (0, import_node_path22.join)(PATHS.stateDir, "privileges.json"),
|
|
19290
|
+
loginsPath: (0, import_node_path22.join)(PATHS.stateDir, "login-countries.json"),
|
|
19291
|
+
cursorPath: (0, import_node_path22.join)(PATHS.stateDir, "sudo-cursor.json"),
|
|
18999
19292
|
log: logLine
|
|
19000
19293
|
});
|
|
19001
19294
|
privilegeWatch.start();
|
|
@@ -19018,7 +19311,7 @@ async function runDaemon() {
|
|
|
19018
19311
|
version,
|
|
19019
19312
|
hostname: (0, import_node_os5.hostname)(),
|
|
19020
19313
|
minSeverity,
|
|
19021
|
-
spoolPath: (0,
|
|
19314
|
+
spoolPath: (0, import_node_path22.join)(PATHS.stateDir, "cloud-spool.jsonl"),
|
|
19022
19315
|
log: logLine,
|
|
19023
19316
|
ruleModules: new Set(ruleEngine.getRules().flatMap((rule) => rule.source_types)),
|
|
19024
19317
|
runHardening: runHardeningChecks
|
|
@@ -19035,8 +19328,8 @@ async function runDaemon() {
|
|
|
19035
19328
|
const autoUpdate = new AutoUpdate({
|
|
19036
19329
|
version,
|
|
19037
19330
|
settings: updateSettings(config.update),
|
|
19038
|
-
pkgRoot: (0,
|
|
19039
|
-
statePath: (0,
|
|
19331
|
+
pkgRoot: (0, import_node_path22.join)(__dirname, ".."),
|
|
19332
|
+
statePath: (0, import_node_path22.join)(PATHS.stateDir, "auto-update.json"),
|
|
19040
19333
|
bus,
|
|
19041
19334
|
log: logLine,
|
|
19042
19335
|
restartDaemon
|