@profullstack/threatcrush 0.13.18 → 0.13.20
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 +21 -1
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +82 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13057,23 +13057,29 @@ function initialState(now = Date.now()) {
|
|
|
13057
13057
|
moduleIndex: 0,
|
|
13058
13058
|
moduleFilter: null,
|
|
13059
13059
|
sourceFilter: null,
|
|
13060
|
-
showNoise: false
|
|
13060
|
+
showNoise: false,
|
|
13061
|
+
muteCron: false
|
|
13061
13062
|
};
|
|
13062
13063
|
}
|
|
13063
|
-
function
|
|
13064
|
+
function isCronLine(event) {
|
|
13065
|
+
if (event.severity !== "low" && event.severity !== "info") return false;
|
|
13066
|
+
return /\[CRON\] \([^)]+\) CMD /.test(event.message);
|
|
13067
|
+
}
|
|
13068
|
+
function isNoise(event, muteCron = false) {
|
|
13064
13069
|
if (event.severity !== "low" && event.severity !== "info") return false;
|
|
13065
13070
|
if (/^Client error 4\d\d:/.test(event.message)) return true;
|
|
13071
|
+
if (muteCron && isCronLine(event)) return true;
|
|
13066
13072
|
return /\b(veth|docker|br-|cni|cali|flannel|vxlan)[\w.-]*: entered (promiscuous|allmulticast) mode|\(unregistering\): left (promiscuous|allmulticast) mode/.test(event.message);
|
|
13067
13073
|
}
|
|
13068
13074
|
function matchesFilters(state, e) {
|
|
13069
13075
|
return (!state.moduleFilter || e.module === state.moduleFilter) && (!state.sourceFilter || e.source_ip === state.sourceFilter);
|
|
13070
13076
|
}
|
|
13071
13077
|
function visibleEvents(state) {
|
|
13072
|
-
return state.events.filter((e) => matchesFilters(state, e) && (state.showNoise || !isNoise(e)));
|
|
13078
|
+
return state.events.filter((e) => matchesFilters(state, e) && (state.showNoise || !isNoise(e, state.muteCron)));
|
|
13073
13079
|
}
|
|
13074
13080
|
function hiddenNoise(state) {
|
|
13075
13081
|
if (state.showNoise) return 0;
|
|
13076
|
-
return state.events.filter((e) => matchesFilters(state, e) && isNoise(e)).length;
|
|
13082
|
+
return state.events.filter((e) => matchesFilters(state, e) && isNoise(e, state.muteCron)).length;
|
|
13077
13083
|
}
|
|
13078
13084
|
function hasFilter(state) {
|
|
13079
13085
|
return Boolean(state.moduleFilter || state.sourceFilter);
|
|
@@ -13223,6 +13229,8 @@ function reducer(state, action) {
|
|
|
13223
13229
|
return { ...state, sourceFilter: null, scrollBack: 0 };
|
|
13224
13230
|
case "toggle_noise":
|
|
13225
13231
|
return { ...state, showNoise: !state.showNoise, scrollBack: 0 };
|
|
13232
|
+
case "toggle_cron":
|
|
13233
|
+
return { ...state, muteCron: !state.muteCron, scrollBack: 0 };
|
|
13226
13234
|
case "counters":
|
|
13227
13235
|
return {
|
|
13228
13236
|
...state,
|
|
@@ -13258,7 +13266,8 @@ function reducer(state, action) {
|
|
|
13258
13266
|
moduleFilter: state.moduleFilter,
|
|
13259
13267
|
sourceFilter: state.sourceFilter,
|
|
13260
13268
|
moduleIndex: state.moduleIndex,
|
|
13261
|
-
showNoise: state.showNoise
|
|
13269
|
+
showNoise: state.showNoise,
|
|
13270
|
+
muteCron: state.muteCron
|
|
13262
13271
|
};
|
|
13263
13272
|
}
|
|
13264
13273
|
}
|
|
@@ -13550,7 +13559,9 @@ function severityPanel(parent, state, theme) {
|
|
|
13550
13559
|
}
|
|
13551
13560
|
function noiseNote(state) {
|
|
13552
13561
|
const hidden = hiddenNoise(state);
|
|
13553
|
-
|
|
13562
|
+
if (hidden === 0) return void 0;
|
|
13563
|
+
const keys = state.muteCron ? "n/c show" : "n shows";
|
|
13564
|
+
return `${hidden} routine hidden \xB7 ${keys}`;
|
|
13554
13565
|
}
|
|
13555
13566
|
function filterLabel(state) {
|
|
13556
13567
|
return [state.moduleFilter, state.sourceFilter ? `src ${state.sourceFilter}` : null].filter(Boolean).join(" \xB7 ");
|
|
@@ -13791,7 +13802,10 @@ function footer(ui, state, theme) {
|
|
|
13791
13802
|
...state.focus === "modules" ? [{ key: "\u23CE", label: state.moduleFilter ? "unfilter" : "filter" }] : state.focus === "threats" || state.focus === "bans" ? [{ key: "\u23CE", label: state.sourceFilter ? "unfilter" : "filter" }, { key: "b", label: "ban" }, { key: "u", label: "unban" }] : [{ key: "b", label: "ban" }, { key: "u", label: "unban" }],
|
|
13792
13803
|
{ key: "p", label: state.paused ? "resume" : "pause" },
|
|
13793
13804
|
{ key: "r", label: "reset" },
|
|
13794
|
-
{ key: "n", label: state.showNoise ? "hide 4xx" : "show 4xx" }
|
|
13805
|
+
{ key: "n", label: state.showNoise ? "hide 4xx" : "show 4xx" },
|
|
13806
|
+
// Only offer the cron toggle once a cron line has actually shown up, or
|
|
13807
|
+
// while it is muting, so the hint never advertises a key with nothing to act on.
|
|
13808
|
+
...state.muteCron || state.events.some(isCronLine) ? [{ key: "c", label: state.muteCron ? "show cron" : "mute cron" }] : []
|
|
13795
13809
|
],
|
|
13796
13810
|
right: [
|
|
13797
13811
|
// The notice is the answer to "did my keypress do anything", so it takes
|
|
@@ -14060,6 +14074,9 @@ async function startDashboard(options = {}) {
|
|
|
14060
14074
|
case "n":
|
|
14061
14075
|
dispatch({ type: "toggle_noise" });
|
|
14062
14076
|
break;
|
|
14077
|
+
case "c":
|
|
14078
|
+
dispatch({ type: "toggle_cron" });
|
|
14079
|
+
break;
|
|
14063
14080
|
case "tab":
|
|
14064
14081
|
dispatch({ type: "focus_next" });
|
|
14065
14082
|
break;
|
|
@@ -30496,8 +30513,41 @@ async function serversCommand(options) {
|
|
|
30496
30513
|
console.log(source_default.dim(" Use the web dashboard to add servers: https://threatcrush.com/dashboard\n"));
|
|
30497
30514
|
return;
|
|
30498
30515
|
}
|
|
30516
|
+
if (action === "restart-all") {
|
|
30517
|
+
await restartAllCommand({ org });
|
|
30518
|
+
return;
|
|
30519
|
+
}
|
|
30499
30520
|
console.log(source_default.red(` Unknown action: ${action}`));
|
|
30500
|
-
console.log(source_default.dim(" Available: list, link, unlink\n"));
|
|
30521
|
+
console.log(source_default.dim(" Available: list, link, unlink, restart-all\n"));
|
|
30522
|
+
}
|
|
30523
|
+
async function restartAllCommand(opts) {
|
|
30524
|
+
let orgs;
|
|
30525
|
+
try {
|
|
30526
|
+
orgs = await fetchOrgs();
|
|
30527
|
+
} catch {
|
|
30528
|
+
console.log(source_default.red(" Not logged in. Run `threatcrush login`.\n"));
|
|
30529
|
+
process.exitCode = 1;
|
|
30530
|
+
return;
|
|
30531
|
+
}
|
|
30532
|
+
let org;
|
|
30533
|
+
try {
|
|
30534
|
+
org = await chooseOrg(orgs, opts.org, askChoice);
|
|
30535
|
+
} catch (err) {
|
|
30536
|
+
console.log(source_default.red(` \u2717 ${err.message}
|
|
30537
|
+
`));
|
|
30538
|
+
process.exitCode = 1;
|
|
30539
|
+
return;
|
|
30540
|
+
}
|
|
30541
|
+
const res = await cloudFetch(`/api/orgs/${org.id}/restart-all`, { method: "POST", body: "{}" });
|
|
30542
|
+
const data = await res.json().catch(() => ({}));
|
|
30543
|
+
if (!res.ok) {
|
|
30544
|
+
console.log(source_default.red(` \u2717 ${data.error || `Restart failed (${res.status})`}
|
|
30545
|
+
`));
|
|
30546
|
+
process.exitCode = 1;
|
|
30547
|
+
return;
|
|
30548
|
+
}
|
|
30549
|
+
console.log(source_default.green(` \u2713 Restart queued for ${data.queued ?? 0} server(s) in /${org.slug}. They reconnect within a minute.
|
|
30550
|
+
`));
|
|
30501
30551
|
}
|
|
30502
30552
|
async function fetchOrgs() {
|
|
30503
30553
|
const res = await cloudFetch("/api/orgs");
|
|
@@ -33366,6 +33416,18 @@ var RemediationConsumer = class {
|
|
|
33366
33416
|
}
|
|
33367
33417
|
this.manager.removeFromAllowlist(target);
|
|
33368
33418
|
return { status: "executed", executed_at };
|
|
33419
|
+
case "restart": {
|
|
33420
|
+
if (!this.opts.restartDaemon) return failed("restart not supported by this daemon");
|
|
33421
|
+
setTimeout(() => {
|
|
33422
|
+
try {
|
|
33423
|
+
this.opts.log("[cloud] dashboard requested a restart \u2014 restarting now");
|
|
33424
|
+
this.opts.restartDaemon?.();
|
|
33425
|
+
} catch (err) {
|
|
33426
|
+
this.opts.log(`[cloud] restart failed: ${err.message}`);
|
|
33427
|
+
}
|
|
33428
|
+
}, 3e3).unref?.();
|
|
33429
|
+
return { status: "executed", executed_at };
|
|
33430
|
+
}
|
|
33369
33431
|
default:
|
|
33370
33432
|
return failed(`unsupported action_type: ${action.action_type}`);
|
|
33371
33433
|
}
|
|
@@ -34760,6 +34822,14 @@ async function runDaemon() {
|
|
|
34760
34822
|
});
|
|
34761
34823
|
const version = readVersion2();
|
|
34762
34824
|
logLine(`[daemon] starting threatcrushd v${version} mode=${PATHS.mode}`);
|
|
34825
|
+
const restartDaemon = () => {
|
|
34826
|
+
if (PATHS.mode === "system") {
|
|
34827
|
+
(0, import_node_child_process10.spawn)("systemctl", ["restart", "threatcrushd"], { detached: true, stdio: "ignore" }).unref();
|
|
34828
|
+
} else {
|
|
34829
|
+
(0, import_node_child_process10.spawn)(process.execPath, process.argv.slice(1), { detached: true, stdio: "ignore" }).unref();
|
|
34830
|
+
setTimeout(() => process.exit(0), 500).unref();
|
|
34831
|
+
}
|
|
34832
|
+
};
|
|
34763
34833
|
const nodeProblem = daemonNodeProblem(process.versions.node);
|
|
34764
34834
|
if (nodeProblem) {
|
|
34765
34835
|
logLine(`[daemon] ${nodeProblem}`);
|
|
@@ -34844,7 +34914,7 @@ async function runDaemon() {
|
|
|
34844
34914
|
runHardening: runHardeningChecks
|
|
34845
34915
|
});
|
|
34846
34916
|
cloudSync.start();
|
|
34847
|
-
remediationConsumer = new RemediationConsumer(remediation, { log: logLine });
|
|
34917
|
+
remediationConsumer = new RemediationConsumer(remediation, { log: logLine, restartDaemon });
|
|
34848
34918
|
remediationConsumer.start();
|
|
34849
34919
|
allowlistSync = new AllowlistSync(remediation, { log: logLine });
|
|
34850
34920
|
allowlistSync.start();
|
|
@@ -37277,6 +37347,9 @@ serversCmd.command("link").option("--org <id|slug>", "Organization to link into
|
|
|
37277
37347
|
serversCmd.command("unlink").description("Stop this machine reporting to the dashboard").action(async () => {
|
|
37278
37348
|
await serversCommand({ action: "unlink" });
|
|
37279
37349
|
});
|
|
37350
|
+
serversCmd.command("restart-all").option("--org <id|slug>", "Organization (default: current org, or your only org)").description("Queue a daemon restart for every server you administer").action(async (opts) => {
|
|
37351
|
+
await serversCommand({ action: "restart-all", org: opts.org });
|
|
37352
|
+
});
|
|
37280
37353
|
var propsCmd = program2.command("properties").alias("props").alias("targets").description("Manage scan/pentest targets (properties) in the current org").action(async () => {
|
|
37281
37354
|
await propertiesListCommand({});
|
|
37282
37355
|
});
|