@profullstack/threatcrush 0.13.57 → 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 +203 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40445,15 +40445,15 @@ function httpSender(cfg) {
|
|
|
40445
40445
|
});
|
|
40446
40446
|
const raw = await resp.text();
|
|
40447
40447
|
if (cfg.responsePath === "text") return raw;
|
|
40448
|
-
let
|
|
40448
|
+
let json2;
|
|
40449
40449
|
try {
|
|
40450
|
-
|
|
40450
|
+
json2 = JSON.parse(raw);
|
|
40451
40451
|
} catch {
|
|
40452
40452
|
return raw;
|
|
40453
40453
|
}
|
|
40454
|
-
if (cfg.responsePath) return String(dig(
|
|
40454
|
+
if (cfg.responsePath) return String(dig(json2, cfg.responsePath) ?? "");
|
|
40455
40455
|
return String(
|
|
40456
|
-
dig(
|
|
40456
|
+
dig(json2, "choices.0.message.content") ?? dig(json2, "choices.0.text") ?? dig(json2, "message.content") ?? dig(json2, "content") ?? dig(json2, "output") ?? dig(json2, "response") ?? dig(json2, "text") ?? raw
|
|
40457
40457
|
);
|
|
40458
40458
|
};
|
|
40459
40459
|
}
|
|
@@ -44222,12 +44222,12 @@ async function reportToAbuseIPDB(payload, apiKey) {
|
|
|
44222
44222
|
if (res.status === 429) {
|
|
44223
44223
|
return { destination: "abuseipdb", ok: false, detail: "rate-limited by AbuseIPDB (daily cap)" };
|
|
44224
44224
|
}
|
|
44225
|
-
const
|
|
44225
|
+
const json2 = await res.json().catch(() => ({}));
|
|
44226
44226
|
if (!res.ok) {
|
|
44227
|
-
const detail =
|
|
44227
|
+
const detail = json2.errors?.map((e) => e.detail).filter(Boolean).join("; ") || `HTTP ${res.status}`;
|
|
44228
44228
|
return { destination: "abuseipdb", ok: false, detail };
|
|
44229
44229
|
}
|
|
44230
|
-
const score =
|
|
44230
|
+
const score = json2.data?.abuseConfidenceScore;
|
|
44231
44231
|
return { destination: "abuseipdb", ok: true, detail: score !== void 0 ? `confidence ${score}` : "reported" };
|
|
44232
44232
|
} catch (err) {
|
|
44233
44233
|
return { destination: "abuseipdb", ok: false, detail: err.message };
|
|
@@ -44704,6 +44704,13 @@ var RemediationConsumer = class {
|
|
|
44704
44704
|
}, 3e3).unref?.();
|
|
44705
44705
|
return { status: "executed", executed_at };
|
|
44706
44706
|
}
|
|
44707
|
+
case "update": {
|
|
44708
|
+
if (!this.opts.updateNow) return failed("update not supported by this daemon");
|
|
44709
|
+
this.opts.log("[cloud] dashboard requested an update");
|
|
44710
|
+
const outcome = await this.opts.updateNow();
|
|
44711
|
+
if (outcome.startsWith("updated to") || outcome.startsWith("up to date")) return { status: "executed", executed_at };
|
|
44712
|
+
return failed(outcome);
|
|
44713
|
+
}
|
|
44707
44714
|
default:
|
|
44708
44715
|
return failed(`unsupported action_type: ${action.action_type}`);
|
|
44709
44716
|
}
|
|
@@ -44871,8 +44878,13 @@ var AutoUpdate = class {
|
|
|
44871
44878
|
}, ms);
|
|
44872
44879
|
this.timer.unref?.();
|
|
44873
44880
|
}
|
|
44874
|
-
/**
|
|
44875
|
-
|
|
44881
|
+
/**
|
|
44882
|
+
* One check; returns what it did, for logs and tests.
|
|
44883
|
+
* `force` is the dashboard's "Update now": no min_age wait and no
|
|
44884
|
+
* retry-after-a-day for a version that failed before. `restartDelayMs`
|
|
44885
|
+
* restarts that much later, so the action's result is reported first.
|
|
44886
|
+
*/
|
|
44887
|
+
async check(opts = {}) {
|
|
44876
44888
|
if (this.busy) return "busy";
|
|
44877
44889
|
this.busy = true;
|
|
44878
44890
|
try {
|
|
@@ -44889,13 +44901,13 @@ var AutoUpdate = class {
|
|
|
44889
44901
|
}
|
|
44890
44902
|
const pick = pickUpdate(doc, this.opts.version, {
|
|
44891
44903
|
allowMajor: this.opts.settings.allowMajor,
|
|
44892
|
-
minAgeMs: this.opts.settings.minAgeMs,
|
|
44904
|
+
minAgeMs: opts.force ? 0 : this.opts.settings.minAgeMs,
|
|
44893
44905
|
now: this.now()
|
|
44894
44906
|
});
|
|
44895
44907
|
if (pick.version === null) return this.note(pick.reason, !pick.reason.startsWith("up to date"));
|
|
44896
44908
|
const target = pick.version;
|
|
44897
44909
|
const last = this.lastAttempt();
|
|
44898
|
-
if (last?.version === target && this.now() - last.at < RETRY_AFTER_MS) {
|
|
44910
|
+
if (!opts.force && last?.version === target && this.now() - last.at < RETRY_AFTER_MS) {
|
|
44899
44911
|
return this.note(`${target} was tried at ${new Date(last.at).toISOString()} and did not take; retrying after a day`);
|
|
44900
44912
|
}
|
|
44901
44913
|
const plan = installPlan({
|
|
@@ -44918,7 +44930,8 @@ var AutoUpdate = class {
|
|
|
44918
44930
|
return this.note(`install of ${target} failed (exit ${code}): ${tail}`);
|
|
44919
44931
|
}
|
|
44920
44932
|
this.opts.log(`[update] ${target} installed; restarting onto it`);
|
|
44921
|
-
this.opts.restartDaemon();
|
|
44933
|
+
if (opts.restartDelayMs) setTimeout(() => this.opts.restartDaemon(), opts.restartDelayMs).unref?.();
|
|
44934
|
+
else this.opts.restartDaemon();
|
|
44922
44935
|
return `updated to ${target}`;
|
|
44923
44936
|
} finally {
|
|
44924
44937
|
this.busy = false;
|
|
@@ -47446,6 +47459,7 @@ async function runDaemon() {
|
|
|
47446
47459
|
}
|
|
47447
47460
|
let cloudSync = null;
|
|
47448
47461
|
let remediationConsumer = null;
|
|
47462
|
+
let autoUpdateRef = null;
|
|
47449
47463
|
let allowlistSync = null;
|
|
47450
47464
|
if (config.cloud?.enabled === false) {
|
|
47451
47465
|
logLine("[cloud] disabled by [cloud] enabled = false");
|
|
@@ -47462,7 +47476,12 @@ async function runDaemon() {
|
|
|
47462
47476
|
runHardening: runHardeningChecks
|
|
47463
47477
|
});
|
|
47464
47478
|
cloudSync.start();
|
|
47465
|
-
remediationConsumer = new RemediationConsumer(remediation, {
|
|
47479
|
+
remediationConsumer = new RemediationConsumer(remediation, {
|
|
47480
|
+
log: logLine,
|
|
47481
|
+
restartDaemon,
|
|
47482
|
+
// autoUpdate is created below; the action only runs once polling starts.
|
|
47483
|
+
updateNow: () => autoUpdateRef ? autoUpdateRef.check({ force: true, restartDelayMs: 3e3 }) : Promise.resolve("updater not started")
|
|
47484
|
+
});
|
|
47466
47485
|
remediationConsumer.start();
|
|
47467
47486
|
allowlistSync = new AllowlistSync(remediation, { log: logLine });
|
|
47468
47487
|
allowlistSync.start();
|
|
@@ -47472,7 +47491,7 @@ async function runDaemon() {
|
|
|
47472
47491
|
const abuseReporter = new AbuseReporter({ bus, section: config.abuse_reporter, log: logLine });
|
|
47473
47492
|
abuseReporter.start();
|
|
47474
47493
|
const watchdog = startWatchdog({ bus, config: config.watchdog, stateDir: PATHS.stateDir, log: logLine });
|
|
47475
|
-
const autoUpdate = new AutoUpdate({
|
|
47494
|
+
const autoUpdate = autoUpdateRef = new AutoUpdate({
|
|
47476
47495
|
version,
|
|
47477
47496
|
settings: updateSettings(config.update),
|
|
47478
47497
|
pkgRoot: (0, import_node_path33.join)(__dirname, ".."),
|
|
@@ -49008,11 +49027,11 @@ function computeScore(results) {
|
|
|
49008
49027
|
if (maxScore === 0) return 100;
|
|
49009
49028
|
return Math.max(0, Math.round((maxScore - deductions) / maxScore * 100));
|
|
49010
49029
|
}
|
|
49011
|
-
async function uploadFindings(results,
|
|
49012
|
-
const say = (line2) =>
|
|
49030
|
+
async function uploadFindings(results, json2) {
|
|
49031
|
+
const say = (line2) => json2 ? console.error(line2) : console.log(line2);
|
|
49013
49032
|
const link = currentLink();
|
|
49014
49033
|
if (!link) {
|
|
49015
|
-
if (!
|
|
49034
|
+
if (!json2) say(source_default.gray(" Not linked to the dashboard; run `threatcrush servers link` to upload findings.\n"));
|
|
49016
49035
|
return;
|
|
49017
49036
|
}
|
|
49018
49037
|
let res;
|
|
@@ -50269,7 +50288,7 @@ init_ipc_client();
|
|
|
50269
50288
|
// src/core/user-agent.ts
|
|
50270
50289
|
init_cli_config();
|
|
50271
50290
|
var USER_AGENT = `threatcrush/${PKG_VERSION} (node ${process.version}; ${process.platform})`;
|
|
50272
|
-
function isOurHost(url,
|
|
50291
|
+
function isOurHost(url, api4 = apiUrl()) {
|
|
50273
50292
|
let host;
|
|
50274
50293
|
try {
|
|
50275
50294
|
host = new URL(url).hostname.toLowerCase();
|
|
@@ -50278,7 +50297,7 @@ function isOurHost(url, api3 = apiUrl()) {
|
|
|
50278
50297
|
}
|
|
50279
50298
|
let apiHost = "";
|
|
50280
50299
|
try {
|
|
50281
|
-
apiHost = new URL(
|
|
50300
|
+
apiHost = new URL(api4).hostname.toLowerCase();
|
|
50282
50301
|
} catch {
|
|
50283
50302
|
}
|
|
50284
50303
|
return host === apiHost || host === "threatcrush.com" || host.endsWith(".threatcrush.com");
|
|
@@ -50407,6 +50426,135 @@ async function uploadResult(result, opts) {
|
|
|
50407
50426
|
}
|
|
50408
50427
|
}
|
|
50409
50428
|
|
|
50429
|
+
// src/commands/webhooks.ts
|
|
50430
|
+
init_cli_config();
|
|
50431
|
+
function orgOrExplain() {
|
|
50432
|
+
if (!hasSession()) {
|
|
50433
|
+
console.log(source_default.red(` Not signed in. Run ${source_default.white("threatcrush login")} first.
|
|
50434
|
+
`));
|
|
50435
|
+
process.exitCode = 1;
|
|
50436
|
+
return null;
|
|
50437
|
+
}
|
|
50438
|
+
const org = readCliConfig().current_org_id;
|
|
50439
|
+
if (!org) {
|
|
50440
|
+
console.log(source_default.red(` No current org. Run ${source_default.white("threatcrush orgs use <slug>")}.
|
|
50441
|
+
`));
|
|
50442
|
+
process.exitCode = 1;
|
|
50443
|
+
return null;
|
|
50444
|
+
}
|
|
50445
|
+
return org;
|
|
50446
|
+
}
|
|
50447
|
+
async function api2(path2, init) {
|
|
50448
|
+
const org = orgOrExplain();
|
|
50449
|
+
if (!org) return null;
|
|
50450
|
+
const res = await cloudFetch(`/api/v1/webhooks${path2}?org_id=${encodeURIComponent(org)}`, init);
|
|
50451
|
+
const data = await res.json().catch(() => ({}));
|
|
50452
|
+
if (!res.ok) {
|
|
50453
|
+
console.log(source_default.red(` ${data.error || `HTTP ${res.status}`}${res.status === 401 ? ` \u2014 run ${source_default.white("threatcrush login")}` : ""}
|
|
50454
|
+
`));
|
|
50455
|
+
process.exitCode = 1;
|
|
50456
|
+
return null;
|
|
50457
|
+
}
|
|
50458
|
+
return data;
|
|
50459
|
+
}
|
|
50460
|
+
var json = (v) => console.log(JSON.stringify(v, null, 2));
|
|
50461
|
+
function printSecret(id, secret) {
|
|
50462
|
+
console.log(source_default.green(`
|
|
50463
|
+
Signing secret for ${id} (shown once, keep it in your vault):`));
|
|
50464
|
+
console.log(` ${source_default.white(secret)}`);
|
|
50465
|
+
console.log(source_default.dim(" Verify the webhook-signature header with any Standard Webhooks library.\n"));
|
|
50466
|
+
}
|
|
50467
|
+
async function webhooksListCommand(opts = {}) {
|
|
50468
|
+
const data = await api2("");
|
|
50469
|
+
if (!data) return;
|
|
50470
|
+
if (opts.json) return json(data);
|
|
50471
|
+
console.log(source_default.bold("\n Webhook endpoints") + source_default.dim(` events: ${data.event_types.join(", ")}
|
|
50472
|
+
`));
|
|
50473
|
+
if (!data.endpoints.length) {
|
|
50474
|
+
console.log(source_default.dim(` None yet. Add one: threatcrush webhooks add <https-url> [--events detection.created,findings.*]
|
|
50475
|
+
`));
|
|
50476
|
+
return;
|
|
50477
|
+
}
|
|
50478
|
+
for (const e of data.endpoints) {
|
|
50479
|
+
const state = e.enabled ? source_default.green("on ") : source_default.gray("off");
|
|
50480
|
+
console.log(` ${source_default.gray(e.id)} ${state} ${e.url}`);
|
|
50481
|
+
console.log(source_default.dim(` ${e.events.join(", ")}${e.description ? ` \xB7 ${e.description}` : ""}${e.failures ? ` \xB7 ${e.failures} failures in a row` : ""}${e.disabled_reason ? ` \xB7 ${e.disabled_reason}` : ""}`));
|
|
50482
|
+
}
|
|
50483
|
+
console.log();
|
|
50484
|
+
}
|
|
50485
|
+
async function webhooksAddCommand(url, opts) {
|
|
50486
|
+
const body = {
|
|
50487
|
+
url,
|
|
50488
|
+
...opts.events ? { events: opts.events.split(",").map((s) => s.trim()).filter(Boolean) } : {},
|
|
50489
|
+
...opts.description ? { description: opts.description } : {}
|
|
50490
|
+
};
|
|
50491
|
+
const data = await api2("", { method: "POST", body: JSON.stringify(body) });
|
|
50492
|
+
if (!data) return;
|
|
50493
|
+
if (opts.json) return json(data);
|
|
50494
|
+
console.log(source_default.green(` Added ${data.endpoint.id} \u2192 ${data.endpoint.url} (${data.endpoint.events.join(", ")})`));
|
|
50495
|
+
printSecret(data.endpoint.id, data.secret);
|
|
50496
|
+
}
|
|
50497
|
+
async function webhooksUpdateCommand(id, opts) {
|
|
50498
|
+
const patch = {};
|
|
50499
|
+
if (opts.url) patch.url = opts.url;
|
|
50500
|
+
if (opts.events) patch.events = opts.events.split(",").map((s) => s.trim()).filter(Boolean);
|
|
50501
|
+
if (opts.description !== void 0) patch.description = opts.description;
|
|
50502
|
+
if (opts.enable) patch.enabled = true;
|
|
50503
|
+
if (opts.disable) patch.enabled = false;
|
|
50504
|
+
const data = await api2(`/${encodeURIComponent(id)}`, { method: "PATCH", body: JSON.stringify(patch) });
|
|
50505
|
+
if (!data) return;
|
|
50506
|
+
if (opts.json) return json(data);
|
|
50507
|
+
console.log(source_default.green(` Updated ${data.id}: ${data.enabled ? "on" : "off"}, ${data.url}, ${data.events.join(", ")}
|
|
50508
|
+
`));
|
|
50509
|
+
}
|
|
50510
|
+
async function webhooksRemoveCommand(id) {
|
|
50511
|
+
if (await api2(`/${encodeURIComponent(id)}`, { method: "DELETE" })) console.log(source_default.green(` Removed ${id}
|
|
50512
|
+
`));
|
|
50513
|
+
}
|
|
50514
|
+
async function webhooksTestCommand(id) {
|
|
50515
|
+
const r = await api2(`/${encodeURIComponent(id)}/test`, { method: "POST" });
|
|
50516
|
+
if (!r) return;
|
|
50517
|
+
if (r.ok) console.log(source_default.green(` Test delivered (HTTP ${r.status})
|
|
50518
|
+
`));
|
|
50519
|
+
else {
|
|
50520
|
+
console.log(source_default.red(` Test failed: ${r.error ?? `HTTP ${r.status}`}
|
|
50521
|
+
`));
|
|
50522
|
+
process.exitCode = 1;
|
|
50523
|
+
}
|
|
50524
|
+
}
|
|
50525
|
+
async function webhooksSecretCommand(id, opts) {
|
|
50526
|
+
const r = opts.rotate ? await api2(`/${encodeURIComponent(id)}/rotate`, { method: "POST" }) : await api2(`/${encodeURIComponent(id)}/secret`);
|
|
50527
|
+
if (r) printSecret(id, r.secret);
|
|
50528
|
+
}
|
|
50529
|
+
async function webhooksDeliveriesCommand(id, opts) {
|
|
50530
|
+
const limit = Math.min(200, Number(opts.limit) || 20);
|
|
50531
|
+
const path2 = id ? `/${encodeURIComponent(id)}/deliveries` : "/deliveries";
|
|
50532
|
+
const org = readCliConfig().current_org_id;
|
|
50533
|
+
if (!org) return void orgOrExplain();
|
|
50534
|
+
const res = await cloudFetch(`/api/v1/webhooks${path2}?org_id=${encodeURIComponent(org)}&limit=${limit}`);
|
|
50535
|
+
const data = await res.json().catch(() => ({}));
|
|
50536
|
+
if (!res.ok) {
|
|
50537
|
+
console.log(source_default.red(` ${data.error || `HTTP ${res.status}`}
|
|
50538
|
+
`));
|
|
50539
|
+
process.exitCode = 1;
|
|
50540
|
+
return;
|
|
50541
|
+
}
|
|
50542
|
+
if (opts.json) return json(data);
|
|
50543
|
+
const rows2 = data.deliveries ?? [];
|
|
50544
|
+
if (!rows2.length) return void console.log(source_default.dim(" No deliveries yet.\n"));
|
|
50545
|
+
for (const d of rows2) {
|
|
50546
|
+
const color = d.status === "delivered" ? source_default.green : d.status === "failed" ? source_default.red : source_default.yellow;
|
|
50547
|
+
console.log(` ${source_default.gray(d.created_at.slice(0, 19).replace("T", " "))} ${color(d.status.padEnd(9))} ${d.event_type.padEnd(20)} ${d.attempts} tries${d.last_status ? `, HTTP ${d.last_status}` : ""}${d.last_error ? source_default.dim(` \xB7 ${d.last_error}`) : ""}`);
|
|
50548
|
+
}
|
|
50549
|
+
console.log(source_default.dim(`
|
|
50550
|
+
Resend one: threatcrush webhooks retry <delivery-id>
|
|
50551
|
+
`));
|
|
50552
|
+
}
|
|
50553
|
+
async function webhooksRetryCommand(deliveryId) {
|
|
50554
|
+
if (await api2(`/deliveries/${encodeURIComponent(deliveryId)}/retry`, { method: "POST" })) console.log(source_default.green(` Queued ${deliveryId} again
|
|
50555
|
+
`));
|
|
50556
|
+
}
|
|
50557
|
+
|
|
50410
50558
|
// src/commands/findings.ts
|
|
50411
50559
|
init_cli_config();
|
|
50412
50560
|
var TRIAGE = {
|
|
@@ -50430,7 +50578,7 @@ var STATUS_LABEL = {
|
|
|
50430
50578
|
false_positive: "false+",
|
|
50431
50579
|
ignored: "ignored"
|
|
50432
50580
|
};
|
|
50433
|
-
function
|
|
50581
|
+
function orgOrExplain2() {
|
|
50434
50582
|
if (!hasSession()) {
|
|
50435
50583
|
console.log(source_default.red(` Not signed in. Run ${source_default.white("threatcrush login")} first.
|
|
50436
50584
|
`));
|
|
@@ -50446,7 +50594,7 @@ function orgOrExplain() {
|
|
|
50446
50594
|
}
|
|
50447
50595
|
return org;
|
|
50448
50596
|
}
|
|
50449
|
-
async function
|
|
50597
|
+
async function api3(path2, init) {
|
|
50450
50598
|
const res = await cloudFetch(path2, init);
|
|
50451
50599
|
const data = await res.json().catch(() => ({}));
|
|
50452
50600
|
if (!res.ok) {
|
|
@@ -50460,14 +50608,14 @@ async function api2(path2, init) {
|
|
|
50460
50608
|
var short = (id) => id.slice(0, 8);
|
|
50461
50609
|
var day = (iso) => iso.slice(0, 10);
|
|
50462
50610
|
async function findingsListCommand(opts) {
|
|
50463
|
-
const org =
|
|
50611
|
+
const org = orgOrExplain2();
|
|
50464
50612
|
if (!org) return;
|
|
50465
50613
|
const qs = new URLSearchParams();
|
|
50466
50614
|
if (opts.status) qs.set("status", opts.status);
|
|
50467
50615
|
if (opts.severity) qs.set("severity", opts.severity);
|
|
50468
50616
|
if (opts.source) qs.set("source", opts.source);
|
|
50469
50617
|
qs.set("limit", String(Math.min(500, Number(opts.limit) || 100)));
|
|
50470
|
-
const data = await
|
|
50618
|
+
const data = await api3(`/api/orgs/${org}/scan-findings?${qs}`);
|
|
50471
50619
|
if (!data) return;
|
|
50472
50620
|
if (opts.json) {
|
|
50473
50621
|
console.log(JSON.stringify(data, null, 2));
|
|
@@ -50497,7 +50645,7 @@ async function resolveIds(org, prefixes) {
|
|
|
50497
50645
|
const full = prefixes.filter((p) => /^[0-9a-f-]{36}$/i.test(p));
|
|
50498
50646
|
const partial = prefixes.filter((p) => !full.includes(p));
|
|
50499
50647
|
if (!partial.length) return full;
|
|
50500
|
-
const data = await
|
|
50648
|
+
const data = await api3(`/api/orgs/${org}/scan-findings?status=all&limit=500`);
|
|
50501
50649
|
if (!data) return null;
|
|
50502
50650
|
for (const p of partial) {
|
|
50503
50651
|
const hits = data.findings.filter((f) => f.id.startsWith(p.toLowerCase()));
|
|
@@ -50512,11 +50660,11 @@ async function resolveIds(org, prefixes) {
|
|
|
50512
50660
|
return full;
|
|
50513
50661
|
}
|
|
50514
50662
|
async function findingsShowCommand(id, opts) {
|
|
50515
|
-
const org =
|
|
50663
|
+
const org = orgOrExplain2();
|
|
50516
50664
|
if (!org) return;
|
|
50517
50665
|
const [full] = await resolveIds(org, [id]) ?? [];
|
|
50518
50666
|
if (!full) return;
|
|
50519
|
-
const data = await
|
|
50667
|
+
const data = await api3(`/api/orgs/${org}/scan-findings/${full}`);
|
|
50520
50668
|
if (!data) return;
|
|
50521
50669
|
if (opts.json) {
|
|
50522
50670
|
console.log(JSON.stringify(data.finding, null, 2));
|
|
@@ -50536,7 +50684,7 @@ async function findingsShowCommand(id, opts) {
|
|
|
50536
50684
|
console.log();
|
|
50537
50685
|
}
|
|
50538
50686
|
async function findingsTriageCommand(verb, ids, opts) {
|
|
50539
|
-
const org =
|
|
50687
|
+
const org = orgOrExplain2();
|
|
50540
50688
|
if (!org) return;
|
|
50541
50689
|
if (!ids.length) {
|
|
50542
50690
|
console.log(source_default.red(` Give at least one finding id (see threatcrush findings).
|
|
@@ -50548,7 +50696,7 @@ async function findingsTriageCommand(verb, ids, opts) {
|
|
|
50548
50696
|
if (!full) return;
|
|
50549
50697
|
const body = { ids: full, status: TRIAGE[verb] };
|
|
50550
50698
|
if (opts.note !== void 0) body.note = opts.note;
|
|
50551
|
-
const data = await
|
|
50699
|
+
const data = await api3(`/api/orgs/${org}/scan-findings`, { method: "PATCH", body: JSON.stringify(body) });
|
|
50552
50700
|
if (!data) return;
|
|
50553
50701
|
console.log(source_default.green(` \u2713 ${data.updated.length} finding(s) \u2192 ${TRIAGE[verb].replace("_", " ")}
|
|
50554
50702
|
`));
|
|
@@ -50910,6 +51058,33 @@ for (const verb of Object.keys(TRIAGE)) {
|
|
|
50910
51058
|
await findingsTriageCommand(verb, ids, opts);
|
|
50911
51059
|
});
|
|
50912
51060
|
}
|
|
51061
|
+
var webhooks = program2.command("webhooks").description("Your org's webhook endpoints: detection.created, findings.raised, reputation.changed (also on the web app and MCP)").option("--json", "emit JSON").action(async (opts) => {
|
|
51062
|
+
await webhooksListCommand(opts);
|
|
51063
|
+
});
|
|
51064
|
+
webhooks.command("list").description("List endpoints").option("--json", "emit JSON").action(async (opts) => {
|
|
51065
|
+
await webhooksListCommand(opts);
|
|
51066
|
+
});
|
|
51067
|
+
webhooks.command("add <url>").description("Add an endpoint (prints its signing secret once)").option("--events <list>", "comma list of patterns: *, detection.created, findings.*, ... (default *)").option("--description <text>", "a note for you").option("--json", "emit JSON").action(async (url, opts) => {
|
|
51068
|
+
await webhooksAddCommand(url, opts);
|
|
51069
|
+
});
|
|
51070
|
+
webhooks.command("update <id>").description("Change url, events, description, or switch on/off").option("--url <url>").option("--events <list>").option("--description <text>").option("--enable", "switch on (clears the failure count)").option("--disable", "switch off").option("--json", "emit JSON").action(async (id, opts) => {
|
|
51071
|
+
await webhooksUpdateCommand(id, opts);
|
|
51072
|
+
});
|
|
51073
|
+
webhooks.command("rm <id>").alias("remove").description("Remove an endpoint").action(async (id) => {
|
|
51074
|
+
await webhooksRemoveCommand(id);
|
|
51075
|
+
});
|
|
51076
|
+
webhooks.command("test <id>").description("Send a signed webhook.test now").action(async (id) => {
|
|
51077
|
+
await webhooksTestCommand(id);
|
|
51078
|
+
});
|
|
51079
|
+
webhooks.command("secret <id>").description("Show the signing secret (--rotate replaces it; the old one stops working)").option("--rotate", "make a new secret").action(async (id, opts) => {
|
|
51080
|
+
await webhooksSecretCommand(id, opts);
|
|
51081
|
+
});
|
|
51082
|
+
webhooks.command("deliveries [id]").description("Recent deliveries, for one endpoint or all").option("--limit <n>", "how many (max 200)").option("--json", "emit JSON").action(async (id, opts) => {
|
|
51083
|
+
await webhooksDeliveriesCommand(id, opts);
|
|
51084
|
+
});
|
|
51085
|
+
webhooks.command("retry <deliveryId>").description("Send one delivery again").action(async (id) => {
|
|
51086
|
+
await webhooksRetryCommand(id);
|
|
51087
|
+
});
|
|
50913
51088
|
program2.command("status").description("Show daemon status and loaded modules").action(async () => {
|
|
50914
51089
|
await statusCommand();
|
|
50915
51090
|
});
|