@jupiterone/jupiterone-mcp 2.1.1 → 2.2.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/dist/client/graphql/queries.d.ts +1 -1
- package/dist/client/graphql/queries.d.ts.map +1 -1
- package/dist/client/graphql/queries.js +4 -0
- package/dist/client/graphql/queries.js.map +1 -1
- package/dist/generated/description-map.d.ts.map +1 -1
- package/dist/generated/description-map.js +396 -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 +35 -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 +56 -10
- package/dist/server/tools/errors.d.ts.map +1 -1
- package/dist/server/tools/errors.js +194 -10
- package/dist/server/tools/errors.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 +6 -0
- package/dist/server/tools/telemetry.d.ts.map +1 -1
- package/dist/server/tools/telemetry.js.map +1 -1
- 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 +140 -4
- 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 +7 -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,85 @@
|
|
|
1
|
+
import type { JupiterOneClient } from '../../client/jupiterone-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a string literal in a query turned out to mean against the account's real data.
|
|
4
|
+
*
|
|
5
|
+
* `partial-case-match` is the reason this exists. A query filtering `severity = 'high'` against a
|
|
6
|
+
* property that also holds `HIGH` and `High` succeeds, returns a plausible non-zero count, and
|
|
7
|
+
* silently under-reports by a third — so the widget is not blank, it is confidently wrong. Blank
|
|
8
|
+
* gets investigated; a confident number gets believed.
|
|
9
|
+
*/
|
|
10
|
+
export type DiagnosisVerdict = 'case-mismatch' | 'partial-case-match' | 'type-mismatch' | 'property-never-set' | 'target-empty' | 'value-not-found' | 'literal-ok' | 'split-categories' | 'unverifiable';
|
|
11
|
+
export interface LiteralDiagnosis {
|
|
12
|
+
queryName?: string;
|
|
13
|
+
target: string;
|
|
14
|
+
field: string;
|
|
15
|
+
operator: '=' | '!=';
|
|
16
|
+
literal: string;
|
|
17
|
+
verdict: DiagnosisVerdict;
|
|
18
|
+
/** Entities matching the literal exactly. Null when the probe could not establish it. */
|
|
19
|
+
exactCount: number | null;
|
|
20
|
+
/** Only same-value-different-casing groups, never a dump of the property's values. */
|
|
21
|
+
variants?: Array<{
|
|
22
|
+
value: string;
|
|
23
|
+
count: number;
|
|
24
|
+
}>;
|
|
25
|
+
correctedQuery?: string;
|
|
26
|
+
note: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const DIAGNOSIS_BUDGET_MS = 20000;
|
|
29
|
+
/**
|
|
30
|
+
* Budget for a diagnosis pass that runs after a write has already succeeded, anchored at request
|
|
31
|
+
* start by its caller.
|
|
32
|
+
*
|
|
33
|
+
* Tighter than the read-path budget because overrunning costs something different in kind: a
|
|
34
|
+
* response that lands after the host has given up makes the agent retry a create that worked, and
|
|
35
|
+
* the duplicate it then makes is the collision this diagnosis exists to help avoid.
|
|
36
|
+
*/
|
|
37
|
+
export declare const POST_WRITE_DIAGNOSIS_BUDGET_MS = 15000;
|
|
38
|
+
/**
|
|
39
|
+
* Diagnose a query's string literals against live data.
|
|
40
|
+
*
|
|
41
|
+
* Advisory by construction and never blocking: every verdict is point-in-time. Between two
|
|
42
|
+
* measurements 48 hours apart on the same account, one entity type disappeared entirely and another
|
|
43
|
+
* property's casing was normalised — so a data-dependent block would make identical widget JSON
|
|
44
|
+
* succeed one day and fail the next.
|
|
45
|
+
*
|
|
46
|
+
* `maxProbes` caps values, not written literals: the casings of one value are folded into a single
|
|
47
|
+
* group and probed once (see `groupCasings`), so a multi-casing enumeration neither spends the
|
|
48
|
+
* budget several times over nor reports its own arms as findings.
|
|
49
|
+
*/
|
|
50
|
+
export declare function diagnoseQueryLiterals(client: JupiterOneClient, query: string, options?: {
|
|
51
|
+
queryName?: string;
|
|
52
|
+
maxProbes?: number;
|
|
53
|
+
deadlineAt?: number;
|
|
54
|
+
}): Promise<LiteralDiagnosis[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Entity targets in a query that match nothing in this account.
|
|
57
|
+
*
|
|
58
|
+
* The quietest failure there is: a widget on a type the account does not hold returns one row
|
|
59
|
+
* containing `0` from `count(e)`, so it renders a confident zero forever and every row-based check
|
|
60
|
+
* calls it healthy. Probed directly rather than checked against `list-entity-types`, because that
|
|
61
|
+
* index has been measured omitting types live queries return — it is a positive oracle only, so a
|
|
62
|
+
* type missing from it would produce a false "does not exist".
|
|
63
|
+
*/
|
|
64
|
+
export declare function diagnoseEmptyTargets(client: JupiterOneClient, query: string, options?: {
|
|
65
|
+
deadlineAt?: number;
|
|
66
|
+
maxProbes?: number;
|
|
67
|
+
}): Promise<LiteralDiagnosis[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the categories this chart will actually draw collapse into fewer than they appear.
|
|
70
|
+
*
|
|
71
|
+
* Judged on the rows the preflight already fetched, which is both free and the only correct
|
|
72
|
+
* population: an earlier version probed the target's whole population instead, and would have
|
|
73
|
+
* reported `Finding.severity` as split (eighteen casings) for a widget filtered to
|
|
74
|
+
* `status = 'open'`, whose real output is four clean lowercase categories. The widget's own filters
|
|
75
|
+
* are part of the question.
|
|
76
|
+
*
|
|
77
|
+
* The failure it does catch is real: an unfiltered severity chart renders eighteen bars for six
|
|
78
|
+
* severities, `high`/`HIGH`/`High` each getting one, plus an unlabelled bar for the rows with no
|
|
79
|
+
* value at all. Every count is then a fraction of its true total and it still looks like a chart.
|
|
80
|
+
*/
|
|
81
|
+
export declare function detectCategorySplit(target: string, field: string, categoryColumn: string, resultRows: unknown[], options?: {
|
|
82
|
+
queryName?: string;
|
|
83
|
+
measure?: string;
|
|
84
|
+
}): LiteralDiagnosis | null;
|
|
85
|
+
//# sourceMappingURL=value-probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-probe.d.ts","sourceRoot":"","sources":["../../../src/server/tools/value-probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAQ1E;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GACxB,eAAe,GACf,oBAAoB,GACpB,eAAe,GACf,oBAAoB,GACpB,cAAc,GACd,iBAAiB,GACjB,YAAY,GACZ,kBAAkB,GAClB,cAAc,CAAC;AAEnB,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,GAAG,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,yFAAyF;IACzF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AASD,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,QAAS,CAAC;AAqZrD;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5E,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAyB7B;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAkC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,OAAO,EAAE,EACrB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACrD,gBAAgB,GAAG,IAAI,CAqDzB"}
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.POST_WRITE_DIAGNOSIS_BUDGET_MS = exports.DIAGNOSIS_BUDGET_MS = void 0;
|
|
4
|
+
exports.diagnoseQueryLiterals = diagnoseQueryLiterals;
|
|
5
|
+
exports.diagnoseEmptyTargets = diagnoseEmptyTargets;
|
|
6
|
+
exports.detectCategorySplit = detectCategorySplit;
|
|
7
|
+
const query_language_parser_1 = require("@jupiterone/query-language-parser");
|
|
8
|
+
const j1ql_filters_js_1 = require("../../utils/j1ql-filters.js");
|
|
9
|
+
/**
|
|
10
|
+
* Poll budget per probe, and for the whole diagnosis pass, inside the remote's ~55s deadline.
|
|
11
|
+
*
|
|
12
|
+
* A probe already in flight when the pass runs out of budget still finishes, so any caller
|
|
13
|
+
* anchoring this to its own request start must leave PROBE_POLL_ATTEMPTS seconds of headroom.
|
|
14
|
+
*/
|
|
15
|
+
const PROBE_POLL_ATTEMPTS = 6;
|
|
16
|
+
exports.DIAGNOSIS_BUDGET_MS = 20_000;
|
|
17
|
+
/**
|
|
18
|
+
* Budget for a diagnosis pass that runs after a write has already succeeded, anchored at request
|
|
19
|
+
* start by its caller.
|
|
20
|
+
*
|
|
21
|
+
* Tighter than the read-path budget because overrunning costs something different in kind: a
|
|
22
|
+
* response that lands after the host has given up makes the agent retry a create that worked, and
|
|
23
|
+
* the duplicate it then makes is the collision this diagnosis exists to help avoid.
|
|
24
|
+
*/
|
|
25
|
+
exports.POST_WRITE_DIAGNOSIS_BUDGET_MS = 15_000;
|
|
26
|
+
const fold = (value) => value.toLowerCase();
|
|
27
|
+
/**
|
|
28
|
+
* Fold extracted filters into one group per value, keeping the casings the query enumerates.
|
|
29
|
+
*
|
|
30
|
+
* Grouped by operator as well as target and field, because a mixed pair like
|
|
31
|
+
* `severity = 'critical' AND severity != 'CRITICAL'` is two opposite filters, not an enumeration —
|
|
32
|
+
* folding them together would quote back a filter the query never wrote.
|
|
33
|
+
*/
|
|
34
|
+
function groupCasings(filters) {
|
|
35
|
+
const groups = new Map();
|
|
36
|
+
for (const filter of filters) {
|
|
37
|
+
const key = `${filter.target}|${filter.field}|${filter.operator}|${fold(filter.literal)}`;
|
|
38
|
+
const group = groups.get(key);
|
|
39
|
+
if (!group)
|
|
40
|
+
groups.set(key, { filter, casings: [filter.literal] });
|
|
41
|
+
else if (!group.casings.includes(filter.literal))
|
|
42
|
+
group.casings.push(filter.literal);
|
|
43
|
+
}
|
|
44
|
+
return [...groups.values()];
|
|
45
|
+
}
|
|
46
|
+
/** Escape every non-alphanumeric character for embedding in a J1QL regex literal. */
|
|
47
|
+
function escapeForRegex(literal) {
|
|
48
|
+
if (/[\n\r]/.test(literal))
|
|
49
|
+
return null;
|
|
50
|
+
return literal.replace(/[^A-Za-z0-9]/g, (character) => `\\${character}`);
|
|
51
|
+
}
|
|
52
|
+
function rows(result) {
|
|
53
|
+
const data = result?.data;
|
|
54
|
+
return Array.isArray(data) ? data : [];
|
|
55
|
+
}
|
|
56
|
+
const countOf = (row) => (typeof row.n === 'number' ? row.n : 0);
|
|
57
|
+
/**
|
|
58
|
+
* Rewrite one literal in a query, verified by re-parsing and re-extracting.
|
|
59
|
+
*
|
|
60
|
+
* Only the literal's own quoted occurrence is touched, and the result must parse and yield exactly
|
|
61
|
+
* the intended filter set — the same verify-your-own-output discipline the alias rewriter uses,
|
|
62
|
+
* because a corrected query that quietly means something else is worse than no correction.
|
|
63
|
+
*/
|
|
64
|
+
function rewriteLiteral(query, filter, replacement) {
|
|
65
|
+
const quoted = [`'${filter.literal}'`, `"${filter.literal}"`];
|
|
66
|
+
const present = quoted.filter((form) => query.split(form).length === 2);
|
|
67
|
+
if (present.length !== 1)
|
|
68
|
+
return null;
|
|
69
|
+
const corrected = query.replace(present[0], replacement);
|
|
70
|
+
// Parseability is the invariant. Re-extraction is not: unquoting a literal for the type-mismatch
|
|
71
|
+
// fix legitimately removes the string filter that was extracted in the first place.
|
|
72
|
+
try {
|
|
73
|
+
(0, query_language_parser_1.parse)(corrected);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return corrected;
|
|
79
|
+
}
|
|
80
|
+
/** `('high' OR 'HIGH')` — exact multi-value equality over the casings actually observed. */
|
|
81
|
+
function anyOfLiterals(values) {
|
|
82
|
+
return `(${values.map((value) => `'${value.replace(/'/g, "\\'")}'`).join(' OR ')})`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Rewrite whichever arm of the group can be rewritten unambiguously.
|
|
86
|
+
*
|
|
87
|
+
* Exactly one arm changes. The other casings are already in the query, so folding the missing ones
|
|
88
|
+
* into one arm adds them without restating the set — a correction that repeats an arm the caller
|
|
89
|
+
* already wrote reads as a bug in the advice, which is how the un-grouped version failed live.
|
|
90
|
+
* Later arms are tried only because `rewriteLiteral` declines an ambiguous one, so a literal that
|
|
91
|
+
* also appears elsewhere in the query no longer costs the whole correction.
|
|
92
|
+
*/
|
|
93
|
+
function rewriteArm(query, group, replacement) {
|
|
94
|
+
for (const arm of group.casings) {
|
|
95
|
+
const corrected = rewriteLiteral(query, { ...group.filter, literal: arm }, replacement(arm));
|
|
96
|
+
if (corrected)
|
|
97
|
+
return corrected;
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
function formatCount(value) {
|
|
102
|
+
return value.toLocaleString('en-US');
|
|
103
|
+
}
|
|
104
|
+
function describeVariants(variants) {
|
|
105
|
+
return variants.map((variant) => `${variant.value}: ${formatCount(variant.count)}`).join(', ');
|
|
106
|
+
}
|
|
107
|
+
/** A verdict that establishes nothing, for when a probe fails or the budget runs out mid-pass. */
|
|
108
|
+
function unverifiable(group, why) {
|
|
109
|
+
return { ...group.filter, exactCount: null, verdict: 'unverifiable', note: why };
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The filter as the query wrote it.
|
|
113
|
+
*
|
|
114
|
+
* Every note quotes the filter back, so the text has to carry the real operator and the real value:
|
|
115
|
+
* a note that prints `=` for a query that wrote `!=` describes a different filter than the one being
|
|
116
|
+
* explained, and one that prints a single arm of an enumeration describes a narrower one — either
|
|
117
|
+
* way the advice that follows reads against a filter the caller cannot find in their query.
|
|
118
|
+
*/
|
|
119
|
+
function filterText({ filter, casings }) {
|
|
120
|
+
const value = casings.length === 1 ? `'${filter.literal}'` : anyOfLiterals(casings);
|
|
121
|
+
return `\`${filter.field} ${filter.operator} ${value}\``;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* What it means that the literal as written matches nothing while other casings of it exist.
|
|
125
|
+
*
|
|
126
|
+
* The two operators fail in opposite directions and need opposite readings: an equality filter
|
|
127
|
+
* catches none of the entities it was aimed at, while an exclusion filter removes none of them and
|
|
128
|
+
* hands every one of them back in the result.
|
|
129
|
+
*/
|
|
130
|
+
function caseMismatchNote(group, variants) {
|
|
131
|
+
const { filter, casings } = group;
|
|
132
|
+
const total = formatCount(variants.reduce((sum, variant) => sum + variant.count, 0));
|
|
133
|
+
if (filter.operator === '!=') {
|
|
134
|
+
return (`${filterText(group)} excludes nothing — no ${filter.target} entity holds exactly ` +
|
|
135
|
+
`${casings.map((casing) => `'${casing}'`).join(' or ')} — while ${total} of them hold the ` +
|
|
136
|
+
`same value in another casing (${describeVariants(variants)}) and all stay in the result. ` +
|
|
137
|
+
`J1QL string comparison is case-sensitive.`);
|
|
138
|
+
}
|
|
139
|
+
return (`${filterText(group)} matches nothing, but ${total} ${filter.target} entities hold the same ` +
|
|
140
|
+
`value in another casing (${describeVariants(variants)}). J1QL string equality is ` +
|
|
141
|
+
`case-sensitive.`);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* What the other casings mean for a filter that does match, or exclude, some of them.
|
|
145
|
+
*
|
|
146
|
+
* The keep-it clause is the one part an enumeration changes: a lone filter is being offered a wider
|
|
147
|
+
* one, while a query that already lists casings is being told the store holds one it did not list —
|
|
148
|
+
* so the intent it might be defending is the list, not the single casing it never wrote.
|
|
149
|
+
*/
|
|
150
|
+
function partialMatchNote(group, exactCount, variants) {
|
|
151
|
+
const { filter, casings } = group;
|
|
152
|
+
const total = formatCount(variants.reduce((sum, variant) => sum + variant.count, 0));
|
|
153
|
+
const intent = casings.length > 1
|
|
154
|
+
? `enumerating exactly ${casings.join(', ')}`
|
|
155
|
+
: filter.operator === '!='
|
|
156
|
+
? 'excluding this exact casing alone'
|
|
157
|
+
: 'exact-case matching';
|
|
158
|
+
if (filter.operator === '!=') {
|
|
159
|
+
return (`${filterText(group)} excludes ${formatCount(exactCount)} entities, but ${total} more ` +
|
|
160
|
+
`${filter.target} entities hold the same value in other casings ` +
|
|
161
|
+
`(${describeVariants(variants)}) and are NOT excluded. If none of the casings belong in the ` +
|
|
162
|
+
`result, use correctedQuery; if ${intent} is intentional, keep it.`);
|
|
163
|
+
}
|
|
164
|
+
return (`${filterText(group)} matches ${formatCount(exactCount)} entities, but ${total} more ` +
|
|
165
|
+
`${filter.target} entities hold the same value in other casings ` +
|
|
166
|
+
`(${describeVariants(variants)}). If this should count them all, use correctedQuery; if ` +
|
|
167
|
+
`${intent} is intentional, keep it.`);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The verdict when the target stores a casing of the value that the query never wrote.
|
|
171
|
+
*
|
|
172
|
+
* Two shapes, and which one it is decides what the caller has to do: nothing the query wrote
|
|
173
|
+
* matches, so the filter is dead — or some of it does and more is being left out, which is the
|
|
174
|
+
* failure that renders as a confident wrong number rather than a blank. An enumeration reaches both:
|
|
175
|
+
* `= ('critical' OR 'CRITICAL')` is dead when the store holds only `Critical`, and partial when it
|
|
176
|
+
* holds `Critical` too. `exactCount` is the sum over the casings the query does write, so the split
|
|
177
|
+
* between the two verdicts stays exactly "does this filter match anything at all".
|
|
178
|
+
*/
|
|
179
|
+
function casingVerdict(query, group, exactCount, variants) {
|
|
180
|
+
const missing = variants.map((variant) => variant.value);
|
|
181
|
+
const allCasings = rewriteArm(query, group, (arm) => anyOfLiterals([arm, ...missing]));
|
|
182
|
+
if (exactCount === 0) {
|
|
183
|
+
return {
|
|
184
|
+
...group.filter,
|
|
185
|
+
verdict: 'case-mismatch',
|
|
186
|
+
exactCount: 0,
|
|
187
|
+
variants,
|
|
188
|
+
// An exclusion has to name every casing to exclude the value. Swapping in the single variant
|
|
189
|
+
// an equality filter would want leaves the rest of them in the result, which is the same
|
|
190
|
+
// defect one step further along, delivered as a correction.
|
|
191
|
+
correctedQuery: group.filter.operator === '!='
|
|
192
|
+
? allCasings
|
|
193
|
+
: (rewriteArm(query, group, () => `'${variants[0].value}'`) ?? allCasings),
|
|
194
|
+
note: caseMismatchNote(group, variants),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
...group.filter,
|
|
199
|
+
verdict: 'partial-case-match',
|
|
200
|
+
exactCount,
|
|
201
|
+
variants,
|
|
202
|
+
correctedQuery: allCasings,
|
|
203
|
+
note: partialMatchNote(group, exactCount, variants),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* What it means that a correctly cased, correctly typed literal is nowhere in the data.
|
|
208
|
+
*
|
|
209
|
+
* For an equality filter the query is exonerated and the empty result is honest. For an exclusion
|
|
210
|
+
* filter the finding is stronger: it removes nothing, so whatever emptied the result, this is not
|
|
211
|
+
* it — and saying so stops the caller rewriting the one clause that was never involved.
|
|
212
|
+
*/
|
|
213
|
+
function valueNotFoundNote(group, withProperty) {
|
|
214
|
+
const { filter } = group;
|
|
215
|
+
const evidence = `Verified: ${filterText(group)} is correctly cased and typed — no ${filter.target} entity ` +
|
|
216
|
+
`currently holds that value (the property is set on ${formatCount(withProperty)} entities)`;
|
|
217
|
+
if (filter.operator === '!=') {
|
|
218
|
+
return (`${evidence}, so this filter excludes nothing and is not the reason for an empty result. ` +
|
|
219
|
+
`Look at the rest of the query, or drop this clause if it was meant to exclude something ` +
|
|
220
|
+
`that is really there.`);
|
|
221
|
+
}
|
|
222
|
+
return (`${evidence}. If this should catch future occurrences, set \`noResultMessage\` so the empty ` +
|
|
223
|
+
`state explains itself.`);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The verdict when nothing holds the literal in any casing — the target, the property name, the
|
|
227
|
+
* literal's type, or the value itself is the reason, and the distribution probe separates them.
|
|
228
|
+
*/
|
|
229
|
+
function absentValueVerdict(query, group, distribution) {
|
|
230
|
+
const { filter } = group;
|
|
231
|
+
const base = { ...filter, exactCount: 0 };
|
|
232
|
+
if (distribution.length === 0) {
|
|
233
|
+
return {
|
|
234
|
+
...base,
|
|
235
|
+
verdict: 'target-empty',
|
|
236
|
+
note: `\`${filter.target}\` matches no entities in this account right now, so this renders empty ` +
|
|
237
|
+
`regardless of the filter. Confirm the type with list-entity-types — and note a type can ` +
|
|
238
|
+
`exist while absent from that list, so treat it as a positive check only.`,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const typeMatch = distribution.find((row) => row.value !== undefined &&
|
|
242
|
+
typeof row.value !== 'string' &&
|
|
243
|
+
String(row.value) === filter.literal);
|
|
244
|
+
if (typeMatch) {
|
|
245
|
+
return {
|
|
246
|
+
...base,
|
|
247
|
+
verdict: 'type-mismatch',
|
|
248
|
+
// The representative arm only: the replacement is the unquoted form of that arm's value, so
|
|
249
|
+
// dropping it onto a different casing would unquote a word that is not a literal at all.
|
|
250
|
+
correctedQuery: rewriteLiteral(query, filter, String(typeMatch.value)) ?? undefined,
|
|
251
|
+
note: `${filterText(group)} compares against the string '${filter.literal}', but ` +
|
|
252
|
+
`${filter.target}.${filter.field} holds ${typeof typeMatch.value} ` +
|
|
253
|
+
`${String(typeMatch.value)} (${formatCount(countOf(typeMatch))} entities). Drop the quotes.`,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
const withProperty = distribution
|
|
257
|
+
.filter((row) => row.value !== undefined)
|
|
258
|
+
.reduce((sum, row) => sum + countOf(row), 0);
|
|
259
|
+
if (withProperty === 0) {
|
|
260
|
+
return {
|
|
261
|
+
...base,
|
|
262
|
+
verdict: 'property-never-set',
|
|
263
|
+
note: `\`${filter.field}\` is not set on any ${filter.target} entity — most likely a property-name ` +
|
|
264
|
+
`typo. Discover the real names with \`FIND ${filter.target} AS e RETURN e.* LIMIT 5\`.`,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
return { ...base, verdict: 'value-not-found', note: valueNotFoundNote(group, withProperty) };
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Classify one value against the account's data, using at most two probes.
|
|
271
|
+
*
|
|
272
|
+
* Probe A asks for every casing of the value at once (`= /literal/i`, grouped and counted), which is
|
|
273
|
+
* bounded by the number of variants rather than by the property's cardinality. The regex is
|
|
274
|
+
* unanchored because the shared parser rejects anchors, so equality is re-established in code by
|
|
275
|
+
* case-folded comparison — that discards substring over-matches like `highest` for `/high/i` while
|
|
276
|
+
* keeping every true variant, since a variant always matches its own unanchored regex.
|
|
277
|
+
*
|
|
278
|
+
* One probe covers the whole group: a case-insensitive regex on any arm returns every casing, so an
|
|
279
|
+
* enumeration costs exactly what a single filter costs.
|
|
280
|
+
*/
|
|
281
|
+
async function diagnoseLiteral(client, query, group, deadlineAt) {
|
|
282
|
+
const { filter } = group;
|
|
283
|
+
const escaped = escapeForRegex(filter.literal);
|
|
284
|
+
if (!escaped)
|
|
285
|
+
return null;
|
|
286
|
+
if (Date.now() > deadlineAt)
|
|
287
|
+
return null;
|
|
288
|
+
const probe = async (j1ql) => client.executeJ1qlQuery({ query: j1ql, maxPollAttempts: PROBE_POLL_ATTEMPTS });
|
|
289
|
+
const unreadable = `Could not verify \`${filter.field}\` against stored values.`;
|
|
290
|
+
let variantRows;
|
|
291
|
+
try {
|
|
292
|
+
variantRows = rows(await probe(`FIND ${filter.target} WITH ${filter.field} = /${escaped}/i AS e ` +
|
|
293
|
+
`RETURN e.${filter.field} AS value, count(e) AS n ORDER BY n DESC LIMIT 250`));
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
return unverifiable(group, unreadable);
|
|
297
|
+
}
|
|
298
|
+
const matches = variantRows
|
|
299
|
+
.filter((row) => typeof row.value === 'string')
|
|
300
|
+
.map((row) => ({ value: row.value, count: countOf(row) }))
|
|
301
|
+
.filter((row) => fold(row.value) === fold(filter.literal));
|
|
302
|
+
// Every casing the query itself writes is already counted, so it is not a variant. This is what
|
|
303
|
+
// makes the recommended `= ('critical' OR 'CRITICAL' OR 'Critical')` silent instead of accusing
|
|
304
|
+
// each arm of missing the other two.
|
|
305
|
+
const written = new Set(group.casings);
|
|
306
|
+
const exactCount = matches
|
|
307
|
+
.filter((row) => written.has(row.value))
|
|
308
|
+
.reduce((sum, row) => sum + row.count, 0);
|
|
309
|
+
const variants = matches.filter((row) => !written.has(row.value));
|
|
310
|
+
if (variants.length > 0)
|
|
311
|
+
return casingVerdict(query, group, exactCount, variants);
|
|
312
|
+
if (exactCount > 0)
|
|
313
|
+
return { ...filter, verdict: 'literal-ok', exactCount, note: '' };
|
|
314
|
+
// Nothing matches in any casing. One distribution probe separates a missing property or an empty
|
|
315
|
+
// target from a value that is simply, correctly, absent.
|
|
316
|
+
if (Date.now() > deadlineAt) {
|
|
317
|
+
return unverifiable(group, 'Diagnosis budget spent before verification.');
|
|
318
|
+
}
|
|
319
|
+
let distribution;
|
|
320
|
+
try {
|
|
321
|
+
distribution = rows(await probe(`FIND ${filter.target} AS e RETURN e.${filter.field} AS value, count(e) AS n ` +
|
|
322
|
+
`ORDER BY n DESC LIMIT 250`));
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
return unverifiable(group, unreadable);
|
|
326
|
+
}
|
|
327
|
+
return absentValueVerdict(query, group, distribution);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Diagnose a query's string literals against live data.
|
|
331
|
+
*
|
|
332
|
+
* Advisory by construction and never blocking: every verdict is point-in-time. Between two
|
|
333
|
+
* measurements 48 hours apart on the same account, one entity type disappeared entirely and another
|
|
334
|
+
* property's casing was normalised — so a data-dependent block would make identical widget JSON
|
|
335
|
+
* succeed one day and fail the next.
|
|
336
|
+
*
|
|
337
|
+
* `maxProbes` caps values, not written literals: the casings of one value are folded into a single
|
|
338
|
+
* group and probed once (see `groupCasings`), so a multi-casing enumeration neither spends the
|
|
339
|
+
* budget several times over nor reports its own arms as findings.
|
|
340
|
+
*/
|
|
341
|
+
async function diagnoseQueryLiterals(client, query, options = {}) {
|
|
342
|
+
const deadlineAt = options.deadlineAt ?? Date.now() + exports.DIAGNOSIS_BUDGET_MS;
|
|
343
|
+
const maxProbes = options.maxProbes ?? 4;
|
|
344
|
+
const seen = new Set();
|
|
345
|
+
const filters = (0, j1ql_filters_js_1.extractStringEqualityFilters)(query).filter((filter) => {
|
|
346
|
+
const key = `${filter.target}|${filter.field}|${filter.literal}`;
|
|
347
|
+
if (seen.has(key))
|
|
348
|
+
return false;
|
|
349
|
+
seen.add(key);
|
|
350
|
+
return true;
|
|
351
|
+
});
|
|
352
|
+
const out = [];
|
|
353
|
+
for (const group of groupCasings(filters).slice(0, maxProbes)) {
|
|
354
|
+
try {
|
|
355
|
+
const diagnosis = await diagnoseLiteral(client, query, group, deadlineAt);
|
|
356
|
+
// `literal-ok` is only worth reporting when the caller is explaining an empty result.
|
|
357
|
+
if (diagnosis && diagnosis.verdict !== 'literal-ok') {
|
|
358
|
+
out.push({ ...diagnosis, queryName: options.queryName });
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
// A diagnosis is a convenience; never let one break the call it is attached to.
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return out;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Entity targets in a query that match nothing in this account.
|
|
369
|
+
*
|
|
370
|
+
* The quietest failure there is: a widget on a type the account does not hold returns one row
|
|
371
|
+
* containing `0` from `count(e)`, so it renders a confident zero forever and every row-based check
|
|
372
|
+
* calls it healthy. Probed directly rather than checked against `list-entity-types`, because that
|
|
373
|
+
* index has been measured omitting types live queries return — it is a positive oracle only, so a
|
|
374
|
+
* type missing from it would produce a false "does not exist".
|
|
375
|
+
*/
|
|
376
|
+
async function diagnoseEmptyTargets(client, query, options = {}) {
|
|
377
|
+
const deadlineAt = options.deadlineAt ?? Date.now() + exports.DIAGNOSIS_BUDGET_MS;
|
|
378
|
+
const targets = (0, j1ql_filters_js_1.extractTargets)(query).slice(0, options.maxProbes ?? 2);
|
|
379
|
+
const out = [];
|
|
380
|
+
for (const target of targets) {
|
|
381
|
+
if (Date.now() > deadlineAt)
|
|
382
|
+
break;
|
|
383
|
+
try {
|
|
384
|
+
const result = await client.executeJ1qlQuery({
|
|
385
|
+
query: `FIND ${target} AS e RETURN count(e) AS value`,
|
|
386
|
+
maxPollAttempts: PROBE_POLL_ATTEMPTS,
|
|
387
|
+
});
|
|
388
|
+
const [row] = rows(result);
|
|
389
|
+
const count = typeof row?.value === 'number' ? row.value : null;
|
|
390
|
+
if (count === 0) {
|
|
391
|
+
out.push({
|
|
392
|
+
target,
|
|
393
|
+
field: '_type',
|
|
394
|
+
operator: '=',
|
|
395
|
+
literal: target,
|
|
396
|
+
verdict: 'target-empty',
|
|
397
|
+
exactCount: 0,
|
|
398
|
+
note: `\`${target}\` matches no entities in this account, so anything built on it renders a ` +
|
|
399
|
+
`zero that will never change. Confirm the name with \`list-entity-types\` — and treat ` +
|
|
400
|
+
`that list as a positive check only, since it has been measured omitting types that ` +
|
|
401
|
+
`queries do return.`,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch {
|
|
406
|
+
// Advisory only.
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return out;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Whether the categories this chart will actually draw collapse into fewer than they appear.
|
|
413
|
+
*
|
|
414
|
+
* Judged on the rows the preflight already fetched, which is both free and the only correct
|
|
415
|
+
* population: an earlier version probed the target's whole population instead, and would have
|
|
416
|
+
* reported `Finding.severity` as split (eighteen casings) for a widget filtered to
|
|
417
|
+
* `status = 'open'`, whose real output is four clean lowercase categories. The widget's own filters
|
|
418
|
+
* are part of the question.
|
|
419
|
+
*
|
|
420
|
+
* The failure it does catch is real: an unfiltered severity chart renders eighteen bars for six
|
|
421
|
+
* severities, `high`/`HIGH`/`High` each getting one, plus an unlabelled bar for the rows with no
|
|
422
|
+
* value at all. Every count is then a fraction of its true total and it still looks like a chart.
|
|
423
|
+
*/
|
|
424
|
+
function detectCategorySplit(target, field, categoryColumn, resultRows, options = {}) {
|
|
425
|
+
const byFolded = new Map();
|
|
426
|
+
let unlabelled = 0;
|
|
427
|
+
for (const row of resultRows) {
|
|
428
|
+
const value = row?.[categoryColumn];
|
|
429
|
+
if (typeof value !== 'string') {
|
|
430
|
+
if (value === undefined || value === null)
|
|
431
|
+
unlabelled += 1;
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
byFolded.set(fold(value), [...(byFolded.get(fold(value)) ?? []), value]);
|
|
435
|
+
}
|
|
436
|
+
const split = [...byFolded.values()].filter((variants) => variants.length > 1);
|
|
437
|
+
if (split.length === 0 && unlabelled === 0)
|
|
438
|
+
return null;
|
|
439
|
+
const detail = [];
|
|
440
|
+
if (split.length > 0) {
|
|
441
|
+
detail.push(`${split.length} categor${split.length === 1 ? 'y is' : 'ies are'} split across casings ` +
|
|
442
|
+
`(${split.map((variants) => variants.join('/')).join('; ')})`);
|
|
443
|
+
}
|
|
444
|
+
if (unlabelled > 0) {
|
|
445
|
+
detail.push(`${unlabelled} rows have no \`${field}\` and group into one unlabelled category`);
|
|
446
|
+
}
|
|
447
|
+
const example = split[0] ?? [];
|
|
448
|
+
const casings = example.map((variant) => `'${variant}'`).join(' OR ') || "'critical' OR 'CRITICAL'";
|
|
449
|
+
// The example must be in the shape THIS chart's render gate accepts, or the advice is a query
|
|
450
|
+
// the server itself then rejects: a `y`-measure chart (bar/line) reads `x`+`y` per query, so its
|
|
451
|
+
// per-category query also returns the category label as `x`. `value`-measure charts (pie) take
|
|
452
|
+
// the bare count — their slices are labelled by query name.
|
|
453
|
+
const exampleQuery = options.measure === 'y'
|
|
454
|
+
? `FIND ${target} WITH ${field} = (${casings}) AS e ` +
|
|
455
|
+
`RETURN '${example[0] ?? 'Critical'}' AS x, count(e) AS y`
|
|
456
|
+
: `FIND ${target} WITH ${field} = (${casings}) AS e RETURN count(e) AS value`;
|
|
457
|
+
return {
|
|
458
|
+
target,
|
|
459
|
+
field,
|
|
460
|
+
operator: '=',
|
|
461
|
+
literal: field,
|
|
462
|
+
verdict: 'split-categories',
|
|
463
|
+
exactCount: null,
|
|
464
|
+
queryName: options.queryName,
|
|
465
|
+
note: `This chart groups by \`${field}\`, and the values it returns do not group cleanly: ` +
|
|
466
|
+
`${detail.join('; ')}. It will draw more categories than exist, each holding a fraction of ` +
|
|
467
|
+
`its real total. J1QL has no case-folding function, so a single grouped query cannot fix ` +
|
|
468
|
+
`this — give the widget one query per category instead, each counting every casing and named ` +
|
|
469
|
+
`for the category it represents, and the chart will label its series by query name. For ` +
|
|
470
|
+
`example: \`${exampleQuery}\`.`,
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
//# sourceMappingURL=value-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-probe.js","sourceRoot":"","sources":["../../../src/server/tools/value-probe.ts"],"names":[],"mappings":";;;AA4dA,sDA6BC;AAWD,oDAsCC;AAeD,kDA2DC;AAnnBD,6EAA0D;AAC1D,iEAIqC;AAoCrC;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACjB,QAAA,mBAAmB,GAAG,MAAM,CAAC;AAE1C;;;;;;;GAOG;AACU,QAAA,8BAA8B,GAAG,MAAM,CAAC;AAErD,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;AAoBpD;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,OAA+B;IACnD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC/C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,IAAI,IAAI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,GAAG,CAChE,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,mBAAmB,KAAK,2CAA2C,CAAC,CAAC;IAChG,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,0BAA0B,CAAC;IACpG,8FAA8F;IAC9F,iGAAiG;IACjG,+FAA+F;IAC/F,4DAA4D;IAC5D,MAAM,YAAY,GAChB,OAAO,CAAC,OAAO,KAAK,GAAG;QACrB,CAAC,CAAC,QAAQ,MAAM,SAAS,KAAK,OAAO,OAAO,SAAS;YACnD,WAAW,OAAO,CAAC,CAAC,CAAC,IAAI,UAAU,uBAAuB;QAC5D,CAAC,CAAC,QAAQ,MAAM,SAAS,KAAK,OAAO,OAAO,iCAAiC,CAAC;IAClF,OAAO;QACL,MAAM;QACN,KAAK;QACL,QAAQ,EAAE,GAAG;QACb,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,kBAAkB;QAC3B,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,IAAI,EACF,0BAA0B,KAAK,sDAAsD;YACrF,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,wEAAwE;YAC5F,0FAA0F;YAC1F,8FAA8F;YAC9F,yFAAyF;YACzF,cAAc,YAAY,KAAK;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { JupiterOneClient } from '../../client/jupiterone-client.js';
|
|
2
|
+
import type { Query } from '../../types/jupiterone.js';
|
|
3
|
+
import type { ToolResult } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Static checks against documented product behaviour, run before a widget is written.
|
|
6
|
+
*
|
|
7
|
+
* A different certainty class from the value diagnosis: these are facts about what JupiterOne
|
|
8
|
+
* Insights supports, stable on product-release timescales, not point-in-time facts about an
|
|
9
|
+
* account's data. That is why one of them blocks and the others inform.
|
|
10
|
+
*/
|
|
11
|
+
export interface WidgetConfigFinding {
|
|
12
|
+
code: 'managed-board' | 'markdown-without-text' | 'percentage-line-without-x' | 'percentage-numerator-unmatched' | 'percentage-total-empty' | 'percentage-without-total' | 'trend-with-parameters' | 'trend-has-no-history' | 'unsupported-chart-type';
|
|
13
|
+
blocking: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check a widget's configuration against documented product behaviour.
|
|
18
|
+
*
|
|
19
|
+
* Returns findings in severity order — every blocking finding precedes the advisory ones, so the
|
|
20
|
+
* rejection's `lintCode` names the first real reason. A finding blocks only where the widget is
|
|
21
|
+
* verified to draw nothing (`managed-board`, `markdown-without-text`, `unsupported-chart-type`) or
|
|
22
|
+
* to draw a number that is provably not the one asked for (`percentage-numerator-unmatched`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function lintWidgetConfig(client: JupiterOneClient, dashboardId: string, input: {
|
|
25
|
+
type?: string;
|
|
26
|
+
config?: {
|
|
27
|
+
queries?: Query[];
|
|
28
|
+
settings?: unknown;
|
|
29
|
+
};
|
|
30
|
+
} | undefined, operation: 'create' | 'update'): Promise<WidgetConfigFinding[]>;
|
|
31
|
+
/**
|
|
32
|
+
* The rejection an agent receives for a blocking configuration finding.
|
|
33
|
+
*
|
|
34
|
+
* Carries `lintCode` so the telemetry chokepoint can count blocks by cause rather than
|
|
35
|
+
* string-matching the message, the same way the render-contract gate carries `contractOk`. Error
|
|
36
|
+
* results are exempt from output-schema validation, so it never reaches a client validator.
|
|
37
|
+
*/
|
|
38
|
+
export declare function widgetConfigErrorResponse(operation: 'create' | 'update', findings: WidgetConfigFinding[]): ToolResult;
|
|
39
|
+
//# sourceMappingURL=widget-config-lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-config-lint.d.ts","sourceRoot":"","sources":["../../../src/server/tools/widget-config-lint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EACA,eAAe,GACf,uBAAuB,GACvB,2BAA2B,GAC3B,gCAAgC,GAChC,wBAAwB,GACxB,0BAA0B,GAC1B,uBAAuB,GACvB,sBAAsB,GACtB,wBAAwB,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AA8PD;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,GAAG,SAAS,EACxF,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAC7B,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAmDhC;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,QAAQ,GAAG,QAAQ,EAC9B,QAAQ,EAAE,mBAAmB,EAAE,GAC9B,UAAU,CAQZ"}
|