@profullstack/threatcrush 0.13.58 → 0.13.59
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 +26 -7
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +26 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -17113,6 +17113,13 @@ var RemediationConsumer = class {
|
|
|
17113
17113
|
}, 3e3).unref?.();
|
|
17114
17114
|
return { status: "executed", executed_at };
|
|
17115
17115
|
}
|
|
17116
|
+
case "update": {
|
|
17117
|
+
if (!this.opts.updateNow) return failed("update not supported by this daemon");
|
|
17118
|
+
this.opts.log("[cloud] dashboard requested an update");
|
|
17119
|
+
const outcome = await this.opts.updateNow();
|
|
17120
|
+
if (outcome.startsWith("updated to") || outcome.startsWith("up to date")) return { status: "executed", executed_at };
|
|
17121
|
+
return failed(outcome);
|
|
17122
|
+
}
|
|
17116
17123
|
default:
|
|
17117
17124
|
return failed(`unsupported action_type: ${action.action_type}`);
|
|
17118
17125
|
}
|
|
@@ -17279,8 +17286,13 @@ var AutoUpdate = class {
|
|
|
17279
17286
|
}, ms);
|
|
17280
17287
|
this.timer.unref?.();
|
|
17281
17288
|
}
|
|
17282
|
-
/**
|
|
17283
|
-
|
|
17289
|
+
/**
|
|
17290
|
+
* One check; returns what it did, for logs and tests.
|
|
17291
|
+
* `force` is the dashboard's "Update now": no min_age wait and no
|
|
17292
|
+
* retry-after-a-day for a version that failed before. `restartDelayMs`
|
|
17293
|
+
* restarts that much later, so the action's result is reported first.
|
|
17294
|
+
*/
|
|
17295
|
+
async check(opts = {}) {
|
|
17284
17296
|
if (this.busy) return "busy";
|
|
17285
17297
|
this.busy = true;
|
|
17286
17298
|
try {
|
|
@@ -17297,13 +17309,13 @@ var AutoUpdate = class {
|
|
|
17297
17309
|
}
|
|
17298
17310
|
const pick = pickUpdate(doc, this.opts.version, {
|
|
17299
17311
|
allowMajor: this.opts.settings.allowMajor,
|
|
17300
|
-
minAgeMs: this.opts.settings.minAgeMs,
|
|
17312
|
+
minAgeMs: opts.force ? 0 : this.opts.settings.minAgeMs,
|
|
17301
17313
|
now: this.now()
|
|
17302
17314
|
});
|
|
17303
17315
|
if (pick.version === null) return this.note(pick.reason, !pick.reason.startsWith("up to date"));
|
|
17304
17316
|
const target = pick.version;
|
|
17305
17317
|
const last = this.lastAttempt();
|
|
17306
|
-
if (last?.version === target && this.now() - last.at < RETRY_AFTER_MS) {
|
|
17318
|
+
if (!opts.force && last?.version === target && this.now() - last.at < RETRY_AFTER_MS) {
|
|
17307
17319
|
return this.note(`${target} was tried at ${new Date(last.at).toISOString()} and did not take; retrying after a day`);
|
|
17308
17320
|
}
|
|
17309
17321
|
const plan = installPlan({
|
|
@@ -17326,7 +17338,8 @@ var AutoUpdate = class {
|
|
|
17326
17338
|
return this.note(`install of ${target} failed (exit ${code}): ${tail}`);
|
|
17327
17339
|
}
|
|
17328
17340
|
this.opts.log(`[update] ${target} installed; restarting onto it`);
|
|
17329
|
-
this.opts.restartDaemon();
|
|
17341
|
+
if (opts.restartDelayMs) setTimeout(() => this.opts.restartDaemon(), opts.restartDelayMs).unref?.();
|
|
17342
|
+
else this.opts.restartDaemon();
|
|
17330
17343
|
return `updated to ${target}`;
|
|
17331
17344
|
} finally {
|
|
17332
17345
|
this.busy = false;
|
|
@@ -20015,6 +20028,7 @@ async function runDaemon() {
|
|
|
20015
20028
|
}
|
|
20016
20029
|
let cloudSync = null;
|
|
20017
20030
|
let remediationConsumer = null;
|
|
20031
|
+
let autoUpdateRef = null;
|
|
20018
20032
|
let allowlistSync = null;
|
|
20019
20033
|
if (config.cloud?.enabled === false) {
|
|
20020
20034
|
logLine("[cloud] disabled by [cloud] enabled = false");
|
|
@@ -20031,7 +20045,12 @@ async function runDaemon() {
|
|
|
20031
20045
|
runHardening: runHardeningChecks
|
|
20032
20046
|
});
|
|
20033
20047
|
cloudSync.start();
|
|
20034
|
-
remediationConsumer = new RemediationConsumer(remediation, {
|
|
20048
|
+
remediationConsumer = new RemediationConsumer(remediation, {
|
|
20049
|
+
log: logLine,
|
|
20050
|
+
restartDaemon,
|
|
20051
|
+
// autoUpdate is created below; the action only runs once polling starts.
|
|
20052
|
+
updateNow: () => autoUpdateRef ? autoUpdateRef.check({ force: true, restartDelayMs: 3e3 }) : Promise.resolve("updater not started")
|
|
20053
|
+
});
|
|
20035
20054
|
remediationConsumer.start();
|
|
20036
20055
|
allowlistSync = new AllowlistSync(remediation, { log: logLine });
|
|
20037
20056
|
allowlistSync.start();
|
|
@@ -20041,7 +20060,7 @@ async function runDaemon() {
|
|
|
20041
20060
|
const abuseReporter = new AbuseReporter({ bus, section: config.abuse_reporter, log: logLine });
|
|
20042
20061
|
abuseReporter.start();
|
|
20043
20062
|
const watchdog = startWatchdog({ bus, config: config.watchdog, stateDir: PATHS.stateDir, log: logLine });
|
|
20044
|
-
const autoUpdate = new AutoUpdate({
|
|
20063
|
+
const autoUpdate = autoUpdateRef = new AutoUpdate({
|
|
20045
20064
|
version,
|
|
20046
20065
|
settings: updateSettings(config.update),
|
|
20047
20066
|
pkgRoot: (0, import_node_path23.join)(__dirname, ".."),
|