@crimson-crawler/crimson-crawler-client 4.1.1 → 5.0.1
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/NOTICE +21 -0
- package/README.md +198 -94
- package/dist/.package-build.json +1 -1
- package/dist/_generated/index.cjs +54 -34
- package/dist/_generated/index.d.cts +2 -2
- package/dist/_generated/index.d.ts +2 -2
- package/dist/_generated/index.js +1 -1
- package/dist/_generated/sdk.gen.cjs +54 -34
- package/dist/_generated/sdk.gen.d.cts +402 -173
- package/dist/_generated/sdk.gen.d.ts +402 -173
- package/dist/_generated/sdk.gen.js +1 -1
- package/dist/_generated/types.gen.d.cts +14117 -3953
- package/dist/_generated/types.gen.d.ts +14117 -3953
- package/dist/{chunk-4HSWOQA6.cjs → chunk-ASYQPVBW.cjs} +46 -0
- package/dist/{chunk-C53EHGN4.js → chunk-EZD3XBDV.js} +86 -65
- package/dist/{chunk-2X3CCE46.js → chunk-MHC5LRPW.js} +42 -1
- package/dist/{chunk-4PCL3ANB.cjs → chunk-TAMKRTM6.cjs} +87 -64
- package/dist/index.cjs +900 -175
- package/dist/index.d.cts +558 -99
- package/dist/index.d.ts +558 -99
- package/dist/index.js +851 -130
- package/dist/presets-cAYp-Cru.d.cts +122 -0
- package/dist/presets-cAYp-Cru.d.ts +122 -0
- package/dist/presets.cjs +27 -19
- package/dist/presets.d.cts +1 -1
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +1 -1
- package/package.json +9 -5
- package/dist/presets-BMN8jy08.d.cts +0 -110
- package/dist/presets-BMN8jy08.d.ts +0 -110
package/dist/index.js
CHANGED
|
@@ -1,9 +1,55 @@
|
|
|
1
|
-
import { CVE_FULL_WALK, IOC_FULL_WALK, CWE_FULL_WALK, TECHNIQUE_FULL, PRODUCT_FULL, PACKAGE_FULL, ATLAS_FULL, CAMPAIGN_FULL, CAPEC_FULL, DEFEND_FULL, DISARM_FULL, GROUP_FULL, LOCATION_FULL, SECTOR_FULL, SOFTWARE_FULL } from './chunk-
|
|
2
|
-
export { presets_exports as presets } from './chunk-
|
|
3
|
-
import { enrichCve, enrichIoc, enrichCwe, enrichTechnique, enrichProduct, enrichPackage, searchCti, enrichAtlas, enrichCampaign, enrichCapec, enrichDefend, enrichDisarm, enrichGroup, enrichLocation, enrichSector, enrichSoftware, enrichBatch, enrichPocSource, assessGroupExposure, assessIocPortfolio, assessTechniqueCoverage, assessVulnerabilityExposure, searchCve, searchD3Fend, searchKev, searchKnowledgebase, searchMisp, searchPoc, searchVendor, artifactEnrich, artifactEnrichStatus, inventoryEnrich, inventoryEnrichStatus } from './chunk-
|
|
1
|
+
import { CVE_FULL_WALK, IOC_FULL_WALK, CWE_FULL_WALK, TECHNIQUE_FULL, PRODUCT_FULL, PACKAGE_FULL, ATLAS_FULL, CAMPAIGN_FULL, CAPEC_FULL, CLOAK_FULL, DEFEND_FULL, DISARM_FULL, F3_FULL, GROUP_FULL, LOCATION_FULL, SECTOR_FULL, SOFTWARE_FULL } from './chunk-EZD3XBDV.js';
|
|
2
|
+
export { presets_exports as presets } from './chunk-EZD3XBDV.js';
|
|
3
|
+
import { enrichCve, enrichIoc, enrichCwe, enrichTechnique, enrichProduct, enrichPackage, searchCti, enrichAtlas, enrichCampaign, enrichCapec, enrichCloak, enrichDefend, enrichDisarm, enrichF3, enrichGroup, enrichLocation, enrichSector, enrichSoftware, enrichBatch, enrichPocSource, assessGroupExposure, assessIocPortfolio, assessTechniqueCoverage, assessVulnerabilityExposure, searchCve, searchD3Fend, searchKev, searchCsaf, searchKnowledgebase, searchMisp, searchPoc, searchVendor, artifactEnrich, artifactEnrichStatus, inventoryEnrich, inventoryEnrichStatus, eventEnrich, eventEnrichStatus } from './chunk-MHC5LRPW.js';
|
|
4
4
|
import { createClient, client } from './chunk-QU4MM663.js';
|
|
5
5
|
import './chunk-MLKGABMK.js';
|
|
6
6
|
|
|
7
|
+
// src/cve-catalog.ts
|
|
8
|
+
function resolve(entries, keys) {
|
|
9
|
+
return keys.map((key) => {
|
|
10
|
+
if (typeof key !== "string" || !entries || !Object.hasOwn(entries, key)) {
|
|
11
|
+
throw new Error("Invalid CVE context catalogue reference");
|
|
12
|
+
}
|
|
13
|
+
return entries[key];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function expandCveContext(page) {
|
|
17
|
+
if (!("cve_context_catalog" in page)) {
|
|
18
|
+
if ((page.cves ?? []).some(
|
|
19
|
+
(row) => Object.keys(row.catalog_refs ?? {}).length
|
|
20
|
+
)) {
|
|
21
|
+
throw new Error("Invalid CVE context catalogue reference");
|
|
22
|
+
}
|
|
23
|
+
return page;
|
|
24
|
+
}
|
|
25
|
+
const catalog = page.cve_context_catalog ?? {};
|
|
26
|
+
for (const row of page.cves ?? []) {
|
|
27
|
+
for (const [field, keys] of Object.entries(row.catalog_refs ?? {})) {
|
|
28
|
+
if (!Array.isArray(keys))
|
|
29
|
+
throw new Error("Invalid CVE context catalogue reference");
|
|
30
|
+
switch (field) {
|
|
31
|
+
case "attack_patterns":
|
|
32
|
+
row.attack_patterns = resolve(catalog.attack_patterns, keys);
|
|
33
|
+
break;
|
|
34
|
+
case "techniques":
|
|
35
|
+
row.techniques = resolve(catalog.techniques, keys);
|
|
36
|
+
break;
|
|
37
|
+
case "mitigations":
|
|
38
|
+
row.mitigations = resolve(catalog.mitigations, keys);
|
|
39
|
+
break;
|
|
40
|
+
case "weaknesses":
|
|
41
|
+
row.weaknesses = resolve(catalog.weaknesses, keys);
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error("Invalid CVE context catalogue reference");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
row.catalog_refs = {};
|
|
48
|
+
}
|
|
49
|
+
page.cve_context_catalog = {};
|
|
50
|
+
return page;
|
|
51
|
+
}
|
|
52
|
+
|
|
7
53
|
// src/exceptions.ts
|
|
8
54
|
var CrawlerClientError = class extends Error {
|
|
9
55
|
constructor(message) {
|
|
@@ -28,6 +74,76 @@ var UnexpectedStatus = class extends CrawlerClientError {
|
|
|
28
74
|
body;
|
|
29
75
|
};
|
|
30
76
|
|
|
77
|
+
// src/paging.ts
|
|
78
|
+
function snapshotExpired(error) {
|
|
79
|
+
if (!(error instanceof UnexpectedStatus) || error.status !== 409)
|
|
80
|
+
return false;
|
|
81
|
+
let body = error.body;
|
|
82
|
+
if (typeof body === "string") {
|
|
83
|
+
try {
|
|
84
|
+
body = JSON.parse(body);
|
|
85
|
+
} catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!body || typeof body !== "object") return false;
|
|
90
|
+
const value = body;
|
|
91
|
+
return value.error === "snapshot_expired" || value.detail?.error === "snapshot_expired";
|
|
92
|
+
}
|
|
93
|
+
async function collectSnapshotPages(fetch, nextOffset) {
|
|
94
|
+
for (let attempt = 0; ; attempt++) {
|
|
95
|
+
const pages = [];
|
|
96
|
+
let offset = 0;
|
|
97
|
+
let snapshotId;
|
|
98
|
+
try {
|
|
99
|
+
for (; ; ) {
|
|
100
|
+
const page = await fetch(offset, snapshotId);
|
|
101
|
+
const current = page.snapshot_id ?? void 0;
|
|
102
|
+
const next = nextOffset(page);
|
|
103
|
+
if (current !== void 0 && (typeof current !== "string" || !current) || snapshotId !== void 0 && current !== snapshotId || next != null && current === void 0) {
|
|
104
|
+
throw new Error("Enrichment returned an invalid snapshot identifier");
|
|
105
|
+
}
|
|
106
|
+
snapshotId = current;
|
|
107
|
+
pages.push(page);
|
|
108
|
+
if (next == null) return pages;
|
|
109
|
+
if (!Number.isInteger(next) || next <= offset) {
|
|
110
|
+
throw new Error("Enrichment returned an invalid next offset");
|
|
111
|
+
}
|
|
112
|
+
offset = next;
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (attempt === 0 && snapshotExpired(error)) continue;
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function* iterOsvPages(fetch) {
|
|
121
|
+
let offset = 0;
|
|
122
|
+
let snapshotId;
|
|
123
|
+
for (; ; ) {
|
|
124
|
+
const page = await fetch(offset, snapshotId);
|
|
125
|
+
if (snapshotId !== void 0 && page.errors?.some(
|
|
126
|
+
(error) => error.service === "osv" && error.error === "stored_copy_unavailable"
|
|
127
|
+
)) {
|
|
128
|
+
throw new Error("stored_copy_unavailable");
|
|
129
|
+
}
|
|
130
|
+
const current = page.osv_snapshot_id ?? void 0;
|
|
131
|
+
const next = page.osv_next_offset;
|
|
132
|
+
if (current !== void 0 && (typeof current !== "string" || !current) || current !== void 0 && snapshotId !== void 0 && current !== snapshotId) {
|
|
133
|
+
throw new Error("Enrichment returned an invalid OSV snapshot identifier");
|
|
134
|
+
}
|
|
135
|
+
if (next != null) {
|
|
136
|
+
if (current === void 0 || !Number.isInteger(next) || next < 0 || snapshotId !== void 0 && next <= offset) {
|
|
137
|
+
throw new Error("Enrichment returned an invalid OSV continuation");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
yield page;
|
|
141
|
+
if (next == null) return;
|
|
142
|
+
offset = next;
|
|
143
|
+
snapshotId = current;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
31
147
|
// src/_auth.ts
|
|
32
148
|
function withApiKeyHeader(input, init, headerName, apiKey, origin) {
|
|
33
149
|
const inherited = init?.headers ?? (input instanceof Request ? input.headers : void 0);
|
|
@@ -35,9 +151,9 @@ function withApiKeyHeader(input, init, headerName, apiKey, origin) {
|
|
|
35
151
|
const raw = typeof input === "string" ? input : input instanceof URL ? input.href : input instanceof Request ? input.url : String(input);
|
|
36
152
|
let sameOrigin;
|
|
37
153
|
try {
|
|
38
|
-
sameOrigin = new URL(raw).origin === origin;
|
|
154
|
+
sameOrigin = !raw.startsWith("//") && !raw.startsWith("/\\") && new URL(raw).origin === origin;
|
|
39
155
|
} catch {
|
|
40
|
-
sameOrigin =
|
|
156
|
+
sameOrigin = false;
|
|
41
157
|
}
|
|
42
158
|
if (sameOrigin) {
|
|
43
159
|
headers.set(headerName, apiKey);
|
|
@@ -45,6 +161,21 @@ function withApiKeyHeader(input, init, headerName, apiKey, origin) {
|
|
|
45
161
|
return headers;
|
|
46
162
|
}
|
|
47
163
|
|
|
164
|
+
// src/tlp.ts
|
|
165
|
+
var TLP_VALUES = [
|
|
166
|
+
"CLEAR",
|
|
167
|
+
"GREEN",
|
|
168
|
+
"AMBER",
|
|
169
|
+
"AMBER+STRICT",
|
|
170
|
+
"RED"
|
|
171
|
+
];
|
|
172
|
+
var TLP_INVALID_MESSAGE = `tlp must be one of ${TLP_VALUES.join(", ")}`;
|
|
173
|
+
function validateTlp(value) {
|
|
174
|
+
if (value === void 0) return void 0;
|
|
175
|
+
if (TLP_VALUES.includes(value)) return value;
|
|
176
|
+
throw new RangeError(TLP_INVALID_MESSAGE);
|
|
177
|
+
}
|
|
178
|
+
|
|
48
179
|
// src/url.ts
|
|
49
180
|
function pathSegment(value) {
|
|
50
181
|
return encodeURIComponent(value);
|
|
@@ -99,6 +230,28 @@ function downloadFilename(disposition, fallback) {
|
|
|
99
230
|
}
|
|
100
231
|
return basename;
|
|
101
232
|
}
|
|
233
|
+
var STOP_STATUSES = {
|
|
234
|
+
502: "generation failed",
|
|
235
|
+
402: "no AI provider",
|
|
236
|
+
429: "rate limited"
|
|
237
|
+
};
|
|
238
|
+
var QUOTA_ERROR = "report_inference_quota_exceeded";
|
|
239
|
+
function errorCode(body) {
|
|
240
|
+
let parsed = body;
|
|
241
|
+
if (typeof body === "string") {
|
|
242
|
+
try {
|
|
243
|
+
parsed = JSON.parse(body);
|
|
244
|
+
} catch {
|
|
245
|
+
return void 0;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return parsed && typeof parsed === "object" ? parsed.error : void 0;
|
|
249
|
+
}
|
|
250
|
+
function stopNote(err) {
|
|
251
|
+
if (err.status === 429 && errorCode(err.body) === QUOTA_ERROR)
|
|
252
|
+
return "quota exhausted";
|
|
253
|
+
return STOP_STATUSES[err.status];
|
|
254
|
+
}
|
|
102
255
|
var AiReportsApi = class {
|
|
103
256
|
baseUrl;
|
|
104
257
|
// True ES2022 private field, not TypeScript `private`: `private` is erased at compile
|
|
@@ -176,12 +329,19 @@ var AiReportsApi = class {
|
|
|
176
329
|
* Create a DRAFT report from a template + source artifacts. Renders the scaffold (static +
|
|
177
330
|
* deterministic data sections) and returns the list of AI sections still to fill.
|
|
178
331
|
*
|
|
179
|
-
*
|
|
332
|
+
* `tlp` is an optional TLP 2.0 marking stored on the report exactly (`CLEAR` / `GREEN` / `AMBER` /
|
|
333
|
+
* `AMBER+STRICT` / `RED`). Omit it to use your default report TLP (the Report Generator's
|
|
334
|
+
* Settings), raised to the most restrictive source marking. An invalid value throws `RangeError`
|
|
335
|
+
* before any request.
|
|
336
|
+
*
|
|
337
|
+
* Resolves `{ id, name, html, ai_sections: [{section_type, label, ...}], skipped: [...], tlp }`.
|
|
180
338
|
*/
|
|
181
339
|
async createDraft(template, options = {}) {
|
|
340
|
+
const tlp = validateTlp(options.tlp);
|
|
182
341
|
const body = { template };
|
|
183
342
|
if (options.sourceIds !== void 0) body.source_ids = options.sourceIds;
|
|
184
343
|
if (options.name !== void 0) body.name = options.name;
|
|
344
|
+
if (tlp !== void 0) body.tlp = tlp;
|
|
185
345
|
return await (await this.request("POST", "/ai-reports/reports", { json: body })).json();
|
|
186
346
|
}
|
|
187
347
|
/**
|
|
@@ -234,13 +394,19 @@ var AiReportsApi = class {
|
|
|
234
394
|
/**
|
|
235
395
|
* Export a report as `html` or `md`. The body IS the export file.
|
|
236
396
|
*
|
|
397
|
+
* `options.tlp` sets the TLP 2.0 marking written into the document (`CLEAR` / `GREEN` / `AMBER` /
|
|
398
|
+
* `AMBER+STRICT` / `RED`), overriding the report's stored TLP; omit it to stamp the report's own
|
|
399
|
+
* stored TLP. An invalid value throws a `RangeError` before any request.
|
|
400
|
+
*
|
|
237
401
|
* Resolves `{ content, bytes, filename, contentType }`. `filename` is a sanitized basename from
|
|
238
|
-
* `Content-Disposition`. PDF/DOCX are browser-editor-only
|
|
402
|
+
* `Content-Disposition`. PDF/DOCX are browser-editor-only. Reports built in the browser export here too.
|
|
239
403
|
*/
|
|
240
|
-
async exportReport(reportId, fmt = "html") {
|
|
404
|
+
async exportReport(reportId, fmt = "html", options = {}) {
|
|
405
|
+
const tlp = validateTlp(options.tlp);
|
|
241
406
|
const resp = await this.request(
|
|
242
407
|
"GET",
|
|
243
|
-
`/ai-reports/reports/${pathSegment(reportId)}/export/${pathSegment(fmt)}
|
|
408
|
+
`/ai-reports/reports/${pathSegment(reportId)}/export/${pathSegment(fmt)}`,
|
|
409
|
+
tlp === void 0 ? {} : { params: { tlp } }
|
|
244
410
|
);
|
|
245
411
|
const disposition = resp.headers.get("content-disposition") ?? "";
|
|
246
412
|
const filename = downloadFilename(disposition, `${reportId}.${fmt}`);
|
|
@@ -254,13 +420,22 @@ var AiReportsApi = class {
|
|
|
254
420
|
}
|
|
255
421
|
/**
|
|
256
422
|
* Generate a report end-to-end: create the draft, fill every AI section, return the finished
|
|
257
|
-
* report. The convenience over `createDraft` + `fillSection
|
|
423
|
+
* report. The convenience over `createDraft` + `fillSection`; `options.tlp` is passed to
|
|
424
|
+
* `createDraft` (an exact marking; omit it for your default raised by the sources).
|
|
258
425
|
*
|
|
259
|
-
*
|
|
426
|
+
* Report sections run on the account's own AI provider (bring-your-own-key, saved in portal
|
|
427
|
+
* API Dashboard → AI Provider). If a section's model call fails (502), generation stops there and
|
|
428
|
+
* returns what filled so far:
|
|
260
429
|
* the report keeps the sections completed before the failure, the failed section is recorded in
|
|
261
430
|
* `sections` as `{ error: "generation failed", status: 502 }`, and that section plus any after it
|
|
262
431
|
* stay unfilled cards. Re-run `generateReport` or fill the rest individually with `fillSection`.
|
|
263
432
|
*
|
|
433
|
+
* No AI key at all (402) stops the loop the same way, recorded as
|
|
434
|
+
* `{ error: "no AI provider", status: 402 }` — add a key, then fill the rest with `fillSection`. A
|
|
435
|
+
* spent daily allowance on the built-in AI (429) is recorded as `{ error: "quota exhausted", status: 429 }`
|
|
436
|
+
* (your own key has no limit), and a gateway rate limit as `{ error: "rate limited", status: 429 }`.
|
|
437
|
+
* Draft creation never calls a model.
|
|
438
|
+
*
|
|
264
439
|
* Resolves `{ report, sections: [<fill result per section>], skipped: [...] }`.
|
|
265
440
|
*/
|
|
266
441
|
async generateReport(template, options = {}) {
|
|
@@ -273,12 +448,12 @@ var AiReportsApi = class {
|
|
|
273
448
|
try {
|
|
274
449
|
result = await this.fillSection(reportId);
|
|
275
450
|
} catch (err) {
|
|
276
|
-
if (err instanceof UnexpectedStatus
|
|
277
|
-
if (err
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
451
|
+
if (!(err instanceof UnexpectedStatus)) throw err;
|
|
452
|
+
if (err.status === 409) break;
|
|
453
|
+
const note = stopNote(err);
|
|
454
|
+
if (note === void 0) throw err;
|
|
455
|
+
sections.push({ error: note, status: err.status });
|
|
456
|
+
break;
|
|
282
457
|
}
|
|
283
458
|
sections.push(result);
|
|
284
459
|
if (result.complete) break;
|
|
@@ -390,14 +565,18 @@ var ArtifactManagerApi = class {
|
|
|
390
565
|
* List your artifacts (newest first, no content).
|
|
391
566
|
*
|
|
392
567
|
* @param options `kind` (input|enrichment|report) · `folder` (UUID or `"__root__"`)
|
|
393
|
-
* · `since`/`until` (ISO `created_at` window)
|
|
568
|
+
* · `since`/`until` (ISO `created_at` window) · `search` (names and contents, like the portal's search box)
|
|
569
|
+
* · `tlp` (filter by exact TLP 2.0 marking; each returned artifact carries its own `tlp`).
|
|
394
570
|
*/
|
|
395
571
|
async listArtifacts(options = {}) {
|
|
572
|
+
const tlp = validateTlp(options.tlp);
|
|
396
573
|
const params = {};
|
|
397
574
|
if (options.kind) params.kind = options.kind;
|
|
398
575
|
if (options.folder) params.folder = options.folder;
|
|
399
576
|
if (options.since) params.since = options.since;
|
|
400
577
|
if (options.until) params.until = options.until;
|
|
578
|
+
if (options.search) params.search = options.search;
|
|
579
|
+
if (tlp !== void 0) params.tlp = tlp;
|
|
401
580
|
const resp = await this.request("GET", "/artifact-manager/artifacts", {
|
|
402
581
|
params
|
|
403
582
|
});
|
|
@@ -407,14 +586,17 @@ var ArtifactManagerApi = class {
|
|
|
407
586
|
* Upload input artifacts (max 20/call, ≤10 MB content each).
|
|
408
587
|
*
|
|
409
588
|
* @param artifacts Each `{ name, content, format: "paste"|"file", mime? }`.
|
|
410
|
-
* @param options File into an existing `folderId`, or create one via `newFolderName
|
|
589
|
+
* @param options File into an existing `folderId`, or create one via `newFolderName`; `tlp` marks
|
|
590
|
+
* EVERY artifact in the batch (default `AMBER`).
|
|
411
591
|
* @returns `{ ids, folderId }` — the new artifact ids.
|
|
412
592
|
*/
|
|
413
593
|
async uploadArtifacts(artifacts, options = {}) {
|
|
594
|
+
const tlp = validateTlp(options.tlp);
|
|
414
595
|
const body = { artifacts };
|
|
415
596
|
if (options.folderId !== void 0) body.folderId = options.folderId;
|
|
416
597
|
if (options.newFolderName !== void 0)
|
|
417
598
|
body.newFolderName = options.newFolderName;
|
|
599
|
+
if (tlp !== void 0) body.tlp = tlp;
|
|
418
600
|
const resp = await this.request("POST", "/artifact-manager/artifacts", {
|
|
419
601
|
json: body
|
|
420
602
|
});
|
|
@@ -447,20 +629,24 @@ var ArtifactManagerApi = class {
|
|
|
447
629
|
name: decodeHeader(resp.headers.get("x-artifact-name"), artifactId),
|
|
448
630
|
format: resp.headers.get("x-artifact-format") ?? "",
|
|
449
631
|
mime: resp.headers.get("x-artifact-mime") ?? "",
|
|
632
|
+
tlp: resp.headers.get("x-artifact-tlp") ?? "",
|
|
450
633
|
created_at: resp.headers.get("x-artifact-created") ?? ""
|
|
451
634
|
};
|
|
452
635
|
}
|
|
453
636
|
/**
|
|
454
|
-
* Partial update: rename, star/unstar, and/or
|
|
637
|
+
* Partial update: rename, star/unstar, move between folders, and/or set the TLP marking.
|
|
455
638
|
*
|
|
456
639
|
* `folderId: null` moves the artifact back to root; omit it to leave the
|
|
457
|
-
* folder unchanged.
|
|
640
|
+
* folder unchanged. A call that sets only `tlp` is valid; an invalid value
|
|
641
|
+
* throws a `RangeError` before any request.
|
|
458
642
|
*/
|
|
459
643
|
async updateArtifact(artifactId, update) {
|
|
644
|
+
const tlp = validateTlp(update.tlp);
|
|
460
645
|
const body = {};
|
|
461
646
|
if (update.name !== void 0) body.name = update.name;
|
|
462
647
|
if (update.favorite !== void 0) body.favorite = update.favorite;
|
|
463
648
|
if ("folderId" in update) body.folderId = update.folderId;
|
|
649
|
+
if (tlp !== void 0) body.tlp = tlp;
|
|
464
650
|
const resp = await this.request(
|
|
465
651
|
"PATCH",
|
|
466
652
|
`/artifact-manager/artifacts/${pathSegment(artifactId)}`,
|
|
@@ -552,12 +738,17 @@ var ArtifactManagerApi = class {
|
|
|
552
738
|
}
|
|
553
739
|
/** Bundle an explicit set of your artifacts into one `.zip` (the bulk "Download .zip"). Enrichments
|
|
554
740
|
* contribute their machine exports under a per-enrichment subfolder; every other kind contributes its raw
|
|
555
|
-
* deliverable. Returns the raw `.zip` bytes.
|
|
556
|
-
|
|
741
|
+
* deliverable. Returns the raw `.zip` bytes. `options.tlp` marks every wrapped export, overriding each
|
|
742
|
+
* artifact's own stored TLP; omit it to mark each with that artifact's own TLP.
|
|
743
|
+
* See {@link downloadFolder} for the whole-folder twin. */
|
|
744
|
+
async downloadBundle(artifactIds, options = {}) {
|
|
745
|
+
const tlp = validateTlp(options.tlp);
|
|
746
|
+
const body = { ids: artifactIds };
|
|
747
|
+
if (tlp !== void 0) body.tlp = tlp;
|
|
557
748
|
const resp = await this.request(
|
|
558
749
|
"POST",
|
|
559
750
|
"/artifact-manager/artifacts/bundle",
|
|
560
|
-
{ json:
|
|
751
|
+
{ json: body }
|
|
561
752
|
);
|
|
562
753
|
return new Uint8Array(await resp.arrayBuffer());
|
|
563
754
|
}
|
|
@@ -591,11 +782,18 @@ var ArtifactManagerApi = class {
|
|
|
591
782
|
return (await resp.json()).formats;
|
|
592
783
|
}
|
|
593
784
|
/** Download one export. The body is the export file; `filename` is a sanitized basename from
|
|
594
|
-
* `Content-Disposition`. Text formats land in `content`; binary XLSX formats in `bytes`.
|
|
595
|
-
|
|
785
|
+
* `Content-Disposition`. Text formats land in `content`; binary XLSX formats in `bytes`.
|
|
786
|
+
*
|
|
787
|
+
* `options.tlp` sets the TLP 2.0 marking written into the export (`CLEAR` / `GREEN` / `AMBER` /
|
|
788
|
+
* `AMBER+STRICT` / `RED`), overriding the artifact's stored TLP; omit it to stamp the artifact's
|
|
789
|
+
* own stored TLP. Formats with no marking slot — OpenVEX, CSV and the
|
|
790
|
+
* DISA eMASS worksheet — ignore it. An invalid value throws a `RangeError` before any request. */
|
|
791
|
+
async getExport(enrichmentId, format, options = {}) {
|
|
792
|
+
const tlp = validateTlp(options.tlp);
|
|
596
793
|
const resp = await this.request(
|
|
597
794
|
"GET",
|
|
598
|
-
`/artifact-manager/artifacts/${pathSegment(enrichmentId)}/exports/${pathSegment(format)}
|
|
795
|
+
`/artifact-manager/artifacts/${pathSegment(enrichmentId)}/exports/${pathSegment(format)}`,
|
|
796
|
+
tlp === void 0 ? {} : { params: { tlp } }
|
|
599
797
|
);
|
|
600
798
|
const disposition = resp.headers.get("content-disposition") ?? "";
|
|
601
799
|
const filename = downloadFilename2(disposition, format);
|
|
@@ -610,11 +808,14 @@ var ArtifactManagerApi = class {
|
|
|
610
808
|
/** Download EVERY machine export of a saved artifact as one `.zip` (one file per format —
|
|
611
809
|
* `stix.json`, `vex.json`, `emass.xlsx`, …). The bulk twin of {@link getExport}, matching the export
|
|
612
810
|
* panel's "Download all (.zip)" button. Works for any saved enrichment / inventory-enrichment /
|
|
613
|
-
* inventory id. Returns the raw `.zip` bytes.
|
|
614
|
-
|
|
811
|
+
* inventory id. Returns the raw `.zip` bytes. `options.tlp` marks each export, overriding the
|
|
812
|
+
* artifact's stored TLP; omit it to stamp each with the artifact's own stored TLP. */
|
|
813
|
+
async downloadAllExports(enrichmentId, options = {}) {
|
|
814
|
+
const tlp = validateTlp(options.tlp);
|
|
615
815
|
const resp = await this.request(
|
|
616
816
|
"GET",
|
|
617
|
-
`/artifact-manager/artifacts/${pathSegment(enrichmentId)}/exports/all
|
|
817
|
+
`/artifact-manager/artifacts/${pathSegment(enrichmentId)}/exports/all`,
|
|
818
|
+
tlp === void 0 ? {} : { params: { tlp } }
|
|
618
819
|
);
|
|
619
820
|
return new Uint8Array(await resp.arrayBuffer());
|
|
620
821
|
}
|
|
@@ -665,14 +866,50 @@ var ArtifactManagerApi = class {
|
|
|
665
866
|
}
|
|
666
867
|
/** Download every artifact filed under a folder as one `<folder>.zip` (the folder "Download .zip").
|
|
667
868
|
* Enrichments contribute their machine exports under a per-enrichment subfolder; every other kind
|
|
668
|
-
* contributes its raw deliverable. Returns the raw `.zip` bytes.
|
|
669
|
-
|
|
869
|
+
* contributes its raw deliverable. Returns the raw `.zip` bytes. `options.tlp` marks every wrapped
|
|
870
|
+
* export, overriding each artifact's own stored TLP; omit it to mark each with that artifact's own
|
|
871
|
+
* stored TLP. */
|
|
872
|
+
async downloadFolder(folderId, options = {}) {
|
|
873
|
+
const tlp = validateTlp(options.tlp);
|
|
670
874
|
const resp = await this.request(
|
|
671
875
|
"GET",
|
|
672
|
-
`/artifact-manager/folders/${pathSegment(folderId)}/exports/all
|
|
876
|
+
`/artifact-manager/folders/${pathSegment(folderId)}/exports/all`,
|
|
877
|
+
tlp === void 0 ? {} : { params: { tlp } }
|
|
673
878
|
);
|
|
674
879
|
return new Uint8Array(await resp.arrayBuffer());
|
|
675
880
|
}
|
|
881
|
+
// -- Enricher settings -------------------------------------------------- //
|
|
882
|
+
/** Your default TLP 2.0 marking for NEW enrichments, as two independent values —
|
|
883
|
+
* `AMBER` for either one you have not set. The Artifact Enricher page's Settings
|
|
884
|
+
* button edits the same two values. */
|
|
885
|
+
async getEnricherSettings() {
|
|
886
|
+
const resp = await this.request("GET", "/artifact-manager/settings");
|
|
887
|
+
return await resp.json();
|
|
888
|
+
}
|
|
889
|
+
/** Set the default marking a NEW enrichment starts from. Pass one or both — only what
|
|
890
|
+
* you pass is written, and the stored pair is returned. An invalid value throws
|
|
891
|
+
* before any request; passing neither throws too.
|
|
892
|
+
*
|
|
893
|
+
* The value is a BASELINE, not an override: an enrichment saved afterwards is marked
|
|
894
|
+
* with the most restrictive of the setting and the artifacts it was built from, so a
|
|
895
|
+
* more restrictive source still wins. An explicit `tlp` on `client.enricher.enrich(...)`
|
|
896
|
+
* overrides `artifact_tlp` for that run's exports. */
|
|
897
|
+
async setEnricherSettings(options) {
|
|
898
|
+
const artifactTlp = validateTlp(options.artifactTlp);
|
|
899
|
+
const inventoryTlp = validateTlp(options.inventoryTlp);
|
|
900
|
+
const json = {};
|
|
901
|
+
if (artifactTlp !== void 0) json.artifact_tlp = artifactTlp;
|
|
902
|
+
if (inventoryTlp !== void 0) json.inventory_tlp = inventoryTlp;
|
|
903
|
+
if (!Object.keys(json).length) {
|
|
904
|
+
throw new RangeError(
|
|
905
|
+
"setEnricherSettings needs artifactTlp and/or inventoryTlp"
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
const resp = await this.request("PUT", "/artifact-manager/settings", {
|
|
909
|
+
json
|
|
910
|
+
});
|
|
911
|
+
return await resp.json();
|
|
912
|
+
}
|
|
676
913
|
};
|
|
677
914
|
|
|
678
915
|
// src/_poll.ts
|
|
@@ -689,8 +926,8 @@ async function beforeDeadline(operation, remaining, enrichmentId) {
|
|
|
689
926
|
if (remaining <= 0) throw timeoutError(enrichmentId);
|
|
690
927
|
let cancelDeadline = () => {
|
|
691
928
|
};
|
|
692
|
-
const deadline = new Promise((
|
|
693
|
-
const timer = setTimeout(() =>
|
|
929
|
+
const deadline = new Promise((resolve2) => {
|
|
930
|
+
const timer = setTimeout(() => resolve2(TIMED_OUT), remaining);
|
|
694
931
|
cancelDeadline = () => clearTimeout(timer);
|
|
695
932
|
});
|
|
696
933
|
void Promise.resolve(operation).catch(() => void 0);
|
|
@@ -745,7 +982,7 @@ async function pollUntilDone(request, enrichmentId, statusPath, opts) {
|
|
|
745
982
|
remaining = remainingMs(deadline);
|
|
746
983
|
await beforeDeadline(
|
|
747
984
|
new Promise(
|
|
748
|
-
(
|
|
985
|
+
(resolve2) => setTimeout(resolve2, Math.min(opts.pollIntervalMs, remaining))
|
|
749
986
|
),
|
|
750
987
|
remaining,
|
|
751
988
|
enrichmentId
|
|
@@ -780,12 +1017,20 @@ function assembleBriefing(report, meta) {
|
|
|
780
1017
|
const actions = [...seen.values()].sort(
|
|
781
1018
|
(a, b) => (a.kev ? 0 : 1) - (b.kev ? 0 : 1) || (b.weaponization_score || 0) - (a.weaponization_score || 0)
|
|
782
1019
|
).slice(0, 10);
|
|
1020
|
+
const unverifiedAssets = assets.filter(
|
|
1021
|
+
(asset) => asset.status !== "error" && (asset.match === "none" || asset.match === "cpe_fuzzy")
|
|
1022
|
+
).map((asset) => ({
|
|
1023
|
+
product: asset.product || asset.name || "\u2014",
|
|
1024
|
+
versions: (Array.isArray(asset.versions) ? asset.versions : []).filter(Boolean).slice(0, 1),
|
|
1025
|
+
match_detail: asset.match_detail ?? null
|
|
1026
|
+
}));
|
|
783
1027
|
const out = {
|
|
784
1028
|
format: meta.format,
|
|
785
1029
|
parsed_count: meta.parsedCount,
|
|
786
1030
|
enrichment_id: meta.enrichmentId,
|
|
787
1031
|
report,
|
|
788
|
-
recommended_actions: actions
|
|
1032
|
+
recommended_actions: actions,
|
|
1033
|
+
unverified_assets: unverifiedAssets
|
|
789
1034
|
};
|
|
790
1035
|
if (meta.truncated) out.truncated = meta.truncated;
|
|
791
1036
|
return out;
|
|
@@ -819,6 +1064,29 @@ function wireContent(content) {
|
|
|
819
1064
|
function wireSources(sources) {
|
|
820
1065
|
return sources.map((s) => ({ ...s, content: wireContent(s.content) }));
|
|
821
1066
|
}
|
|
1067
|
+
function historyParams(opts) {
|
|
1068
|
+
const types = Array.isArray(opts.types) ? opts.types.join(",") : opts.types;
|
|
1069
|
+
const raw = {
|
|
1070
|
+
type: types,
|
|
1071
|
+
q: opts.q,
|
|
1072
|
+
since: opts.since,
|
|
1073
|
+
until: opts.until,
|
|
1074
|
+
actor: opts.actor,
|
|
1075
|
+
limit: opts.limit,
|
|
1076
|
+
cursor: opts.cursor
|
|
1077
|
+
};
|
|
1078
|
+
const params = {};
|
|
1079
|
+
for (const [k, v] of Object.entries(raw))
|
|
1080
|
+
if (v !== void 0) params[k] = String(v);
|
|
1081
|
+
return params;
|
|
1082
|
+
}
|
|
1083
|
+
function manifestVexOverlay(manifest) {
|
|
1084
|
+
const overlay = manifest.vex_overlay;
|
|
1085
|
+
if (!overlay || typeof overlay !== "object" || !("document" in overlay))
|
|
1086
|
+
return void 0;
|
|
1087
|
+
const doc = overlay.document;
|
|
1088
|
+
return typeof doc === "string" && doc.trim() ? doc : void 0;
|
|
1089
|
+
}
|
|
822
1090
|
function inventoryBody(inventoryName, o) {
|
|
823
1091
|
const body = { inventory_name: inventoryName };
|
|
824
1092
|
if (o.description !== void 0) body.description = o.description;
|
|
@@ -931,14 +1199,37 @@ var InventoryManagerApi = class {
|
|
|
931
1199
|
);
|
|
932
1200
|
return (await resp.json()).matrix;
|
|
933
1201
|
}
|
|
1202
|
+
/**
|
|
1203
|
+
* One page of an inventory's change history, newest first. Covers asset, attachment, TLP, rename,
|
|
1204
|
+
* settings and VEX changes, saved enrichments and generated reports. Exports and Copy for AI are
|
|
1205
|
+
* not logged. Pass `cursor` from a previous page's `next_cursor` to continue.
|
|
1206
|
+
*/
|
|
1207
|
+
async getHistory(inventoryId, opts = {}) {
|
|
1208
|
+
const resp = await this.request(
|
|
1209
|
+
"GET",
|
|
1210
|
+
`/inventory-manager/inventories/${pathSegment(inventoryId)}/history`,
|
|
1211
|
+
{ params: historyParams(opts) }
|
|
1212
|
+
);
|
|
1213
|
+
return await resp.json();
|
|
1214
|
+
}
|
|
1215
|
+
/** Yield every history item newest first, following `next_cursor` across pages until exhausted. */
|
|
1216
|
+
async *iterHistory(inventoryId, opts = {}) {
|
|
1217
|
+
let cursor;
|
|
1218
|
+
do {
|
|
1219
|
+
const page = await this.getHistory(inventoryId, { ...opts, cursor });
|
|
1220
|
+
yield* page.items;
|
|
1221
|
+
cursor = page.next_cursor ?? void 0;
|
|
1222
|
+
} while (cursor);
|
|
1223
|
+
}
|
|
934
1224
|
/**
|
|
935
1225
|
* Create an Inventory Manager inventory (a continuously-monitored context window).
|
|
936
1226
|
*
|
|
937
1227
|
* @param inventoryName The inventory's display name.
|
|
938
1228
|
* @param options `description`, `items` (asset inventory — each `{ product, vendor?, versions?,
|
|
939
1229
|
* ecosystem?, category?, criticality?, notes? }`), `monitoring` (always full depth — no fast/lite
|
|
940
|
-
* mode), `linkedArtifactIds
|
|
941
|
-
* @returns `{ id, item_count }
|
|
1230
|
+
* mode), `linkedArtifactIds` (each takes the new inventory's own TLP 2.0 marking).
|
|
1231
|
+
* @returns `{ id, item_count }`, plus `attachment_tlp` / `attachment_tlp_ids` when
|
|
1232
|
+
* `linkedArtifactIds` were passed (the marking carried onto them).
|
|
942
1233
|
*/
|
|
943
1234
|
async createInventory(inventoryName, options = {}) {
|
|
944
1235
|
const resp = await this.request("POST", "/inventory-manager/inventories", {
|
|
@@ -950,7 +1241,10 @@ var InventoryManagerApi = class {
|
|
|
950
1241
|
* Update an inventory's definition (name, description, inventory, monitoring, attachments).
|
|
951
1242
|
* This is a **partial merge** (PATCH): only the fields you pass change — omitted fields are PRESERVED,
|
|
952
1243
|
* including the asset-group metadata and daily-report config this method doesn't expose. `inventoryName`
|
|
953
|
-
* is still required by the API.
|
|
1244
|
+
* is still required by the API. Any artifact newly added through `linkedArtifactIds` takes the
|
|
1245
|
+
* inventory's own TLP 2.0 marking (already-attached artifacts are left alone). Resolves
|
|
1246
|
+
* `{ id, item_count }`, plus `attachment_tlp` / `attachment_tlp_ids` (the marking carried onto newly
|
|
1247
|
+
* attached artifacts).
|
|
954
1248
|
*/
|
|
955
1249
|
async updateInventory(inventoryId, options) {
|
|
956
1250
|
const resp = await this.request(
|
|
@@ -965,10 +1259,14 @@ var InventoryManagerApi = class {
|
|
|
965
1259
|
*
|
|
966
1260
|
* @param options `format` — one of `json` (asset JSON), `sbom` (CycloneDX / SPDX SBOM), `csv`,
|
|
967
1261
|
* `nmap` (nmap `-sV` XML), `list` (CPE / purl list), `grype`, `trivy` (SCA JSON), `depcheck`
|
|
968
|
-
* (OWASP Dependency-Check JSON), `nessus` (`.nessus` XML), `gvm` (OpenVAS / Greenbone XML)
|
|
969
|
-
* `
|
|
970
|
-
*
|
|
971
|
-
*
|
|
1262
|
+
* (OWASP Dependency-Check JSON), `nessus` (`.nessus` XML), `gvm` (OpenVAS / Greenbone XML),
|
|
1263
|
+
* `vex` (a VEX suppression overlay — OpenVEX 0.2.0 / CSAF 2.0 VEX JSON; attaches to the
|
|
1264
|
+
* inventory named by `inventoryId`, or creates a bare inventory holding it — imports NO assets);
|
|
1265
|
+
* `content` — the file's text (or `Uint8Array` for the binary `xlsx`); optional
|
|
1266
|
+
* `inventoryName` / `description` (override anything the file carries).
|
|
1267
|
+
* @returns `{ id, item_count, imported, format, truncated?, dropped? }` — `dropped` (SBOM imports
|
|
1268
|
+
* only) counts dependency edges the parser could not retain (#334). `format:'vex'` returns
|
|
1269
|
+
* `{ id, imported:0, format:'vex', statements }` instead.
|
|
972
1270
|
*/
|
|
973
1271
|
async importInventory(options) {
|
|
974
1272
|
const body = {
|
|
@@ -1000,7 +1298,7 @@ var InventoryManagerApi = class {
|
|
|
1000
1298
|
* override. A binary `xlsx` source can't be sniffed, so it needs `format: "xlsx"` + `Uint8Array` content
|
|
1001
1299
|
* (base64-encoded on the wire). A source that fails to parse is ISOLATED (it appears in `per_source` with
|
|
1002
1300
|
* its `error`, contributing nothing — never failing the whole call).
|
|
1003
|
-
* @returns `{ items, count, asset_groups, truncated?, per_source: [{ label, contributed, truncated?, error? }] }`.
|
|
1301
|
+
* @returns `{ items, count, asset_groups, truncated?, dropped?, per_source: [{ label, contributed, truncated?, dropped?, error? }] }`.
|
|
1004
1302
|
*/
|
|
1005
1303
|
async parseMulti(sources) {
|
|
1006
1304
|
const resp = await this.request(
|
|
@@ -1066,12 +1364,16 @@ var InventoryManagerApi = class {
|
|
|
1066
1364
|
* Apply a recommended upgrade — set the matched asset's version to the published fix the Inventory
|
|
1067
1365
|
* Enricher surfaced (`recommended_fix_version` / `recommended_fix_version_kev`), PRESERVING everything
|
|
1068
1366
|
* else on the inventory. Match is by `product` (case-insensitive; `vendor` disambiguates duplicate
|
|
1069
|
-
* product names).
|
|
1070
|
-
*
|
|
1367
|
+
* product names). This rewrites **every** asset carrying that product — pass `group` to scope the fix
|
|
1368
|
+
* to one host/asset group (`group` is the asset's own grouping, which host-derived imports set per
|
|
1369
|
+
* host). Writes the inventory only — it does NOT re-enrich (the next enrichment / daily monitor
|
|
1370
|
+
* confirms the CVEs cleared). Resolves `{ id, product, version, applied, item_count }` (404 when no
|
|
1371
|
+
* asset matches, or none matches within `group`).
|
|
1071
1372
|
*/
|
|
1072
|
-
async applyAssetFix(inventoryId, product, version, vendor) {
|
|
1373
|
+
async applyAssetFix(inventoryId, product, version, vendor, group) {
|
|
1073
1374
|
const json = { product, version };
|
|
1074
1375
|
if (vendor !== void 0) json.vendor = vendor;
|
|
1376
|
+
if (group !== void 0) json.group = group;
|
|
1075
1377
|
const resp = await this.request(
|
|
1076
1378
|
"PATCH",
|
|
1077
1379
|
`/inventory-manager/inventories/${pathSegment(inventoryId)}/asset-version`,
|
|
@@ -1094,15 +1396,22 @@ var InventoryManagerApi = class {
|
|
|
1094
1396
|
*
|
|
1095
1397
|
* @param inventoryId The inventory id.
|
|
1096
1398
|
* @param format `json` / `csv` / `list` (CPE/purl) / `cyclonedx` / `spdx` (3.0.1) / `spdx2` (SPDX 2.3)
|
|
1097
|
-
* / `workbook` (binary Excel .xlsx). `json` / `csv` / `list` round-trip
|
|
1098
|
-
* {@link importInventory}. Defaults to `json`.
|
|
1099
|
-
|
|
1100
|
-
|
|
1399
|
+
* / `workbook` (binary Excel .xlsx) / `all` (.zip of every format). `json` / `csv` / `list` round-trip
|
|
1400
|
+
* back through {@link importInventory}. Defaults to `json`.
|
|
1401
|
+
* @param options.tlp The TLP 2.0 marking written into the asset-inventory formats that have a slot
|
|
1402
|
+
* (`cyclonedx` / `spdx` / `spdx2` / `workbook`; `CLEAR` / `GREEN` / `AMBER` / `AMBER+STRICT` / `RED`),
|
|
1403
|
+
* overriding the inventory's stored TLP; omit it to stamp the inventory's own stored TLP.
|
|
1404
|
+
* `json` / `csv` / `list` have no marking slot and ignore it. An invalid value
|
|
1405
|
+
* throws a `RangeError` before any request.
|
|
1406
|
+
*/
|
|
1407
|
+
async exportInventory(inventoryId, format = "json", options = {}) {
|
|
1408
|
+
const tlp = validateTlp(options.tlp);
|
|
1101
1409
|
const resp = await this.request(
|
|
1102
1410
|
"GET",
|
|
1103
|
-
`/inventory-manager/inventories/${pathSegment(inventoryId)}/export/${pathSegment(format)}
|
|
1411
|
+
`/inventory-manager/inventories/${pathSegment(inventoryId)}/export/${pathSegment(format)}`,
|
|
1412
|
+
tlp === void 0 ? {} : { params: { tlp } }
|
|
1104
1413
|
);
|
|
1105
|
-
return format === "workbook" ? new Uint8Array(await resp.arrayBuffer()) : await resp.text();
|
|
1414
|
+
return format === "workbook" || format === "all" ? new Uint8Array(await resp.arrayBuffer()) : await resp.text();
|
|
1106
1415
|
}
|
|
1107
1416
|
/** Delete an inventory. Resolves `true` on success (404 throws). */
|
|
1108
1417
|
async deleteInventory(inventoryId) {
|
|
@@ -1112,7 +1421,9 @@ var InventoryManagerApi = class {
|
|
|
1112
1421
|
);
|
|
1113
1422
|
return Boolean((await resp.json()).deleted);
|
|
1114
1423
|
}
|
|
1115
|
-
/** Link an existing artifact to an inventory.
|
|
1424
|
+
/** Link an existing artifact to an inventory. The newly attached artifact takes the INVENTORY's own
|
|
1425
|
+
* TLP 2.0 marking (it can raise or lower the artifact's marking). Resolves to
|
|
1426
|
+
* `{ ok, linked, already, attachment_tlp, attachment_tlp_ids }`. */
|
|
1116
1427
|
async attachToInventory(inventoryId, artifactId) {
|
|
1117
1428
|
const resp = await this.request(
|
|
1118
1429
|
"POST",
|
|
@@ -1138,7 +1449,8 @@ var InventoryManagerApi = class {
|
|
|
1138
1449
|
* REPLACE an inventory's attached reference artifacts in one call (the bulk twin of
|
|
1139
1450
|
* {@link attachToInventory}), PRESERVING its inventory / monitoring / alert-prefs. Only attachable
|
|
1140
1451
|
* kinds (`input` / `enrichment` / `report`) are kept; inventories and inventory enrichments are skipped. Deduped +
|
|
1141
|
-
* capped at 100.
|
|
1452
|
+
* capped at 100. Each newly attached artifact takes the inventory's own TLP 2.0 marking. Resolves
|
|
1453
|
+
* `{ id, linked_count, attached, skipped, mode, attachment_tlp, attachment_tlp_ids }`.
|
|
1142
1454
|
*/
|
|
1143
1455
|
async setAttachments(inventoryId, artifactIds) {
|
|
1144
1456
|
const resp = await this.request(
|
|
@@ -1151,7 +1463,8 @@ var InventoryManagerApi = class {
|
|
|
1151
1463
|
return await resp.json();
|
|
1152
1464
|
}
|
|
1153
1465
|
/** APPEND several artifacts to an inventory's attachments in one call (bulk {@link attachToInventory});
|
|
1154
|
-
* same filtering/cap/return as {@link setAttachments}
|
|
1466
|
+
* same filtering/cap/return as {@link setAttachments} — including the re-marking of the newly attached
|
|
1467
|
+
* artifacts to the inventory's own TLP 2.0 marking. */
|
|
1155
1468
|
async addAttachments(inventoryId, artifactIds) {
|
|
1156
1469
|
const resp = await this.request(
|
|
1157
1470
|
"PATCH",
|
|
@@ -1227,7 +1540,14 @@ var InventoryManagerApi = class {
|
|
|
1227
1540
|
* The enrichment submit is enrichment compute and **counts toward your usage** (it rides your key to
|
|
1228
1541
|
* `/v1/inventory-enrich`); reading the inventory and polling do not.
|
|
1229
1542
|
*
|
|
1230
|
-
*
|
|
1543
|
+
* The inventory's attached **VEX suppression overlay** (imported with `format: 'vex'`) always rides along
|
|
1544
|
+
* as the engine's `vex_overlay`, so findings the VEX marks `not_affected`/`fixed` come back
|
|
1545
|
+
* `suppressed_by_vex` (retained + justification, excluded from the actionable counts) instead of being
|
|
1546
|
+
* re-reported. Nothing to pass — it is read from the inventory manifest.
|
|
1547
|
+
*
|
|
1548
|
+
* Resolves to `{ enrichment_id, report }`; `report` is the InventoryEnrichmentResult (per-asset CVEs with
|
|
1549
|
+
* CVSS vectors, EPSS percentile, NIST LEV (`lev`), KEV detail, Metasploit / Nuclei, `provenance`; plus `technique_catalog` and
|
|
1550
|
+
* `mitigation_catalog`). If the inventory's inventory is empty this short-circuits and
|
|
1231
1551
|
* resolves to `{ enrichment_id: null, empty: true }` without submitting. Throws `UnexpectedStatus` on a
|
|
1232
1552
|
* non-2xx (or enrichment error), or `Error` if the enrichment doesn't finish within `timeoutMs`.
|
|
1233
1553
|
*/
|
|
@@ -1240,13 +1560,13 @@ var InventoryManagerApi = class {
|
|
|
1240
1560
|
const items = Array.isArray(manifest.inventory) ? manifest.inventory : [];
|
|
1241
1561
|
if (items.length === 0) return { enrichment_id: null, empty: true };
|
|
1242
1562
|
const doAttach = options.enrichAttachments ?? manifest.enrich_attachments === true;
|
|
1243
|
-
let
|
|
1563
|
+
let attachmentsTexts = [];
|
|
1244
1564
|
let attachmentsFiles;
|
|
1245
1565
|
let attachmentOmissions = [];
|
|
1246
1566
|
if (doAttach) {
|
|
1247
1567
|
const ids = (Array.isArray(manifest.attached) ? manifest.attached : []).map((a) => a?.id).filter((x) => typeof x === "string");
|
|
1248
1568
|
const resolved = await this.resolveAttachments(ids);
|
|
1249
|
-
|
|
1569
|
+
attachmentsTexts = resolved.texts;
|
|
1250
1570
|
if (resolved.files.length) attachmentsFiles = resolved.files;
|
|
1251
1571
|
attachmentOmissions = resolved.omissions;
|
|
1252
1572
|
if (options.strictAttachments && attachmentOmissions.length) {
|
|
@@ -1257,8 +1577,9 @@ var InventoryManagerApi = class {
|
|
|
1257
1577
|
}
|
|
1258
1578
|
const result = await this.enrichItems(items, {
|
|
1259
1579
|
...options,
|
|
1260
|
-
|
|
1261
|
-
attachmentsFiles
|
|
1580
|
+
attachmentsTexts,
|
|
1581
|
+
attachmentsFiles,
|
|
1582
|
+
vexOverlay: manifestVexOverlay(manifest)
|
|
1262
1583
|
});
|
|
1263
1584
|
if (doAttach) result.attachment_omissions = attachmentOmissions;
|
|
1264
1585
|
if (options.save && result.enrichment_id) {
|
|
@@ -1269,11 +1590,15 @@ var InventoryManagerApi = class {
|
|
|
1269
1590
|
}
|
|
1270
1591
|
return result;
|
|
1271
1592
|
}
|
|
1272
|
-
/** Fetch the inventory's attached artifacts (≤20) and split them for the engine
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1593
|
+
/** Fetch the inventory's attached artifacts (≤20) and split them for the engine: TEXT artifacts become
|
|
1594
|
+
* one `texts` entry each, carrying the id and name of the artifact they came from, and BINARY ones
|
|
1595
|
+
* (`X-Artifact-Format: file`) become raw `files` entries that name their source artifact too.
|
|
1596
|
+
* Attribution is per artifact rather than a whole-run id list — the id is known for the exact block
|
|
1597
|
+
* fetched, so nothing has to be inferred from the text later. Resolution is permissive: every skipped
|
|
1598
|
+
* attachment is returned in `omissions`; callers that need complete evidence should use
|
|
1599
|
+
* `enrichInventory({ strictAttachments: true })`. */
|
|
1275
1600
|
async resolveAttachments(attachmentIds) {
|
|
1276
|
-
const
|
|
1601
|
+
const texts = [];
|
|
1277
1602
|
const files = [];
|
|
1278
1603
|
const omissions = attachmentIds.slice(20).map((attachmentId) => ({
|
|
1279
1604
|
attachment_id: attachmentId,
|
|
@@ -1302,7 +1627,11 @@ var InventoryManagerApi = class {
|
|
|
1302
1627
|
}
|
|
1303
1628
|
}
|
|
1304
1629
|
if (resp.headers.get("X-Artifact-Format") === "file") {
|
|
1305
|
-
files.push({
|
|
1630
|
+
files.push({
|
|
1631
|
+
filename: name,
|
|
1632
|
+
content_b64: content,
|
|
1633
|
+
source_artifact_id: aid
|
|
1634
|
+
});
|
|
1306
1635
|
continue;
|
|
1307
1636
|
}
|
|
1308
1637
|
if (total >= 5e5) {
|
|
@@ -1313,8 +1642,11 @@ var InventoryManagerApi = class {
|
|
|
1313
1642
|
continue;
|
|
1314
1643
|
}
|
|
1315
1644
|
const chunk = content.slice(0, Math.min(8e4, 5e5 - total));
|
|
1316
|
-
|
|
1317
|
-
|
|
1645
|
+
texts.push({
|
|
1646
|
+
text: chunk,
|
|
1647
|
+
source_artifact_id: aid,
|
|
1648
|
+
filename: name
|
|
1649
|
+
});
|
|
1318
1650
|
total += chunk.length;
|
|
1319
1651
|
} catch (error) {
|
|
1320
1652
|
omissions.push({
|
|
@@ -1323,8 +1655,7 @@ ${chunk}`);
|
|
|
1323
1655
|
});
|
|
1324
1656
|
}
|
|
1325
1657
|
}
|
|
1326
|
-
|
|
1327
|
-
return { text: text.trim() ? text : void 0, files, omissions };
|
|
1658
|
+
return { texts, files, omissions };
|
|
1328
1659
|
}
|
|
1329
1660
|
/**
|
|
1330
1661
|
* Persist a COMPLETED inventory enrichment into this inventory's saved history, by its engine
|
|
@@ -1358,8 +1689,14 @@ ${chunk}`);
|
|
|
1358
1689
|
if (options.include) body.include = options.include;
|
|
1359
1690
|
if (options.attachmentsText)
|
|
1360
1691
|
body.attachments_text = options.attachmentsText;
|
|
1692
|
+
if (options.attachmentsTexts?.length)
|
|
1693
|
+
body.attachments_texts = options.attachmentsTexts;
|
|
1694
|
+
if (options.attachedArtifactIds?.length)
|
|
1695
|
+
body.attached_artifact_ids = options.attachedArtifactIds;
|
|
1361
1696
|
if (options.attachmentsFiles?.length)
|
|
1362
1697
|
body.attachments_files = options.attachmentsFiles;
|
|
1698
|
+
if (options.vexOverlay)
|
|
1699
|
+
body.vex_overlay = { format: "vex", content: options.vexOverlay };
|
|
1363
1700
|
const submit = await (await this.request("POST", "/v1/inventory-enrich", { json: body })).json();
|
|
1364
1701
|
const enrichmentId = submit.enrichment_id;
|
|
1365
1702
|
const job = await pollUntilDone(
|
|
@@ -1375,9 +1712,11 @@ ${chunk}`);
|
|
|
1375
1712
|
return { enrichment_id: enrichmentId, report: job.result };
|
|
1376
1713
|
}
|
|
1377
1714
|
/** Parse a scan / inventory FILE into canonical asset items WITHOUT saving anything (the parse-only twin
|
|
1378
|
-
* of `importInventory`). You PICK the `format` — one of json/sbom/csv/nmap/list/grype/trivy/depcheck/nessus/gvm/xlsx
|
|
1379
|
-
* (no auto-detect; pass a `Uint8Array` for the binary `xlsx`
|
|
1380
|
-
* `{
|
|
1715
|
+
* of `importInventory`). You PICK the `format` — one of json/sbom/csv/nmap/list/grype/trivy/depcheck/nessus/gvm/xlsx/vex
|
|
1716
|
+
* (no auto-detect; pass a `Uint8Array` for the binary `xlsx`; `vex` is a VEX suppression overlay
|
|
1717
|
+
* parse — OpenVEX/CSAF — returning `{ items: [], vex_overlay }`). Resolves
|
|
1718
|
+
* `{ format, items, count, inventory_name?, truncated?, dropped? }` (`dropped` — SBOM only — is the
|
|
1719
|
+
* dependency edges not retained, #334). Usage-exempt — the building block for `ingestScan`. */
|
|
1381
1720
|
async parseScan(content, format) {
|
|
1382
1721
|
const resp = await this.request(
|
|
1383
1722
|
"POST",
|
|
@@ -1388,10 +1727,11 @@ ${chunk}`);
|
|
|
1388
1727
|
}
|
|
1389
1728
|
/** Scan → briefing in one call: parse the scan FILE (`parseScan`), enrich the discovered assets against
|
|
1390
1729
|
* the `/v1/inventory-enrich` ranking engine, and assemble a structured briefing. `format` is one of
|
|
1391
|
-
* json/sbom/csv/nmap/list/grype/trivy/depcheck/nessus/gvm/xlsx. The parse is usage-exempt; the enrichment **submit counts
|
|
1730
|
+
* json/sbom/csv/nmap/list/grype/trivy/depcheck/nessus/gvm/xlsx/vex. The parse is usage-exempt; the enrichment **submit counts
|
|
1392
1731
|
* toward usage** (one `/v1/inventory-enrich` request). Resolves
|
|
1393
|
-
* `{ format, parsed_count, truncated?, enrichment_id, report, recommended_actions }`
|
|
1394
|
-
* engine's KEV-first-ranked findings + rollup
|
|
1732
|
+
* `{ format, parsed_count, truncated?, enrichment_id, report, recommended_actions, unverified_assets }`
|
|
1733
|
+
* (report = the engine's KEV-first-ranked findings + rollup; unverified_assets names the assets whose
|
|
1734
|
+
* identity never resolved). An empty parse short-circuits to
|
|
1395
1735
|
* `{ format, parsed_count: 0, enrichment_id: null, empty: true }`. */
|
|
1396
1736
|
async ingestScan(content, format, options = {}) {
|
|
1397
1737
|
return ingestScan(this, content, format, options);
|
|
@@ -1445,8 +1785,13 @@ var EnricherApi = class {
|
|
|
1445
1785
|
/**
|
|
1446
1786
|
* Run an artifact enrichment end-to-end against the /v1 engine: submit → poll → return the report.
|
|
1447
1787
|
*
|
|
1448
|
-
* Stages pasted `text` + base64 `files` (`[{ filename, content_b64 }]`), submits
|
|
1449
|
-
* `/v1/artifact-enrich`, polls the job until done, and resolves to the enrichment report.
|
|
1788
|
+
* Stages pasted `text` + base64 `files` (`[{ filename, content_b64, source_artifact_id? }]`), submits
|
|
1789
|
+
* to `/v1/artifact-enrich`, polls the job until done, and resolves to the enrichment report.
|
|
1790
|
+
*
|
|
1791
|
+
* `texts` is the per-artifact form of `text` (`[{ text, source_artifact_id?, filename? }]`) — use it
|
|
1792
|
+
* when the blocks came from several stored artifacts, so the report attributes each reference to the
|
|
1793
|
+
* artifact it appeared in. `attachedArtifactIds` names the artifacts an opaque `text` blob came from;
|
|
1794
|
+
* attribution is never inferred from the text itself.
|
|
1450
1795
|
*
|
|
1451
1796
|
* `stakeholder` is the optional SSVC stakeholder context applied to every reference when `include`
|
|
1452
1797
|
* contains `"ssvc"` (`{ method, exposure, human_impact, mission_prevalence, public_wellbeing_impact }`;
|
|
@@ -1454,7 +1799,10 @@ var EnricherApi = class {
|
|
|
1454
1799
|
*
|
|
1455
1800
|
* Counts toward your API usage (it's `/v1/artifact-enrich` compute). Throws `UnexpectedStatus` on a
|
|
1456
1801
|
* non-2xx (or enrichment error), or `Error` if the enrichment doesn't finish within `timeoutMs`.
|
|
1457
|
-
* Resolves to `{ enrichment_id, report }`.
|
|
1802
|
+
* Resolves to `{ enrichment_id, report }`. `report` is the ArtifactEnrichmentReport (`report.meta.schema_version`):
|
|
1803
|
+
* each reference carries its full record — CVSS vectors, EPSS percentile, NIST LEV (`lev`), CWEs, the CISA KEV record,
|
|
1804
|
+
* Metasploit / Nuclei, OSV fixed versions, ATT&CK v18 detection data, knowledge-base profiles, threat actors
|
|
1805
|
+
* targeting a country or sector, and `provenance`.
|
|
1458
1806
|
*/
|
|
1459
1807
|
async enrich(options = {}) {
|
|
1460
1808
|
validatePollOptions(
|
|
@@ -1463,10 +1811,15 @@ var EnricherApi = class {
|
|
|
1463
1811
|
);
|
|
1464
1812
|
const body = {};
|
|
1465
1813
|
if (options.text) body.text = options.text;
|
|
1814
|
+
if (options.texts) body.texts = options.texts;
|
|
1466
1815
|
if (options.files) body.files = options.files;
|
|
1816
|
+
if (options.attachedArtifactIds)
|
|
1817
|
+
body.attached_artifact_ids = options.attachedArtifactIds;
|
|
1467
1818
|
if (options.formats) body.formats = options.formats;
|
|
1468
1819
|
if (options.include) body.include = options.include;
|
|
1469
1820
|
if (options.stakeholder) body.stakeholder = options.stakeholder;
|
|
1821
|
+
const tlp = validateTlp(options.tlp);
|
|
1822
|
+
if (tlp !== void 0) body.tlp = tlp;
|
|
1470
1823
|
const submit = await (await this.request("POST", "/v1/artifact-enrich", { json: body })).json();
|
|
1471
1824
|
const enrichmentId = submit.enrichment_id;
|
|
1472
1825
|
const job = await pollUntilDone(
|
|
@@ -1499,6 +1852,40 @@ var EnricherApi = class {
|
|
|
1499
1852
|
}
|
|
1500
1853
|
return result;
|
|
1501
1854
|
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Run an Event Enrichment end-to-end against the /v1 engine: submit → poll → return the result.
|
|
1857
|
+
*
|
|
1858
|
+
* Submits a raw security event (a Defender XDR / Sentinel alert, a SIEM/EDR log line, any JSON or
|
|
1859
|
+
* text) to `/v1/event-enrich`, polls the job until done, and resolves to
|
|
1860
|
+
* `{ enrichment_id, result }` — where `result` is the EventEnrichmentResult (per-indicator
|
|
1861
|
+
* findings + the aggregate event threat assessment). CC extracts every indicator server-side.
|
|
1862
|
+
* Each CVE indicator carries `kev` and `weaponized` (a Metasploit module exists, which floors its
|
|
1863
|
+
* verdict at high); `threat_assessment` counts both as `kev_count` / `weaponized_count`.
|
|
1864
|
+
*
|
|
1865
|
+
* Counts toward your API usage (it's `/v1/event-enrich` compute). Throws `UnexpectedStatus` on a
|
|
1866
|
+
* non-2xx (or enrichment error), or `Error` if the enrichment doesn't finish within `timeoutMs`.
|
|
1867
|
+
*/
|
|
1868
|
+
async enrichEvent(options) {
|
|
1869
|
+
validatePollOptions(
|
|
1870
|
+
options.pollIntervalMs ?? 1500,
|
|
1871
|
+
options.timeoutMs ?? 12e5
|
|
1872
|
+
);
|
|
1873
|
+
const body = { event: options.event };
|
|
1874
|
+
if (options.eventId) body.event_id = options.eventId;
|
|
1875
|
+
const submit = await (await this.request("POST", "/v1/event-enrich", { json: body })).json();
|
|
1876
|
+
const enrichmentId = submit.enrichment_id;
|
|
1877
|
+
const job = await pollUntilDone(
|
|
1878
|
+
(m, p, timeoutMs) => this.request(m, p, { timeoutMs }),
|
|
1879
|
+
enrichmentId,
|
|
1880
|
+
`/v1/event-enrich/${pathSegment(enrichmentId)}`,
|
|
1881
|
+
{
|
|
1882
|
+
pollIntervalMs: options.pollIntervalMs ?? 1500,
|
|
1883
|
+
timeoutMs: options.timeoutMs ?? 12e5,
|
|
1884
|
+
onProgress: options.onProgress
|
|
1885
|
+
}
|
|
1886
|
+
);
|
|
1887
|
+
return { enrichment_id: enrichmentId, result: job.result };
|
|
1888
|
+
}
|
|
1502
1889
|
};
|
|
1503
1890
|
|
|
1504
1891
|
// src/retry.ts
|
|
@@ -1513,7 +1900,7 @@ var RETRY_MAX_DELAY = 8;
|
|
|
1513
1900
|
var RETRY_JITTER_RATIO = 0.25;
|
|
1514
1901
|
var RETRY_AFTER_MAX = 60;
|
|
1515
1902
|
var DEFAULT_MAX_RETRIES = 2;
|
|
1516
|
-
var defaultSleep = (seconds) => new Promise((
|
|
1903
|
+
var defaultSleep = (seconds) => new Promise((resolve2) => setTimeout(resolve2, seconds * 1e3));
|
|
1517
1904
|
function computeBackoff(attempt, rng = Math.random) {
|
|
1518
1905
|
const raw = RETRY_BASE_DELAY * 2 ** attempt;
|
|
1519
1906
|
const jitter = raw * RETRY_JITTER_RATIO * (rng() * 2 - 1);
|
|
@@ -1631,9 +2018,12 @@ var CrawlerClient = class {
|
|
|
1631
2018
|
"verifySsl=false is only supported in Node.js; this runtime cannot disable TLS verification per client."
|
|
1632
2019
|
);
|
|
1633
2020
|
}
|
|
1634
|
-
insecureDispatcher ??= import('undici').then(
|
|
1635
|
-
(
|
|
1636
|
-
|
|
2021
|
+
insecureDispatcher ??= import('undici').then(({ Agent }) => {
|
|
2022
|
+
console.warn(
|
|
2023
|
+
"Crimson Crawler: TLS certificate verification is disabled (verifySsl=false). Do not use in production."
|
|
2024
|
+
);
|
|
2025
|
+
return new Agent({ connect: { rejectUnauthorized: false } });
|
|
2026
|
+
});
|
|
1637
2027
|
const dispatcher = await insecureDispatcher;
|
|
1638
2028
|
const scopedInit = { ...init, dispatcher };
|
|
1639
2029
|
return globalThis.fetch(input, scopedInit);
|
|
@@ -1713,7 +2103,7 @@ var CrawlerClient = class {
|
|
|
1713
2103
|
this._enricher = new EnricherApi(this.baseUrl, apiKey, retryFetch);
|
|
1714
2104
|
this._aiReports = new AiReportsApi(this.baseUrl, apiKey, retryFetch);
|
|
1715
2105
|
}
|
|
1716
|
-
/** Underlying Hey API client, scoped to this instance. Use to call any of the
|
|
2106
|
+
/** Underlying Hey API client, scoped to this instance. Use to call any of the 37 `/v1` operations (31 synchronous + 6 async-engine) directly. */
|
|
1717
2107
|
get api() {
|
|
1718
2108
|
return this._client;
|
|
1719
2109
|
}
|
|
@@ -1731,6 +2121,8 @@ var CrawlerClient = class {
|
|
|
1731
2121
|
* artifacts + saved enrichment history) over the same key. Its own section at
|
|
1732
2122
|
* `/inventory-manager/inventories/*` (outside the `/v1` OpenAPI contract). **Usage-exempt** except
|
|
1733
2123
|
* `enrichInventory`'s submit, which is enrichment compute and counts toward your usage.
|
|
2124
|
+
* For full log sources, PoCs, Sigma rules, or D3FEND rows, call `enrichCveFull` with the CVE ID,
|
|
2125
|
+
* `techniques`, the base layer, and its `*_full` token.
|
|
1734
2126
|
*/
|
|
1735
2127
|
get inventoryManager() {
|
|
1736
2128
|
return this._inventoryManager;
|
|
@@ -1755,23 +2147,57 @@ var CrawlerClient = class {
|
|
|
1755
2147
|
/**
|
|
1756
2148
|
* Walk the full CVE → CWE → CAPEC → ATT&CK → TIE chain plus MISP/knowledge base/web.
|
|
1757
2149
|
*
|
|
2150
|
+
* Returns one page. OSV advisories are paged: while `osv_next_offset` is set, request the next
|
|
2151
|
+
* page with that offset and the response's `osv_snapshot_id`, or stream the whole walk with
|
|
2152
|
+
* {@link iterCveOsvPages}.
|
|
2153
|
+
*
|
|
1758
2154
|
* @param cveId CVE identifier (e.g. `CVE-2024-3400`).
|
|
1759
|
-
* @param include Override
|
|
1760
|
-
|
|
1761
|
-
|
|
2155
|
+
* @param include Override `CVE_FULL_WALK`, which includes stored permissive OSV and Android
|
|
2156
|
+
* bulletin data. Restricted or unknown-licence OSV records require `osv_restricted`, which the
|
|
2157
|
+
* cursor is bound to.
|
|
2158
|
+
* @param options `osvOffset` (from the previous page's `osv_next_offset`) and `osvSnapshotId`
|
|
2159
|
+
* (the previous page's `osv_snapshot_id`; required with a continuation). A continuation answers
|
|
2160
|
+
* 409 `snapshot_expired` when its snapshot is gone and 503 `snapshot_unavailable` when the store is down.
|
|
2161
|
+
*/
|
|
2162
|
+
async enrichCveFull(cveId, include = CVE_FULL_WALK, options = {}) {
|
|
1762
2163
|
const result = await enrichCve({
|
|
1763
2164
|
client: this._client,
|
|
1764
|
-
body: {
|
|
2165
|
+
body: {
|
|
2166
|
+
cve_id: cveId,
|
|
2167
|
+
include: [...include],
|
|
2168
|
+
...options.osvOffset !== void 0 && {
|
|
2169
|
+
osv_offset: options.osvOffset
|
|
2170
|
+
},
|
|
2171
|
+
...options.osvSnapshotId !== void 0 && {
|
|
2172
|
+
osv_snapshot_id: options.osvSnapshotId
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
1765
2175
|
});
|
|
1766
2176
|
return ensureOk(result);
|
|
1767
2177
|
}
|
|
1768
2178
|
/**
|
|
1769
|
-
*
|
|
2179
|
+
* Stream every OSV advisory page of one CVE without an aggregate buffer. The first page is the
|
|
2180
|
+
* complete enrichment; later pages repeat the request with the cursor and carry the next
|
|
2181
|
+
* `osv_advisories` slice. A changed or expired snapshot throws `UnexpectedStatus` (409
|
|
2182
|
+
* `snapshot_expired`) instead of restarting after a yield. The caller owns any collection bound;
|
|
2183
|
+
* `osv_advisories_total` is exact.
|
|
2184
|
+
*/
|
|
2185
|
+
async *iterCveOsvPages(cveId, include = CVE_FULL_WALK) {
|
|
2186
|
+
yield* iterOsvPages(
|
|
2187
|
+
(osvOffset, osvSnapshotId) => this.enrichCveFull(cveId, include, {
|
|
2188
|
+
osvOffset,
|
|
2189
|
+
...osvSnapshotId !== void 0 && { osvSnapshotId }
|
|
2190
|
+
})
|
|
2191
|
+
);
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Enrich an IOC against MISP, link to ATT&CK, and add knowledge base context.
|
|
1770
2195
|
*
|
|
1771
2196
|
* @param value Indicator value (hash, IP, domain, URL).
|
|
1772
2197
|
* @param iocType MISP-style attribute type — `ip-dst`, `ip-src`, `domain`,
|
|
1773
2198
|
* `hostname`, `md5`, `sha1`, `sha256`, `url`, etc. Defaults to `ip-dst`.
|
|
1774
|
-
* @param include Override
|
|
2199
|
+
* @param include Override `IOC_FULL_WALK`. `network_context` and `listed_on` are defaults;
|
|
2200
|
+
* `domain_context` and `hashlookup` remain explicit includes.
|
|
1775
2201
|
*/
|
|
1776
2202
|
async enrichIocFull(value, iocType = "ip-dst", include = IOC_FULL_WALK) {
|
|
1777
2203
|
const result = await enrichIoc({
|
|
@@ -1783,29 +2209,45 @@ var CrawlerClient = class {
|
|
|
1783
2209
|
/**
|
|
1784
2210
|
* Walk CWE → CAPEC → ATT&CK with TIE predictions.
|
|
1785
2211
|
*
|
|
1786
|
-
* @param cweId CWE identifier (e.g. `CWE-79`).
|
|
1787
|
-
* @param
|
|
2212
|
+
* @param cweId CWE identifier (e.g. `CWE-79`). Supply this or `search`.
|
|
2213
|
+
* @param options Optional `search` keyword (discover weaknesses by name) and `include` override.
|
|
1788
2214
|
*/
|
|
1789
|
-
async enrichCweFull(cweId,
|
|
2215
|
+
async enrichCweFull(cweId = null, options = {}) {
|
|
1790
2216
|
const result = await enrichCwe({
|
|
1791
2217
|
client: this._client,
|
|
1792
|
-
body: {
|
|
2218
|
+
body: {
|
|
2219
|
+
cwe_id: cweId ?? void 0,
|
|
2220
|
+
search: options.search,
|
|
2221
|
+
include: [...options.include ?? CWE_FULL_WALK]
|
|
2222
|
+
}
|
|
1793
2223
|
});
|
|
1794
2224
|
return ensureOk(result);
|
|
1795
2225
|
}
|
|
1796
2226
|
/**
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2227
|
+
* Enrich one or more ATT&CK techniques with TIE, adversary attribution,
|
|
2228
|
+
* and Navigator JSON.
|
|
2229
|
+
*
|
|
2230
|
+
* @param techniqueIds ATT&CK technique IDs (e.g. `["T1190", "T1059.001"]`). Omit it when
|
|
2231
|
+
* looking up by `assetId`.
|
|
2232
|
+
* @param framework ATT&CK matrix variant — `enterprise`, `ics`, or `mobile`.
|
|
2233
|
+
* @param include Override the default `TECHNIQUE_FULL` chain. `fraud` (opt-in) adds the MITRE
|
|
2234
|
+
* F3 fraud techniques whose borrowed ATT&CK ids resolve to each returned technique; the
|
|
2235
|
+
* other opt-ins are `fight` (FiGHT techniques by id), `lolbas` (facts-only binaries),
|
|
2236
|
+
* `sigma`, `lotl` (LOLDrivers plus the facts-only GTFOBins and HijackLibs rows mapped
|
|
2237
|
+
* onto the technique), `atomic_red_team` (Atomic Red Team tests: name, GUID, platforms,
|
|
2238
|
+
* executor and elevation flag, never a command body), `framework_mappings`, `asset_classes`, `log_sources` and
|
|
2239
|
+
* `analytic_details`.
|
|
2240
|
+
|
|
2241
|
+
* @param assetId ICS asset to look up from (e.g. `"A0002"`) — returns the techniques that
|
|
2242
|
+
* asset's classes target. Requires `framework: "ics"` and is mutually exclusive with
|
|
2243
|
+
* `techniqueIds`: it is a selector in its own right, not an added filter.
|
|
2244
|
+
*/
|
|
2245
|
+
async enrichTechniqueFull(techniqueIds, framework = "enterprise", include = TECHNIQUE_FULL, assetId) {
|
|
1805
2246
|
const result = await enrichTechnique({
|
|
1806
2247
|
client: this._client,
|
|
1807
2248
|
body: {
|
|
1808
|
-
technique_ids: techniqueIds,
|
|
2249
|
+
...techniqueIds !== void 0 && { technique_ids: techniqueIds },
|
|
2250
|
+
...assetId !== void 0 && { asset_id: assetId },
|
|
1809
2251
|
framework,
|
|
1810
2252
|
include: [...include]
|
|
1811
2253
|
}
|
|
@@ -1813,10 +2255,12 @@ var CrawlerClient = class {
|
|
|
1813
2255
|
return ensureOk(result);
|
|
1814
2256
|
}
|
|
1815
2257
|
/**
|
|
1816
|
-
*
|
|
2258
|
+
* Return one page of enriched CVEs for a product/version.
|
|
2259
|
+
* For full log sources, PoCs, Sigma rules, or D3FEND rows, call `enrichCveFull` with the CVE ID,
|
|
2260
|
+
* `techniques`, the base layer, and its `*_full` token.
|
|
1817
2261
|
*
|
|
1818
|
-
* @param product Product name (e.g. `"
|
|
1819
|
-
* @param options Optional
|
|
2262
|
+
* @param product Product name (e.g. `"http_server"`, `"nginx"`).
|
|
2263
|
+
* @param options Optional version, vendor, include, limit, and offset. The full preset defaults to 2 CVEs per page.
|
|
1820
2264
|
*/
|
|
1821
2265
|
async enrichProductFull(product, options = {}) {
|
|
1822
2266
|
const result = await enrichProduct({
|
|
@@ -1825,10 +2269,22 @@ var CrawlerClient = class {
|
|
|
1825
2269
|
product,
|
|
1826
2270
|
...options.version !== void 0 && { version: options.version },
|
|
1827
2271
|
...options.vendor !== void 0 && { vendor: options.vendor },
|
|
2272
|
+
limit: options.limit ?? 2,
|
|
2273
|
+
...options.offset !== void 0 && { offset: options.offset },
|
|
2274
|
+
...options.snapshotId !== void 0 && {
|
|
2275
|
+
snapshot_id: options.snapshotId
|
|
2276
|
+
},
|
|
1828
2277
|
include: [...options.include ?? PRODUCT_FULL]
|
|
1829
2278
|
}
|
|
1830
2279
|
});
|
|
1831
|
-
return ensureOk(result);
|
|
2280
|
+
return expandCveContext(ensureOk(result));
|
|
2281
|
+
}
|
|
2282
|
+
async *iterProductCves(product, options = {}) {
|
|
2283
|
+
const pages = await collectSnapshotPages(
|
|
2284
|
+
(offset, snapshotId) => this.enrichProductFull(product, { ...options, offset, snapshotId }),
|
|
2285
|
+
(page) => page.cves_next_offset
|
|
2286
|
+
);
|
|
2287
|
+
yield* pages;
|
|
1832
2288
|
}
|
|
1833
2289
|
/**
|
|
1834
2290
|
* Enrich an open-source package — OSV.dev advisories + full CVE enrichment.
|
|
@@ -1849,10 +2305,42 @@ var CrawlerClient = class {
|
|
|
1849
2305
|
ecosystem,
|
|
1850
2306
|
package: packageName,
|
|
1851
2307
|
...options.version !== void 0 && { version: options.version },
|
|
2308
|
+
limit: options.limit ?? 5,
|
|
2309
|
+
...options.offset !== void 0 && { offset: options.offset },
|
|
2310
|
+
...options.snapshotId !== void 0 && {
|
|
2311
|
+
snapshot_id: options.snapshotId
|
|
2312
|
+
},
|
|
1852
2313
|
include: [...options.include ?? PACKAGE_FULL]
|
|
1853
2314
|
}
|
|
1854
2315
|
});
|
|
1855
|
-
return ensureOk(result);
|
|
2316
|
+
return expandCveContext(ensureOk(result));
|
|
2317
|
+
}
|
|
2318
|
+
async *iterPackageAdvisories(ecosystem, packageName, options = {}) {
|
|
2319
|
+
let offset = 0;
|
|
2320
|
+
let snapshotId;
|
|
2321
|
+
while (true) {
|
|
2322
|
+
const page = await this.enrichPackageFull(ecosystem, packageName, {
|
|
2323
|
+
...options,
|
|
2324
|
+
offset,
|
|
2325
|
+
snapshotId
|
|
2326
|
+
});
|
|
2327
|
+
if (page.errors?.some(
|
|
2328
|
+
(error) => error.service === "osv" && error.error === "stored_copy_unavailable"
|
|
2329
|
+
)) {
|
|
2330
|
+
throw new Error("stored_copy_unavailable");
|
|
2331
|
+
}
|
|
2332
|
+
if (snapshotId !== void 0 && page.snapshot_id !== snapshotId) {
|
|
2333
|
+
throw new Error("Enrichment returned a different snapshot identifier");
|
|
2334
|
+
}
|
|
2335
|
+
const nextOffset = page.next_offset;
|
|
2336
|
+
if (nextOffset != null && (!page.snapshot_id || !Number.isInteger(nextOffset) || nextOffset <= offset)) {
|
|
2337
|
+
throw new Error("Enrichment returned an invalid package continuation");
|
|
2338
|
+
}
|
|
2339
|
+
yield page;
|
|
2340
|
+
if (nextOffset == null) return;
|
|
2341
|
+
offset = nextOffset;
|
|
2342
|
+
snapshotId = page.snapshot_id ?? void 0;
|
|
2343
|
+
}
|
|
1856
2344
|
}
|
|
1857
2345
|
/**
|
|
1858
2346
|
* Keyword-search the ATT&CK knowledge base for matching techniques.
|
|
@@ -1935,6 +2423,26 @@ var CrawlerClient = class {
|
|
|
1935
2423
|
});
|
|
1936
2424
|
return ensureOk(result);
|
|
1937
2425
|
}
|
|
2426
|
+
/**
|
|
2427
|
+
* Resolve a CLOAK concealment technique — details and knowledge base context.
|
|
2428
|
+
*
|
|
2429
|
+
* CLOAK objects carry no ATT&CK references, so there is no linked-technique layer:
|
|
2430
|
+
* the response has no `linked_techniques` field at all.
|
|
2431
|
+
*
|
|
2432
|
+
* @param cloakId CLOAK identifier (e.g. `TTP-496`, or a technique slug such as `ta6-te129`).
|
|
2433
|
+
* @param options Optional `search` keyword and `include` override (default `CLOAK_FULL`).
|
|
2434
|
+
*/
|
|
2435
|
+
async enrichCloakFull(cloakId, options = {}) {
|
|
2436
|
+
const result = await enrichCloak({
|
|
2437
|
+
client: this._client,
|
|
2438
|
+
body: {
|
|
2439
|
+
...cloakId !== void 0 && { cloak_id: cloakId },
|
|
2440
|
+
...options.search !== void 0 && { search: options.search },
|
|
2441
|
+
include: [...options.include ?? CLOAK_FULL]
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
return ensureOk(result);
|
|
2445
|
+
}
|
|
1938
2446
|
/**
|
|
1939
2447
|
* Resolve a D3FEND defensive technique and the offensive techniques it counters.
|
|
1940
2448
|
*
|
|
@@ -1953,7 +2461,11 @@ var CrawlerClient = class {
|
|
|
1953
2461
|
return ensureOk(result);
|
|
1954
2462
|
}
|
|
1955
2463
|
/**
|
|
1956
|
-
* Walk a DISARM disinformation technique to its
|
|
2464
|
+
* Walk a DISARM disinformation technique to its family links and context.
|
|
2465
|
+
*
|
|
2466
|
+
* DISARM has no course-of-action objects and no ATT&CK-Enterprise-keyed actors/campaigns, so the
|
|
2467
|
+
* response carries the technique, its DISARM family (`relatedDisarmTechniques`), and the
|
|
2468
|
+
* knowledge-base / web / summary context — nothing else.
|
|
1957
2469
|
*
|
|
1958
2470
|
* @param techniqueId DISARM technique ID (e.g. `T0086`).
|
|
1959
2471
|
* @param options Optional `search` keyword and `include` override (default `DISARM_FULL`).
|
|
@@ -1969,6 +2481,28 @@ var CrawlerClient = class {
|
|
|
1969
2481
|
});
|
|
1970
2482
|
return ensureOk(result);
|
|
1971
2483
|
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Walk a MITRE F3 fraud technique to the ATT&CK techniques it borrows.
|
|
2486
|
+
*
|
|
2487
|
+
* F3 borrows real ATT&CK `T####` ids for the techniques it shares with Enterprise
|
|
2488
|
+
* ATT&CK, so a `T`-shaped id resolves here too. Unlike the other framework walks,
|
|
2489
|
+
* calling with neither an id nor `search` is valid — the server answers 200 with
|
|
2490
|
+
* nothing selected rather than rejecting the request.
|
|
2491
|
+
*
|
|
2492
|
+
* @param f3Id F3 identifier (e.g. `F1031`, `F1025.003`).
|
|
2493
|
+
* @param options Optional `search` keyword and `include` override (default `F3_FULL`).
|
|
2494
|
+
*/
|
|
2495
|
+
async enrichF3Full(f3Id, options = {}) {
|
|
2496
|
+
const result = await enrichF3({
|
|
2497
|
+
client: this._client,
|
|
2498
|
+
body: {
|
|
2499
|
+
...f3Id !== void 0 && { f3_id: f3Id },
|
|
2500
|
+
...options.search !== void 0 && { search: options.search },
|
|
2501
|
+
include: [...options.include ?? F3_FULL]
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
return ensureOk(result);
|
|
2505
|
+
}
|
|
1972
2506
|
/**
|
|
1973
2507
|
* Profile a threat actor: techniques, tooling, campaigns, exploited CVEs, and targeting.
|
|
1974
2508
|
*
|
|
@@ -1983,15 +2517,33 @@ var CrawlerClient = class {
|
|
|
1983
2517
|
...groupId !== void 0 && { group_id: groupId },
|
|
1984
2518
|
...options.search !== void 0 && { search: options.search },
|
|
1985
2519
|
framework: options.framework ?? "enterprise",
|
|
2520
|
+
...options.limit !== void 0 && { limit: options.limit },
|
|
2521
|
+
...options.offset !== void 0 && { offset: options.offset },
|
|
2522
|
+
...options.snapshotId !== void 0 && {
|
|
2523
|
+
snapshot_id: options.snapshotId
|
|
2524
|
+
},
|
|
1986
2525
|
include: [...options.include ?? GROUP_FULL]
|
|
1987
2526
|
}
|
|
1988
2527
|
});
|
|
1989
|
-
|
|
2528
|
+
const page = ensureOk(result);
|
|
2529
|
+
expandGroupCatalogue(
|
|
2530
|
+
page.log_source_catalog,
|
|
2531
|
+
page.log_source_refs,
|
|
2532
|
+
page.group?.techniques
|
|
2533
|
+
);
|
|
2534
|
+
return page;
|
|
2535
|
+
}
|
|
2536
|
+
async *iterGroupPages(groupId, options = {}) {
|
|
2537
|
+
const pages = await collectSnapshotPages(
|
|
2538
|
+
(offset, snapshotId) => this.enrichGroupFull(groupId, { ...options, offset, snapshotId }),
|
|
2539
|
+
(page) => page.techniques_next_offset
|
|
2540
|
+
);
|
|
2541
|
+
yield* pages;
|
|
1990
2542
|
}
|
|
1991
2543
|
/**
|
|
1992
|
-
* Map a region's
|
|
2544
|
+
* Map a region's profile — details plus knowledge base context.
|
|
1993
2545
|
*
|
|
1994
|
-
* @param locationId Region identifier (e.g. `
|
|
2546
|
+
* @param locationId Region identifier (e.g. `US`, or a STIX location ID).
|
|
1995
2547
|
* @param options Optional `search` keyword and `include` override (default `LOCATION_FULL`).
|
|
1996
2548
|
*/
|
|
1997
2549
|
async enrichLocationFull(locationId, options = {}) {
|
|
@@ -2006,9 +2558,9 @@ var CrawlerClient = class {
|
|
|
2006
2558
|
return ensureOk(result);
|
|
2007
2559
|
}
|
|
2008
2560
|
/**
|
|
2009
|
-
* Map an industry sector's
|
|
2561
|
+
* Map an industry sector's profile — details plus knowledge base context.
|
|
2010
2562
|
*
|
|
2011
|
-
* @param sectorId Sector identifier (e.g. `energy`, or
|
|
2563
|
+
* @param sectorId Sector identifier (e.g. `energy`, or a STIX sector ID).
|
|
2012
2564
|
* @param options Optional `search` keyword and `include` override (default `SECTOR_FULL`).
|
|
2013
2565
|
*/
|
|
2014
2566
|
async enrichSectorFull(sectorId, options = {}) {
|
|
@@ -2057,7 +2609,21 @@ var CrawlerClient = class {
|
|
|
2057
2609
|
client: this._client,
|
|
2058
2610
|
body: { items }
|
|
2059
2611
|
});
|
|
2060
|
-
|
|
2612
|
+
const response = ensureOk(result);
|
|
2613
|
+
for (const row of response.results ?? []) {
|
|
2614
|
+
if ((row.type === "product" || row.type === "package") && row.data) {
|
|
2615
|
+
expandCveContext(row.data);
|
|
2616
|
+
}
|
|
2617
|
+
if (row.type === "group" && row.data) {
|
|
2618
|
+
const group = row.data;
|
|
2619
|
+
expandGroupCatalogue(
|
|
2620
|
+
group.log_source_catalog,
|
|
2621
|
+
group.log_source_refs,
|
|
2622
|
+
group.group?.techniques
|
|
2623
|
+
);
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
return response;
|
|
2061
2627
|
}
|
|
2062
2628
|
/**
|
|
2063
2629
|
* Fetch the source of a public proof-of-concept exploit repository.
|
|
@@ -2096,10 +2662,28 @@ var CrawlerClient = class {
|
|
|
2096
2662
|
},
|
|
2097
2663
|
...options.search !== void 0 && { search: [...options.search] },
|
|
2098
2664
|
framework: options.framework ?? "enterprise",
|
|
2665
|
+
...options.limit !== void 0 && { limit: options.limit },
|
|
2666
|
+
...options.offset !== void 0 && { offset: options.offset },
|
|
2667
|
+
...options.snapshotId !== void 0 && {
|
|
2668
|
+
snapshot_id: options.snapshotId
|
|
2669
|
+
},
|
|
2099
2670
|
...options.include !== void 0 && { include: [...options.include] }
|
|
2100
2671
|
}
|
|
2101
2672
|
});
|
|
2102
|
-
|
|
2673
|
+
const page = ensureOk(result);
|
|
2674
|
+
expandGroupCatalogue(
|
|
2675
|
+
page.log_source_catalog,
|
|
2676
|
+
page.log_source_refs,
|
|
2677
|
+
page.techniques
|
|
2678
|
+
);
|
|
2679
|
+
return page;
|
|
2680
|
+
}
|
|
2681
|
+
async *iterGroupExposurePages(options = {}) {
|
|
2682
|
+
const pages = await collectSnapshotPages(
|
|
2683
|
+
(offset, snapshotId) => this.assessGroupExposure({ ...options, offset, snapshotId }),
|
|
2684
|
+
(page) => page.techniques_next_offset
|
|
2685
|
+
);
|
|
2686
|
+
yield* pages;
|
|
2103
2687
|
}
|
|
2104
2688
|
/**
|
|
2105
2689
|
* Assess a portfolio of indicators — MISP corroboration, linked techniques, attribution.
|
|
@@ -2137,9 +2721,14 @@ var CrawlerClient = class {
|
|
|
2137
2721
|
/**
|
|
2138
2722
|
* Prioritize a set of CVEs — weaponization, exploit chains, and remediation order.
|
|
2139
2723
|
*
|
|
2724
|
+
* Returns one page. OSV advisories are aggregated across `cveIds` and paged: while
|
|
2725
|
+
* `osv_next_offset` is set, request the next page with that offset and the response's
|
|
2726
|
+
* `osv_snapshot_id`, or stream the whole walk with {@link iterVulnerabilityExposureOsvPages}.
|
|
2727
|
+
*
|
|
2140
2728
|
* @param cveIds CVE identifiers to assess.
|
|
2141
|
-
* @param options Optional `include` layers
|
|
2142
|
-
* tunes the decision to your
|
|
2729
|
+
* @param options Optional `include` layers (a continuation must repeat them; `osv_restricted`
|
|
2730
|
+
* is the licence opt-in), an SSVC `stakeholder` profile that tunes the decision to your
|
|
2731
|
+
* deployment, and the `osvOffset` / `osvSnapshotId` cursor from the previous page.
|
|
2143
2732
|
*/
|
|
2144
2733
|
async assessVulnerabilityExposure(cveIds, options = {}) {
|
|
2145
2734
|
const result = await assessVulnerabilityExposure({
|
|
@@ -2149,11 +2738,31 @@ var CrawlerClient = class {
|
|
|
2149
2738
|
...options.include !== void 0 && { include: [...options.include] },
|
|
2150
2739
|
...options.stakeholder !== void 0 && {
|
|
2151
2740
|
stakeholder: options.stakeholder
|
|
2741
|
+
},
|
|
2742
|
+
...options.osvOffset !== void 0 && {
|
|
2743
|
+
osv_offset: options.osvOffset
|
|
2744
|
+
},
|
|
2745
|
+
...options.osvSnapshotId !== void 0 && {
|
|
2746
|
+
osv_snapshot_id: options.osvSnapshotId
|
|
2152
2747
|
}
|
|
2153
2748
|
}
|
|
2154
2749
|
});
|
|
2155
2750
|
return ensureOk(result);
|
|
2156
2751
|
}
|
|
2752
|
+
/**
|
|
2753
|
+
* Stream every OSV advisory page of a vulnerability-exposure assessment without an aggregate
|
|
2754
|
+
* buffer. Same contract as {@link iterCveOsvPages}: the first page is the whole assessment, a
|
|
2755
|
+
* changed or expired snapshot throws instead of restarting, and the caller owns any collection bound.
|
|
2756
|
+
*/
|
|
2757
|
+
async *iterVulnerabilityExposureOsvPages(cveIds, options = {}) {
|
|
2758
|
+
yield* iterOsvPages(
|
|
2759
|
+
(osvOffset, osvSnapshotId) => this.assessVulnerabilityExposure(cveIds, {
|
|
2760
|
+
...options,
|
|
2761
|
+
osvOffset,
|
|
2762
|
+
...osvSnapshotId !== void 0 && { osvSnapshotId }
|
|
2763
|
+
})
|
|
2764
|
+
);
|
|
2765
|
+
}
|
|
2157
2766
|
// -- Search ------------------------------------------------------------ //
|
|
2158
2767
|
//
|
|
2159
2768
|
// Search endpoints query a corpus and return matches; they never walk an
|
|
@@ -2180,7 +2789,8 @@ var CrawlerClient = class {
|
|
|
2180
2789
|
...options.deprecated !== void 0 && {
|
|
2181
2790
|
deprecated: options.deprecated
|
|
2182
2791
|
},
|
|
2183
|
-
...options.revoked !== void 0 && { revoked: options.revoked }
|
|
2792
|
+
...options.revoked !== void 0 && { revoked: options.revoked },
|
|
2793
|
+
...options.include !== void 0 && { include: [...options.include] }
|
|
2184
2794
|
}
|
|
2185
2795
|
});
|
|
2186
2796
|
return ensureOk(result);
|
|
@@ -2194,6 +2804,9 @@ var CrawlerClient = class {
|
|
|
2194
2804
|
*
|
|
2195
2805
|
* @param query Free-text query. Omit it to filter purely on the structured fields.
|
|
2196
2806
|
* @param options Any combination of the corpus filters, plus `sort`, `limit`, `page`.
|
|
2807
|
+
* `include` replaces the server defaults: `details`, `statistics`, `cna`, `epss_reports`,
|
|
2808
|
+
* and `kb_rankings` default on. `kb_rankings` keeps the top 100 rows per KB without yearly
|
|
2809
|
+
* trends; `kb_rankings_full` restores all fetched rows and trends.
|
|
2197
2810
|
*/
|
|
2198
2811
|
async searchCve(query, options = {}) {
|
|
2199
2812
|
const result = await searchCve({
|
|
@@ -2251,7 +2864,9 @@ var CrawlerClient = class {
|
|
|
2251
2864
|
* Search the D3FEND defensive-countermeasure ontology.
|
|
2252
2865
|
*
|
|
2253
2866
|
* @param query Free-text query (e.g. `"network traffic analysis"`).
|
|
2254
|
-
* @param options `d3fendForm` to scope to a tactic/mitigation/artifact, plus `limit`, `page
|
|
2867
|
+
* @param options `d3fendForm` to scope to a tactic/mitigation/artifact, plus `limit`, `page`,
|
|
2868
|
+
* and `include`. `versions` defaults on and attaches each returned technique's revision history.
|
|
2869
|
+
* An explicit include replaces the defaults; pass `[]` to omit all optional layers.
|
|
2255
2870
|
*/
|
|
2256
2871
|
async searchD3fend(query, options = {}) {
|
|
2257
2872
|
const result = await searchD3Fend({
|
|
@@ -2262,7 +2877,8 @@ var CrawlerClient = class {
|
|
|
2262
2877
|
d3fend_form: options.d3fendForm
|
|
2263
2878
|
},
|
|
2264
2879
|
limit: options.limit ?? 20,
|
|
2265
|
-
page: options.page ?? 1
|
|
2880
|
+
page: options.page ?? 1,
|
|
2881
|
+
...options.include !== void 0 && { include: [...options.include] }
|
|
2266
2882
|
}
|
|
2267
2883
|
});
|
|
2268
2884
|
return ensureOk(result);
|
|
@@ -2272,7 +2888,9 @@ var CrawlerClient = class {
|
|
|
2272
2888
|
*
|
|
2273
2889
|
* An empty call pages the whole catalog; `cveId` checks one CVE's KEV status.
|
|
2274
2890
|
*
|
|
2275
|
-
* @param options `cveId`, `ransomwareStatus`, `limit`, `page`.
|
|
2891
|
+
* @param options `cveId`, `ransomwareStatus`, `limit`, `page`, and `include`. `statistics`
|
|
2892
|
+
* defaults on for deployment-wide corpus coverage. An explicit include replaces the defaults;
|
|
2893
|
+
* pass `[]` to omit all optional layers.
|
|
2276
2894
|
*/
|
|
2277
2895
|
async searchKev(options = {}) {
|
|
2278
2896
|
const result = await searchKev({
|
|
@@ -2283,6 +2901,35 @@ var CrawlerClient = class {
|
|
|
2283
2901
|
ransomware_status: options.ransomwareStatus
|
|
2284
2902
|
},
|
|
2285
2903
|
limit: options.limit ?? 50,
|
|
2904
|
+
page: options.page ?? 1,
|
|
2905
|
+
...options.include !== void 0 && { include: [...options.include] }
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2908
|
+
return ensureOk(result);
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2911
|
+
* Search the seeded CSAF vendor-advisory corpus.
|
|
2912
|
+
*
|
|
2913
|
+
* Filters combine with AND; this is the door for CVE-less advisories (publisher, sector,
|
|
2914
|
+
* product, CPE, TLP). `total` is the unpaginated match count.
|
|
2915
|
+
*/
|
|
2916
|
+
async searchCsaf(options = {}) {
|
|
2917
|
+
const result = await searchCsaf({
|
|
2918
|
+
client: this._client,
|
|
2919
|
+
body: {
|
|
2920
|
+
...options.cveId !== void 0 && { cve_id: options.cveId },
|
|
2921
|
+
...options.advisoryId !== void 0 && {
|
|
2922
|
+
advisory_id: options.advisoryId
|
|
2923
|
+
},
|
|
2924
|
+
...options.publisher !== void 0 && {
|
|
2925
|
+
publisher: options.publisher
|
|
2926
|
+
},
|
|
2927
|
+
...options.sector !== void 0 && { sector: options.sector },
|
|
2928
|
+
...options.product !== void 0 && { product: options.product },
|
|
2929
|
+
...options.cpe !== void 0 && { cpe: options.cpe },
|
|
2930
|
+
...options.tlp !== void 0 && { tlp: options.tlp },
|
|
2931
|
+
sort: options.sort ?? "newest",
|
|
2932
|
+
limit: options.limit ?? 20,
|
|
2286
2933
|
page: options.page ?? 1
|
|
2287
2934
|
}
|
|
2288
2935
|
});
|
|
@@ -2310,11 +2957,20 @@ var CrawlerClient = class {
|
|
|
2310
2957
|
return ensureOk(result);
|
|
2311
2958
|
}
|
|
2312
2959
|
/**
|
|
2313
|
-
* Search MISP events and attributes.
|
|
2960
|
+
* Search our curated MISP (public threat feeds) for events and attributes.
|
|
2961
|
+
* Feed list: https://crimsoncrawler.com/docs/guides/data-sources/#our-curated-misp.
|
|
2314
2962
|
*
|
|
2315
2963
|
* @param options Attribute filters (`value`, `typeAttribute`, `category`, `toIds`),
|
|
2316
2964
|
* event filters (`eventId`, `eventinfo`, `tags`, `threatLevelId`, `published`),
|
|
2317
2965
|
* a `dateFrom`/`dateTo` window, plus `limit` and `page`.
|
|
2966
|
+
* `include` takes any of `"sightings"` (asks MISP for the inline `Sighting` array so each
|
|
2967
|
+
* attribute's `sightings[]`/`sighting_count` and each returned event's sightings are real
|
|
2968
|
+
* counts instead of 0), `"event_reports"` (the analyst-written markdown narratives for the
|
|
2969
|
+
* matched events), `"stats"` (per-event attribute/object/sighting counts), `"tags"` (the
|
|
2970
|
+
* instance's tag vocabulary), `"feeds"` (feed previews), `"objects"` (full event bodies with
|
|
2971
|
+
* resolved references), `"misp_events_full"` (full event bodies), and `"version"`. Events
|
|
2972
|
+
* otherwise return summaries; `misp_events_total` is null when unknown.
|
|
2973
|
+
* Omit `include` for event reports, tags and version; pass `[]` to omit them.
|
|
2318
2974
|
*/
|
|
2319
2975
|
async searchMisp(options = {}) {
|
|
2320
2976
|
const result = await searchMisp({
|
|
@@ -2339,6 +2995,7 @@ var CrawlerClient = class {
|
|
|
2339
2995
|
},
|
|
2340
2996
|
...options.dateFrom !== void 0 && { date_from: options.dateFrom },
|
|
2341
2997
|
...options.dateTo !== void 0 && { date_to: options.dateTo },
|
|
2998
|
+
...options.include !== void 0 && { include: [...options.include] },
|
|
2342
2999
|
limit: options.limit ?? 50,
|
|
2343
3000
|
page: options.page ?? 1
|
|
2344
3001
|
}
|
|
@@ -2375,7 +3032,8 @@ var CrawlerClient = class {
|
|
|
2375
3032
|
const result = await searchVendor({
|
|
2376
3033
|
client: this._client,
|
|
2377
3034
|
body: {
|
|
2378
|
-
vendor,
|
|
3035
|
+
vendor: vendor ?? void 0,
|
|
3036
|
+
q: options.q,
|
|
2379
3037
|
limit: options.limit ?? 50
|
|
2380
3038
|
}
|
|
2381
3039
|
});
|
|
@@ -2402,11 +3060,15 @@ var CrawlerClient = class {
|
|
|
2402
3060
|
client: this._client,
|
|
2403
3061
|
body: {
|
|
2404
3062
|
...options.text !== void 0 && { text: options.text },
|
|
3063
|
+
...options.texts !== void 0 && { texts: options.texts },
|
|
2405
3064
|
...options.files !== void 0 && { files: options.files },
|
|
2406
3065
|
...options.formats !== void 0 && { formats: options.formats },
|
|
2407
3066
|
...options.include !== void 0 && { include: [...options.include] },
|
|
2408
3067
|
...options.stakeholder !== void 0 && {
|
|
2409
3068
|
stakeholder: options.stakeholder
|
|
3069
|
+
},
|
|
3070
|
+
...options.attachedArtifactIds !== void 0 && {
|
|
3071
|
+
attached_artifact_ids: options.attachedArtifactIds
|
|
2410
3072
|
}
|
|
2411
3073
|
}
|
|
2412
3074
|
});
|
|
@@ -2432,8 +3094,13 @@ var CrawlerClient = class {
|
|
|
2432
3094
|
* fleet-level risk picture.
|
|
2433
3095
|
*
|
|
2434
3096
|
* @param items Assets to enrich, each at minimum `{ product }`.
|
|
2435
|
-
* @param options Optional `attachmentsText
|
|
2436
|
-
*
|
|
3097
|
+
* @param options Optional attachment context — `attachmentsText` (one opaque blob),
|
|
3098
|
+
* `attachmentsTexts` (one `{ text, source_artifact_id?, filename? }` entry per artifact, so
|
|
3099
|
+
* each block keeps its own attribution), `attachedArtifactIds` (the artifacts an opaque
|
|
3100
|
+
* `attachmentsText` came from) and `attachmentsFiles` (raw binary the engine parses) — plus
|
|
3101
|
+
* per-asset CVE `include` layers and `vexOverlay` — an OpenVEX 0.2.0 / CSAF 2.0 VEX
|
|
3102
|
+
* document (text) whose `not_affected`/`fixed` statements mark matching findings
|
|
3103
|
+
* `suppressed_by_vex` (retained + justification, excluded from the actionable counts).
|
|
2437
3104
|
*/
|
|
2438
3105
|
async inventoryEnrich(items, options = {}) {
|
|
2439
3106
|
const result = await inventoryEnrich({
|
|
@@ -2443,10 +3110,19 @@ var CrawlerClient = class {
|
|
|
2443
3110
|
...options.attachmentsText !== void 0 && {
|
|
2444
3111
|
attachments_text: options.attachmentsText
|
|
2445
3112
|
},
|
|
3113
|
+
...options.attachmentsTexts !== void 0 && {
|
|
3114
|
+
attachments_texts: options.attachmentsTexts
|
|
3115
|
+
},
|
|
3116
|
+
...options.attachedArtifactIds !== void 0 && {
|
|
3117
|
+
attached_artifact_ids: options.attachedArtifactIds
|
|
3118
|
+
},
|
|
2446
3119
|
...options.attachmentsFiles !== void 0 && {
|
|
2447
3120
|
attachments_files: options.attachmentsFiles
|
|
2448
3121
|
},
|
|
2449
|
-
...options.include !== void 0 && { include: [...options.include] }
|
|
3122
|
+
...options.include !== void 0 && { include: [...options.include] },
|
|
3123
|
+
...options.vexOverlay !== void 0 && {
|
|
3124
|
+
vex_overlay: { format: "vex", content: options.vexOverlay }
|
|
3125
|
+
}
|
|
2450
3126
|
}
|
|
2451
3127
|
});
|
|
2452
3128
|
return ensureOk(result);
|
|
@@ -2463,7 +3139,52 @@ var CrawlerClient = class {
|
|
|
2463
3139
|
});
|
|
2464
3140
|
return ensureOk(result);
|
|
2465
3141
|
}
|
|
3142
|
+
/**
|
|
3143
|
+
* Submit a raw security event to the async Event Enricher engine.
|
|
3144
|
+
*
|
|
3145
|
+
* Returns immediately with an `enrichment_id` — poll {@link eventEnrichStatus}
|
|
3146
|
+
* for the result (per-indicator findings + the aggregate event threat
|
|
3147
|
+
* assessment), or use {@link enricher}.`enrichEvent` to run the whole lifecycle.
|
|
3148
|
+
* CC extracts every indicator server-side — you do NOT pre-parse the alert.
|
|
3149
|
+
*
|
|
3150
|
+
* @param event The raw event — a Defender XDR / Sentinel alert JSON, a SIEM/EDR
|
|
3151
|
+
* log line, or any text (≤200,000 chars).
|
|
3152
|
+
* @param options.eventId Optional caller-side event identifier (≤200 chars), echoed back on the result.
|
|
3153
|
+
*/
|
|
3154
|
+
async eventEnrich(event, options = {}) {
|
|
3155
|
+
const result = await eventEnrich({
|
|
3156
|
+
client: this._client,
|
|
3157
|
+
body: {
|
|
3158
|
+
event,
|
|
3159
|
+
...options.eventId !== void 0 && { event_id: options.eventId }
|
|
3160
|
+
}
|
|
3161
|
+
});
|
|
3162
|
+
return ensureOk(result);
|
|
3163
|
+
}
|
|
3164
|
+
/**
|
|
3165
|
+
* Read the progress or result of an event enrichment.
|
|
3166
|
+
*
|
|
3167
|
+
* @param enrichmentId The `enrichment_id` returned by {@link eventEnrich}.
|
|
3168
|
+
*/
|
|
3169
|
+
async eventEnrichStatus(enrichmentId) {
|
|
3170
|
+
const result = await eventEnrichStatus({
|
|
3171
|
+
client: this._client,
|
|
3172
|
+
path: { enrichment_id: enrichmentId }
|
|
3173
|
+
});
|
|
3174
|
+
return ensureOk(result);
|
|
3175
|
+
}
|
|
2466
3176
|
};
|
|
3177
|
+
function expandGroupCatalogue(catalog, refs, rows) {
|
|
3178
|
+
if (!catalog || !refs || !rows) return;
|
|
3179
|
+
for (const row of rows) {
|
|
3180
|
+
if (typeof row === "string") continue;
|
|
3181
|
+
const indices = refs[row.technique_id] ?? [];
|
|
3182
|
+
if (indices.some((i) => !Number.isInteger(i) || i < 0 || i >= catalog.length)) {
|
|
3183
|
+
throw new Error("Invalid group log-source catalogue reference");
|
|
3184
|
+
}
|
|
3185
|
+
if (indices.length) row.log_sources = indices.map((i) => catalog[i]);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
2467
3188
|
function ensureOk(result) {
|
|
2468
3189
|
if (result.data !== void 0 && result.error === void 0) {
|
|
2469
3190
|
return result.data;
|
|
@@ -2479,9 +3200,9 @@ function ensureOk(result) {
|
|
|
2479
3200
|
|
|
2480
3201
|
// package.json
|
|
2481
3202
|
var package_default = {
|
|
2482
|
-
version: "
|
|
3203
|
+
version: "5.0.1"};
|
|
2483
3204
|
|
|
2484
3205
|
// src/index.ts
|
|
2485
3206
|
var __version__ = package_default.version;
|
|
2486
3207
|
|
|
2487
|
-
export { AiReportsApi, ArtifactManagerApi, BASE_URL, CrawlerClient, CrawlerClientError, DEFAULT_TIMEOUT_MS, ENV_API_KEY, ENV_BASE_URL, ENV_VERIFY_SSL, EnricherApi, InventoryManagerApi, MissingCredentials, UnexpectedStatus, __version__, assembleBriefing, ingestScan };
|
|
3208
|
+
export { AiReportsApi, ArtifactManagerApi, BASE_URL, CrawlerClient, CrawlerClientError, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, ENV_API_KEY, ENV_BASE_URL, ENV_VERIFY_SSL, EnricherApi, InventoryManagerApi, MissingCredentials, TLP_INVALID_MESSAGE, TLP_VALUES, UnexpectedStatus, __version__, assembleBriefing, ingestScan, validateTlp };
|