@profullstack/threatcrush 0.13.16 → 0.13.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/systemd/threatcrushd.service +6 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16304,7 +16304,7 @@ var import_readline = __toESM(require("readline"));
|
|
|
16304
16304
|
var import_node_child_process15 = require("child_process");
|
|
16305
16305
|
var import_node_fs36 = require("fs");
|
|
16306
16306
|
var import_node_path24 = require("path");
|
|
16307
|
-
var
|
|
16307
|
+
var import_node_os11 = require("os");
|
|
16308
16308
|
|
|
16309
16309
|
// src/commands/monitor.ts
|
|
16310
16310
|
var import_node_fs7 = require("fs");
|
|
@@ -35048,6 +35048,7 @@ async function releaseStaleSocket() {
|
|
|
35048
35048
|
var import_node_child_process12 = require("child_process");
|
|
35049
35049
|
var import_node_fs32 = require("fs");
|
|
35050
35050
|
var import_node_path22 = require("path");
|
|
35051
|
+
var import_node_os10 = require("os");
|
|
35051
35052
|
var UNIT_PATH = "/etc/systemd/system/threatcrushd.service";
|
|
35052
35053
|
var DAEMON_UNIT_NAME = "threatcrushd.service";
|
|
35053
35054
|
function resolveTemplate() {
|
|
@@ -35087,6 +35088,9 @@ function looksLikeNodeScript(path) {
|
|
|
35087
35088
|
function execStartCommand(binPath, nodePath, isNodeScript) {
|
|
35088
35089
|
return isNodeScript ? `${nodePath} ${binPath} daemon` : `${binPath} daemon`;
|
|
35089
35090
|
}
|
|
35091
|
+
function renderUnit(template, opts) {
|
|
35092
|
+
return template.replaceAll("{{BIN_PATH}} daemon", opts.exec).replaceAll("{{BIN_PATH}}", opts.binPath).replaceAll("{{CONFIG_DIR}}", opts.configDir);
|
|
35093
|
+
}
|
|
35090
35094
|
function nodeVersionDir(path) {
|
|
35091
35095
|
const m = path.match(
|
|
35092
35096
|
/^(.*?\/(?:installs\/node(?:js)?|\.nvm\/versions\/node|node-versions|tools\/image\/node|n\/versions\/node)\/[^/]+)\//
|
|
@@ -35195,7 +35199,8 @@ async function installServiceCommand() {
|
|
|
35195
35199
|
}
|
|
35196
35200
|
}
|
|
35197
35201
|
const exec = execStartCommand(binPath, nodePath, isNodeScript);
|
|
35198
|
-
const
|
|
35202
|
+
const configDir = (0, import_node_path22.join)((0, import_node_os10.homedir)(), ".threatcrush");
|
|
35203
|
+
const unit = renderUnit(resolveTemplate(), { exec, binPath, configDir });
|
|
35199
35204
|
(0, import_node_fs32.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
|
|
35200
35205
|
console.log(source_default.green(` \u2713 Installed unit file: ${UNIT_PATH}`));
|
|
35201
35206
|
console.log(source_default.dim(` ExecStart=${exec}`));
|
|
@@ -35207,7 +35212,7 @@ async function installServiceCommand() {
|
|
|
35207
35212
|
console.log(source_default.dim(` threatcrush for the new Node and re-run ${source_default.white("threatcrush install-service")}.`));
|
|
35208
35213
|
console.log(source_default.dim(" Installing with a system Node (/usr/bin/node or /usr/local/bin/node) avoids this."));
|
|
35209
35214
|
}
|
|
35210
|
-
ensureSystemDirs();
|
|
35215
|
+
ensureSystemDirs(configDir);
|
|
35211
35216
|
stopUserModeDaemon();
|
|
35212
35217
|
try {
|
|
35213
35218
|
(0, import_node_child_process12.execSync)("systemctl daemon-reload", { stdio: "inherit" });
|
|
@@ -35229,13 +35234,16 @@ async function installServiceCommand() {
|
|
|
35229
35234
|
}
|
|
35230
35235
|
console.log();
|
|
35231
35236
|
}
|
|
35232
|
-
function ensureSystemDirs() {
|
|
35237
|
+
function ensureSystemDirs(configDir) {
|
|
35233
35238
|
const dirs = [
|
|
35234
35239
|
{ path: "/etc/threatcrush", groupWritable: true },
|
|
35235
35240
|
{ path: "/etc/threatcrush/modules", groupWritable: true, sticky: true },
|
|
35236
35241
|
{ path: "/etc/threatcrush/threatcrushd.conf.d", groupWritable: true },
|
|
35237
35242
|
{ path: "/var/log/threatcrush", groupWritable: false },
|
|
35238
|
-
{ path: "/var/lib/threatcrush", groupWritable: false }
|
|
35243
|
+
{ path: "/var/lib/threatcrush", groupWritable: false },
|
|
35244
|
+
// The daemon's own session dir, root-only: it holds the cloud access and
|
|
35245
|
+
// refresh tokens, so nobody else may read or write it.
|
|
35246
|
+
{ path: configDir, groupWritable: false }
|
|
35239
35247
|
// /run/threatcrush is deliberately absent: it lives on a tmpfs, so creating
|
|
35240
35248
|
// it here only lasts until the next reboot. The unit's RuntimeDirectory=
|
|
35241
35249
|
// recreates it on every start instead.
|
|
@@ -36665,7 +36673,7 @@ ${source_default.dim(" C R U S H")}
|
|
|
36665
36673
|
var API_URL6 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
|
|
36666
36674
|
var PKG_NAME = "@profullstack/threatcrush";
|
|
36667
36675
|
var DESKTOP_PKG_NAME = "@profullstack/threatcrush-desktop";
|
|
36668
|
-
var INSTALL_CONFIG_PATH = (0, import_node_path24.join)((0,
|
|
36676
|
+
var INSTALL_CONFIG_PATH = (0, import_node_path24.join)((0, import_node_os11.homedir)(), ".threatcrush", "install.json");
|
|
36669
36677
|
function detectPackageManager() {
|
|
36670
36678
|
try {
|
|
36671
36679
|
const npmGlobal = (0, import_node_child_process15.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
|
|
@@ -37138,7 +37146,7 @@ storeCmd.command("search <query>").description("Search for modules in the store"
|
|
|
37138
37146
|
});
|
|
37139
37147
|
storeCmd.command("publish <url>").description("Publish a module from a git URL or web URL").action(async (url) => {
|
|
37140
37148
|
console.log(LOGO2);
|
|
37141
|
-
const configPath = (0, import_node_path24.join)((0,
|
|
37149
|
+
const configPath = (0, import_node_path24.join)((0, import_node_os11.homedir)(), ".threatcrush", "config.json");
|
|
37142
37150
|
let email = "";
|
|
37143
37151
|
try {
|
|
37144
37152
|
const config = JSON.parse((0, import_node_fs36.readFileSync)(configPath, "utf-8"));
|
|
@@ -37158,7 +37166,7 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
|
|
|
37158
37166
|
return;
|
|
37159
37167
|
}
|
|
37160
37168
|
try {
|
|
37161
|
-
const dir = (0, import_node_path24.join)((0,
|
|
37169
|
+
const dir = (0, import_node_path24.join)((0, import_node_os11.homedir)(), ".threatcrush");
|
|
37162
37170
|
if (!(0, import_node_fs36.existsSync)(dir)) (0, import_node_fs36.mkdirSync)(dir, { recursive: true });
|
|
37163
37171
|
(0, import_node_fs36.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
|
|
37164
37172
|
console.log(source_default.dim(` Saved email to ${configPath}`));
|