@jupiterone/jupiterone-mcp 2.1.1 → 2.3.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/README.md +18 -2
- package/dist/client/graphql/queries.d.ts +48 -1
- package/dist/client/graphql/queries.d.ts.map +1 -1
- package/dist/client/graphql/queries.js +329 -1
- package/dist/client/graphql/queries.js.map +1 -1
- package/dist/client/jupiterone-client.d.ts +8 -0
- package/dist/client/jupiterone-client.d.ts.map +1 -1
- package/dist/client/jupiterone-client.js +13 -0
- package/dist/client/jupiterone-client.js.map +1 -1
- package/dist/client/services/threat-service.d.ts +31 -0
- package/dist/client/services/threat-service.d.ts.map +1 -0
- package/dist/client/services/threat-service.js +72 -0
- package/dist/client/services/threat-service.js.map +1 -0
- package/dist/generated/description-map.d.ts.map +1 -1
- package/dist/generated/description-map.js +602 -14
- package/dist/generated/description-map.js.map +1 -1
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +51 -1
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/tools/alerts.d.ts.map +1 -1
- package/dist/server/tools/alerts.js +2 -5
- package/dist/server/tools/alerts.js.map +1 -1
- package/dist/server/tools/dashboard-layout.d.ts +80 -3
- package/dist/server/tools/dashboard-layout.d.ts.map +1 -1
- package/dist/server/tools/dashboard-layout.js +220 -15
- package/dist/server/tools/dashboard-layout.js.map +1 -1
- package/dist/server/tools/dashboards.d.ts.map +1 -1
- package/dist/server/tools/dashboards.js +379 -10
- package/dist/server/tools/dashboards.js.map +1 -1
- package/dist/server/tools/errors.d.ts +61 -10
- package/dist/server/tools/errors.d.ts.map +1 -1
- package/dist/server/tools/errors.js +201 -10
- package/dist/server/tools/errors.js.map +1 -1
- package/dist/server/tools/index.d.ts.map +1 -1
- package/dist/server/tools/index.js +2 -0
- package/dist/server/tools/index.js.map +1 -1
- package/dist/server/tools/integrations.d.ts.map +1 -1
- package/dist/server/tools/integrations.js +15 -4
- package/dist/server/tools/integrations.js.map +1 -1
- package/dist/server/tools/j1ql.d.ts.map +1 -1
- package/dist/server/tools/j1ql.js +72 -4
- package/dist/server/tools/j1ql.js.map +1 -1
- package/dist/server/tools/rules.d.ts.map +1 -1
- package/dist/server/tools/rules.js +57 -6
- package/dist/server/tools/rules.js.map +1 -1
- package/dist/server/tools/telemetry.d.ts +7 -1
- package/dist/server/tools/telemetry.d.ts.map +1 -1
- package/dist/server/tools/telemetry.js.map +1 -1
- package/dist/server/tools/threat.d.ts +3 -0
- package/dist/server/tools/threat.d.ts.map +1 -0
- package/dist/server/tools/threat.js +284 -0
- package/dist/server/tools/threat.js.map +1 -0
- package/dist/server/tools/types.d.ts +5 -0
- package/dist/server/tools/types.d.ts.map +1 -1
- package/dist/server/tools/types.js +7 -1
- package/dist/server/tools/types.js.map +1 -1
- package/dist/server/tools/usage.d.ts +13 -3
- package/dist/server/tools/usage.d.ts.map +1 -1
- package/dist/server/tools/usage.js +186 -7
- package/dist/server/tools/usage.js.map +1 -1
- package/dist/server/tools/value-probe.d.ts +85 -0
- package/dist/server/tools/value-probe.d.ts.map +1 -0
- package/dist/server/tools/value-probe.js +473 -0
- package/dist/server/tools/value-probe.js.map +1 -0
- package/dist/server/tools/widget-config-lint.d.ts +39 -0
- package/dist/server/tools/widget-config-lint.d.ts.map +1 -0
- package/dist/server/tools/widget-config-lint.js +290 -0
- package/dist/server/tools/widget-config-lint.js.map +1 -0
- package/dist/server/tools/widget-preflight.d.ts +63 -0
- package/dist/server/tools/widget-preflight.d.ts.map +1 -0
- package/dist/server/tools/widget-preflight.js +238 -0
- package/dist/server/tools/widget-preflight.js.map +1 -0
- package/dist/server/tools/widget-render-contract.d.ts +134 -0
- package/dist/server/tools/widget-render-contract.d.ts.map +1 -0
- package/dist/server/tools/widget-render-contract.js +421 -0
- package/dist/server/tools/widget-render-contract.js.map +1 -0
- package/dist/server/tools/widget-settings-keys.d.ts +51 -0
- package/dist/server/tools/widget-settings-keys.d.ts.map +1 -0
- package/dist/server/tools/widget-settings-keys.js +152 -0
- package/dist/server/tools/widget-settings-keys.js.map +1 -0
- package/dist/types/jupiterone.d.ts +139 -0
- package/dist/types/jupiterone.d.ts.map +1 -1
- package/dist/utils/j1ql-filters.d.ts +48 -0
- package/dist/utils/j1ql-filters.d.ts.map +1 -0
- package/dist/utils/j1ql-filters.js +184 -0
- package/dist/utils/j1ql-filters.js.map +1 -0
- package/dist/utils/j1ql-validator.d.ts +0 -5
- package/dist/utils/j1ql-validator.d.ts.map +1 -1
- package/dist/utils/j1ql-validator.js +27 -6
- package/dist/utils/j1ql-validator.js.map +1 -1
- package/node_modules/dtrace-provider/build/Makefile +1 -1
- package/package.json +1 -1
- package/dist/utils/description-loader.d.ts +0 -2
- package/dist/utils/description-loader.d.ts.map +0 -1
- package/dist/utils/description-loader.js +0 -17
- package/dist/utils/description-loader.js.map +0 -1
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.threatTools = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const load_description_js_1 = require("../../utils/load-description.js");
|
|
6
|
+
const result_js_1 = require("./result.js");
|
|
7
|
+
const types_js_1 = require("./types.js");
|
|
8
|
+
/**
|
|
9
|
+
* Threat tools — the MCP surface over JupiterOne's Emerging Exposures capability.
|
|
10
|
+
*
|
|
11
|
+
* - get-threat per-CVE decision-grade brief (compact by default, full with `detail`)
|
|
12
|
+
* - get-threat-trending the cached trending region
|
|
13
|
+
* - check-threat-exposure this account's own exposure per CVE (direct/scanner match)
|
|
14
|
+
*
|
|
15
|
+
* All three are READ_ONLY and account-scoped (they inherit the multi-tenant `accountId` injection
|
|
16
|
+
* through the registration chokepoint). Each backing query is gated server-side by the
|
|
17
|
+
* VulnerabilityManagement entitlement + vuln-read permission; a caller without them gets the
|
|
18
|
+
* standard access-denied envelope.
|
|
19
|
+
*
|
|
20
|
+
* The brief and environment queries return unions; the handlers flatten them to a discriminated
|
|
21
|
+
* `outcome` / `status` field so the model always sees one shape. `source_unavailable` /
|
|
22
|
+
* `unavailable` are NEVER conflated with "no such CVE" / "not affected".
|
|
23
|
+
*/
|
|
24
|
+
// The environment traversal serves the whole batch in one round trip; the schema caps it (matching
|
|
25
|
+
// the backend's own ≤25 rule) so we fail fast with a clear message rather than triggering the
|
|
26
|
+
// server's request error.
|
|
27
|
+
const MAX_EXPOSURE_SUBJECTS = 25;
|
|
28
|
+
const CVE_ID_DESCRIPTION = 'A CVE identifier, e.g. "CVE-2021-44228". Case-insensitive; validated server-side.';
|
|
29
|
+
// The backing queries are gated by an account entitlement as well as by RBAC, and the generic
|
|
30
|
+
// access-denied frame talks only about account access — a customer without Emerging Exposures would
|
|
31
|
+
// otherwise be told to check their membership.
|
|
32
|
+
const ACCESS_DENIED_HINT = 'The threat tools also require the VulnerabilityManagement entitlement on the account and ' +
|
|
33
|
+
'vulnerability read permission for the caller. If other JupiterOne tools work on this account, ' +
|
|
34
|
+
'the entitlement is the likely cause: ask an account admin about Emerging Exposures rather than ' +
|
|
35
|
+
're-authenticating.';
|
|
36
|
+
/**
|
|
37
|
+
* Join emphasis-tagged narrative runs into plain text for the model.
|
|
38
|
+
*
|
|
39
|
+
* The runs are inline spans of a single sentence and carry their own spacing — the wire sends
|
|
40
|
+
* `"…rated "`, `"critical"`, `". "`, `"It has been exploited in the wild."` — so they concatenate
|
|
41
|
+
* directly. Joining on a space put a gap before every emphasised run and before the closing
|
|
42
|
+
* punctuation ("rated critical ."), in the two fields a model quotes most. Whitespace runs are
|
|
43
|
+
* collapsed so spacing added on the other side cannot reintroduce the doubles.
|
|
44
|
+
*/
|
|
45
|
+
function joinSegments(segments) {
|
|
46
|
+
return (segments ?? [])
|
|
47
|
+
.map((segment) => segment?.text ?? '')
|
|
48
|
+
.join('')
|
|
49
|
+
.replace(/\s+/g, ' ')
|
|
50
|
+
.trim();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Flatten the fixed-order metric-tile union into a single decision-signals object. A tile can carry
|
|
54
|
+
* a null value (renders as an empty label upstream); it is kept so the model sees "no data" rather
|
|
55
|
+
* than an absent key.
|
|
56
|
+
*/
|
|
57
|
+
function flattenTiles(tiles) {
|
|
58
|
+
const signals = {};
|
|
59
|
+
for (const tile of tiles ?? []) {
|
|
60
|
+
switch (tile.__typename) {
|
|
61
|
+
case 'EmergingExposureCvssTile':
|
|
62
|
+
signals.cvss = { score: tile.score ?? null, severity: tile.severity ?? null };
|
|
63
|
+
break;
|
|
64
|
+
case 'EmergingExposureEpssTile':
|
|
65
|
+
signals.epss = { percentile: tile.percentile ?? null };
|
|
66
|
+
break;
|
|
67
|
+
case 'EmergingExposureMaturityTile':
|
|
68
|
+
signals.exploitMaturity = tile.maturity ?? null;
|
|
69
|
+
break;
|
|
70
|
+
case 'EmergingExposureKevTile':
|
|
71
|
+
signals.kevState = tile.state ?? null;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return signals;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The default get-threat payload: a decision-first projection of a resolved brief. The full brief
|
|
79
|
+
* object is returned only when `detail: true`.
|
|
80
|
+
*/
|
|
81
|
+
function projectCompactBrief(brief) {
|
|
82
|
+
const { verdict, timeline, whoIsUsingIt } = brief;
|
|
83
|
+
const nodes = timeline?.nodes ?? [];
|
|
84
|
+
return {
|
|
85
|
+
outcome: 'found',
|
|
86
|
+
subjectId: brief.subjectId,
|
|
87
|
+
assessedAt: brief.assessedAt,
|
|
88
|
+
tier: verdict?.tier,
|
|
89
|
+
stance: verdict?.stance,
|
|
90
|
+
impactLabel: verdict?.impactLabel ?? null,
|
|
91
|
+
// The join key for a product-presence search of the graph; trending rows often lack it.
|
|
92
|
+
affectedProduct: brief.fingerprint?.affectedProduct ?? null,
|
|
93
|
+
headline: joinSegments(verdict?.headline),
|
|
94
|
+
support: joinSegments(verdict?.support),
|
|
95
|
+
beats: verdict?.beats ?? [],
|
|
96
|
+
threatSignals: flattenTiles(brief.tiles),
|
|
97
|
+
ssvc: brief.ssvc ?? null,
|
|
98
|
+
remediation: brief.remediation ?? null,
|
|
99
|
+
// The nodes a decision hangs on: what has actually happened (done) and what happened recently
|
|
100
|
+
// (hot). Fixed node order is preserved.
|
|
101
|
+
timelineHighlights: nodes.filter((node) => node.state === 'done' || node.state === 'hot'),
|
|
102
|
+
kev: {
|
|
103
|
+
inCisaKev: timeline?.inCisaKev ?? null,
|
|
104
|
+
inVulncheckKev: timeline?.inVulncheckKev ?? null,
|
|
105
|
+
cisaKevDateAdded: timeline?.cisaKevDateAdded ?? null,
|
|
106
|
+
vulncheckKevDateAdded: timeline?.vulncheckKevDateAdded ?? null,
|
|
107
|
+
lead: timeline?.kevLead ?? null,
|
|
108
|
+
},
|
|
109
|
+
coverageGap: brief.coverage?.coverageGap ?? null,
|
|
110
|
+
activeExploitation: whoIsUsingIt?.exploitationActivity ?? null,
|
|
111
|
+
whoIsUsingIt: {
|
|
112
|
+
threatActors: whoIsUsingIt?.threatActors ?? null,
|
|
113
|
+
ransomware: whoIsUsingIt?.ransomware ?? null,
|
|
114
|
+
botnets: whoIsUsingIt?.botnets ?? null,
|
|
115
|
+
honeypot: whoIsUsingIt?.honeypot ?? null,
|
|
116
|
+
canaries: whoIsUsingIt?.canaries ?? null,
|
|
117
|
+
github: whoIsUsingIt?.github ?? null,
|
|
118
|
+
counts: whoIsUsingIt?.counts ?? null,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A union member this module does not know is schema drift, not an outage. Reporting it as a
|
|
124
|
+
* retry state would have every call ask for a retry that can never succeed; throwing surfaces it as
|
|
125
|
+
* an error with a class in telemetry. Typed `never` so adding a member to the union without a case
|
|
126
|
+
* here fails the build.
|
|
127
|
+
*/
|
|
128
|
+
function unexpectedMember(field, member) {
|
|
129
|
+
const typename = member.__typename;
|
|
130
|
+
return new Error(`Invalid response from JupiterOne API: ${field} returned unexpected __typename ${String(typename)}`);
|
|
131
|
+
}
|
|
132
|
+
/** Flatten the brief outcome union to a discriminated `outcome` field. */
|
|
133
|
+
function projectBriefResult(result, detail) {
|
|
134
|
+
switch (result.__typename) {
|
|
135
|
+
case 'EmergingExposureBrief':
|
|
136
|
+
return detail
|
|
137
|
+
? { outcome: 'found', subjectId: result.subjectId, brief: result }
|
|
138
|
+
: projectCompactBrief(result);
|
|
139
|
+
case 'EmergingExposureNotFound':
|
|
140
|
+
return { outcome: 'not_found', subjectId: result.subjectId };
|
|
141
|
+
case 'EmergingExposureInvalidInput':
|
|
142
|
+
return { outcome: 'invalid_input', message: result.message };
|
|
143
|
+
case 'EmergingExposureSourceUnavailable':
|
|
144
|
+
// An explicit retry state — never "no such CVE". The validated id rides along.
|
|
145
|
+
return {
|
|
146
|
+
outcome: 'source_unavailable',
|
|
147
|
+
subjectId: result.subjectId,
|
|
148
|
+
retryable: result.retryable ?? true,
|
|
149
|
+
};
|
|
150
|
+
default:
|
|
151
|
+
throw unexpectedMember('emergingExposure', result);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** Flatten one environment union member to a discriminated `status` field. */
|
|
155
|
+
function projectEnvironmentResult(result) {
|
|
156
|
+
switch (result.__typename) {
|
|
157
|
+
case 'EmergingExposureEnvironment':
|
|
158
|
+
return {
|
|
159
|
+
subjectId: result.subjectId,
|
|
160
|
+
status: 'checked',
|
|
161
|
+
scannerConfirmedAssetCount: result.scannerConfirmedAssetCount,
|
|
162
|
+
unifiedVulnerabilityId: result.unifiedVulnerabilityId ?? null,
|
|
163
|
+
assetExposure: result.assetExposure ?? null,
|
|
164
|
+
};
|
|
165
|
+
case 'EmergingExposureEnvironmentInvalidSubject':
|
|
166
|
+
return { subjectId: result.subjectId, status: 'invalid_input', message: result.message };
|
|
167
|
+
case 'EmergingExposureEnvironmentUnavailable':
|
|
168
|
+
return {
|
|
169
|
+
subjectId: result.subjectId,
|
|
170
|
+
status: 'unavailable',
|
|
171
|
+
retryable: result.retryable ?? true,
|
|
172
|
+
};
|
|
173
|
+
default:
|
|
174
|
+
throw unexpectedMember('emergingExposureEnvironments', result);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Output envelopes are open (`.loose()` via the SDK wrapper): the documented keys are a contract,
|
|
178
|
+
// and the handlers deliberately forward richer nested content (the full brief under `detail`,
|
|
179
|
+
// upstream display fields) on top of them. Scalars copied straight from the API are `.nullish()`:
|
|
180
|
+
// the schema declares them non-null, but an advertised non-nullable scalar the backend ever nulls
|
|
181
|
+
// rejects the whole call on a validating client (the hasSkippedSteps failure), and the cost of
|
|
182
|
+
// admitting null here is nothing.
|
|
183
|
+
const getThreatOutput = {
|
|
184
|
+
// 'found' rather than 'resolved': a weaker model read "resolved" as "remediated" on dev, which
|
|
185
|
+
// is what the word means everywhere else in vulnerability management. Same for 'checked' below.
|
|
186
|
+
outcome: zod_1.z.enum(['found', 'not_found', 'invalid_input', 'source_unavailable']),
|
|
187
|
+
subjectId: zod_1.z.string().nullish(),
|
|
188
|
+
message: zod_1.z.string().nullish(),
|
|
189
|
+
retryable: zod_1.z.boolean().optional(),
|
|
190
|
+
tier: zod_1.z.string().nullish(),
|
|
191
|
+
stance: zod_1.z.string().nullish(),
|
|
192
|
+
headline: zod_1.z.string().optional(),
|
|
193
|
+
support: zod_1.z.string().optional(),
|
|
194
|
+
coverageGap: zod_1.z.boolean().nullish(),
|
|
195
|
+
affectedProduct: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullish(),
|
|
196
|
+
brief: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
197
|
+
};
|
|
198
|
+
const getThreatTrendingOutput = {
|
|
199
|
+
generatedAt: zod_1.z.string().nullish(),
|
|
200
|
+
items: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.any())),
|
|
201
|
+
};
|
|
202
|
+
const checkThreatExposureOutput = {
|
|
203
|
+
results: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.any())),
|
|
204
|
+
};
|
|
205
|
+
exports.threatTools = [
|
|
206
|
+
(0, types_js_1.defineTool)({
|
|
207
|
+
name: 'get-threat',
|
|
208
|
+
title: 'Get Threat Brief',
|
|
209
|
+
description: (0, load_description_js_1.loadDescription)('get-threat.md'),
|
|
210
|
+
inputSchema: {
|
|
211
|
+
cveId: zod_1.z.string().describe(CVE_ID_DESCRIPTION),
|
|
212
|
+
assetExposure: zod_1.z
|
|
213
|
+
.enum(['public', 'internal'])
|
|
214
|
+
.optional()
|
|
215
|
+
.describe('Optional BOD 26-04 asset-exposure hook. When supplied, remediation returns a single ' +
|
|
216
|
+
'resolved branch instead of the two-branch conditional. Omit to get both branches.'),
|
|
217
|
+
detail: zod_1.z
|
|
218
|
+
.boolean()
|
|
219
|
+
.optional()
|
|
220
|
+
.describe('When true, return the full brief (larger payload: CPE footprint, threat-actor ' +
|
|
221
|
+
'techniques and control mappings, detection tooling, exploit references). Default ' +
|
|
222
|
+
'false returns a compact, decision-first summary.'),
|
|
223
|
+
},
|
|
224
|
+
outputSchema: getThreatOutput,
|
|
225
|
+
annotations: types_js_1.READ_ONLY,
|
|
226
|
+
accessDeniedHint: ACCESS_DENIED_HINT,
|
|
227
|
+
errorContext: 'Error fetching threat brief',
|
|
228
|
+
handler: async ({ cveId, assetExposure, detail }, client) => {
|
|
229
|
+
const wantsDetail = detail ?? false;
|
|
230
|
+
const result = await client.getThreatBrief(cveId, { assetExposure, detail: wantsDetail });
|
|
231
|
+
return (0, result_js_1.structuredResult)(projectBriefResult(result, wantsDetail));
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
(0, types_js_1.defineTool)({
|
|
235
|
+
name: 'get-threat-trending',
|
|
236
|
+
title: 'Get Trending Threats',
|
|
237
|
+
description: (0, load_description_js_1.loadDescription)('get-threat-trending.md'),
|
|
238
|
+
inputSchema: {
|
|
239
|
+
limit: zod_1.z
|
|
240
|
+
.number()
|
|
241
|
+
.int()
|
|
242
|
+
.min(1)
|
|
243
|
+
.max(50)
|
|
244
|
+
.optional()
|
|
245
|
+
.describe('Optional client-side cap on the number of trending items returned. The server list ' +
|
|
246
|
+
'is ranked and capped upstream (25 rows today); list order is the ranking.'),
|
|
247
|
+
},
|
|
248
|
+
outputSchema: getThreatTrendingOutput,
|
|
249
|
+
annotations: types_js_1.READ_ONLY,
|
|
250
|
+
accessDeniedHint: ACCESS_DENIED_HINT,
|
|
251
|
+
errorContext: 'Error fetching trending threats',
|
|
252
|
+
handler: async ({ limit }, client) => {
|
|
253
|
+
const { generatedAt, items } = await client.getThreatTrending();
|
|
254
|
+
return (0, result_js_1.structuredResult)({
|
|
255
|
+
generatedAt,
|
|
256
|
+
items: limit === undefined ? items : items.slice(0, limit),
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
}),
|
|
260
|
+
(0, types_js_1.defineTool)({
|
|
261
|
+
name: 'check-threat-exposure',
|
|
262
|
+
title: 'Check Threat Exposure',
|
|
263
|
+
description: (0, load_description_js_1.loadDescription)('check-threat-exposure.md'),
|
|
264
|
+
inputSchema: {
|
|
265
|
+
cveIds: zod_1.z
|
|
266
|
+
.array(zod_1.z.string())
|
|
267
|
+
.min(1)
|
|
268
|
+
.max(MAX_EXPOSURE_SUBJECTS)
|
|
269
|
+
.describe(`The CVE identifiers to check against this account's graph (1–${MAX_EXPOSURE_SUBJECTS}). ` +
|
|
270
|
+
'Each is answered independently; a malformed id fails only its own entry.'),
|
|
271
|
+
},
|
|
272
|
+
outputSchema: checkThreatExposureOutput,
|
|
273
|
+
annotations: types_js_1.READ_ONLY,
|
|
274
|
+
accessDeniedHint: ACCESS_DENIED_HINT,
|
|
275
|
+
errorContext: 'Error checking threat exposure',
|
|
276
|
+
handler: async ({ cveIds }, client) => {
|
|
277
|
+
// The brief accepts any casing but the environment lookup rejects a lowercase id as
|
|
278
|
+
// invalid_input (observed on dev), so normalise here rather than teach callers two rules.
|
|
279
|
+
const results = await client.checkThreatExposure(cveIds.map((id) => id.trim().toUpperCase()));
|
|
280
|
+
return (0, result_js_1.structuredResult)({ results: results.map(projectEnvironmentResult) });
|
|
281
|
+
},
|
|
282
|
+
}),
|
|
283
|
+
];
|
|
284
|
+
//# sourceMappingURL=threat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threat.js","sourceRoot":"","sources":["../../../src/server/tools/threat.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAQxB,yEAAkE;AAClE,2CAA+C;AAC/C,yCAAwE;AAExE;;;;;;;;;;;;;;;GAeG;AAEH,mGAAmG;AACnG,8FAA8F;AAC9F,0BAA0B;AAC1B,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAM,kBAAkB,GACtB,mFAAmF,CAAC;AAEtF,8FAA8F;AAC9F,oGAAoG;AACpG,+CAA+C;AAC/C,MAAM,kBAAkB,GACtB,2FAA2F;IAC3F,gGAAgG;IAChG,iGAAiG;IACjG,oBAAoB,CAAC;AAEvB;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,QAAqD;IACzE,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;SACpB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;SACrC,IAAI,CAAC,EAAE,CAAC;SACR,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,KAA4C;IAChE,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,IAAI,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QAC/B,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;YACxB,KAAK,0BAA0B;gBAC7B,OAAO,CAAC,IAAI,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,QAAQ,EAAE,IAAI,CA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,CAAC,CAAC;iBACN,GAAG,CAAC,qBAAqB,CAAC;iBAC1B,QAAQ,CACP,gEAAgE,qBAAqB,KAAK;gBACxF,0EAA0E,CAC7E;SACJ;QACD,YAAY,EAAE,yBAAyB;QACvC,WAAW,EAAE,oBAAS;QACtB,gBAAgB,EAAE,kBAAkB;QACpC,YAAY,EAAE,gCAAgC;QAC9C,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE;YACpC,oFAAoF;YACpF,0FAA0F;YAC1F,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YAC9F,OAAO,IAAA,4BAAgB,EAAC,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;QAC9E,CAAC;KACF,CAAC;CACH,CAAC"}
|
|
@@ -68,6 +68,11 @@ export interface ToolDefinition<T extends z.ZodRawShape = z.ZodRawShape> {
|
|
|
68
68
|
handler: ToolHandler<T>;
|
|
69
69
|
/** Prefix for the generic error envelope when the handler throws (e.g. "Error listing rules"). */
|
|
70
70
|
errorContext: string;
|
|
71
|
+
/**
|
|
72
|
+
* Appended to the access-denied frame when this tool's backing API gates on more than account
|
|
73
|
+
* membership (an entitlement, say), so a 403 from an unentitled account is not read as a revoked one.
|
|
74
|
+
*/
|
|
75
|
+
accessDeniedHint?: string;
|
|
71
76
|
/** Optional validator-aware error formatter (J1QL uses this for actionable suggestions). */
|
|
72
77
|
formatError?: (error: unknown, params: z.infer<z.ZodObject<T>>, validator: J1QLValidator) => ToolResult;
|
|
73
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,EA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C,CAAC,WAAW,GAAG,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxE;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,6FAA6F;IAC7F,WAAW,EAAE,eAAe,CAAC;IAC7B,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACxB,kGAAkG;IAClG,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4FAA4F;IAC5F,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC/B,SAAS,EAAE,aAAa,KACrB,UAAU,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAE1F;AAED,mGAAmG;AACnG,eAAO,MAAM,SAAS,EAAE,eAAwC,CAAC;AAGjE,eAAO,MAAM,MAAM,EAAE,eAIpB,CAAC;AACF,eAAO,MAAM,MAAM,EAAE,eAAgE,CAAC"}
|
|
@@ -11,6 +11,12 @@ function defineTool(def) {
|
|
|
11
11
|
}
|
|
12
12
|
/** Annotation presets. A read tool, a pure create, and a state-mutating call (update/evaluate). */
|
|
13
13
|
exports.READ_ONLY = { readOnlyHint: true };
|
|
14
|
-
|
|
14
|
+
// Repeating a create makes a second object rather than converging on one state — which is exactly
|
|
15
|
+
// how a lost response turns into a duplicate widget, so the hint is worth stating.
|
|
16
|
+
exports.CREATE = {
|
|
17
|
+
readOnlyHint: false,
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
idempotentHint: false,
|
|
20
|
+
};
|
|
15
21
|
exports.MUTATE = { readOnlyHint: false, destructiveHint: true };
|
|
16
22
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/server/tools/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/server/tools/types.ts"],"names":[],"mappings":";;;AA+FA,gCAEC;AAND;;;GAGG;AACH,SAAgB,UAAU,CAA0B,GAAsB;IACxE,OAAO,GAAgC,CAAC;AAC1C,CAAC;AAED,mGAAmG;AACtF,QAAA,SAAS,GAAoB,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AACjE,kGAAkG;AAClG,mFAAmF;AACtE,QAAA,MAAM,GAAoB;IACrC,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,KAAK;CACtB,CAAC;AACW,QAAA,MAAM,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import type { ToolResult } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Redacts
|
|
3
|
+
* Redacts literal values in a J1QL query, preserving structure (entity types, operators,
|
|
4
4
|
* property names) so query *shape* is captured for usage analytics without literal values.
|
|
5
5
|
*
|
|
6
6
|
* Ported from query-engine's `redactCypher` (sdk-graph/src/cypher/redact.ts), adapted for J1QL
|
|
7
7
|
* (single- and double-quoted literals). The patterns span escaped quotes (`\'` / `\"`) so a
|
|
8
8
|
* literal is always replaced in full; imperfect boundaries only ever over-redact, never leak.
|
|
9
|
+
*
|
|
10
|
+
* A regex literal is a value too, and `WITH email = /alice@corp\.com/i` used to reach telemetry
|
|
11
|
+
* verbatim. Its pattern is replaced and the flags are kept: the flags say how the match behaves
|
|
12
|
+
* without carrying any of the account's data. Strings are redacted FIRST, so a slash inside a
|
|
13
|
+
* quoted literal is already gone and cannot open a regex that swallows the rest of the query.
|
|
9
14
|
*/
|
|
10
15
|
export declare function redactJ1ql(query: string): string;
|
|
11
16
|
export declare function truncateReason(reason: string): string;
|
|
12
17
|
/** Allowlisted, sanitized summary of tool inputs for usage telemetry. */
|
|
13
18
|
export declare function summarizeInput(params: Record<string, unknown>): Record<string, unknown>;
|
|
14
|
-
/**
|
|
15
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Result metadata (counts, pagination, status) derived from the structured payload.
|
|
21
|
+
*
|
|
22
|
+
* The tool name is read for exactly one lift — the created board's id, below — because a
|
|
23
|
+
* top-level `id` means a different thing on every tool that returns one.
|
|
24
|
+
*/
|
|
25
|
+
export declare function summarizeResult(result: ToolResult, toolName?: string): Record<string, unknown>;
|
|
16
26
|
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/server/tools/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/server/tools/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKhD;AAID,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AA+ED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWvF;AA+FD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA0D9F"}
|
|
@@ -5,25 +5,32 @@ exports.truncateReason = truncateReason;
|
|
|
5
5
|
exports.summarizeInput = summarizeInput;
|
|
6
6
|
exports.summarizeResult = summarizeResult;
|
|
7
7
|
/**
|
|
8
|
-
* Redacts
|
|
8
|
+
* Redacts literal values in a J1QL query, preserving structure (entity types, operators,
|
|
9
9
|
* property names) so query *shape* is captured for usage analytics without literal values.
|
|
10
10
|
*
|
|
11
11
|
* Ported from query-engine's `redactCypher` (sdk-graph/src/cypher/redact.ts), adapted for J1QL
|
|
12
12
|
* (single- and double-quoted literals). The patterns span escaped quotes (`\'` / `\"`) so a
|
|
13
13
|
* literal is always replaced in full; imperfect boundaries only ever over-redact, never leak.
|
|
14
|
+
*
|
|
15
|
+
* A regex literal is a value too, and `WITH email = /alice@corp\.com/i` used to reach telemetry
|
|
16
|
+
* verbatim. Its pattern is replaced and the flags are kept: the flags say how the match behaves
|
|
17
|
+
* without carrying any of the account's data. Strings are redacted FIRST, so a slash inside a
|
|
18
|
+
* quoted literal is already gone and cannot open a regex that swallows the rest of the query.
|
|
14
19
|
*/
|
|
15
20
|
function redactJ1ql(query) {
|
|
16
21
|
return query
|
|
17
22
|
.replace(/'(?:[^'\\]|\\.)*'/g, "'[REDACTED]'")
|
|
18
|
-
.replace(/"(?:[^"\\]|\\.)*"/g, '"[REDACTED]"')
|
|
23
|
+
.replace(/"(?:[^"\\]|\\.)*"/g, '"[REDACTED]"')
|
|
24
|
+
.replace(/\/(?:[^/\\\n]|\\.)+\/([A-Za-z]*)/g, '/[REDACTED]/$1');
|
|
19
25
|
}
|
|
20
26
|
const REASON_MAX = 500;
|
|
21
27
|
function truncateReason(reason) {
|
|
22
28
|
return reason.length > REASON_MAX ? `${reason.slice(0, REASON_MAX)}…` : reason;
|
|
23
29
|
}
|
|
24
|
-
// Allowlist of
|
|
25
|
-
// which keeps sensitive payloads out: action headers/endpoints/
|
|
26
|
-
// templates, J1QL variables/flags/scopeFilters, rule
|
|
30
|
+
// Allowlist of inputs safe to log verbatim (scalars, plus the CVE-id list). Everything not listed
|
|
31
|
+
// is dropped (default-deny), which keeps sensitive payloads out: action headers/endpoints/
|
|
32
|
+
// recipients/body, integration config, templates, J1QL variables/flags/scopeFilters, rule
|
|
33
|
+
// operations, and the raw widget input.
|
|
27
34
|
const SAFE_INPUT_KEYS = [
|
|
28
35
|
'ruleId',
|
|
29
36
|
'dashboardId',
|
|
@@ -44,7 +51,57 @@ const SAFE_INPUT_KEYS = [
|
|
|
44
51
|
'tag',
|
|
45
52
|
'includeConfig',
|
|
46
53
|
'includeDeleted',
|
|
54
|
+
// The widget being updated. Without it, an upstream 500 on update-dashboard-widget (observed
|
|
55
|
+
// twice on dev, 2026-08-21) can be tied to a board but not to the widget that drew it.
|
|
56
|
+
'widgetId',
|
|
57
|
+
// The threat tools' brief options: a boolean and a schema-validated enum. Their CVE ids are
|
|
58
|
+
// logged too, but through summarizeCveIds below, which admits only well-formed identifiers.
|
|
59
|
+
'assetExposure',
|
|
60
|
+
'detail',
|
|
47
61
|
];
|
|
62
|
+
/**
|
|
63
|
+
* Named lifts out of a widget-write payload.
|
|
64
|
+
*
|
|
65
|
+
* The widget object as a whole stays out of telemetry (default-deny above), but that left
|
|
66
|
+
* `create-dashboard-widget` recording nothing except its `dashboardId` — so the widget failures in
|
|
67
|
+
* TD-9016 were unmeasurable by construction. The chart type and the query *shape* are the two
|
|
68
|
+
* fields that make them diagnosable, and both are safe: the type is an enum, and the query goes
|
|
69
|
+
* through the same redactor as every other logged J1QL.
|
|
70
|
+
*/
|
|
71
|
+
function summarizeWidgetInput(input, out) {
|
|
72
|
+
if (!input || typeof input !== 'object' || Array.isArray(input))
|
|
73
|
+
return;
|
|
74
|
+
const widget = input;
|
|
75
|
+
if (typeof widget.type === 'string')
|
|
76
|
+
out.widgetType = widget.type;
|
|
77
|
+
const queries = widget.config?.queries;
|
|
78
|
+
if (Array.isArray(queries)) {
|
|
79
|
+
const shapes = queries
|
|
80
|
+
.map((entry) => entry?.query)
|
|
81
|
+
.filter((query) => typeof query === 'string')
|
|
82
|
+
.map(redactJ1ql);
|
|
83
|
+
if (shapes.length > 0)
|
|
84
|
+
out.widgetQueries = shapes;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* CVE identifiers are public vocabulary and which CVEs customers ask about is the threat tools'
|
|
89
|
+
* primary usage signal. But the input schemas accept any string, so a "CVE id" can carry anything
|
|
90
|
+
* a caller typed. Only values shaped like a CVE id are logged (canonically cased); everything else
|
|
91
|
+
* is replaced by a marker, so the batch size and the malformed-input rate stay measurable without
|
|
92
|
+
* the text.
|
|
93
|
+
*/
|
|
94
|
+
const CVE_ID = /^CVE-\d{4}-\d{4,7}$/i;
|
|
95
|
+
const NOT_A_CVE_ID = '[NOT_A_CVE_ID]';
|
|
96
|
+
function loggableCveId(value) {
|
|
97
|
+
return typeof value === 'string' && CVE_ID.test(value) ? value.toUpperCase() : NOT_A_CVE_ID;
|
|
98
|
+
}
|
|
99
|
+
function summarizeCveIds(params, out) {
|
|
100
|
+
if (params.cveId !== undefined)
|
|
101
|
+
out.cveId = loggableCveId(params.cveId);
|
|
102
|
+
if (Array.isArray(params.cveIds))
|
|
103
|
+
out.cveIds = params.cveIds.map(loggableCveId);
|
|
104
|
+
}
|
|
48
105
|
/** Allowlisted, sanitized summary of tool inputs for usage telemetry. */
|
|
49
106
|
function summarizeInput(params) {
|
|
50
107
|
const out = {};
|
|
@@ -57,8 +114,96 @@ function summarizeInput(params) {
|
|
|
57
114
|
// The cursor is an opaque pagination token — record only that paging was requested.
|
|
58
115
|
if (params.cursor !== undefined)
|
|
59
116
|
out.hasCursor = true;
|
|
117
|
+
summarizeWidgetInput(params.input, out);
|
|
118
|
+
summarizeCveIds(params, out);
|
|
60
119
|
return out;
|
|
61
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* What a widget write was allowed to draw, and what the server had to fix for it.
|
|
123
|
+
*
|
|
124
|
+
* The counterpart to `summarizeWidgetInput`: the input side records what was asked for, this side
|
|
125
|
+
* records what the gate, the preflight and the layout fill did about it. Every field is an enum, a
|
|
126
|
+
* boolean or a count — the notes, ids and grids they come from stay out.
|
|
127
|
+
*/
|
|
128
|
+
function summarizeWidgetResult(obj, out) {
|
|
129
|
+
// A rejected widget records why, so contract rejections are countable by chart type and missing
|
|
130
|
+
// column instead of by string-matching the error text. `correctionOffered` separates a rejection
|
|
131
|
+
// that shipped a ready-to-run query from one that only named the shape — without it, corrector
|
|
132
|
+
// adoption (rejection with a fix, then a success) cannot be told from shape hints alone.
|
|
133
|
+
if (typeof obj.contractOk === 'boolean')
|
|
134
|
+
out.contractOk = obj.contractOk;
|
|
135
|
+
if (Array.isArray(obj.missingRequired))
|
|
136
|
+
out.missingRequired = obj.missingRequired;
|
|
137
|
+
if (typeof obj.chartType === 'string')
|
|
138
|
+
out.widgetType = obj.chartType;
|
|
139
|
+
if (typeof obj.correctionOffered === 'boolean')
|
|
140
|
+
out.correctionOffered = obj.correctionOffered;
|
|
141
|
+
// A config-lint block carries its cause as a code, so managed-board and empty-markdown blocks are
|
|
142
|
+
// countable the same way as contract rejections instead of by matching their message text.
|
|
143
|
+
if (typeof obj.lintCode === 'string')
|
|
144
|
+
out.lintCode = obj.lintCode;
|
|
145
|
+
// Widget writes report what the widget will draw; carrying it here is what makes the
|
|
146
|
+
// "created successfully, renders blank" failure countable rather than invisible.
|
|
147
|
+
const preflight = obj.renderPreflight;
|
|
148
|
+
if (preflight && typeof preflight === 'object') {
|
|
149
|
+
if (typeof preflight.status === 'string')
|
|
150
|
+
out.preflightStatus = preflight.status;
|
|
151
|
+
if (typeof preflight.reason === 'string')
|
|
152
|
+
out.preflightSkipReason = preflight.reason;
|
|
153
|
+
if (typeof preflight.rowsReturned === 'number')
|
|
154
|
+
out.rowsReturned = preflight.rowsReturned;
|
|
155
|
+
if (typeof preflight.willRenderEmpty === 'boolean') {
|
|
156
|
+
out.willRenderEmpty = preflight.willRenderEmpty;
|
|
157
|
+
}
|
|
158
|
+
// The preflight's own wall clock. A widget write's durationMs already contains it, so without
|
|
159
|
+
// this the only way to separate a slow API from a slow probe is to compare release versions.
|
|
160
|
+
if (typeof preflight.preflightMs === 'number')
|
|
161
|
+
out.preflightMs = preflight.preflightMs;
|
|
162
|
+
}
|
|
163
|
+
// Present only when the fill placed something, so the field is its firing rate: the direct
|
|
164
|
+
// measure of the default-position failure it was built for, otherwise prose in configNotes.
|
|
165
|
+
if (typeof obj.layoutAutoFilled === 'boolean')
|
|
166
|
+
out.layoutAutoFilled = obj.layoutAutoFilled;
|
|
167
|
+
// Key paths only, never values — the guess-rate metric for settings keys that cached session
|
|
168
|
+
// docs cannot teach (the first prompt-driven build guessed `number.dataLabelUnit`; the teaching
|
|
169
|
+
// note corrected it mid-session and telemetry showed nothing).
|
|
170
|
+
if (Array.isArray(obj.droppedSettingsKeys))
|
|
171
|
+
out.droppedSettingsKeys = obj.droppedSettingsKeys;
|
|
172
|
+
// Counts, not the lists: a widget id is no use to an aggregate query, and the grid is the
|
|
173
|
+
// caller's data.
|
|
174
|
+
if (Array.isArray(obj.omittedWidgets))
|
|
175
|
+
out.omittedWidgetCount = obj.omittedWidgets.length;
|
|
176
|
+
if (Array.isArray(obj.layoutOverlaps))
|
|
177
|
+
out.layoutOverlapCount = obj.layoutOverlaps.length;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Verdict mix and correction-offer rate out of whichever advisory block the tool attached.
|
|
181
|
+
*
|
|
182
|
+
* The verdict is the only field of a diagnosis entry that is safe here: it is a closed enum, while
|
|
183
|
+
* the note, the field name, the matched literal and the corrected query are all built from the
|
|
184
|
+
* account's own data. So a correction is recorded as having been offered, and never by its content
|
|
185
|
+
* — the same default-deny rule as the input allowlist.
|
|
186
|
+
*/
|
|
187
|
+
function summarizeDiagnosis(obj, out) {
|
|
188
|
+
const preflight = obj.renderPreflight;
|
|
189
|
+
const blocks = [preflight?.diagnosis, obj.queryDiagnosis, obj.emptyResultDiagnosis];
|
|
190
|
+
const entries = blocks
|
|
191
|
+
.filter((block) => Array.isArray(block))
|
|
192
|
+
.flat()
|
|
193
|
+
.filter((entry) => !!entry && typeof entry === 'object' && !Array.isArray(entry));
|
|
194
|
+
if (entries.length === 0)
|
|
195
|
+
return;
|
|
196
|
+
const verdicts = entries
|
|
197
|
+
.map((entry) => entry.verdict)
|
|
198
|
+
.filter((verdict) => typeof verdict === 'string');
|
|
199
|
+
if (verdicts.length > 0)
|
|
200
|
+
out.diagnosisVerdicts = [...new Set(verdicts)];
|
|
201
|
+
// Reported as false when the probes ran and offered nothing, because the offer rate needs its
|
|
202
|
+
// denominator: a diagnosis with no fix and no diagnosis at all are different events. Keyed on a
|
|
203
|
+
// string rather than the key's presence — a verdict that could not build one still carries the
|
|
204
|
+
// field, set to undefined.
|
|
205
|
+
out.correctionOffered = entries.some((entry) => typeof entry.correctedQuery === 'string');
|
|
206
|
+
}
|
|
62
207
|
const COLLECTION_KEYS = [
|
|
63
208
|
'data',
|
|
64
209
|
'rules',
|
|
@@ -69,9 +214,16 @@ const COLLECTION_KEYS = [
|
|
|
69
214
|
'evaluations',
|
|
70
215
|
'activeAlerts',
|
|
71
216
|
'dashboards',
|
|
217
|
+
'items',
|
|
218
|
+
'results',
|
|
72
219
|
];
|
|
73
|
-
/**
|
|
74
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Result metadata (counts, pagination, status) derived from the structured payload.
|
|
222
|
+
*
|
|
223
|
+
* The tool name is read for exactly one lift — the created board's id, below — because a
|
|
224
|
+
* top-level `id` means a different thing on every tool that returns one.
|
|
225
|
+
*/
|
|
226
|
+
function summarizeResult(result, toolName) {
|
|
75
227
|
const out = { isError: !!result.isError };
|
|
76
228
|
const sc = result.structuredContent;
|
|
77
229
|
if (!sc || typeof sc !== 'object' || Array.isArray(sc))
|
|
@@ -79,6 +231,11 @@ function summarizeResult(result) {
|
|
|
79
231
|
const obj = sc;
|
|
80
232
|
if (typeof obj.status === 'string')
|
|
81
233
|
out.status = obj.status;
|
|
234
|
+
// The threat brief's four-way discriminator. Without it a `source_unavailable` (the intelligence
|
|
235
|
+
// source is down) and a `not_found` are the same successful row, and the one signal that says
|
|
236
|
+
// whether that source is healthy is lost.
|
|
237
|
+
if (typeof obj.outcome === 'string')
|
|
238
|
+
out.outcome = obj.outcome;
|
|
82
239
|
// The query correlation id ties an IN_PROGRESS handle issuance to its later get-query-results
|
|
83
240
|
// redemptions, making the deferred-query lifecycle joinable in telemetry.
|
|
84
241
|
if (typeof obj.correlationId === 'string')
|
|
@@ -95,6 +252,28 @@ function summarizeResult(result) {
|
|
|
95
252
|
}
|
|
96
253
|
}
|
|
97
254
|
}
|
|
255
|
+
// check-threat-exposure answers per subject, so its discriminator lives inside each `results`
|
|
256
|
+
// entry; a count alone makes a batch of real counts and a batch of `unavailable` identical.
|
|
257
|
+
if (Array.isArray(obj.results)) {
|
|
258
|
+
const counts = {};
|
|
259
|
+
for (const entry of obj.results) {
|
|
260
|
+
const status = entry?.status;
|
|
261
|
+
if (typeof status === 'string')
|
|
262
|
+
counts[status] = (counts[status] ?? 0) + 1;
|
|
263
|
+
}
|
|
264
|
+
if (Object.keys(counts).length > 0)
|
|
265
|
+
out.resultStatusCounts = counts;
|
|
266
|
+
}
|
|
267
|
+
summarizeWidgetResult(obj, out);
|
|
268
|
+
summarizeDiagnosis(obj, out);
|
|
269
|
+
// The board-creation event is the one event in a build sequence with no dashboardId: every
|
|
270
|
+
// widget write carries one as input, and the create only returns it. Lifting it under the same
|
|
271
|
+
// name joins the board to the widgets that follow. Keyed on the tool name because a top-level
|
|
272
|
+
// `id` is a rule id on one tool and a job id on another, and a mislabelled dashboardId would
|
|
273
|
+
// poison the per-board funnel this exists to serve.
|
|
274
|
+
if (toolName === 'create-dashboard' && !result.isError && typeof obj.id === 'string') {
|
|
275
|
+
out.dashboardId = obj.id;
|
|
276
|
+
}
|
|
98
277
|
const pageInfo = obj.pageInfo;
|
|
99
278
|
if (pageInfo && typeof pageInfo === 'object' && 'hasNextPage' in pageInfo) {
|
|
100
279
|
out.hasNextPage = !!pageInfo.hasNextPage;
|