@profullstack/threatcrush 0.13.68 → 0.13.69
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 +139 -73
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +327 -261
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
mod
|
|
31
31
|
));
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js
|
|
34
34
|
var require_parser = __commonJS({
|
|
35
|
-
"
|
|
35
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js"(exports2, module2) {
|
|
36
36
|
"use strict";
|
|
37
37
|
var ParserEND = 1114112;
|
|
38
38
|
var ParserError = class _ParserError extends Error {
|
|
@@ -155,9 +155,9 @@ var require_parser = __commonJS({
|
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
//
|
|
158
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js
|
|
159
159
|
var require_create_datetime = __commonJS({
|
|
160
|
-
"
|
|
160
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js"(exports2, module2) {
|
|
161
161
|
"use strict";
|
|
162
162
|
module2.exports = (value) => {
|
|
163
163
|
const date = new Date(value);
|
|
@@ -170,9 +170,9 @@ var require_create_datetime = __commonJS({
|
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
172
|
|
|
173
|
-
//
|
|
173
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js
|
|
174
174
|
var require_format_num = __commonJS({
|
|
175
|
-
"
|
|
175
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js"(exports2, module2) {
|
|
176
176
|
"use strict";
|
|
177
177
|
module2.exports = (d, num) => {
|
|
178
178
|
num = String(num);
|
|
@@ -182,9 +182,9 @@ var require_format_num = __commonJS({
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
-
//
|
|
185
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js
|
|
186
186
|
var require_create_datetime_float = __commonJS({
|
|
187
|
-
"
|
|
187
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js"(exports2, module2) {
|
|
188
188
|
"use strict";
|
|
189
189
|
var f = require_format_num();
|
|
190
190
|
var FloatingDateTime = class extends Date {
|
|
@@ -209,9 +209,9 @@ var require_create_datetime_float = __commonJS({
|
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
-
//
|
|
212
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js
|
|
213
213
|
var require_create_date = __commonJS({
|
|
214
|
-
"
|
|
214
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js"(exports2, module2) {
|
|
215
215
|
"use strict";
|
|
216
216
|
var f = require_format_num();
|
|
217
217
|
var DateTime = global.Date;
|
|
@@ -235,9 +235,9 @@ var require_create_date = __commonJS({
|
|
|
235
235
|
}
|
|
236
236
|
});
|
|
237
237
|
|
|
238
|
-
//
|
|
238
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js
|
|
239
239
|
var require_create_time = __commonJS({
|
|
240
|
-
"
|
|
240
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js"(exports2, module2) {
|
|
241
241
|
"use strict";
|
|
242
242
|
var f = require_format_num();
|
|
243
243
|
var Time = class extends Date {
|
|
@@ -260,9 +260,9 @@ var require_create_time = __commonJS({
|
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
262
|
|
|
263
|
-
//
|
|
263
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js
|
|
264
264
|
var require_toml_parser = __commonJS({
|
|
265
|
-
"
|
|
265
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js"(exports, module) {
|
|
266
266
|
"use strict";
|
|
267
267
|
module.exports = makeParserClass(require_parser());
|
|
268
268
|
module.exports.makeParserClass = makeParserClass;
|
|
@@ -1573,9 +1573,9 @@ var require_toml_parser = __commonJS({
|
|
|
1573
1573
|
}
|
|
1574
1574
|
});
|
|
1575
1575
|
|
|
1576
|
-
//
|
|
1576
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js
|
|
1577
1577
|
var require_parse_pretty_error = __commonJS({
|
|
1578
|
-
"
|
|
1578
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js"(exports2, module2) {
|
|
1579
1579
|
"use strict";
|
|
1580
1580
|
module2.exports = prettyError;
|
|
1581
1581
|
function prettyError(err, buf) {
|
|
@@ -1609,9 +1609,9 @@ var require_parse_pretty_error = __commonJS({
|
|
|
1609
1609
|
}
|
|
1610
1610
|
});
|
|
1611
1611
|
|
|
1612
|
-
//
|
|
1612
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js
|
|
1613
1613
|
var require_parse_string = __commonJS({
|
|
1614
|
-
"
|
|
1614
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js"(exports2, module2) {
|
|
1615
1615
|
"use strict";
|
|
1616
1616
|
module2.exports = parseString;
|
|
1617
1617
|
var TOMLParser = require_toml_parser();
|
|
@@ -1631,9 +1631,9 @@ var require_parse_string = __commonJS({
|
|
|
1631
1631
|
}
|
|
1632
1632
|
});
|
|
1633
1633
|
|
|
1634
|
-
//
|
|
1634
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js
|
|
1635
1635
|
var require_parse_async = __commonJS({
|
|
1636
|
-
"
|
|
1636
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js"(exports2, module2) {
|
|
1637
1637
|
"use strict";
|
|
1638
1638
|
module2.exports = parseAsync;
|
|
1639
1639
|
var TOMLParser = require_toml_parser();
|
|
@@ -1665,9 +1665,9 @@ var require_parse_async = __commonJS({
|
|
|
1665
1665
|
}
|
|
1666
1666
|
});
|
|
1667
1667
|
|
|
1668
|
-
//
|
|
1668
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js
|
|
1669
1669
|
var require_parse_stream = __commonJS({
|
|
1670
|
-
"
|
|
1670
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js"(exports2, module2) {
|
|
1671
1671
|
"use strict";
|
|
1672
1672
|
module2.exports = parseStream;
|
|
1673
1673
|
var stream = require("stream");
|
|
@@ -1744,9 +1744,9 @@ var require_parse_stream = __commonJS({
|
|
|
1744
1744
|
}
|
|
1745
1745
|
});
|
|
1746
1746
|
|
|
1747
|
-
//
|
|
1747
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js
|
|
1748
1748
|
var require_parse = __commonJS({
|
|
1749
|
-
"
|
|
1749
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js"(exports2, module2) {
|
|
1750
1750
|
"use strict";
|
|
1751
1751
|
module2.exports = require_parse_string();
|
|
1752
1752
|
module2.exports.async = require_parse_async();
|
|
@@ -1755,9 +1755,9 @@ var require_parse = __commonJS({
|
|
|
1755
1755
|
}
|
|
1756
1756
|
});
|
|
1757
1757
|
|
|
1758
|
-
//
|
|
1758
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js
|
|
1759
1759
|
var require_stringify = __commonJS({
|
|
1760
|
-
"
|
|
1760
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js"(exports2, module2) {
|
|
1761
1761
|
"use strict";
|
|
1762
1762
|
module2.exports = stringify;
|
|
1763
1763
|
module2.exports.value = stringifyInline;
|
|
@@ -2016,9 +2016,9 @@ var require_stringify = __commonJS({
|
|
|
2016
2016
|
}
|
|
2017
2017
|
});
|
|
2018
2018
|
|
|
2019
|
-
//
|
|
2019
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js
|
|
2020
2020
|
var require_toml = __commonJS({
|
|
2021
|
-
"
|
|
2021
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js"(exports2) {
|
|
2022
2022
|
"use strict";
|
|
2023
2023
|
exports2.parse = require_parse();
|
|
2024
2024
|
exports2.stringify = require_stringify();
|
|
@@ -2026,7 +2026,7 @@ var require_toml = __commonJS({
|
|
|
2026
2026
|
});
|
|
2027
2027
|
|
|
2028
2028
|
// src/daemon/index.ts
|
|
2029
|
-
var
|
|
2029
|
+
var import_node_fs38 = require("fs");
|
|
2030
2030
|
var import_node_child_process14 = require("child_process");
|
|
2031
2031
|
var import_node_os6 = require("os");
|
|
2032
2032
|
var import_node_path29 = require("path");
|
|
@@ -12009,7 +12009,7 @@ function findingEvents(serverId, results, observedAt = /* @__PURE__ */ new Date(
|
|
|
12009
12009
|
var import_node_fs19 = require("fs");
|
|
12010
12010
|
var import_node_path13 = require("path");
|
|
12011
12011
|
|
|
12012
|
-
//
|
|
12012
|
+
// ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/utilities.js
|
|
12013
12013
|
function stringReplaceAll(string, substring, postfix) {
|
|
12014
12014
|
let index = string.indexOf(substring);
|
|
12015
12015
|
if (index === -1) {
|
|
@@ -12039,7 +12039,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
|
12039
12039
|
return returnValue;
|
|
12040
12040
|
}
|
|
12041
12041
|
|
|
12042
|
-
//
|
|
12042
|
+
// ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
12043
12043
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
12044
12044
|
var ANSI_UNDERLINE_OFFSET = 20;
|
|
12045
12045
|
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
@@ -12261,7 +12261,7 @@ function assembleStyles() {
|
|
|
12261
12261
|
var ansiStyles = assembleStyles();
|
|
12262
12262
|
var ansi_styles_default = ansiStyles;
|
|
12263
12263
|
|
|
12264
|
-
//
|
|
12264
|
+
// ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/vendor/supports-color/index.js
|
|
12265
12265
|
var import_node_process = __toESM(require("process"), 1);
|
|
12266
12266
|
var import_node_os4 = __toESM(require("os"), 1);
|
|
12267
12267
|
var import_node_tty = __toESM(require("tty"), 1);
|
|
@@ -12403,7 +12403,7 @@ var supportsColor = {
|
|
|
12403
12403
|
};
|
|
12404
12404
|
var supports_color_default = supportsColor;
|
|
12405
12405
|
|
|
12406
|
-
//
|
|
12406
|
+
// ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/index.js
|
|
12407
12407
|
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
12408
12408
|
var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
12409
12409
|
var STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
@@ -20098,8 +20098,68 @@ var SshIntrusionWatch = class {
|
|
|
20098
20098
|
}
|
|
20099
20099
|
};
|
|
20100
20100
|
|
|
20101
|
-
// src/daemon/
|
|
20101
|
+
// src/daemon/key-directory.ts
|
|
20102
20102
|
var import_node_fs30 = require("fs");
|
|
20103
|
+
var fsIO3 = {
|
|
20104
|
+
readFile: (p) => {
|
|
20105
|
+
try {
|
|
20106
|
+
return (0, import_node_fs30.readFileSync)(p, "utf-8");
|
|
20107
|
+
} catch {
|
|
20108
|
+
return null;
|
|
20109
|
+
}
|
|
20110
|
+
},
|
|
20111
|
+
readDir: (p) => {
|
|
20112
|
+
try {
|
|
20113
|
+
return (0, import_node_fs30.readdirSync)(p);
|
|
20114
|
+
} catch {
|
|
20115
|
+
return null;
|
|
20116
|
+
}
|
|
20117
|
+
},
|
|
20118
|
+
exists: (p) => (0, import_node_fs30.existsSync)(p)
|
|
20119
|
+
};
|
|
20120
|
+
var KeyDirectory = class {
|
|
20121
|
+
constructor(io = fsIO3, now = Date.now, ttlMs = 3e5) {
|
|
20122
|
+
this.io = io;
|
|
20123
|
+
this.now = now;
|
|
20124
|
+
this.ttlMs = ttlMs;
|
|
20125
|
+
}
|
|
20126
|
+
io;
|
|
20127
|
+
now;
|
|
20128
|
+
ttlMs;
|
|
20129
|
+
cache = { at: -Infinity, byFp: /* @__PURE__ */ new Map() };
|
|
20130
|
+
lookup(fingerprint) {
|
|
20131
|
+
if (this.now() - this.cache.at > this.ttlMs) {
|
|
20132
|
+
const byFp = /* @__PURE__ */ new Map();
|
|
20133
|
+
for (const [account, keys] of Object.entries(takeSnapshot(this.io).keys)) {
|
|
20134
|
+
for (const [fp, k] of Object.entries(keys)) if (!byFp.has(fp)) byFp.set(fp, { account, comment: k.comment });
|
|
20135
|
+
}
|
|
20136
|
+
this.cache = { at: this.now(), byFp };
|
|
20137
|
+
}
|
|
20138
|
+
return this.cache.byFp.get(fingerprint) ?? null;
|
|
20139
|
+
}
|
|
20140
|
+
};
|
|
20141
|
+
function enrichLoginEvent(event, keys) {
|
|
20142
|
+
if (event.module !== "ssh-guard") return;
|
|
20143
|
+
const details = event.details;
|
|
20144
|
+
const fp = details?.fingerprint;
|
|
20145
|
+
if (!details || typeof fp !== "string" || !fp.startsWith("SHA256:") || "key_kind" in details) return;
|
|
20146
|
+
let entry = null;
|
|
20147
|
+
try {
|
|
20148
|
+
entry = keys.lookup(fp);
|
|
20149
|
+
} catch {
|
|
20150
|
+
entry = null;
|
|
20151
|
+
}
|
|
20152
|
+
if (!entry) {
|
|
20153
|
+
details.key_kind = "unknown";
|
|
20154
|
+
return;
|
|
20155
|
+
}
|
|
20156
|
+
details.key_account = entry.account;
|
|
20157
|
+
if (entry.comment) details.key_comment = entry.comment;
|
|
20158
|
+
details.key_kind = isAutomationKeyComment(entry.comment) ? "automation" : "person";
|
|
20159
|
+
}
|
|
20160
|
+
|
|
20161
|
+
// src/daemon/workers/lightning-watch.ts
|
|
20162
|
+
var import_node_fs31 = require("fs");
|
|
20103
20163
|
var DEFAULT_CLN_LOGS = [
|
|
20104
20164
|
"/home/lightning/.lightning/cln.log",
|
|
20105
20165
|
"/root/.lightning/cln.log",
|
|
@@ -20155,9 +20215,9 @@ var LightningWatch = class {
|
|
|
20155
20215
|
if (this.opts.enabled === false) return [];
|
|
20156
20216
|
const found = [];
|
|
20157
20217
|
for (const path of this.opts.paths?.length ? this.opts.paths : DEFAULT_CLN_LOGS) {
|
|
20158
|
-
if (!(0,
|
|
20218
|
+
if (!(0, import_node_fs31.existsSync)(path)) continue;
|
|
20159
20219
|
try {
|
|
20160
|
-
(0,
|
|
20220
|
+
(0, import_node_fs31.accessSync)(path, import_node_fs31.constants.R_OK);
|
|
20161
20221
|
} catch {
|
|
20162
20222
|
continue;
|
|
20163
20223
|
}
|
|
@@ -20192,7 +20252,7 @@ var LightningWatch = class {
|
|
|
20192
20252
|
};
|
|
20193
20253
|
|
|
20194
20254
|
// src/core/tor-exits.ts
|
|
20195
|
-
var
|
|
20255
|
+
var import_node_fs32 = require("fs");
|
|
20196
20256
|
var import_node_path24 = require("path");
|
|
20197
20257
|
var import_node_net12 = require("net");
|
|
20198
20258
|
var TOR_BULK_EXIT_LIST_URL = "https://check.torproject.org/torbulkexitlist";
|
|
@@ -20261,10 +20321,10 @@ var TorExitList = class _TorExitList {
|
|
|
20261
20321
|
}
|
|
20262
20322
|
loadCache() {
|
|
20263
20323
|
try {
|
|
20264
|
-
if (!(0,
|
|
20265
|
-
const parsed = parseTorExitList((0,
|
|
20324
|
+
if (!(0, import_node_fs32.existsSync)(this.opts.cachePath)) return false;
|
|
20325
|
+
const parsed = parseTorExitList((0, import_node_fs32.readFileSync)(this.opts.cachePath, "utf-8"));
|
|
20266
20326
|
if (parsed.size === 0) return false;
|
|
20267
|
-
this.load(parsed, (0,
|
|
20327
|
+
this.load(parsed, (0, import_node_fs32.statSync)(this.opts.cachePath).mtimeMs);
|
|
20268
20328
|
this.log(`[tor] loaded ${parsed.size} Tor exit addresses from cache (${new Date(this.updatedAt).toISOString()})`);
|
|
20269
20329
|
return true;
|
|
20270
20330
|
} catch (err) {
|
|
@@ -20296,9 +20356,9 @@ var TorExitList = class _TorExitList {
|
|
|
20296
20356
|
const before = this.exits.size;
|
|
20297
20357
|
this.load(parsed);
|
|
20298
20358
|
try {
|
|
20299
|
-
(0,
|
|
20300
|
-
(0,
|
|
20301
|
-
(0,
|
|
20359
|
+
(0, import_node_fs32.mkdirSync)((0, import_node_path24.dirname)(this.opts.cachePath), { recursive: true });
|
|
20360
|
+
(0, import_node_fs32.writeFileSync)(`${this.opts.cachePath}.tmp`, [...parsed].join("\n") + "\n");
|
|
20361
|
+
(0, import_node_fs32.renameSync)(`${this.opts.cachePath}.tmp`, this.opts.cachePath);
|
|
20302
20362
|
} catch (err) {
|
|
20303
20363
|
this.log(`[tor] could not save the exit list cache: ${err.message}`);
|
|
20304
20364
|
}
|
|
@@ -20339,6 +20399,9 @@ var EVIDENCE_FIELDS = [
|
|
|
20339
20399
|
"system_uid",
|
|
20340
20400
|
"fingerprint",
|
|
20341
20401
|
"key_type",
|
|
20402
|
+
"key_comment",
|
|
20403
|
+
"key_kind",
|
|
20404
|
+
"key_account",
|
|
20342
20405
|
"auth_method",
|
|
20343
20406
|
"port",
|
|
20344
20407
|
"path",
|
|
@@ -20516,7 +20579,7 @@ var RuleEngine = class {
|
|
|
20516
20579
|
};
|
|
20517
20580
|
|
|
20518
20581
|
// src/daemon/rules/loader.ts
|
|
20519
|
-
var
|
|
20582
|
+
var import_node_fs33 = require("fs");
|
|
20520
20583
|
var import_node_path25 = require("path");
|
|
20521
20584
|
|
|
20522
20585
|
// src/daemon/rules/default-rules.ts
|
|
@@ -21108,11 +21171,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
|
|
|
21108
21171
|
function loadAllRules(customDir) {
|
|
21109
21172
|
const rules = [...DEFAULT_RULES];
|
|
21110
21173
|
const dir = customDir || RULES_DIR;
|
|
21111
|
-
if ((0,
|
|
21112
|
-
const files = (0,
|
|
21174
|
+
if ((0, import_node_fs33.existsSync)(dir)) {
|
|
21175
|
+
const files = (0, import_node_fs33.readdirSync)(dir).filter((f) => f.endsWith(".json"));
|
|
21113
21176
|
for (const file of files) {
|
|
21114
21177
|
try {
|
|
21115
|
-
const raw = (0,
|
|
21178
|
+
const raw = (0, import_node_fs33.readFileSync)((0, import_node_path25.join)(dir, file), "utf-8");
|
|
21116
21179
|
const parsed = JSON.parse(raw);
|
|
21117
21180
|
const customRules = Array.isArray(parsed) ? parsed : [parsed];
|
|
21118
21181
|
for (const rule of customRules) {
|
|
@@ -21144,7 +21207,7 @@ function loadAllRules(customDir) {
|
|
|
21144
21207
|
|
|
21145
21208
|
// src/daemon/firewall/adapters.ts
|
|
21146
21209
|
var import_node_child_process11 = require("child_process");
|
|
21147
|
-
var
|
|
21210
|
+
var import_node_fs34 = require("fs");
|
|
21148
21211
|
var import_node_path26 = require("path");
|
|
21149
21212
|
var import_node_net13 = require("net");
|
|
21150
21213
|
function assertValidFirewallIp(ip) {
|
|
@@ -21158,9 +21221,9 @@ function assertBannableIp(ip) {
|
|
|
21158
21221
|
}
|
|
21159
21222
|
}
|
|
21160
21223
|
function writeIfAbsent(path, contents) {
|
|
21161
|
-
(0,
|
|
21224
|
+
(0, import_node_fs34.mkdirSync)((0, import_node_path26.dirname)(path), { recursive: true });
|
|
21162
21225
|
try {
|
|
21163
|
-
(0,
|
|
21226
|
+
(0, import_node_fs34.writeFileSync)(path, contents, { flag: "wx" });
|
|
21164
21227
|
} catch (err) {
|
|
21165
21228
|
if (err.code !== "EEXIST") throw err;
|
|
21166
21229
|
}
|
|
@@ -21419,7 +21482,7 @@ function detectFirewallAdapter(backend = "auto") {
|
|
|
21419
21482
|
}
|
|
21420
21483
|
|
|
21421
21484
|
// src/daemon/firewall/remediation.ts
|
|
21422
|
-
var
|
|
21485
|
+
var import_node_fs35 = require("fs");
|
|
21423
21486
|
var import_node_child_process12 = require("child_process");
|
|
21424
21487
|
var import_node_net14 = require("net");
|
|
21425
21488
|
|
|
@@ -21489,19 +21552,19 @@ var defaultDiscovery = {
|
|
|
21489
21552
|
const snapshot = takeSnapshot({
|
|
21490
21553
|
readFile: (p) => {
|
|
21491
21554
|
try {
|
|
21492
|
-
return (0,
|
|
21555
|
+
return (0, import_node_fs35.readFileSync)(p, "utf-8");
|
|
21493
21556
|
} catch {
|
|
21494
21557
|
return null;
|
|
21495
21558
|
}
|
|
21496
21559
|
},
|
|
21497
21560
|
readDir: (p) => {
|
|
21498
21561
|
try {
|
|
21499
|
-
return (0,
|
|
21562
|
+
return (0, import_node_fs35.readdirSync)(p);
|
|
21500
21563
|
} catch {
|
|
21501
21564
|
return null;
|
|
21502
21565
|
}
|
|
21503
21566
|
},
|
|
21504
|
-
exists: (p) => (0,
|
|
21567
|
+
exists: (p) => (0, import_node_fs35.existsSync)(p)
|
|
21505
21568
|
});
|
|
21506
21569
|
const out = /* @__PURE__ */ new Set();
|
|
21507
21570
|
for (const keys of Object.values(snapshot.keys)) {
|
|
@@ -22014,7 +22077,7 @@ var RemediationManager = class {
|
|
|
22014
22077
|
}
|
|
22015
22078
|
logLine(line) {
|
|
22016
22079
|
try {
|
|
22017
|
-
(0,
|
|
22080
|
+
(0, import_node_fs35.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
22018
22081
|
`);
|
|
22019
22082
|
} catch {
|
|
22020
22083
|
}
|
|
@@ -22054,11 +22117,11 @@ function remediationSettings(section) {
|
|
|
22054
22117
|
}
|
|
22055
22118
|
|
|
22056
22119
|
// src/daemon/watchdog-service.ts
|
|
22057
|
-
var
|
|
22120
|
+
var import_node_fs37 = require("fs");
|
|
22058
22121
|
var import_node_path28 = require("path");
|
|
22059
22122
|
|
|
22060
22123
|
// src/core/watchdog.ts
|
|
22061
|
-
var
|
|
22124
|
+
var import_node_fs36 = require("fs");
|
|
22062
22125
|
var import_node_crypto9 = require("crypto");
|
|
22063
22126
|
var import_node_path27 = require("path");
|
|
22064
22127
|
var WATCHDOG_DIRNAME = "watchdog";
|
|
@@ -22151,10 +22214,10 @@ var WatchdogLog = class {
|
|
|
22151
22214
|
this.dir = dir;
|
|
22152
22215
|
this.file = (0, import_node_path27.join)(dir, LOG_FILE2);
|
|
22153
22216
|
this.shareGid = options.shareGid;
|
|
22154
|
-
(0,
|
|
22217
|
+
(0, import_node_fs36.mkdirSync)(dir, { recursive: true, mode: this.shareGid === void 0 ? 448 : 1528 });
|
|
22155
22218
|
if (this.shareGid !== void 0) {
|
|
22156
|
-
(0,
|
|
22157
|
-
(0,
|
|
22219
|
+
(0, import_node_fs36.chownSync)(dir, process.getuid?.() ?? 0, this.shareGid);
|
|
22220
|
+
(0, import_node_fs36.chmodSync)(dir, 1528);
|
|
22158
22221
|
}
|
|
22159
22222
|
for (const r of readTail(this.file, 512 * 1024)) this.remember(dedupeKey(r));
|
|
22160
22223
|
}
|
|
@@ -22183,16 +22246,16 @@ var WatchdogLog = class {
|
|
|
22183
22246
|
const chunk = this.buffer.join("\n") + "\n";
|
|
22184
22247
|
this.buffer = [];
|
|
22185
22248
|
try {
|
|
22186
|
-
if ((0,
|
|
22187
|
-
(0,
|
|
22249
|
+
if ((0, import_node_fs36.statSync)(this.file).size > ROTATE_BYTES) {
|
|
22250
|
+
(0, import_node_fs36.renameSync)(this.file, (0, import_node_path27.join)(this.dir, ROTATED_FILE));
|
|
22188
22251
|
}
|
|
22189
22252
|
} catch {
|
|
22190
22253
|
}
|
|
22191
|
-
(0,
|
|
22254
|
+
(0, import_node_fs36.appendFileSync)(this.file, chunk, { mode: this.shareGid === void 0 ? 384 : 432 });
|
|
22192
22255
|
if (this.shareGid !== void 0) {
|
|
22193
22256
|
try {
|
|
22194
|
-
(0,
|
|
22195
|
-
(0,
|
|
22257
|
+
(0, import_node_fs36.chownSync)(this.file, process.getuid?.() ?? 0, this.shareGid);
|
|
22258
|
+
(0, import_node_fs36.chmodSync)(this.file, 432);
|
|
22196
22259
|
} catch {
|
|
22197
22260
|
}
|
|
22198
22261
|
}
|
|
@@ -22213,21 +22276,21 @@ function parseLines(text) {
|
|
|
22213
22276
|
function readTail(file, bytes) {
|
|
22214
22277
|
let fd;
|
|
22215
22278
|
try {
|
|
22216
|
-
fd = (0,
|
|
22279
|
+
fd = (0, import_node_fs36.openSync)(file, "r");
|
|
22217
22280
|
} catch (err) {
|
|
22218
22281
|
if (err.code === "ENOENT") return [];
|
|
22219
22282
|
throw err;
|
|
22220
22283
|
}
|
|
22221
22284
|
try {
|
|
22222
|
-
const size = (0,
|
|
22285
|
+
const size = (0, import_node_fs36.fstatSync)(fd).size;
|
|
22223
22286
|
const start = Math.max(0, size - bytes);
|
|
22224
22287
|
const buf = Buffer.alloc(size - start);
|
|
22225
|
-
(0,
|
|
22288
|
+
(0, import_node_fs36.readSync)(fd, buf, 0, buf.length, start);
|
|
22226
22289
|
let text = buf.toString("utf8");
|
|
22227
22290
|
if (start > 0) text = text.slice(text.indexOf("\n") + 1);
|
|
22228
22291
|
return parseLines(text);
|
|
22229
22292
|
} finally {
|
|
22230
|
-
(0,
|
|
22293
|
+
(0, import_node_fs36.closeSync)(fd);
|
|
22231
22294
|
}
|
|
22232
22295
|
}
|
|
22233
22296
|
|
|
@@ -22236,7 +22299,7 @@ function defaultShareGid() {
|
|
|
22236
22299
|
const isRoot2 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
22237
22300
|
if (!isRoot2) return void 0;
|
|
22238
22301
|
try {
|
|
22239
|
-
return (0,
|
|
22302
|
+
return (0, import_node_fs37.statSync)("/var/log/auth.log").gid;
|
|
22240
22303
|
} catch {
|
|
22241
22304
|
return void 0;
|
|
22242
22305
|
}
|
|
@@ -22349,7 +22412,7 @@ function daemonNodeProblem(version) {
|
|
|
22349
22412
|
// src/daemon/index.ts
|
|
22350
22413
|
function readVersion2() {
|
|
22351
22414
|
try {
|
|
22352
|
-
const pkg = JSON.parse((0,
|
|
22415
|
+
const pkg = JSON.parse((0, import_node_fs38.readFileSync)((0, import_node_path29.join)(__dirname, "..", "package.json"), "utf-8"));
|
|
22353
22416
|
return pkg.version || "0.0.0";
|
|
22354
22417
|
} catch {
|
|
22355
22418
|
return "0.0.0";
|
|
@@ -22380,7 +22443,7 @@ async function runPatchCheck() {
|
|
|
22380
22443
|
}
|
|
22381
22444
|
function logLine(line) {
|
|
22382
22445
|
try {
|
|
22383
|
-
(0,
|
|
22446
|
+
(0, import_node_fs38.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
22384
22447
|
`);
|
|
22385
22448
|
} catch {
|
|
22386
22449
|
}
|
|
@@ -22463,8 +22526,11 @@ async function runDaemon() {
|
|
|
22463
22526
|
bus.publish(event);
|
|
22464
22527
|
});
|
|
22465
22528
|
ruleEngine.loadRules(loadAllRules());
|
|
22529
|
+
const keyDirectory = new KeyDirectory();
|
|
22466
22530
|
bus.on("event", (event) => {
|
|
22467
|
-
if (event.module
|
|
22531
|
+
if (event.module === "rule-engine") return;
|
|
22532
|
+
enrichLoginEvent(event, keyDirectory);
|
|
22533
|
+
ruleEngine.evaluate(event);
|
|
22468
22534
|
});
|
|
22469
22535
|
logLine(`[daemon] rule engine loaded ${ruleEngine.getRules().length} rules`);
|
|
22470
22536
|
setInterval(() => ruleEngine.cleanup(), 6e4);
|