@crimson-crawler/crimson-crawler-client 4.1.1 → 5.0.0
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 +892 -170
- package/dist/index.d.cts +558 -99
- package/dist/index.d.ts +558 -99
- package/dist/index.js +843 -125
- 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 +8 -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);
|
|
@@ -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);
|
|
@@ -1713,7 +2100,7 @@ var CrawlerClient = class {
|
|
|
1713
2100
|
this._enricher = new EnricherApi(this.baseUrl, apiKey, retryFetch);
|
|
1714
2101
|
this._aiReports = new AiReportsApi(this.baseUrl, apiKey, retryFetch);
|
|
1715
2102
|
}
|
|
1716
|
-
/** Underlying Hey API client, scoped to this instance. Use to call any of the
|
|
2103
|
+
/** Underlying Hey API client, scoped to this instance. Use to call any of the 37 `/v1` operations (31 synchronous + 6 async-engine) directly. */
|
|
1717
2104
|
get api() {
|
|
1718
2105
|
return this._client;
|
|
1719
2106
|
}
|
|
@@ -1731,6 +2118,8 @@ var CrawlerClient = class {
|
|
|
1731
2118
|
* artifacts + saved enrichment history) over the same key. Its own section at
|
|
1732
2119
|
* `/inventory-manager/inventories/*` (outside the `/v1` OpenAPI contract). **Usage-exempt** except
|
|
1733
2120
|
* `enrichInventory`'s submit, which is enrichment compute and counts toward your usage.
|
|
2121
|
+
* For full log sources, PoCs, Sigma rules, or D3FEND rows, call `enrichCveFull` with the CVE ID,
|
|
2122
|
+
* `techniques`, the base layer, and its `*_full` token.
|
|
1734
2123
|
*/
|
|
1735
2124
|
get inventoryManager() {
|
|
1736
2125
|
return this._inventoryManager;
|
|
@@ -1755,23 +2144,57 @@ var CrawlerClient = class {
|
|
|
1755
2144
|
/**
|
|
1756
2145
|
* Walk the full CVE → CWE → CAPEC → ATT&CK → TIE chain plus MISP/knowledge base/web.
|
|
1757
2146
|
*
|
|
2147
|
+
* Returns one page. OSV advisories are paged: while `osv_next_offset` is set, request the next
|
|
2148
|
+
* page with that offset and the response's `osv_snapshot_id`, or stream the whole walk with
|
|
2149
|
+
* {@link iterCveOsvPages}.
|
|
2150
|
+
*
|
|
1758
2151
|
* @param cveId CVE identifier (e.g. `CVE-2024-3400`).
|
|
1759
|
-
* @param include Override
|
|
1760
|
-
|
|
1761
|
-
|
|
2152
|
+
* @param include Override `CVE_FULL_WALK`, which includes stored permissive OSV and Android
|
|
2153
|
+
* bulletin data. Restricted or unknown-licence OSV records require `osv_restricted`, which the
|
|
2154
|
+
* cursor is bound to.
|
|
2155
|
+
* @param options `osvOffset` (from the previous page's `osv_next_offset`) and `osvSnapshotId`
|
|
2156
|
+
* (the previous page's `osv_snapshot_id`; required with a continuation). A continuation answers
|
|
2157
|
+
* 409 `snapshot_expired` when its snapshot is gone and 503 `snapshot_unavailable` when the store is down.
|
|
2158
|
+
*/
|
|
2159
|
+
async enrichCveFull(cveId, include = CVE_FULL_WALK, options = {}) {
|
|
1762
2160
|
const result = await enrichCve({
|
|
1763
2161
|
client: this._client,
|
|
1764
|
-
body: {
|
|
2162
|
+
body: {
|
|
2163
|
+
cve_id: cveId,
|
|
2164
|
+
include: [...include],
|
|
2165
|
+
...options.osvOffset !== void 0 && {
|
|
2166
|
+
osv_offset: options.osvOffset
|
|
2167
|
+
},
|
|
2168
|
+
...options.osvSnapshotId !== void 0 && {
|
|
2169
|
+
osv_snapshot_id: options.osvSnapshotId
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
1765
2172
|
});
|
|
1766
2173
|
return ensureOk(result);
|
|
1767
2174
|
}
|
|
1768
2175
|
/**
|
|
1769
|
-
*
|
|
2176
|
+
* Stream every OSV advisory page of one CVE without an aggregate buffer. The first page is the
|
|
2177
|
+
* complete enrichment; later pages repeat the request with the cursor and carry the next
|
|
2178
|
+
* `osv_advisories` slice. A changed or expired snapshot throws `UnexpectedStatus` (409
|
|
2179
|
+
* `snapshot_expired`) instead of restarting after a yield. The caller owns any collection bound;
|
|
2180
|
+
* `osv_advisories_total` is exact.
|
|
2181
|
+
*/
|
|
2182
|
+
async *iterCveOsvPages(cveId, include = CVE_FULL_WALK) {
|
|
2183
|
+
yield* iterOsvPages(
|
|
2184
|
+
(osvOffset, osvSnapshotId) => this.enrichCveFull(cveId, include, {
|
|
2185
|
+
osvOffset,
|
|
2186
|
+
...osvSnapshotId !== void 0 && { osvSnapshotId }
|
|
2187
|
+
})
|
|
2188
|
+
);
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Enrich an IOC against MISP, link to ATT&CK, and add knowledge base context.
|
|
1770
2192
|
*
|
|
1771
2193
|
* @param value Indicator value (hash, IP, domain, URL).
|
|
1772
2194
|
* @param iocType MISP-style attribute type — `ip-dst`, `ip-src`, `domain`,
|
|
1773
2195
|
* `hostname`, `md5`, `sha1`, `sha256`, `url`, etc. Defaults to `ip-dst`.
|
|
1774
|
-
* @param include Override
|
|
2196
|
+
* @param include Override `IOC_FULL_WALK`. `network_context` and `listed_on` are defaults;
|
|
2197
|
+
* `domain_context` and `hashlookup` remain explicit includes.
|
|
1775
2198
|
*/
|
|
1776
2199
|
async enrichIocFull(value, iocType = "ip-dst", include = IOC_FULL_WALK) {
|
|
1777
2200
|
const result = await enrichIoc({
|
|
@@ -1783,29 +2206,45 @@ var CrawlerClient = class {
|
|
|
1783
2206
|
/**
|
|
1784
2207
|
* Walk CWE → CAPEC → ATT&CK with TIE predictions.
|
|
1785
2208
|
*
|
|
1786
|
-
* @param cweId CWE identifier (e.g. `CWE-79`).
|
|
1787
|
-
* @param
|
|
2209
|
+
* @param cweId CWE identifier (e.g. `CWE-79`). Supply this or `search`.
|
|
2210
|
+
* @param options Optional `search` keyword (discover weaknesses by name) and `include` override.
|
|
1788
2211
|
*/
|
|
1789
|
-
async enrichCweFull(cweId,
|
|
2212
|
+
async enrichCweFull(cweId = null, options = {}) {
|
|
1790
2213
|
const result = await enrichCwe({
|
|
1791
2214
|
client: this._client,
|
|
1792
|
-
body: {
|
|
2215
|
+
body: {
|
|
2216
|
+
cwe_id: cweId ?? void 0,
|
|
2217
|
+
search: options.search,
|
|
2218
|
+
include: [...options.include ?? CWE_FULL_WALK]
|
|
2219
|
+
}
|
|
1793
2220
|
});
|
|
1794
2221
|
return ensureOk(result);
|
|
1795
2222
|
}
|
|
1796
2223
|
/**
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2224
|
+
* Enrich one or more ATT&CK techniques with TIE, adversary attribution,
|
|
2225
|
+
* and Navigator JSON.
|
|
2226
|
+
*
|
|
2227
|
+
* @param techniqueIds ATT&CK technique IDs (e.g. `["T1190", "T1059.001"]`). Omit it when
|
|
2228
|
+
* looking up by `assetId`.
|
|
2229
|
+
* @param framework ATT&CK matrix variant — `enterprise`, `ics`, or `mobile`.
|
|
2230
|
+
* @param include Override the default `TECHNIQUE_FULL` chain. `fraud` (opt-in) adds the MITRE
|
|
2231
|
+
* F3 fraud techniques whose borrowed ATT&CK ids resolve to each returned technique; the
|
|
2232
|
+
* other opt-ins are `fight` (FiGHT techniques by id), `lolbas` (facts-only binaries),
|
|
2233
|
+
* `sigma`, `lotl` (LOLDrivers plus the facts-only GTFOBins and HijackLibs rows mapped
|
|
2234
|
+
* onto the technique), `atomic_red_team` (Atomic Red Team tests: name, GUID, platforms,
|
|
2235
|
+
* executor and elevation flag, never a command body), `framework_mappings`, `asset_classes`, `log_sources` and
|
|
2236
|
+
* `analytic_details`.
|
|
2237
|
+
|
|
2238
|
+
* @param assetId ICS asset to look up from (e.g. `"A0002"`) — returns the techniques that
|
|
2239
|
+
* asset's classes target. Requires `framework: "ics"` and is mutually exclusive with
|
|
2240
|
+
* `techniqueIds`: it is a selector in its own right, not an added filter.
|
|
2241
|
+
*/
|
|
2242
|
+
async enrichTechniqueFull(techniqueIds, framework = "enterprise", include = TECHNIQUE_FULL, assetId) {
|
|
1805
2243
|
const result = await enrichTechnique({
|
|
1806
2244
|
client: this._client,
|
|
1807
2245
|
body: {
|
|
1808
|
-
technique_ids: techniqueIds,
|
|
2246
|
+
...techniqueIds !== void 0 && { technique_ids: techniqueIds },
|
|
2247
|
+
...assetId !== void 0 && { asset_id: assetId },
|
|
1809
2248
|
framework,
|
|
1810
2249
|
include: [...include]
|
|
1811
2250
|
}
|
|
@@ -1813,10 +2252,12 @@ var CrawlerClient = class {
|
|
|
1813
2252
|
return ensureOk(result);
|
|
1814
2253
|
}
|
|
1815
2254
|
/**
|
|
1816
|
-
*
|
|
2255
|
+
* Return one page of enriched CVEs for a product/version.
|
|
2256
|
+
* For full log sources, PoCs, Sigma rules, or D3FEND rows, call `enrichCveFull` with the CVE ID,
|
|
2257
|
+
* `techniques`, the base layer, and its `*_full` token.
|
|
1817
2258
|
*
|
|
1818
|
-
* @param product Product name (e.g. `"
|
|
1819
|
-
* @param options Optional
|
|
2259
|
+
* @param product Product name (e.g. `"http_server"`, `"nginx"`).
|
|
2260
|
+
* @param options Optional version, vendor, include, limit, and offset. The full preset defaults to 2 CVEs per page.
|
|
1820
2261
|
*/
|
|
1821
2262
|
async enrichProductFull(product, options = {}) {
|
|
1822
2263
|
const result = await enrichProduct({
|
|
@@ -1825,10 +2266,22 @@ var CrawlerClient = class {
|
|
|
1825
2266
|
product,
|
|
1826
2267
|
...options.version !== void 0 && { version: options.version },
|
|
1827
2268
|
...options.vendor !== void 0 && { vendor: options.vendor },
|
|
2269
|
+
limit: options.limit ?? 2,
|
|
2270
|
+
...options.offset !== void 0 && { offset: options.offset },
|
|
2271
|
+
...options.snapshotId !== void 0 && {
|
|
2272
|
+
snapshot_id: options.snapshotId
|
|
2273
|
+
},
|
|
1828
2274
|
include: [...options.include ?? PRODUCT_FULL]
|
|
1829
2275
|
}
|
|
1830
2276
|
});
|
|
1831
|
-
return ensureOk(result);
|
|
2277
|
+
return expandCveContext(ensureOk(result));
|
|
2278
|
+
}
|
|
2279
|
+
async *iterProductCves(product, options = {}) {
|
|
2280
|
+
const pages = await collectSnapshotPages(
|
|
2281
|
+
(offset, snapshotId) => this.enrichProductFull(product, { ...options, offset, snapshotId }),
|
|
2282
|
+
(page) => page.cves_next_offset
|
|
2283
|
+
);
|
|
2284
|
+
yield* pages;
|
|
1832
2285
|
}
|
|
1833
2286
|
/**
|
|
1834
2287
|
* Enrich an open-source package — OSV.dev advisories + full CVE enrichment.
|
|
@@ -1849,10 +2302,42 @@ var CrawlerClient = class {
|
|
|
1849
2302
|
ecosystem,
|
|
1850
2303
|
package: packageName,
|
|
1851
2304
|
...options.version !== void 0 && { version: options.version },
|
|
2305
|
+
limit: options.limit ?? 5,
|
|
2306
|
+
...options.offset !== void 0 && { offset: options.offset },
|
|
2307
|
+
...options.snapshotId !== void 0 && {
|
|
2308
|
+
snapshot_id: options.snapshotId
|
|
2309
|
+
},
|
|
1852
2310
|
include: [...options.include ?? PACKAGE_FULL]
|
|
1853
2311
|
}
|
|
1854
2312
|
});
|
|
1855
|
-
return ensureOk(result);
|
|
2313
|
+
return expandCveContext(ensureOk(result));
|
|
2314
|
+
}
|
|
2315
|
+
async *iterPackageAdvisories(ecosystem, packageName, options = {}) {
|
|
2316
|
+
let offset = 0;
|
|
2317
|
+
let snapshotId;
|
|
2318
|
+
while (true) {
|
|
2319
|
+
const page = await this.enrichPackageFull(ecosystem, packageName, {
|
|
2320
|
+
...options,
|
|
2321
|
+
offset,
|
|
2322
|
+
snapshotId
|
|
2323
|
+
});
|
|
2324
|
+
if (page.errors?.some(
|
|
2325
|
+
(error) => error.service === "osv" && error.error === "stored_copy_unavailable"
|
|
2326
|
+
)) {
|
|
2327
|
+
throw new Error("stored_copy_unavailable");
|
|
2328
|
+
}
|
|
2329
|
+
if (snapshotId !== void 0 && page.snapshot_id !== snapshotId) {
|
|
2330
|
+
throw new Error("Enrichment returned a different snapshot identifier");
|
|
2331
|
+
}
|
|
2332
|
+
const nextOffset = page.next_offset;
|
|
2333
|
+
if (nextOffset != null && (!page.snapshot_id || !Number.isInteger(nextOffset) || nextOffset <= offset)) {
|
|
2334
|
+
throw new Error("Enrichment returned an invalid package continuation");
|
|
2335
|
+
}
|
|
2336
|
+
yield page;
|
|
2337
|
+
if (nextOffset == null) return;
|
|
2338
|
+
offset = nextOffset;
|
|
2339
|
+
snapshotId = page.snapshot_id ?? void 0;
|
|
2340
|
+
}
|
|
1856
2341
|
}
|
|
1857
2342
|
/**
|
|
1858
2343
|
* Keyword-search the ATT&CK knowledge base for matching techniques.
|
|
@@ -1935,6 +2420,26 @@ var CrawlerClient = class {
|
|
|
1935
2420
|
});
|
|
1936
2421
|
return ensureOk(result);
|
|
1937
2422
|
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Resolve a CLOAK concealment technique — details and knowledge base context.
|
|
2425
|
+
*
|
|
2426
|
+
* CLOAK objects carry no ATT&CK references, so there is no linked-technique layer:
|
|
2427
|
+
* the response has no `linked_techniques` field at all.
|
|
2428
|
+
*
|
|
2429
|
+
* @param cloakId CLOAK identifier (e.g. `TTP-496`, or a technique slug such as `ta6-te129`).
|
|
2430
|
+
* @param options Optional `search` keyword and `include` override (default `CLOAK_FULL`).
|
|
2431
|
+
*/
|
|
2432
|
+
async enrichCloakFull(cloakId, options = {}) {
|
|
2433
|
+
const result = await enrichCloak({
|
|
2434
|
+
client: this._client,
|
|
2435
|
+
body: {
|
|
2436
|
+
...cloakId !== void 0 && { cloak_id: cloakId },
|
|
2437
|
+
...options.search !== void 0 && { search: options.search },
|
|
2438
|
+
include: [...options.include ?? CLOAK_FULL]
|
|
2439
|
+
}
|
|
2440
|
+
});
|
|
2441
|
+
return ensureOk(result);
|
|
2442
|
+
}
|
|
1938
2443
|
/**
|
|
1939
2444
|
* Resolve a D3FEND defensive technique and the offensive techniques it counters.
|
|
1940
2445
|
*
|
|
@@ -1953,7 +2458,11 @@ var CrawlerClient = class {
|
|
|
1953
2458
|
return ensureOk(result);
|
|
1954
2459
|
}
|
|
1955
2460
|
/**
|
|
1956
|
-
* Walk a DISARM disinformation technique to its
|
|
2461
|
+
* Walk a DISARM disinformation technique to its family links and context.
|
|
2462
|
+
*
|
|
2463
|
+
* DISARM has no course-of-action objects and no ATT&CK-Enterprise-keyed actors/campaigns, so the
|
|
2464
|
+
* response carries the technique, its DISARM family (`relatedDisarmTechniques`), and the
|
|
2465
|
+
* knowledge-base / web / summary context — nothing else.
|
|
1957
2466
|
*
|
|
1958
2467
|
* @param techniqueId DISARM technique ID (e.g. `T0086`).
|
|
1959
2468
|
* @param options Optional `search` keyword and `include` override (default `DISARM_FULL`).
|
|
@@ -1969,6 +2478,28 @@ var CrawlerClient = class {
|
|
|
1969
2478
|
});
|
|
1970
2479
|
return ensureOk(result);
|
|
1971
2480
|
}
|
|
2481
|
+
/**
|
|
2482
|
+
* Walk a MITRE F3 fraud technique to the ATT&CK techniques it borrows.
|
|
2483
|
+
*
|
|
2484
|
+
* F3 borrows real ATT&CK `T####` ids for the techniques it shares with Enterprise
|
|
2485
|
+
* ATT&CK, so a `T`-shaped id resolves here too. Unlike the other framework walks,
|
|
2486
|
+
* calling with neither an id nor `search` is valid — the server answers 200 with
|
|
2487
|
+
* nothing selected rather than rejecting the request.
|
|
2488
|
+
*
|
|
2489
|
+
* @param f3Id F3 identifier (e.g. `F1031`, `F1025.003`).
|
|
2490
|
+
* @param options Optional `search` keyword and `include` override (default `F3_FULL`).
|
|
2491
|
+
*/
|
|
2492
|
+
async enrichF3Full(f3Id, options = {}) {
|
|
2493
|
+
const result = await enrichF3({
|
|
2494
|
+
client: this._client,
|
|
2495
|
+
body: {
|
|
2496
|
+
...f3Id !== void 0 && { f3_id: f3Id },
|
|
2497
|
+
...options.search !== void 0 && { search: options.search },
|
|
2498
|
+
include: [...options.include ?? F3_FULL]
|
|
2499
|
+
}
|
|
2500
|
+
});
|
|
2501
|
+
return ensureOk(result);
|
|
2502
|
+
}
|
|
1972
2503
|
/**
|
|
1973
2504
|
* Profile a threat actor: techniques, tooling, campaigns, exploited CVEs, and targeting.
|
|
1974
2505
|
*
|
|
@@ -1983,15 +2514,33 @@ var CrawlerClient = class {
|
|
|
1983
2514
|
...groupId !== void 0 && { group_id: groupId },
|
|
1984
2515
|
...options.search !== void 0 && { search: options.search },
|
|
1985
2516
|
framework: options.framework ?? "enterprise",
|
|
2517
|
+
...options.limit !== void 0 && { limit: options.limit },
|
|
2518
|
+
...options.offset !== void 0 && { offset: options.offset },
|
|
2519
|
+
...options.snapshotId !== void 0 && {
|
|
2520
|
+
snapshot_id: options.snapshotId
|
|
2521
|
+
},
|
|
1986
2522
|
include: [...options.include ?? GROUP_FULL]
|
|
1987
2523
|
}
|
|
1988
2524
|
});
|
|
1989
|
-
|
|
2525
|
+
const page = ensureOk(result);
|
|
2526
|
+
expandGroupCatalogue(
|
|
2527
|
+
page.log_source_catalog,
|
|
2528
|
+
page.log_source_refs,
|
|
2529
|
+
page.group?.techniques
|
|
2530
|
+
);
|
|
2531
|
+
return page;
|
|
2532
|
+
}
|
|
2533
|
+
async *iterGroupPages(groupId, options = {}) {
|
|
2534
|
+
const pages = await collectSnapshotPages(
|
|
2535
|
+
(offset, snapshotId) => this.enrichGroupFull(groupId, { ...options, offset, snapshotId }),
|
|
2536
|
+
(page) => page.techniques_next_offset
|
|
2537
|
+
);
|
|
2538
|
+
yield* pages;
|
|
1990
2539
|
}
|
|
1991
2540
|
/**
|
|
1992
|
-
* Map a region's
|
|
2541
|
+
* Map a region's profile — details plus knowledge base context.
|
|
1993
2542
|
*
|
|
1994
|
-
* @param locationId Region identifier (e.g. `
|
|
2543
|
+
* @param locationId Region identifier (e.g. `US`, or a STIX location ID).
|
|
1995
2544
|
* @param options Optional `search` keyword and `include` override (default `LOCATION_FULL`).
|
|
1996
2545
|
*/
|
|
1997
2546
|
async enrichLocationFull(locationId, options = {}) {
|
|
@@ -2006,9 +2555,9 @@ var CrawlerClient = class {
|
|
|
2006
2555
|
return ensureOk(result);
|
|
2007
2556
|
}
|
|
2008
2557
|
/**
|
|
2009
|
-
* Map an industry sector's
|
|
2558
|
+
* Map an industry sector's profile — details plus knowledge base context.
|
|
2010
2559
|
*
|
|
2011
|
-
* @param sectorId Sector identifier (e.g. `energy`, or
|
|
2560
|
+
* @param sectorId Sector identifier (e.g. `energy`, or a STIX sector ID).
|
|
2012
2561
|
* @param options Optional `search` keyword and `include` override (default `SECTOR_FULL`).
|
|
2013
2562
|
*/
|
|
2014
2563
|
async enrichSectorFull(sectorId, options = {}) {
|
|
@@ -2057,7 +2606,21 @@ var CrawlerClient = class {
|
|
|
2057
2606
|
client: this._client,
|
|
2058
2607
|
body: { items }
|
|
2059
2608
|
});
|
|
2060
|
-
|
|
2609
|
+
const response = ensureOk(result);
|
|
2610
|
+
for (const row of response.results ?? []) {
|
|
2611
|
+
if ((row.type === "product" || row.type === "package") && row.data) {
|
|
2612
|
+
expandCveContext(row.data);
|
|
2613
|
+
}
|
|
2614
|
+
if (row.type === "group" && row.data) {
|
|
2615
|
+
const group = row.data;
|
|
2616
|
+
expandGroupCatalogue(
|
|
2617
|
+
group.log_source_catalog,
|
|
2618
|
+
group.log_source_refs,
|
|
2619
|
+
group.group?.techniques
|
|
2620
|
+
);
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
return response;
|
|
2061
2624
|
}
|
|
2062
2625
|
/**
|
|
2063
2626
|
* Fetch the source of a public proof-of-concept exploit repository.
|
|
@@ -2096,10 +2659,28 @@ var CrawlerClient = class {
|
|
|
2096
2659
|
},
|
|
2097
2660
|
...options.search !== void 0 && { search: [...options.search] },
|
|
2098
2661
|
framework: options.framework ?? "enterprise",
|
|
2662
|
+
...options.limit !== void 0 && { limit: options.limit },
|
|
2663
|
+
...options.offset !== void 0 && { offset: options.offset },
|
|
2664
|
+
...options.snapshotId !== void 0 && {
|
|
2665
|
+
snapshot_id: options.snapshotId
|
|
2666
|
+
},
|
|
2099
2667
|
...options.include !== void 0 && { include: [...options.include] }
|
|
2100
2668
|
}
|
|
2101
2669
|
});
|
|
2102
|
-
|
|
2670
|
+
const page = ensureOk(result);
|
|
2671
|
+
expandGroupCatalogue(
|
|
2672
|
+
page.log_source_catalog,
|
|
2673
|
+
page.log_source_refs,
|
|
2674
|
+
page.techniques
|
|
2675
|
+
);
|
|
2676
|
+
return page;
|
|
2677
|
+
}
|
|
2678
|
+
async *iterGroupExposurePages(options = {}) {
|
|
2679
|
+
const pages = await collectSnapshotPages(
|
|
2680
|
+
(offset, snapshotId) => this.assessGroupExposure({ ...options, offset, snapshotId }),
|
|
2681
|
+
(page) => page.techniques_next_offset
|
|
2682
|
+
);
|
|
2683
|
+
yield* pages;
|
|
2103
2684
|
}
|
|
2104
2685
|
/**
|
|
2105
2686
|
* Assess a portfolio of indicators — MISP corroboration, linked techniques, attribution.
|
|
@@ -2137,9 +2718,14 @@ var CrawlerClient = class {
|
|
|
2137
2718
|
/**
|
|
2138
2719
|
* Prioritize a set of CVEs — weaponization, exploit chains, and remediation order.
|
|
2139
2720
|
*
|
|
2721
|
+
* Returns one page. OSV advisories are aggregated across `cveIds` and paged: while
|
|
2722
|
+
* `osv_next_offset` is set, request the next page with that offset and the response's
|
|
2723
|
+
* `osv_snapshot_id`, or stream the whole walk with {@link iterVulnerabilityExposureOsvPages}.
|
|
2724
|
+
*
|
|
2140
2725
|
* @param cveIds CVE identifiers to assess.
|
|
2141
|
-
* @param options Optional `include` layers
|
|
2142
|
-
* tunes the decision to your
|
|
2726
|
+
* @param options Optional `include` layers (a continuation must repeat them; `osv_restricted`
|
|
2727
|
+
* is the licence opt-in), an SSVC `stakeholder` profile that tunes the decision to your
|
|
2728
|
+
* deployment, and the `osvOffset` / `osvSnapshotId` cursor from the previous page.
|
|
2143
2729
|
*/
|
|
2144
2730
|
async assessVulnerabilityExposure(cveIds, options = {}) {
|
|
2145
2731
|
const result = await assessVulnerabilityExposure({
|
|
@@ -2149,11 +2735,31 @@ var CrawlerClient = class {
|
|
|
2149
2735
|
...options.include !== void 0 && { include: [...options.include] },
|
|
2150
2736
|
...options.stakeholder !== void 0 && {
|
|
2151
2737
|
stakeholder: options.stakeholder
|
|
2738
|
+
},
|
|
2739
|
+
...options.osvOffset !== void 0 && {
|
|
2740
|
+
osv_offset: options.osvOffset
|
|
2741
|
+
},
|
|
2742
|
+
...options.osvSnapshotId !== void 0 && {
|
|
2743
|
+
osv_snapshot_id: options.osvSnapshotId
|
|
2152
2744
|
}
|
|
2153
2745
|
}
|
|
2154
2746
|
});
|
|
2155
2747
|
return ensureOk(result);
|
|
2156
2748
|
}
|
|
2749
|
+
/**
|
|
2750
|
+
* Stream every OSV advisory page of a vulnerability-exposure assessment without an aggregate
|
|
2751
|
+
* buffer. Same contract as {@link iterCveOsvPages}: the first page is the whole assessment, a
|
|
2752
|
+
* changed or expired snapshot throws instead of restarting, and the caller owns any collection bound.
|
|
2753
|
+
*/
|
|
2754
|
+
async *iterVulnerabilityExposureOsvPages(cveIds, options = {}) {
|
|
2755
|
+
yield* iterOsvPages(
|
|
2756
|
+
(osvOffset, osvSnapshotId) => this.assessVulnerabilityExposure(cveIds, {
|
|
2757
|
+
...options,
|
|
2758
|
+
osvOffset,
|
|
2759
|
+
...osvSnapshotId !== void 0 && { osvSnapshotId }
|
|
2760
|
+
})
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2157
2763
|
// -- Search ------------------------------------------------------------ //
|
|
2158
2764
|
//
|
|
2159
2765
|
// Search endpoints query a corpus and return matches; they never walk an
|
|
@@ -2180,7 +2786,8 @@ var CrawlerClient = class {
|
|
|
2180
2786
|
...options.deprecated !== void 0 && {
|
|
2181
2787
|
deprecated: options.deprecated
|
|
2182
2788
|
},
|
|
2183
|
-
...options.revoked !== void 0 && { revoked: options.revoked }
|
|
2789
|
+
...options.revoked !== void 0 && { revoked: options.revoked },
|
|
2790
|
+
...options.include !== void 0 && { include: [...options.include] }
|
|
2184
2791
|
}
|
|
2185
2792
|
});
|
|
2186
2793
|
return ensureOk(result);
|
|
@@ -2194,6 +2801,9 @@ var CrawlerClient = class {
|
|
|
2194
2801
|
*
|
|
2195
2802
|
* @param query Free-text query. Omit it to filter purely on the structured fields.
|
|
2196
2803
|
* @param options Any combination of the corpus filters, plus `sort`, `limit`, `page`.
|
|
2804
|
+
* `include` replaces the server defaults: `details`, `statistics`, `cna`, `epss_reports`,
|
|
2805
|
+
* and `kb_rankings` default on. `kb_rankings` keeps the top 100 rows per KB without yearly
|
|
2806
|
+
* trends; `kb_rankings_full` restores all fetched rows and trends.
|
|
2197
2807
|
*/
|
|
2198
2808
|
async searchCve(query, options = {}) {
|
|
2199
2809
|
const result = await searchCve({
|
|
@@ -2251,7 +2861,9 @@ var CrawlerClient = class {
|
|
|
2251
2861
|
* Search the D3FEND defensive-countermeasure ontology.
|
|
2252
2862
|
*
|
|
2253
2863
|
* @param query Free-text query (e.g. `"network traffic analysis"`).
|
|
2254
|
-
* @param options `d3fendForm` to scope to a tactic/mitigation/artifact, plus `limit`, `page
|
|
2864
|
+
* @param options `d3fendForm` to scope to a tactic/mitigation/artifact, plus `limit`, `page`,
|
|
2865
|
+
* and `include`. `versions` defaults on and attaches each returned technique's revision history.
|
|
2866
|
+
* An explicit include replaces the defaults; pass `[]` to omit all optional layers.
|
|
2255
2867
|
*/
|
|
2256
2868
|
async searchD3fend(query, options = {}) {
|
|
2257
2869
|
const result = await searchD3Fend({
|
|
@@ -2262,7 +2874,8 @@ var CrawlerClient = class {
|
|
|
2262
2874
|
d3fend_form: options.d3fendForm
|
|
2263
2875
|
},
|
|
2264
2876
|
limit: options.limit ?? 20,
|
|
2265
|
-
page: options.page ?? 1
|
|
2877
|
+
page: options.page ?? 1,
|
|
2878
|
+
...options.include !== void 0 && { include: [...options.include] }
|
|
2266
2879
|
}
|
|
2267
2880
|
});
|
|
2268
2881
|
return ensureOk(result);
|
|
@@ -2272,7 +2885,9 @@ var CrawlerClient = class {
|
|
|
2272
2885
|
*
|
|
2273
2886
|
* An empty call pages the whole catalog; `cveId` checks one CVE's KEV status.
|
|
2274
2887
|
*
|
|
2275
|
-
* @param options `cveId`, `ransomwareStatus`, `limit`, `page`.
|
|
2888
|
+
* @param options `cveId`, `ransomwareStatus`, `limit`, `page`, and `include`. `statistics`
|
|
2889
|
+
* defaults on for deployment-wide corpus coverage. An explicit include replaces the defaults;
|
|
2890
|
+
* pass `[]` to omit all optional layers.
|
|
2276
2891
|
*/
|
|
2277
2892
|
async searchKev(options = {}) {
|
|
2278
2893
|
const result = await searchKev({
|
|
@@ -2283,6 +2898,35 @@ var CrawlerClient = class {
|
|
|
2283
2898
|
ransomware_status: options.ransomwareStatus
|
|
2284
2899
|
},
|
|
2285
2900
|
limit: options.limit ?? 50,
|
|
2901
|
+
page: options.page ?? 1,
|
|
2902
|
+
...options.include !== void 0 && { include: [...options.include] }
|
|
2903
|
+
}
|
|
2904
|
+
});
|
|
2905
|
+
return ensureOk(result);
|
|
2906
|
+
}
|
|
2907
|
+
/**
|
|
2908
|
+
* Search the seeded CSAF vendor-advisory corpus.
|
|
2909
|
+
*
|
|
2910
|
+
* Filters combine with AND; this is the door for CVE-less advisories (publisher, sector,
|
|
2911
|
+
* product, CPE, TLP). `total` is the unpaginated match count.
|
|
2912
|
+
*/
|
|
2913
|
+
async searchCsaf(options = {}) {
|
|
2914
|
+
const result = await searchCsaf({
|
|
2915
|
+
client: this._client,
|
|
2916
|
+
body: {
|
|
2917
|
+
...options.cveId !== void 0 && { cve_id: options.cveId },
|
|
2918
|
+
...options.advisoryId !== void 0 && {
|
|
2919
|
+
advisory_id: options.advisoryId
|
|
2920
|
+
},
|
|
2921
|
+
...options.publisher !== void 0 && {
|
|
2922
|
+
publisher: options.publisher
|
|
2923
|
+
},
|
|
2924
|
+
...options.sector !== void 0 && { sector: options.sector },
|
|
2925
|
+
...options.product !== void 0 && { product: options.product },
|
|
2926
|
+
...options.cpe !== void 0 && { cpe: options.cpe },
|
|
2927
|
+
...options.tlp !== void 0 && { tlp: options.tlp },
|
|
2928
|
+
sort: options.sort ?? "newest",
|
|
2929
|
+
limit: options.limit ?? 20,
|
|
2286
2930
|
page: options.page ?? 1
|
|
2287
2931
|
}
|
|
2288
2932
|
});
|
|
@@ -2310,11 +2954,20 @@ var CrawlerClient = class {
|
|
|
2310
2954
|
return ensureOk(result);
|
|
2311
2955
|
}
|
|
2312
2956
|
/**
|
|
2313
|
-
* Search MISP events and attributes.
|
|
2957
|
+
* Search our curated MISP (public threat feeds) for events and attributes.
|
|
2958
|
+
* Feed list: https://crimsoncrawler.com/docs/guides/data-sources/#our-curated-misp.
|
|
2314
2959
|
*
|
|
2315
2960
|
* @param options Attribute filters (`value`, `typeAttribute`, `category`, `toIds`),
|
|
2316
2961
|
* event filters (`eventId`, `eventinfo`, `tags`, `threatLevelId`, `published`),
|
|
2317
2962
|
* a `dateFrom`/`dateTo` window, plus `limit` and `page`.
|
|
2963
|
+
* `include` takes any of `"sightings"` (asks MISP for the inline `Sighting` array so each
|
|
2964
|
+
* attribute's `sightings[]`/`sighting_count` and each returned event's sightings are real
|
|
2965
|
+
* counts instead of 0), `"event_reports"` (the analyst-written markdown narratives for the
|
|
2966
|
+
* matched events), `"stats"` (per-event attribute/object/sighting counts), `"tags"` (the
|
|
2967
|
+
* instance's tag vocabulary), `"feeds"` (feed previews), `"objects"` (full event bodies with
|
|
2968
|
+
* resolved references), `"misp_events_full"` (full event bodies), and `"version"`. Events
|
|
2969
|
+
* otherwise return summaries; `misp_events_total` is null when unknown.
|
|
2970
|
+
* Omit `include` for event reports, tags and version; pass `[]` to omit them.
|
|
2318
2971
|
*/
|
|
2319
2972
|
async searchMisp(options = {}) {
|
|
2320
2973
|
const result = await searchMisp({
|
|
@@ -2339,6 +2992,7 @@ var CrawlerClient = class {
|
|
|
2339
2992
|
},
|
|
2340
2993
|
...options.dateFrom !== void 0 && { date_from: options.dateFrom },
|
|
2341
2994
|
...options.dateTo !== void 0 && { date_to: options.dateTo },
|
|
2995
|
+
...options.include !== void 0 && { include: [...options.include] },
|
|
2342
2996
|
limit: options.limit ?? 50,
|
|
2343
2997
|
page: options.page ?? 1
|
|
2344
2998
|
}
|
|
@@ -2375,7 +3029,8 @@ var CrawlerClient = class {
|
|
|
2375
3029
|
const result = await searchVendor({
|
|
2376
3030
|
client: this._client,
|
|
2377
3031
|
body: {
|
|
2378
|
-
vendor,
|
|
3032
|
+
vendor: vendor ?? void 0,
|
|
3033
|
+
q: options.q,
|
|
2379
3034
|
limit: options.limit ?? 50
|
|
2380
3035
|
}
|
|
2381
3036
|
});
|
|
@@ -2402,11 +3057,15 @@ var CrawlerClient = class {
|
|
|
2402
3057
|
client: this._client,
|
|
2403
3058
|
body: {
|
|
2404
3059
|
...options.text !== void 0 && { text: options.text },
|
|
3060
|
+
...options.texts !== void 0 && { texts: options.texts },
|
|
2405
3061
|
...options.files !== void 0 && { files: options.files },
|
|
2406
3062
|
...options.formats !== void 0 && { formats: options.formats },
|
|
2407
3063
|
...options.include !== void 0 && { include: [...options.include] },
|
|
2408
3064
|
...options.stakeholder !== void 0 && {
|
|
2409
3065
|
stakeholder: options.stakeholder
|
|
3066
|
+
},
|
|
3067
|
+
...options.attachedArtifactIds !== void 0 && {
|
|
3068
|
+
attached_artifact_ids: options.attachedArtifactIds
|
|
2410
3069
|
}
|
|
2411
3070
|
}
|
|
2412
3071
|
});
|
|
@@ -2432,8 +3091,13 @@ var CrawlerClient = class {
|
|
|
2432
3091
|
* fleet-level risk picture.
|
|
2433
3092
|
*
|
|
2434
3093
|
* @param items Assets to enrich, each at minimum `{ product }`.
|
|
2435
|
-
* @param options Optional `attachmentsText
|
|
2436
|
-
*
|
|
3094
|
+
* @param options Optional attachment context — `attachmentsText` (one opaque blob),
|
|
3095
|
+
* `attachmentsTexts` (one `{ text, source_artifact_id?, filename? }` entry per artifact, so
|
|
3096
|
+
* each block keeps its own attribution), `attachedArtifactIds` (the artifacts an opaque
|
|
3097
|
+
* `attachmentsText` came from) and `attachmentsFiles` (raw binary the engine parses) — plus
|
|
3098
|
+
* per-asset CVE `include` layers and `vexOverlay` — an OpenVEX 0.2.0 / CSAF 2.0 VEX
|
|
3099
|
+
* document (text) whose `not_affected`/`fixed` statements mark matching findings
|
|
3100
|
+
* `suppressed_by_vex` (retained + justification, excluded from the actionable counts).
|
|
2437
3101
|
*/
|
|
2438
3102
|
async inventoryEnrich(items, options = {}) {
|
|
2439
3103
|
const result = await inventoryEnrich({
|
|
@@ -2443,10 +3107,19 @@ var CrawlerClient = class {
|
|
|
2443
3107
|
...options.attachmentsText !== void 0 && {
|
|
2444
3108
|
attachments_text: options.attachmentsText
|
|
2445
3109
|
},
|
|
3110
|
+
...options.attachmentsTexts !== void 0 && {
|
|
3111
|
+
attachments_texts: options.attachmentsTexts
|
|
3112
|
+
},
|
|
3113
|
+
...options.attachedArtifactIds !== void 0 && {
|
|
3114
|
+
attached_artifact_ids: options.attachedArtifactIds
|
|
3115
|
+
},
|
|
2446
3116
|
...options.attachmentsFiles !== void 0 && {
|
|
2447
3117
|
attachments_files: options.attachmentsFiles
|
|
2448
3118
|
},
|
|
2449
|
-
...options.include !== void 0 && { include: [...options.include] }
|
|
3119
|
+
...options.include !== void 0 && { include: [...options.include] },
|
|
3120
|
+
...options.vexOverlay !== void 0 && {
|
|
3121
|
+
vex_overlay: { format: "vex", content: options.vexOverlay }
|
|
3122
|
+
}
|
|
2450
3123
|
}
|
|
2451
3124
|
});
|
|
2452
3125
|
return ensureOk(result);
|
|
@@ -2463,7 +3136,52 @@ var CrawlerClient = class {
|
|
|
2463
3136
|
});
|
|
2464
3137
|
return ensureOk(result);
|
|
2465
3138
|
}
|
|
3139
|
+
/**
|
|
3140
|
+
* Submit a raw security event to the async Event Enricher engine.
|
|
3141
|
+
*
|
|
3142
|
+
* Returns immediately with an `enrichment_id` — poll {@link eventEnrichStatus}
|
|
3143
|
+
* for the result (per-indicator findings + the aggregate event threat
|
|
3144
|
+
* assessment), or use {@link enricher}.`enrichEvent` to run the whole lifecycle.
|
|
3145
|
+
* CC extracts every indicator server-side — you do NOT pre-parse the alert.
|
|
3146
|
+
*
|
|
3147
|
+
* @param event The raw event — a Defender XDR / Sentinel alert JSON, a SIEM/EDR
|
|
3148
|
+
* log line, or any text (≤200,000 chars).
|
|
3149
|
+
* @param options.eventId Optional caller-side event identifier (≤200 chars), echoed back on the result.
|
|
3150
|
+
*/
|
|
3151
|
+
async eventEnrich(event, options = {}) {
|
|
3152
|
+
const result = await eventEnrich({
|
|
3153
|
+
client: this._client,
|
|
3154
|
+
body: {
|
|
3155
|
+
event,
|
|
3156
|
+
...options.eventId !== void 0 && { event_id: options.eventId }
|
|
3157
|
+
}
|
|
3158
|
+
});
|
|
3159
|
+
return ensureOk(result);
|
|
3160
|
+
}
|
|
3161
|
+
/**
|
|
3162
|
+
* Read the progress or result of an event enrichment.
|
|
3163
|
+
*
|
|
3164
|
+
* @param enrichmentId The `enrichment_id` returned by {@link eventEnrich}.
|
|
3165
|
+
*/
|
|
3166
|
+
async eventEnrichStatus(enrichmentId) {
|
|
3167
|
+
const result = await eventEnrichStatus({
|
|
3168
|
+
client: this._client,
|
|
3169
|
+
path: { enrichment_id: enrichmentId }
|
|
3170
|
+
});
|
|
3171
|
+
return ensureOk(result);
|
|
3172
|
+
}
|
|
2466
3173
|
};
|
|
3174
|
+
function expandGroupCatalogue(catalog, refs, rows) {
|
|
3175
|
+
if (!catalog || !refs || !rows) return;
|
|
3176
|
+
for (const row of rows) {
|
|
3177
|
+
if (typeof row === "string") continue;
|
|
3178
|
+
const indices = refs[row.technique_id] ?? [];
|
|
3179
|
+
if (indices.some((i) => !Number.isInteger(i) || i < 0 || i >= catalog.length)) {
|
|
3180
|
+
throw new Error("Invalid group log-source catalogue reference");
|
|
3181
|
+
}
|
|
3182
|
+
if (indices.length) row.log_sources = indices.map((i) => catalog[i]);
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
2467
3185
|
function ensureOk(result) {
|
|
2468
3186
|
if (result.data !== void 0 && result.error === void 0) {
|
|
2469
3187
|
return result.data;
|
|
@@ -2479,9 +3197,9 @@ function ensureOk(result) {
|
|
|
2479
3197
|
|
|
2480
3198
|
// package.json
|
|
2481
3199
|
var package_default = {
|
|
2482
|
-
version: "
|
|
3200
|
+
version: "5.0.0"};
|
|
2483
3201
|
|
|
2484
3202
|
// src/index.ts
|
|
2485
3203
|
var __version__ = package_default.version;
|
|
2486
3204
|
|
|
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 };
|
|
3205
|
+
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 };
|