@profullstack/threatcrush 0.13.54 → 0.13.56
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/README.md +3 -1
- package/dist/index.js +31 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -182,7 +182,9 @@ threatcrush findings show 3f2a9c1d
|
|
|
182
182
|
threatcrush findings ack|fix|fp|ignore|reopen 3f2a9c1d 7b1e… --note "why"
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
In CI, set `THREATCRUSH_API_KEY` to a `tc_agent_` key with write and runs
|
|
186
|
+
upload into that key's org with no login (workflow example in
|
|
187
|
+
docs/SCANNING.md). `--no-upload` (or `THREATCRUSH_UPLOAD=0`) keeps a run local. A repo is named by
|
|
186
188
|
its origin remote (credentials stripped); URL targets lose their query string.
|
|
187
189
|
|
|
188
190
|
### Usage counts
|
package/dist/index.js
CHANGED
|
@@ -50251,7 +50251,8 @@ async function uploadResult(result, opts) {
|
|
|
50251
50251
|
const say = (line2) => (opts.machineReadable ? process.stderr : process.stdout).write(`${line2}
|
|
50252
50252
|
`);
|
|
50253
50253
|
if (uploadDisabled(opts.upload, opts.env)) return { uploaded: false, reason: "disabled" };
|
|
50254
|
-
|
|
50254
|
+
const apiKey = (opts.env ?? process.env).THREATCRUSH_API_KEY?.trim();
|
|
50255
|
+
if (!apiKey && !hasSession()) {
|
|
50255
50256
|
if (!opts.machineReadable && process.stdout.isTTY) {
|
|
50256
50257
|
say(source_default.dim(` Sign in with ${source_default.white("threatcrush login")} to track these findings in the cloud and triage them anywhere.
|
|
50257
50258
|
`));
|
|
@@ -50259,29 +50260,33 @@ async function uploadResult(result, opts) {
|
|
|
50259
50260
|
return { uploaded: false, reason: "signed-out" };
|
|
50260
50261
|
}
|
|
50261
50262
|
const cfg = readCliConfig();
|
|
50262
|
-
if (!cfg.current_org_id) {
|
|
50263
|
+
if (!apiKey && !cfg.current_org_id) {
|
|
50263
50264
|
say(source_default.yellow(` Not saved to the cloud: no current org. Pick one with ${source_default.white("threatcrush orgs use <slug>")}.
|
|
50264
50265
|
`));
|
|
50265
50266
|
return { uploaded: false, reason: "no-org" };
|
|
50266
50267
|
}
|
|
50267
50268
|
try {
|
|
50268
|
-
const
|
|
50269
|
-
|
|
50270
|
-
|
|
50271
|
-
|
|
50272
|
-
|
|
50273
|
-
|
|
50274
|
-
|
|
50275
|
-
|
|
50276
|
-
|
|
50277
|
-
result:
|
|
50278
|
-
|
|
50279
|
-
|
|
50280
|
-
|
|
50281
|
-
|
|
50282
|
-
}
|
|
50283
|
-
})
|
|
50269
|
+
const body = JSON.stringify({
|
|
50270
|
+
source: opts.source,
|
|
50271
|
+
target: opts.target,
|
|
50272
|
+
kind: opts.kind,
|
|
50273
|
+
scope: opts.scope ?? "",
|
|
50274
|
+
worker_id: workerId(),
|
|
50275
|
+
result: {
|
|
50276
|
+
// ai-scan and pentest put the target URL in each finding's location:
|
|
50277
|
+
// clean it like the target, or a ?key= in the URL reaches the cloud.
|
|
50278
|
+
findings: result.findings.map((f) => f.location && /^https?:\/\//i.test(f.location) ? { ...f, location: cleanUrl(f.location) } : f),
|
|
50279
|
+
severity_summary: result.severity_summary,
|
|
50280
|
+
summary: result.summary,
|
|
50281
|
+
error: result.error
|
|
50282
|
+
}
|
|
50284
50283
|
});
|
|
50284
|
+
const res = apiKey ? await fetch(`${apiUrl()}/api/v1/findings/report`, {
|
|
50285
|
+
method: "POST",
|
|
50286
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` },
|
|
50287
|
+
body,
|
|
50288
|
+
signal: AbortSignal.timeout(3e4)
|
|
50289
|
+
}) : await cloudFetch(`/api/orgs/${cfg.current_org_id}/scan-findings/report`, { method: "POST", timeoutMs: 3e4, body });
|
|
50285
50290
|
const data = await res.json().catch(() => ({}));
|
|
50286
50291
|
if (!res.ok || !data.sync) {
|
|
50287
50292
|
say(source_default.yellow(` Not saved to the cloud: ${data.error || `HTTP ${res.status}`}.
|
|
@@ -50289,10 +50294,15 @@ async function uploadResult(result, opts) {
|
|
|
50289
50294
|
return { uploaded: false, reason: "error" };
|
|
50290
50295
|
}
|
|
50291
50296
|
const s = data.sync;
|
|
50292
|
-
const org = cfg.current_org_slug || "your org";
|
|
50293
50297
|
const parts = [`${s.new} new`, `${s.seen + s.reopened} still open${s.reopened ? ` (${s.reopened} back after a fix)` : ""}`, `${s.fixed} fixed`];
|
|
50294
|
-
|
|
50298
|
+
if (apiKey) {
|
|
50299
|
+
say(source_default.cyan(` \u2601 Saved to the API key's org: ${parts.join(" \xB7 ")}. Triage on threatcrush.com (Findings).
|
|
50295
50300
|
`));
|
|
50301
|
+
} else {
|
|
50302
|
+
const org = cfg.current_org_slug || "your org";
|
|
50303
|
+
say(source_default.cyan(` \u2601 Saved to ${org}: ${parts.join(" \xB7 ")}. Triage with ${source_default.white("threatcrush findings")} or on threatcrush.com/org/${org}/findings
|
|
50304
|
+
`));
|
|
50305
|
+
}
|
|
50296
50306
|
return { uploaded: true, sync: s, propertyName: data.property_name };
|
|
50297
50307
|
} catch (err) {
|
|
50298
50308
|
say(source_default.yellow(` Not saved to the cloud: ${err.message}.
|
|
@@ -50379,7 +50389,7 @@ async function findingsListCommand(opts) {
|
|
|
50379
50389
|
for (const f of data.findings) {
|
|
50380
50390
|
const sev = (SEV_COLOR[f.severity] ?? source_default.white)(f.severity.toUpperCase().padEnd(8));
|
|
50381
50391
|
console.log(` ${source_default.gray(short(f.id))} ${sev} ${source_default.dim((STATUS_LABEL[f.status] ?? f.status).padEnd(7))} ${f.message}`);
|
|
50382
|
-
console.log(source_default.dim(` ${f.source} \xB7 ${f.properties?.name ?? "?"}${f.location ? ` \xB7 ${f.location}` : ""} \xB7 seen ${f.times_seen}x, last ${day(f.last_seen_at)}`));
|
|
50392
|
+
console.log(source_default.dim(` ${f.source} \xB7 ${f.properties?.name ?? "?"}${f.location && f.location !== f.properties?.target ? ` \xB7 ${f.location}` : ""} \xB7 seen ${f.times_seen}x, last ${day(f.last_seen_at)}`));
|
|
50383
50393
|
}
|
|
50384
50394
|
if (data.total > data.findings.length) console.log(source_default.dim(`
|
|
50385
50395
|
${data.findings.length} of ${data.total} shown; --limit for more.`));
|