@profullstack/threatcrush 0.13.68 → 0.13.70
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 +122 -42
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +189 -109
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23787,7 +23787,7 @@ var source_default = chalk;
|
|
|
23787
23787
|
// src/index.ts
|
|
23788
23788
|
var import_readline = __toESM(require("readline"));
|
|
23789
23789
|
var import_node_child_process28 = require("child_process");
|
|
23790
|
-
var
|
|
23790
|
+
var import_node_fs68 = require("fs");
|
|
23791
23791
|
var import_node_path51 = require("path");
|
|
23792
23792
|
var import_node_os19 = require("os");
|
|
23793
23793
|
|
|
@@ -41890,12 +41890,12 @@ async function sshConnect(options) {
|
|
|
41890
41890
|
|
|
41891
41891
|
// src/commands/daemon.ts
|
|
41892
41892
|
var import_node_child_process20 = require("child_process");
|
|
41893
|
-
var import_node_fs51 = require("fs");
|
|
41894
|
-
var import_node_path40 = require("path");
|
|
41895
41893
|
var import_node_fs52 = require("fs");
|
|
41894
|
+
var import_node_path40 = require("path");
|
|
41895
|
+
var import_node_fs53 = require("fs");
|
|
41896
41896
|
|
|
41897
41897
|
// src/daemon/index.ts
|
|
41898
|
-
var
|
|
41898
|
+
var import_node_fs51 = require("fs");
|
|
41899
41899
|
var import_node_child_process19 = require("child_process");
|
|
41900
41900
|
var import_node_os14 = require("os");
|
|
41901
41901
|
var import_node_path39 = require("path");
|
|
@@ -42894,6 +42894,12 @@ var DEFAULT_PROTECTED = [
|
|
|
42894
42894
|
"172.16.0.0/12",
|
|
42895
42895
|
"192.168.0.0/16",
|
|
42896
42896
|
"169.254.0.0/16",
|
|
42897
|
+
// RFC 6598 shared address space. Never routed on the public internet, so a
|
|
42898
|
+
// source here is a tailnet peer (Tailscale hands out 100.64.0.0/10) or the
|
|
42899
|
+
// carrier's own NAT, not an attacker. 2026-11-02: dev3's port-scan detector
|
|
42900
|
+
// banned a Tailscale peer four times for dialling several c0mpute ports.
|
|
42901
|
+
// Tailscale's IPv6 range (fd7a:115c:a1e0::/48) is already inside fc00::/7.
|
|
42902
|
+
"100.64.0.0/10",
|
|
42897
42903
|
"fc00::/7",
|
|
42898
42904
|
"fe80::/10"
|
|
42899
42905
|
];
|
|
@@ -48089,8 +48095,68 @@ var SshIntrusionWatch = class {
|
|
|
48089
48095
|
}
|
|
48090
48096
|
};
|
|
48091
48097
|
|
|
48092
|
-
// src/daemon/
|
|
48098
|
+
// src/daemon/key-directory.ts
|
|
48093
48099
|
var import_node_fs44 = require("fs");
|
|
48100
|
+
var fsIO3 = {
|
|
48101
|
+
readFile: (p) => {
|
|
48102
|
+
try {
|
|
48103
|
+
return (0, import_node_fs44.readFileSync)(p, "utf-8");
|
|
48104
|
+
} catch {
|
|
48105
|
+
return null;
|
|
48106
|
+
}
|
|
48107
|
+
},
|
|
48108
|
+
readDir: (p) => {
|
|
48109
|
+
try {
|
|
48110
|
+
return (0, import_node_fs44.readdirSync)(p);
|
|
48111
|
+
} catch {
|
|
48112
|
+
return null;
|
|
48113
|
+
}
|
|
48114
|
+
},
|
|
48115
|
+
exists: (p) => (0, import_node_fs44.existsSync)(p)
|
|
48116
|
+
};
|
|
48117
|
+
var KeyDirectory = class {
|
|
48118
|
+
constructor(io = fsIO3, now = Date.now, ttlMs = 3e5) {
|
|
48119
|
+
this.io = io;
|
|
48120
|
+
this.now = now;
|
|
48121
|
+
this.ttlMs = ttlMs;
|
|
48122
|
+
}
|
|
48123
|
+
io;
|
|
48124
|
+
now;
|
|
48125
|
+
ttlMs;
|
|
48126
|
+
cache = { at: -Infinity, byFp: /* @__PURE__ */ new Map() };
|
|
48127
|
+
lookup(fingerprint) {
|
|
48128
|
+
if (this.now() - this.cache.at > this.ttlMs) {
|
|
48129
|
+
const byFp = /* @__PURE__ */ new Map();
|
|
48130
|
+
for (const [account, keys] of Object.entries(takeSnapshot(this.io).keys)) {
|
|
48131
|
+
for (const [fp, k] of Object.entries(keys)) if (!byFp.has(fp)) byFp.set(fp, { account, comment: k.comment });
|
|
48132
|
+
}
|
|
48133
|
+
this.cache = { at: this.now(), byFp };
|
|
48134
|
+
}
|
|
48135
|
+
return this.cache.byFp.get(fingerprint) ?? null;
|
|
48136
|
+
}
|
|
48137
|
+
};
|
|
48138
|
+
function enrichLoginEvent(event, keys) {
|
|
48139
|
+
if (event.module !== "ssh-guard") return;
|
|
48140
|
+
const details = event.details;
|
|
48141
|
+
const fp = details?.fingerprint;
|
|
48142
|
+
if (!details || typeof fp !== "string" || !fp.startsWith("SHA256:") || "key_kind" in details) return;
|
|
48143
|
+
let entry = null;
|
|
48144
|
+
try {
|
|
48145
|
+
entry = keys.lookup(fp);
|
|
48146
|
+
} catch {
|
|
48147
|
+
entry = null;
|
|
48148
|
+
}
|
|
48149
|
+
if (!entry) {
|
|
48150
|
+
details.key_kind = "unknown";
|
|
48151
|
+
return;
|
|
48152
|
+
}
|
|
48153
|
+
details.key_account = entry.account;
|
|
48154
|
+
if (entry.comment) details.key_comment = entry.comment;
|
|
48155
|
+
details.key_kind = isAutomationKeyComment(entry.comment) ? "automation" : "person";
|
|
48156
|
+
}
|
|
48157
|
+
|
|
48158
|
+
// src/daemon/workers/lightning-watch.ts
|
|
48159
|
+
var import_node_fs45 = require("fs");
|
|
48094
48160
|
var DEFAULT_CLN_LOGS = [
|
|
48095
48161
|
"/home/lightning/.lightning/cln.log",
|
|
48096
48162
|
"/root/.lightning/cln.log",
|
|
@@ -48146,9 +48212,9 @@ var LightningWatch = class {
|
|
|
48146
48212
|
if (this.opts.enabled === false) return [];
|
|
48147
48213
|
const found = [];
|
|
48148
48214
|
for (const path2 of this.opts.paths?.length ? this.opts.paths : DEFAULT_CLN_LOGS) {
|
|
48149
|
-
if (!(0,
|
|
48215
|
+
if (!(0, import_node_fs45.existsSync)(path2)) continue;
|
|
48150
48216
|
try {
|
|
48151
|
-
(0,
|
|
48217
|
+
(0, import_node_fs45.accessSync)(path2, import_node_fs45.constants.R_OK);
|
|
48152
48218
|
} catch {
|
|
48153
48219
|
continue;
|
|
48154
48220
|
}
|
|
@@ -48183,7 +48249,7 @@ var LightningWatch = class {
|
|
|
48183
48249
|
};
|
|
48184
48250
|
|
|
48185
48251
|
// src/core/tor-exits.ts
|
|
48186
|
-
var
|
|
48252
|
+
var import_node_fs46 = require("fs");
|
|
48187
48253
|
var import_node_path35 = require("path");
|
|
48188
48254
|
var import_node_net15 = require("net");
|
|
48189
48255
|
var TOR_BULK_EXIT_LIST_URL = "https://check.torproject.org/torbulkexitlist";
|
|
@@ -48252,10 +48318,10 @@ var TorExitList = class _TorExitList {
|
|
|
48252
48318
|
}
|
|
48253
48319
|
loadCache() {
|
|
48254
48320
|
try {
|
|
48255
|
-
if (!(0,
|
|
48256
|
-
const parsed = parseTorExitList((0,
|
|
48321
|
+
if (!(0, import_node_fs46.existsSync)(this.opts.cachePath)) return false;
|
|
48322
|
+
const parsed = parseTorExitList((0, import_node_fs46.readFileSync)(this.opts.cachePath, "utf-8"));
|
|
48257
48323
|
if (parsed.size === 0) return false;
|
|
48258
|
-
this.load(parsed, (0,
|
|
48324
|
+
this.load(parsed, (0, import_node_fs46.statSync)(this.opts.cachePath).mtimeMs);
|
|
48259
48325
|
this.log(`[tor] loaded ${parsed.size} Tor exit addresses from cache (${new Date(this.updatedAt).toISOString()})`);
|
|
48260
48326
|
return true;
|
|
48261
48327
|
} catch (err) {
|
|
@@ -48287,9 +48353,9 @@ var TorExitList = class _TorExitList {
|
|
|
48287
48353
|
const before2 = this.exits.size;
|
|
48288
48354
|
this.load(parsed);
|
|
48289
48355
|
try {
|
|
48290
|
-
(0,
|
|
48291
|
-
(0,
|
|
48292
|
-
(0,
|
|
48356
|
+
(0, import_node_fs46.mkdirSync)((0, import_node_path35.dirname)(this.opts.cachePath), { recursive: true });
|
|
48357
|
+
(0, import_node_fs46.writeFileSync)(`${this.opts.cachePath}.tmp`, [...parsed].join("\n") + "\n");
|
|
48358
|
+
(0, import_node_fs46.renameSync)(`${this.opts.cachePath}.tmp`, this.opts.cachePath);
|
|
48293
48359
|
} catch (err) {
|
|
48294
48360
|
this.log(`[tor] could not save the exit list cache: ${err.message}`);
|
|
48295
48361
|
}
|
|
@@ -48330,6 +48396,9 @@ var EVIDENCE_FIELDS = [
|
|
|
48330
48396
|
"system_uid",
|
|
48331
48397
|
"fingerprint",
|
|
48332
48398
|
"key_type",
|
|
48399
|
+
"key_comment",
|
|
48400
|
+
"key_kind",
|
|
48401
|
+
"key_account",
|
|
48333
48402
|
"auth_method",
|
|
48334
48403
|
"port",
|
|
48335
48404
|
"path",
|
|
@@ -48507,7 +48576,7 @@ var RuleEngine = class {
|
|
|
48507
48576
|
};
|
|
48508
48577
|
|
|
48509
48578
|
// src/daemon/rules/loader.ts
|
|
48510
|
-
var
|
|
48579
|
+
var import_node_fs47 = require("fs");
|
|
48511
48580
|
var import_node_path36 = require("path");
|
|
48512
48581
|
|
|
48513
48582
|
// src/daemon/rules/default-rules.ts
|
|
@@ -48572,7 +48641,15 @@ var DEFAULT_RULES = [
|
|
|
48572
48641
|
operator: "regex",
|
|
48573
48642
|
// Attempts only. Matching `accepted` here meant a successful root login
|
|
48574
48643
|
// banned the administrator who had just made it.
|
|
48575
|
-
|
|
48644
|
+
//
|
|
48645
|
+
// Anchored to the start of an sshd failure ("Failed SSH login for root
|
|
48646
|
+
// from …" from classifySshAuth, or a raw "[sshd] Failed password for
|
|
48647
|
+
// root …" journal line). Unanchored, `failed.*\broot\b` matched any auth
|
|
48648
|
+
// event that said "failed" anywhere before "root": privilege-watch logs
|
|
48649
|
+
// every sudo as "sudo: <user> ran <command> as root", so a backup script
|
|
48650
|
+
// whose text read "the copy failed its integrity check" paged a
|
|
48651
|
+
// high-severity "Root SSH Login Attempt" against the admin's own account.
|
|
48652
|
+
value: "^(?:\\[[^\\]]*\\] )?failed (?:ssh login|password|publickey|keyboard-interactive\\S*|none) for (?:invalid user )?root\\b"
|
|
48576
48653
|
},
|
|
48577
48654
|
threshold: 1,
|
|
48578
48655
|
window_seconds: 60,
|
|
@@ -49099,11 +49176,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
|
|
|
49099
49176
|
function loadAllRules(customDir) {
|
|
49100
49177
|
const rules = [...DEFAULT_RULES];
|
|
49101
49178
|
const dir = customDir || RULES_DIR;
|
|
49102
|
-
if ((0,
|
|
49103
|
-
const files = (0,
|
|
49179
|
+
if ((0, import_node_fs47.existsSync)(dir)) {
|
|
49180
|
+
const files = (0, import_node_fs47.readdirSync)(dir).filter((f) => f.endsWith(".json"));
|
|
49104
49181
|
for (const file of files) {
|
|
49105
49182
|
try {
|
|
49106
|
-
const raw = (0,
|
|
49183
|
+
const raw = (0, import_node_fs47.readFileSync)((0, import_node_path36.join)(dir, file), "utf-8");
|
|
49107
49184
|
const parsed = JSON.parse(raw);
|
|
49108
49185
|
const customRules = Array.isArray(parsed) ? parsed : [parsed];
|
|
49109
49186
|
for (const rule of customRules) {
|
|
@@ -49135,7 +49212,7 @@ function loadAllRules(customDir) {
|
|
|
49135
49212
|
|
|
49136
49213
|
// src/daemon/firewall/adapters.ts
|
|
49137
49214
|
var import_node_child_process16 = require("child_process");
|
|
49138
|
-
var
|
|
49215
|
+
var import_node_fs48 = require("fs");
|
|
49139
49216
|
var import_node_path37 = require("path");
|
|
49140
49217
|
var import_node_net16 = require("net");
|
|
49141
49218
|
function assertValidFirewallIp(ip) {
|
|
@@ -49149,9 +49226,9 @@ function assertBannableIp(ip) {
|
|
|
49149
49226
|
}
|
|
49150
49227
|
}
|
|
49151
49228
|
function writeIfAbsent(path2, contents) {
|
|
49152
|
-
(0,
|
|
49229
|
+
(0, import_node_fs48.mkdirSync)((0, import_node_path37.dirname)(path2), { recursive: true });
|
|
49153
49230
|
try {
|
|
49154
|
-
(0,
|
|
49231
|
+
(0, import_node_fs48.writeFileSync)(path2, contents, { flag: "wx" });
|
|
49155
49232
|
} catch (err) {
|
|
49156
49233
|
if (err.code !== "EEXIST") throw err;
|
|
49157
49234
|
}
|
|
@@ -49410,7 +49487,7 @@ function detectFirewallAdapter(backend = "auto") {
|
|
|
49410
49487
|
}
|
|
49411
49488
|
|
|
49412
49489
|
// src/daemon/firewall/remediation.ts
|
|
49413
|
-
var
|
|
49490
|
+
var import_node_fs49 = require("fs");
|
|
49414
49491
|
var import_node_child_process17 = require("child_process");
|
|
49415
49492
|
var import_node_net17 = require("net");
|
|
49416
49493
|
init_paths();
|
|
@@ -49482,19 +49559,19 @@ var defaultDiscovery = {
|
|
|
49482
49559
|
const snapshot = takeSnapshot({
|
|
49483
49560
|
readFile: (p) => {
|
|
49484
49561
|
try {
|
|
49485
|
-
return (0,
|
|
49562
|
+
return (0, import_node_fs49.readFileSync)(p, "utf-8");
|
|
49486
49563
|
} catch {
|
|
49487
49564
|
return null;
|
|
49488
49565
|
}
|
|
49489
49566
|
},
|
|
49490
49567
|
readDir: (p) => {
|
|
49491
49568
|
try {
|
|
49492
|
-
return (0,
|
|
49569
|
+
return (0, import_node_fs49.readdirSync)(p);
|
|
49493
49570
|
} catch {
|
|
49494
49571
|
return null;
|
|
49495
49572
|
}
|
|
49496
49573
|
},
|
|
49497
|
-
exists: (p) => (0,
|
|
49574
|
+
exists: (p) => (0, import_node_fs49.existsSync)(p)
|
|
49498
49575
|
});
|
|
49499
49576
|
const out = /* @__PURE__ */ new Set();
|
|
49500
49577
|
for (const keys of Object.values(snapshot.keys)) {
|
|
@@ -50007,7 +50084,7 @@ var RemediationManager = class {
|
|
|
50007
50084
|
}
|
|
50008
50085
|
logLine(line2) {
|
|
50009
50086
|
try {
|
|
50010
|
-
(0,
|
|
50087
|
+
(0, import_node_fs49.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
|
|
50011
50088
|
`);
|
|
50012
50089
|
} catch {
|
|
50013
50090
|
}
|
|
@@ -50051,13 +50128,13 @@ function remediationSettings(section) {
|
|
|
50051
50128
|
init_backoff();
|
|
50052
50129
|
|
|
50053
50130
|
// src/daemon/watchdog-service.ts
|
|
50054
|
-
var
|
|
50131
|
+
var import_node_fs50 = require("fs");
|
|
50055
50132
|
var import_node_path38 = require("path");
|
|
50056
50133
|
function defaultShareGid() {
|
|
50057
50134
|
const isRoot4 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
50058
50135
|
if (!isRoot4) return void 0;
|
|
50059
50136
|
try {
|
|
50060
|
-
return (0,
|
|
50137
|
+
return (0, import_node_fs50.statSync)("/var/log/auth.log").gid;
|
|
50061
50138
|
} catch {
|
|
50062
50139
|
return void 0;
|
|
50063
50140
|
}
|
|
@@ -50178,7 +50255,7 @@ function versionOfNode(path2) {
|
|
|
50178
50255
|
// src/daemon/index.ts
|
|
50179
50256
|
function readVersion2() {
|
|
50180
50257
|
try {
|
|
50181
|
-
const pkg = JSON.parse((0,
|
|
50258
|
+
const pkg = JSON.parse((0, import_node_fs51.readFileSync)((0, import_node_path39.join)(__dirname, "..", "package.json"), "utf-8"));
|
|
50182
50259
|
return pkg.version || "0.0.0";
|
|
50183
50260
|
} catch {
|
|
50184
50261
|
return "0.0.0";
|
|
@@ -50209,7 +50286,7 @@ async function runPatchCheck() {
|
|
|
50209
50286
|
}
|
|
50210
50287
|
function logLine(line2) {
|
|
50211
50288
|
try {
|
|
50212
|
-
(0,
|
|
50289
|
+
(0, import_node_fs51.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line2}
|
|
50213
50290
|
`);
|
|
50214
50291
|
} catch {
|
|
50215
50292
|
}
|
|
@@ -50292,8 +50369,11 @@ async function runDaemon() {
|
|
|
50292
50369
|
bus.publish(event);
|
|
50293
50370
|
});
|
|
50294
50371
|
ruleEngine.loadRules(loadAllRules());
|
|
50372
|
+
const keyDirectory = new KeyDirectory();
|
|
50295
50373
|
bus.on("event", (event) => {
|
|
50296
|
-
if (event.module
|
|
50374
|
+
if (event.module === "rule-engine") return;
|
|
50375
|
+
enrichLoginEvent(event, keyDirectory);
|
|
50376
|
+
ruleEngine.evaluate(event);
|
|
50297
50377
|
});
|
|
50298
50378
|
logLine(`[daemon] rule engine loaded ${ruleEngine.getRules().length} rules`);
|
|
50299
50379
|
setInterval(() => ruleEngine.cleanup(), 6e4);
|
|
@@ -50576,7 +50656,7 @@ async function daemonStart() {
|
|
|
50576
50656
|
return;
|
|
50577
50657
|
}
|
|
50578
50658
|
ensureRuntimeDirs();
|
|
50579
|
-
if (!(0,
|
|
50659
|
+
if (!(0, import_node_fs52.existsSync)(DAEMON_ENTRY)) {
|
|
50580
50660
|
console.log(source_default.red(` Daemon entry not found at ${DAEMON_ENTRY}.`));
|
|
50581
50661
|
console.log(source_default.dim(" Reinstall with `threatcrush update` or `pnpm run build` in the cli package."));
|
|
50582
50662
|
return;
|
|
@@ -50584,8 +50664,8 @@ async function daemonStart() {
|
|
|
50584
50664
|
let out;
|
|
50585
50665
|
let err;
|
|
50586
50666
|
try {
|
|
50587
|
-
out = (0,
|
|
50588
|
-
err = (0,
|
|
50667
|
+
out = (0, import_node_fs53.openSync)(PATHS.logFile, "a");
|
|
50668
|
+
err = (0, import_node_fs53.openSync)(PATHS.logFile, "a");
|
|
50589
50669
|
} catch (e) {
|
|
50590
50670
|
const code = e.code;
|
|
50591
50671
|
console.log(source_default.red(` \u2717 Cannot write daemon log at ${PATHS.logFile} (${code ?? "error"}).`));
|
|
@@ -50673,12 +50753,12 @@ async function waitForExit(pid, timeoutMs) {
|
|
|
50673
50753
|
}
|
|
50674
50754
|
async function releaseStaleSocket() {
|
|
50675
50755
|
const deadline = Date.now() + 2e3;
|
|
50676
|
-
while ((0,
|
|
50756
|
+
while ((0, import_node_fs52.existsSync)(PATHS.socket) && Date.now() < deadline) {
|
|
50677
50757
|
await new Promise((r) => setTimeout(r, 50));
|
|
50678
50758
|
}
|
|
50679
|
-
if ((0,
|
|
50759
|
+
if ((0, import_node_fs52.existsSync)(PATHS.socket)) {
|
|
50680
50760
|
try {
|
|
50681
|
-
(0,
|
|
50761
|
+
(0, import_node_fs52.unlinkSync)(PATHS.socket);
|
|
50682
50762
|
} catch {
|
|
50683
50763
|
}
|
|
50684
50764
|
}
|
|
@@ -50686,26 +50766,26 @@ async function releaseStaleSocket() {
|
|
|
50686
50766
|
|
|
50687
50767
|
// src/commands/service.ts
|
|
50688
50768
|
var import_node_child_process21 = require("child_process");
|
|
50689
|
-
var
|
|
50769
|
+
var import_node_fs54 = require("fs");
|
|
50690
50770
|
var import_node_path41 = require("path");
|
|
50691
50771
|
var import_node_os15 = require("os");
|
|
50692
50772
|
var UNIT_PATH = "/etc/systemd/system/threatcrushd.service";
|
|
50693
50773
|
var DAEMON_UNIT_NAME = "threatcrushd.service";
|
|
50694
50774
|
function resolveTemplate() {
|
|
50695
50775
|
const templatePath = (0, import_node_path41.join)(__dirname, "systemd", "threatcrushd.service");
|
|
50696
|
-
if (!(0,
|
|
50776
|
+
if (!(0, import_node_fs54.existsSync)(templatePath)) {
|
|
50697
50777
|
throw new Error(`systemd unit template not found at ${templatePath}`);
|
|
50698
50778
|
}
|
|
50699
|
-
return (0,
|
|
50779
|
+
return (0, import_node_fs54.readFileSync)(templatePath, "utf-8");
|
|
50700
50780
|
}
|
|
50701
50781
|
function stableBinPath(binPath) {
|
|
50702
50782
|
const stable = binPath.replace(/\/\.pnpm\/[^/]+\/node_modules\//, "/node_modules/");
|
|
50703
50783
|
if (stable === binPath) return binPath;
|
|
50704
|
-
return (0,
|
|
50784
|
+
return (0, import_node_fs54.existsSync)(stable) ? stable : binPath;
|
|
50705
50785
|
}
|
|
50706
50786
|
function resolveBinPath() {
|
|
50707
50787
|
const arg = process.argv[1];
|
|
50708
|
-
if (arg && (0,
|
|
50788
|
+
if (arg && (0, import_node_fs54.existsSync)(arg)) return stableBinPath(arg);
|
|
50709
50789
|
try {
|
|
50710
50790
|
return (0, import_node_child_process21.execSync)("command -v threatcrush", { encoding: "utf-8" }).trim();
|
|
50711
50791
|
} catch {
|
|
@@ -50715,11 +50795,11 @@ function resolveBinPath() {
|
|
|
50715
50795
|
function stableNodePath(execPath) {
|
|
50716
50796
|
const stable = execPath.replace(/(\/installs\/node\/)[^/]+\//, "$1latest/");
|
|
50717
50797
|
if (stable === execPath) return execPath;
|
|
50718
|
-
return (0,
|
|
50798
|
+
return (0, import_node_fs54.existsSync)(stable) ? stable : execPath;
|
|
50719
50799
|
}
|
|
50720
50800
|
function looksLikeNodeScript(path2) {
|
|
50721
50801
|
try {
|
|
50722
|
-
const head = (0,
|
|
50802
|
+
const head = (0, import_node_fs54.readFileSync)(path2, "utf-8").slice(0, 120);
|
|
50723
50803
|
return /^#!.*\bnode\b/.test(head);
|
|
50724
50804
|
} catch {
|
|
50725
50805
|
return false;
|
|
@@ -50759,7 +50839,7 @@ function callerHome() {
|
|
|
50759
50839
|
try {
|
|
50760
50840
|
const line2 = (0, import_node_child_process21.execSync)(`getent passwd ${user}`, { encoding: "utf-8" }).trim();
|
|
50761
50841
|
const home = line2.split(":")[5];
|
|
50762
|
-
return home && (0,
|
|
50842
|
+
return home && (0, import_node_fs54.existsSync)(home) ? home : null;
|
|
50763
50843
|
} catch {
|
|
50764
50844
|
return null;
|
|
50765
50845
|
}
|
|
@@ -50770,10 +50850,10 @@ function stopUserModeDaemon() {
|
|
|
50770
50850
|
const runDir = (0, import_node_path41.join)(home, ".threatcrush", "run");
|
|
50771
50851
|
const pidFile = (0, import_node_path41.join)(runDir, "threatcrushd.pid");
|
|
50772
50852
|
const socket = (0, import_node_path41.join)(runDir, "threatcrushd.sock");
|
|
50773
|
-
if (!(0,
|
|
50853
|
+
if (!(0, import_node_fs54.existsSync)(pidFile) && !(0, import_node_fs54.existsSync)(socket)) return;
|
|
50774
50854
|
let pid = null;
|
|
50775
50855
|
try {
|
|
50776
|
-
pid = Number.parseInt((0,
|
|
50856
|
+
pid = Number.parseInt((0, import_node_fs54.readFileSync)(pidFile, "utf-8").trim(), 10);
|
|
50777
50857
|
} catch {
|
|
50778
50858
|
pid = null;
|
|
50779
50859
|
}
|
|
@@ -50786,7 +50866,7 @@ function stopUserModeDaemon() {
|
|
|
50786
50866
|
}
|
|
50787
50867
|
for (const path2 of [socket, pidFile]) {
|
|
50788
50868
|
try {
|
|
50789
|
-
if ((0,
|
|
50869
|
+
if ((0, import_node_fs54.existsSync)(path2)) (0, import_node_fs54.rmSync)(path2);
|
|
50790
50870
|
} catch {
|
|
50791
50871
|
}
|
|
50792
50872
|
}
|
|
@@ -50804,7 +50884,7 @@ async function installServiceCommand() {
|
|
|
50804
50884
|
}
|
|
50805
50885
|
const noSystemd = systemdUnavailableReason({
|
|
50806
50886
|
hasSystemctl: (0, import_node_child_process21.spawnSync)("sh", ["-c", "command -v systemctl"], { stdio: "ignore" }).status === 0,
|
|
50807
|
-
booted: (0,
|
|
50887
|
+
booted: (0, import_node_fs54.existsSync)("/run/systemd/system")
|
|
50808
50888
|
});
|
|
50809
50889
|
if (noSystemd) {
|
|
50810
50890
|
console.log(source_default.red(` \u2717 systemd isn't available here: ${noSystemd}.`));
|
|
@@ -50826,7 +50906,7 @@ async function installServiceCommand() {
|
|
|
50826
50906
|
const isNodeScript = looksLikeNodeScript(binPath);
|
|
50827
50907
|
let nodePath = stableNodePath(process.execPath);
|
|
50828
50908
|
if (isNodeScript && nodeVersionDir(binPath)) {
|
|
50829
|
-
binPath = (0,
|
|
50909
|
+
binPath = (0, import_node_fs54.realpathSync)(binPath);
|
|
50830
50910
|
nodePath = process.execPath;
|
|
50831
50911
|
}
|
|
50832
50912
|
if (isNodeScript) {
|
|
@@ -50843,7 +50923,7 @@ async function installServiceCommand() {
|
|
|
50843
50923
|
const commandHistoryEnabled = commandHistorySettings(loadConfig().command_history).enabled;
|
|
50844
50924
|
const historyPaths = commandHistoryEnabled ? historyWritableHomes() : [];
|
|
50845
50925
|
const unit = renderUnit(resolveTemplate(), { exec, binPath, configDir, historyPaths });
|
|
50846
|
-
(0,
|
|
50926
|
+
(0, import_node_fs54.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
|
|
50847
50927
|
console.log(source_default.green(` \u2713 Installed unit file: ${UNIT_PATH}`));
|
|
50848
50928
|
console.log(source_default.dim(` ExecStart=${exec}`));
|
|
50849
50929
|
const nodeDir = nodeVersionDir(nodePath);
|
|
@@ -50896,9 +50976,9 @@ function renderLogrotate(logDir = "/var/log/threatcrush") {
|
|
|
50896
50976
|
].join("\n");
|
|
50897
50977
|
}
|
|
50898
50978
|
function installLogrotate() {
|
|
50899
|
-
if (!(0,
|
|
50979
|
+
if (!(0, import_node_fs54.existsSync)((0, import_node_path41.dirname)(LOGROTATE_PATH))) return;
|
|
50900
50980
|
try {
|
|
50901
|
-
(0,
|
|
50981
|
+
(0, import_node_fs54.writeFileSync)(LOGROTATE_PATH, renderLogrotate(), { mode: 420 });
|
|
50902
50982
|
console.log(source_default.green(` \u2713 Log rotation: ${LOGROTATE_PATH} (daily or 200M, keeps 7)`));
|
|
50903
50983
|
} catch (err) {
|
|
50904
50984
|
console.log(source_default.yellow(` ! Could not install log rotation: ${err.message}`));
|
|
@@ -50920,20 +51000,20 @@ function ensureSystemDirs(configDir) {
|
|
|
50920
51000
|
];
|
|
50921
51001
|
let admGid2 = null;
|
|
50922
51002
|
try {
|
|
50923
|
-
admGid2 = (0,
|
|
51003
|
+
admGid2 = (0, import_node_fs54.statSync)("/var/log/auth.log").gid;
|
|
50924
51004
|
} catch {
|
|
50925
51005
|
}
|
|
50926
51006
|
for (const { path: path2, groupWritable, sticky } of dirs) {
|
|
50927
51007
|
try {
|
|
50928
|
-
(0,
|
|
51008
|
+
(0, import_node_fs54.mkdirSync)(path2, { recursive: true });
|
|
50929
51009
|
} catch {
|
|
50930
51010
|
}
|
|
50931
51011
|
try {
|
|
50932
51012
|
if (groupWritable && admGid2 !== null) {
|
|
50933
|
-
(0,
|
|
51013
|
+
(0, import_node_fs54.chmodSync)(path2, sticky ? 1533 : 509);
|
|
50934
51014
|
(0, import_node_child_process21.execSync)(`chgrp adm ${path2}`, { stdio: "ignore" });
|
|
50935
51015
|
} else {
|
|
50936
|
-
(0,
|
|
51016
|
+
(0, import_node_fs54.chmodSync)(path2, 493);
|
|
50937
51017
|
}
|
|
50938
51018
|
} catch {
|
|
50939
51019
|
}
|
|
@@ -50961,7 +51041,7 @@ async function uninstallServiceCommand() {
|
|
|
50961
51041
|
} catch {
|
|
50962
51042
|
}
|
|
50963
51043
|
try {
|
|
50964
|
-
if ((0,
|
|
51044
|
+
if ((0, import_node_fs54.existsSync)(UNIT_PATH)) {
|
|
50965
51045
|
(0, import_node_child_process21.execSync)(`rm -f ${UNIT_PATH}`);
|
|
50966
51046
|
console.log(source_default.green(` \u2713 Removed unit file: ${UNIT_PATH}`));
|
|
50967
51047
|
}
|
|
@@ -50975,7 +51055,7 @@ async function uninstallServiceCommand() {
|
|
|
50975
51055
|
}
|
|
50976
51056
|
|
|
50977
51057
|
// src/commands/save.ts
|
|
50978
|
-
var
|
|
51058
|
+
var import_node_fs55 = require("fs");
|
|
50979
51059
|
var import_toml5 = __toESM(require_toml());
|
|
50980
51060
|
init_cli_config();
|
|
50981
51061
|
init_paths();
|
|
@@ -51014,9 +51094,9 @@ async function saveCommand(opts = {}) {
|
|
|
51014
51094
|
}
|
|
51015
51095
|
const path2 = opts.config ?? PATHS.configFile;
|
|
51016
51096
|
let config = {};
|
|
51017
|
-
if ((0,
|
|
51097
|
+
if ((0, import_node_fs55.existsSync)(path2)) {
|
|
51018
51098
|
try {
|
|
51019
|
-
config = import_toml5.default.parse((0,
|
|
51099
|
+
config = import_toml5.default.parse((0, import_node_fs55.readFileSync)(path2, "utf-8"));
|
|
51020
51100
|
} catch (err) {
|
|
51021
51101
|
console.log(source_default.red(` \u2717 ${path2} is not valid TOML: ${err.message}
|
|
51022
51102
|
`));
|
|
@@ -51129,7 +51209,7 @@ function welcomeCommand() {
|
|
|
51129
51209
|
}
|
|
51130
51210
|
|
|
51131
51211
|
// src/commands/properties.ts
|
|
51132
|
-
var
|
|
51212
|
+
var import_node_fs56 = require("fs");
|
|
51133
51213
|
var import_node_path42 = require("path");
|
|
51134
51214
|
var import_node_readline4 = __toESM(require("readline"));
|
|
51135
51215
|
init_cli_config();
|
|
@@ -51461,7 +51541,7 @@ async function propertiesRunsCommand(opts) {
|
|
|
51461
51541
|
}
|
|
51462
51542
|
function parseImportFile(path2) {
|
|
51463
51543
|
const ext = (0, import_node_path42.extname)(path2).toLowerCase();
|
|
51464
|
-
const raw = (0,
|
|
51544
|
+
const raw = (0, import_node_fs56.readFileSync)(path2, "utf-8");
|
|
51465
51545
|
if (ext === ".json") {
|
|
51466
51546
|
const parsed = JSON.parse(raw);
|
|
51467
51547
|
if (!Array.isArray(parsed)) throw new Error("JSON must be an array of objects");
|
|
@@ -51656,13 +51736,13 @@ async function rulesCommand(opts) {
|
|
|
51656
51736
|
}
|
|
51657
51737
|
|
|
51658
51738
|
// src/commands/harden.ts
|
|
51659
|
-
var
|
|
51739
|
+
var import_node_fs58 = require("fs");
|
|
51660
51740
|
var import_node_child_process22 = require("child_process");
|
|
51661
51741
|
init_cli_config();
|
|
51662
51742
|
|
|
51663
51743
|
// src/commands/cis-report.ts
|
|
51664
51744
|
var import_node_os16 = require("os");
|
|
51665
|
-
var
|
|
51745
|
+
var import_node_fs57 = require("fs");
|
|
51666
51746
|
var CIS_UBUNTU_URL = "https://www.cisecurity.org/benchmark/ubuntu_linux";
|
|
51667
51747
|
var CIS_DEBIAN_URL = "https://www.cisecurity.org/benchmark/debian_linux";
|
|
51668
51748
|
var UBUNTU_2404_CIS_CONTROL_SOURCE = "https://github.com/ComplianceAsCode/content/blob/v0.1.78/controls/cis_ubuntu2404.yml";
|
|
@@ -51682,7 +51762,7 @@ var EDITIONS = {
|
|
|
51682
51762
|
function osRelease() {
|
|
51683
51763
|
let raw = "";
|
|
51684
51764
|
try {
|
|
51685
|
-
raw = (0,
|
|
51765
|
+
raw = (0, import_node_fs57.readFileSync)("/etc/os-release", "utf8");
|
|
51686
51766
|
} catch {
|
|
51687
51767
|
return {};
|
|
51688
51768
|
}
|
|
@@ -51862,7 +51942,7 @@ function writeCisReport(path2, format2, report) {
|
|
|
51862
51942
|
const markdown = renderCisMarkdown(report);
|
|
51863
51943
|
const content = format2 === "json" ? `${JSON.stringify(report, null, 2)}
|
|
51864
51944
|
` : format2 === "pdf" ? renderCisPdf(markdown) : markdown;
|
|
51865
|
-
(0,
|
|
51945
|
+
(0, import_node_fs57.writeFileSync)(path2, content);
|
|
51866
51946
|
}
|
|
51867
51947
|
|
|
51868
51948
|
// src/commands/harden.ts
|
|
@@ -51875,7 +51955,7 @@ function tryExec(cmd) {
|
|
|
51875
51955
|
}
|
|
51876
51956
|
function tryRead(path2) {
|
|
51877
51957
|
try {
|
|
51878
|
-
return (0,
|
|
51958
|
+
return (0, import_node_fs58.readFileSync)(path2, "utf-8");
|
|
51879
51959
|
} catch {
|
|
51880
51960
|
return null;
|
|
51881
51961
|
}
|
|
@@ -51989,8 +52069,8 @@ function checkSshWeakConfig() {
|
|
|
51989
52069
|
};
|
|
51990
52070
|
}
|
|
51991
52071
|
function checkAutoUpdates() {
|
|
51992
|
-
const unattended = (0,
|
|
51993
|
-
const dnfAuto = (0,
|
|
52072
|
+
const unattended = (0, import_node_fs58.existsSync)("/etc/apt/apt.conf.d/20auto-upgrades") || (0, import_node_fs58.existsSync)("/etc/apt/apt.conf.d/50unattended-upgrades");
|
|
52073
|
+
const dnfAuto = (0, import_node_fs58.existsSync)("/etc/dnf/automatic.conf");
|
|
51994
52074
|
if (unattended || dnfAuto) {
|
|
51995
52075
|
return {
|
|
51996
52076
|
key: "auto-updates",
|
|
@@ -52116,7 +52196,7 @@ function checkFail2ban() {
|
|
|
52116
52196
|
explanation: "fail2ban is installed and running."
|
|
52117
52197
|
};
|
|
52118
52198
|
}
|
|
52119
|
-
if ((0,
|
|
52199
|
+
if ((0, import_node_fs58.existsSync)("/etc/fail2ban/fail2ban.conf")) {
|
|
52120
52200
|
return {
|
|
52121
52201
|
key: checkKey,
|
|
52122
52202
|
status: "warn",
|
|
@@ -52336,7 +52416,7 @@ async function hardenCommand(opts) {
|
|
|
52336
52416
|
}
|
|
52337
52417
|
|
|
52338
52418
|
// src/core/patches/index.ts
|
|
52339
|
-
var
|
|
52419
|
+
var import_node_fs59 = require("fs");
|
|
52340
52420
|
var import_node_path43 = require("path");
|
|
52341
52421
|
var import_node_child_process23 = require("child_process");
|
|
52342
52422
|
var import_node_util5 = require("util");
|
|
@@ -52497,9 +52577,9 @@ async function osvRecords(doFetch, ecosystem, source, version) {
|
|
|
52497
52577
|
function newestReleaseMtime(dir) {
|
|
52498
52578
|
try {
|
|
52499
52579
|
let newest = 0;
|
|
52500
|
-
for (const name of (0,
|
|
52580
|
+
for (const name of (0, import_node_fs59.readdirSync)(dir)) {
|
|
52501
52581
|
if (!/Release$/.test(name)) continue;
|
|
52502
|
-
newest = Math.max(newest, (0,
|
|
52582
|
+
newest = Math.max(newest, (0, import_node_fs59.statSync)((0, import_node_path43.join)(dir, name)).mtimeMs);
|
|
52503
52583
|
}
|
|
52504
52584
|
return newest > 0 ? new Date(newest) : null;
|
|
52505
52585
|
} catch {
|
|
@@ -52516,7 +52596,7 @@ async function checkPatches(opts = {}) {
|
|
|
52516
52596
|
let osText = opts.osRelease;
|
|
52517
52597
|
if (osText === void 0) {
|
|
52518
52598
|
try {
|
|
52519
|
-
osText = (0,
|
|
52599
|
+
osText = (0, import_node_fs59.readFileSync)("/etc/os-release", "utf-8");
|
|
52520
52600
|
} catch {
|
|
52521
52601
|
osText = "";
|
|
52522
52602
|
}
|
|
@@ -52748,19 +52828,19 @@ init_paths();
|
|
|
52748
52828
|
|
|
52749
52829
|
// src/commands/feeds-resolver.ts
|
|
52750
52830
|
var import_node_child_process24 = require("child_process");
|
|
52751
|
-
var
|
|
52831
|
+
var import_node_fs60 = require("fs");
|
|
52752
52832
|
var import_node_path44 = require("path");
|
|
52753
52833
|
var realIO = {
|
|
52754
|
-
exists: (p) => (0,
|
|
52834
|
+
exists: (p) => (0, import_node_fs60.existsSync)(p),
|
|
52755
52835
|
read: (p) => {
|
|
52756
52836
|
try {
|
|
52757
|
-
return (0,
|
|
52837
|
+
return (0, import_node_fs60.readFileSync)(p, "utf-8");
|
|
52758
52838
|
} catch {
|
|
52759
52839
|
return null;
|
|
52760
52840
|
}
|
|
52761
52841
|
},
|
|
52762
|
-
write: (p, c) => (0,
|
|
52763
|
-
remove: (p) => (0,
|
|
52842
|
+
write: (p, c) => (0, import_node_fs60.writeFileSync)(p, c),
|
|
52843
|
+
remove: (p) => (0, import_node_fs60.rmSync)(p, { force: true }),
|
|
52764
52844
|
run: (cmd, args) => {
|
|
52765
52845
|
const r = (0, import_node_child_process24.spawnSync)(cmd, args, { encoding: "utf-8", timeout: 3e4 });
|
|
52766
52846
|
return { code: r.status ?? 1, out: `${r.stdout ?? ""}${r.stderr ?? ""}`.trim() };
|
|
@@ -52915,7 +52995,7 @@ async function feedsCommand(action, value, opts) {
|
|
|
52915
52995
|
}
|
|
52916
52996
|
|
|
52917
52997
|
// src/commands/tor.ts
|
|
52918
|
-
var
|
|
52998
|
+
var import_node_fs61 = require("fs");
|
|
52919
52999
|
var import_node_net19 = require("net");
|
|
52920
53000
|
var import_node_path46 = require("path");
|
|
52921
53001
|
init_paths();
|
|
@@ -52926,10 +53006,10 @@ async function torCommand(action, value, opts) {
|
|
|
52926
53006
|
for (const dir of [SYSTEM_PATHS.stateDir, USER_PATHS.stateDir]) {
|
|
52927
53007
|
const path2 = (0, import_node_path46.join)(dir, "tor-exits.txt");
|
|
52928
53008
|
try {
|
|
52929
|
-
if (!(0,
|
|
52930
|
-
exits = parseTorExitList((0,
|
|
53009
|
+
if (!(0, import_node_fs61.existsSync)(path2)) continue;
|
|
53010
|
+
exits = parseTorExitList((0, import_node_fs61.readFileSync)(path2, "utf-8"));
|
|
52931
53011
|
from = path2;
|
|
52932
|
-
updated = (0,
|
|
53012
|
+
updated = (0, import_node_fs61.statSync)(path2).mtime;
|
|
52933
53013
|
break;
|
|
52934
53014
|
} catch {
|
|
52935
53015
|
}
|
|
@@ -52977,13 +53057,13 @@ async function torCommand(action, value, opts) {
|
|
|
52977
53057
|
|
|
52978
53058
|
// src/commands/reputation.ts
|
|
52979
53059
|
var import_node_os17 = require("os");
|
|
52980
|
-
var
|
|
53060
|
+
var import_node_fs62 = require("fs");
|
|
52981
53061
|
var import_node_path47 = require("path");
|
|
52982
53062
|
var API_URL7 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
|
|
52983
53063
|
var CONFIG_PATH4 = (0, import_node_path47.join)((0, import_node_os17.homedir)(), ".threatcrush", "config.json");
|
|
52984
53064
|
function readConfig3() {
|
|
52985
53065
|
try {
|
|
52986
|
-
return JSON.parse((0,
|
|
53066
|
+
return JSON.parse((0, import_node_fs62.readFileSync)(CONFIG_PATH4, "utf-8"));
|
|
52987
53067
|
} catch {
|
|
52988
53068
|
return {};
|
|
52989
53069
|
}
|
|
@@ -53171,7 +53251,7 @@ async function reputationSubscribeCommand(opts) {
|
|
|
53171
53251
|
}
|
|
53172
53252
|
|
|
53173
53253
|
// src/commands/privileged.ts
|
|
53174
|
-
var
|
|
53254
|
+
var import_node_fs63 = require("fs");
|
|
53175
53255
|
init_paths();
|
|
53176
53256
|
var SEV2 = {
|
|
53177
53257
|
critical: source_default.red.bold,
|
|
@@ -53184,19 +53264,19 @@ async function privilegedCommand(opts) {
|
|
|
53184
53264
|
const snapshot = takeSnapshot({
|
|
53185
53265
|
readFile: (p) => {
|
|
53186
53266
|
try {
|
|
53187
|
-
return (0,
|
|
53267
|
+
return (0, import_node_fs63.readFileSync)(p, "utf-8");
|
|
53188
53268
|
} catch {
|
|
53189
53269
|
return null;
|
|
53190
53270
|
}
|
|
53191
53271
|
},
|
|
53192
53272
|
readDir: (p) => {
|
|
53193
53273
|
try {
|
|
53194
|
-
return (0,
|
|
53274
|
+
return (0, import_node_fs63.readdirSync)(p);
|
|
53195
53275
|
} catch {
|
|
53196
53276
|
return null;
|
|
53197
53277
|
}
|
|
53198
53278
|
},
|
|
53199
|
-
exists: (p) => (0,
|
|
53279
|
+
exists: (p) => (0, import_node_fs63.existsSync)(p)
|
|
53200
53280
|
});
|
|
53201
53281
|
let events = [];
|
|
53202
53282
|
let ledgerNote = "";
|
|
@@ -53238,12 +53318,12 @@ async function privilegedCommand(opts) {
|
|
|
53238
53318
|
}
|
|
53239
53319
|
|
|
53240
53320
|
// src/commands/integrity.ts
|
|
53241
|
-
var
|
|
53321
|
+
var import_node_fs64 = require("fs");
|
|
53242
53322
|
var import_node_path48 = require("path");
|
|
53243
53323
|
init_paths();
|
|
53244
53324
|
function readState2(path2) {
|
|
53245
53325
|
try {
|
|
53246
|
-
return JSON.parse((0,
|
|
53326
|
+
return JSON.parse((0, import_node_fs64.readFileSync)(path2, "utf8"));
|
|
53247
53327
|
} catch {
|
|
53248
53328
|
return null;
|
|
53249
53329
|
}
|
|
@@ -53264,7 +53344,7 @@ async function integrityCommand(action = "status", opts = {}) {
|
|
|
53264
53344
|
const config = loadConfig();
|
|
53265
53345
|
const settings = fileIntegritySettings(config.file_integrity);
|
|
53266
53346
|
const systemBaseline = (0, import_node_path48.join)(SYSTEM_PATHS.stateDir, "file-integrity-baseline.json");
|
|
53267
|
-
const useSystemState = PATHS.mode === "system" || systemDaemonPresent() || (0,
|
|
53347
|
+
const useSystemState = PATHS.mode === "system" || systemDaemonPresent() || (0, import_node_fs64.existsSync)(systemBaseline);
|
|
53268
53348
|
const stateDir = useSystemState ? SYSTEM_PATHS.stateDir : PATHS.stateDir;
|
|
53269
53349
|
const baselinePath = (0, import_node_path48.join)(stateDir, "file-integrity-baseline.json");
|
|
53270
53350
|
const observedPath = (0, import_node_path48.join)(stateDir, "file-integrity-observed.json");
|
|
@@ -53335,11 +53415,11 @@ async function integrityCommand(action = "status", opts = {}) {
|
|
|
53335
53415
|
}
|
|
53336
53416
|
|
|
53337
53417
|
// src/commands/edr.ts
|
|
53338
|
-
var
|
|
53418
|
+
var import_node_fs66 = require("fs");
|
|
53339
53419
|
init_paths();
|
|
53340
53420
|
|
|
53341
53421
|
// src/daemon/auditd/rules.ts
|
|
53342
|
-
var
|
|
53422
|
+
var import_node_fs65 = require("fs");
|
|
53343
53423
|
var import_node_child_process25 = require("child_process");
|
|
53344
53424
|
var import_node_path49 = require("path");
|
|
53345
53425
|
var WEB_TOOLS = ["sh", "bash", "dash", "zsh", "curl", "wget"];
|
|
@@ -53352,7 +53432,7 @@ function passwdByName() {
|
|
|
53352
53432
|
raw = (0, import_node_child_process25.execFileSync)("getent", ["passwd"], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
|
|
53353
53433
|
} catch {
|
|
53354
53434
|
try {
|
|
53355
|
-
raw = (0,
|
|
53435
|
+
raw = (0, import_node_fs65.readFileSync)("/etc/passwd", "utf8");
|
|
53356
53436
|
} catch {
|
|
53357
53437
|
return /* @__PURE__ */ new Map();
|
|
53358
53438
|
}
|
|
@@ -53371,8 +53451,8 @@ function existingExecutables(names) {
|
|
|
53371
53451
|
for (const prefix of ["/bin", "/usr/bin", "/usr/local/bin"]) {
|
|
53372
53452
|
const candidate = `${prefix}/${name}`;
|
|
53373
53453
|
try {
|
|
53374
|
-
if (!(0,
|
|
53375
|
-
paths.add((0,
|
|
53454
|
+
if (!(0, import_node_fs65.existsSync)(candidate) || !(0, import_node_fs65.statSync)(candidate).isFile()) continue;
|
|
53455
|
+
paths.add((0, import_node_fs65.realpathSync)(candidate));
|
|
53376
53456
|
} catch {
|
|
53377
53457
|
}
|
|
53378
53458
|
}
|
|
@@ -53383,7 +53463,7 @@ function existingDirectories(paths) {
|
|
|
53383
53463
|
return [...new Set(paths)].filter((path2) => {
|
|
53384
53464
|
if (!(0, import_node_path49.isAbsolute)(path2) || /[\s\r\n]/.test(path2)) return false;
|
|
53385
53465
|
try {
|
|
53386
|
-
return (0,
|
|
53466
|
+
return (0, import_node_fs65.statSync)(path2).isDirectory();
|
|
53387
53467
|
} catch {
|
|
53388
53468
|
return false;
|
|
53389
53469
|
}
|
|
@@ -53444,8 +53524,8 @@ async function edrCommand(action = "status", opts = {}) {
|
|
|
53444
53524
|
}
|
|
53445
53525
|
let readable = false;
|
|
53446
53526
|
try {
|
|
53447
|
-
if ((0,
|
|
53448
|
-
readable = (0,
|
|
53527
|
+
if ((0, import_node_fs66.existsSync)(settings.auditLogPath)) (0, import_node_fs66.accessSync)(settings.auditLogPath, import_node_fs66.constants.R_OK);
|
|
53528
|
+
readable = (0, import_node_fs66.existsSync)(settings.auditLogPath);
|
|
53449
53529
|
} catch {
|
|
53450
53530
|
}
|
|
53451
53531
|
let events = [];
|
|
@@ -53631,7 +53711,7 @@ async function allowlistCommand(opts) {
|
|
|
53631
53711
|
}
|
|
53632
53712
|
|
|
53633
53713
|
// src/commands/abuse.ts
|
|
53634
|
-
var
|
|
53714
|
+
var import_node_fs67 = require("fs");
|
|
53635
53715
|
init_paths();
|
|
53636
53716
|
function rows(records) {
|
|
53637
53717
|
if (records.length === 0) {
|
|
@@ -53691,7 +53771,7 @@ function abuseRetractCommand(id, opts = {}) {
|
|
|
53691
53771
|
);
|
|
53692
53772
|
}
|
|
53693
53773
|
function abuseStatusCommand(opts = {}) {
|
|
53694
|
-
const config = loadConfig((0,
|
|
53774
|
+
const config = loadConfig((0, import_node_fs67.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
|
|
53695
53775
|
const cfg = resolveConfig(config.abuse_reporter);
|
|
53696
53776
|
const hasKey2 = Boolean(cfg.keys.abuseipdb || cfg.keys.stopforumspam);
|
|
53697
53777
|
const active2 = cfg.enabled && (cfg.dryRun || hasKey2);
|
|
@@ -54279,7 +54359,7 @@ function detectPackageManager() {
|
|
|
54279
54359
|
}
|
|
54280
54360
|
function readInstallConfig() {
|
|
54281
54361
|
try {
|
|
54282
|
-
return JSON.parse((0,
|
|
54362
|
+
return JSON.parse((0, import_node_fs68.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
|
|
54283
54363
|
} catch {
|
|
54284
54364
|
return {};
|
|
54285
54365
|
}
|
|
@@ -54702,7 +54782,7 @@ program2.command("uninstall-service").description("Remove the threatcrushd syste
|
|
|
54702
54782
|
program2.command("logs").description("Tail daemon logs").action(async () => {
|
|
54703
54783
|
console.log(LOGO2);
|
|
54704
54784
|
const logPath2 = PATHS.logFile;
|
|
54705
|
-
if (!(0,
|
|
54785
|
+
if (!(0, import_node_fs68.existsSync)(logPath2)) {
|
|
54706
54786
|
console.log(source_default.yellow(` No log file found at ${logPath2}`));
|
|
54707
54787
|
console.log(source_default.dim(" Start the daemon first with `threatcrush start`\n"));
|
|
54708
54788
|
return;
|
|
@@ -54878,7 +54958,7 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
|
|
|
54878
54958
|
const configPath = (0, import_node_path51.join)((0, import_node_os19.homedir)(), ".threatcrush", "config.json");
|
|
54879
54959
|
let email = "";
|
|
54880
54960
|
try {
|
|
54881
|
-
const config = JSON.parse((0,
|
|
54961
|
+
const config = JSON.parse((0, import_node_fs68.readFileSync)(configPath, "utf-8"));
|
|
54882
54962
|
email = config.email || "";
|
|
54883
54963
|
} catch {
|
|
54884
54964
|
}
|
|
@@ -54896,8 +54976,8 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
|
|
|
54896
54976
|
}
|
|
54897
54977
|
try {
|
|
54898
54978
|
const dir = (0, import_node_path51.join)((0, import_node_os19.homedir)(), ".threatcrush");
|
|
54899
|
-
if (!(0,
|
|
54900
|
-
(0,
|
|
54979
|
+
if (!(0, import_node_fs68.existsSync)(dir)) (0, import_node_fs68.mkdirSync)(dir, { recursive: true });
|
|
54980
|
+
(0, import_node_fs68.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
|
|
54901
54981
|
console.log(source_default.dim(` Saved email to ${configPath}`));
|
|
54902
54982
|
} catch {
|
|
54903
54983
|
}
|