@jupiterone/jupiterone-mcp 2.6.1 → 2.7.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 +122 -72
- package/dist/client/graphql/mutations.d.ts +16 -0
- package/dist/client/graphql/mutations.d.ts.map +1 -1
- package/dist/client/graphql/mutations.js +126 -1
- package/dist/client/graphql/mutations.js.map +1 -1
- package/dist/client/graphql/queries.d.ts +27 -2
- package/dist/client/graphql/queries.d.ts.map +1 -1
- package/dist/client/graphql/queries.js +96 -4
- package/dist/client/graphql/queries.js.map +1 -1
- package/dist/client/jupiterone-client.d.ts +30 -0
- package/dist/client/jupiterone-client.d.ts.map +1 -1
- package/dist/client/jupiterone-client.js +60 -0
- package/dist/client/jupiterone-client.js.map +1 -1
- package/dist/client/services/compliance-service.d.ts +48 -1
- package/dist/client/services/compliance-service.d.ts.map +1 -1
- package/dist/client/services/compliance-service.js +292 -0
- package/dist/client/services/compliance-service.js.map +1 -1
- package/dist/client/services/j1ql-service.d.ts +10 -2
- package/dist/client/services/j1ql-service.d.ts.map +1 -1
- package/dist/client/services/j1ql-service.js +11 -3
- package/dist/client/services/j1ql-service.js.map +1 -1
- package/dist/client/services/rule-service.d.ts +3 -1
- package/dist/client/services/rule-service.d.ts.map +1 -1
- package/dist/client/services/rule-service.js +7 -5
- package/dist/client/services/rule-service.js.map +1 -1
- package/dist/generated/description-map.d.ts.map +1 -1
- package/dist/generated/description-map.js +741 -59
- 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 +42 -3
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/skills.d.ts +25 -0
- package/dist/server/skills.d.ts.map +1 -0
- package/dist/server/skills.js +115 -0
- package/dist/server/skills.js.map +1 -0
- package/dist/server/tools/compliance/attestations.d.ts.map +1 -1
- package/dist/server/tools/compliance/attestations.js +20 -37
- package/dist/server/tools/compliance/attestations.js.map +1 -1
- package/dist/server/tools/compliance/authoring.d.ts +3 -0
- package/dist/server/tools/compliance/authoring.d.ts.map +1 -0
- package/dist/server/tools/compliance/authoring.js +773 -0
- package/dist/server/tools/compliance/authoring.js.map +1 -0
- package/dist/server/tools/compliance/controls.d.ts.map +1 -1
- package/dist/server/tools/compliance/controls.js +193 -19
- package/dist/server/tools/compliance/controls.js.map +1 -1
- package/dist/server/tools/compliance/exemptions.d.ts +3 -0
- package/dist/server/tools/compliance/exemptions.d.ts.map +1 -0
- package/dist/server/tools/compliance/exemptions.js +287 -0
- package/dist/server/tools/compliance/exemptions.js.map +1 -0
- package/dist/server/tools/compliance/framework.d.ts +3 -0
- package/dist/server/tools/compliance/framework.d.ts.map +1 -0
- package/dist/server/tools/compliance/framework.js +445 -0
- package/dist/server/tools/compliance/framework.js.map +1 -0
- package/dist/server/tools/compliance/graph.d.ts +56 -0
- package/dist/server/tools/compliance/graph.d.ts.map +1 -0
- package/dist/server/tools/compliance/graph.js +115 -0
- package/dist/server/tools/compliance/graph.js.map +1 -0
- package/dist/server/tools/compliance/index.d.ts +2 -16
- package/dist/server/tools/compliance/index.d.ts.map +1 -1
- package/dist/server/tools/compliance/index.js +45 -15
- package/dist/server/tools/compliance/index.js.map +1 -1
- package/dist/server/tools/compliance/requirements.d.ts +3 -0
- package/dist/server/tools/compliance/requirements.d.ts.map +1 -0
- package/dist/server/tools/compliance/requirements.js +243 -0
- package/dist/server/tools/compliance/requirements.js.map +1 -0
- package/dist/server/tools/compliance/schemas.d.ts +409 -8
- package/dist/server/tools/compliance/schemas.d.ts.map +1 -1
- package/dist/server/tools/compliance/schemas.js +337 -7
- package/dist/server/tools/compliance/schemas.js.map +1 -1
- package/dist/server/tools/compliance/shared.d.ts +103 -1
- package/dist/server/tools/compliance/shared.d.ts.map +1 -1
- package/dist/server/tools/compliance/shared.js +235 -1
- package/dist/server/tools/compliance/shared.js.map +1 -1
- package/dist/server/tools/compliance/summary.d.ts +2 -8
- package/dist/server/tools/compliance/summary.d.ts.map +1 -1
- package/dist/server/tools/compliance/summary.js +149 -87
- package/dist/server/tools/compliance/summary.js.map +1 -1
- package/dist/server/tools/compliance/tests.d.ts +3 -0
- package/dist/server/tools/compliance/tests.d.ts.map +1 -0
- package/dist/server/tools/compliance/tests.js +463 -0
- package/dist/server/tools/compliance/tests.js.map +1 -0
- package/dist/server/tools/compliance/transitions.d.ts +6 -0
- package/dist/server/tools/compliance/transitions.d.ts.map +1 -0
- package/dist/server/tools/compliance/transitions.js +659 -0
- package/dist/server/tools/compliance/transitions.js.map +1 -0
- package/dist/server/tools/dashboards.d.ts.map +1 -1
- package/dist/server/tools/dashboards.js +16 -4
- package/dist/server/tools/dashboards.js.map +1 -1
- package/dist/server/tools/errors.d.ts +11 -1
- package/dist/server/tools/errors.d.ts.map +1 -1
- package/dist/server/tools/errors.js +16 -1
- 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 +48 -51
- package/dist/server/tools/integrations.js.map +1 -1
- package/dist/server/tools/reference.d.ts +1 -1
- package/dist/server/tools/reference.d.ts.map +1 -1
- package/dist/server/tools/reference.js +1 -0
- package/dist/server/tools/reference.js.map +1 -1
- package/dist/server/tools/result.d.ts +3 -2
- package/dist/server/tools/result.d.ts.map +1 -1
- package/dist/server/tools/result.js +3 -2
- package/dist/server/tools/result.js.map +1 -1
- package/dist/server/tools/rules.d.ts.map +1 -1
- package/dist/server/tools/rules.js +19 -21
- package/dist/server/tools/rules.js.map +1 -1
- package/dist/server/tools/types.d.ts +2 -0
- package/dist/server/tools/types.d.ts.map +1 -1
- package/dist/server/tools/types.js.map +1 -1
- package/dist/server/tools/usage.d.ts +21 -7
- package/dist/server/tools/usage.d.ts.map +1 -1
- package/dist/server/tools/usage.js +490 -8
- package/dist/server/tools/usage.js.map +1 -1
- package/dist/server/tools/value-probe.d.ts +1 -1
- package/dist/server/tools/value-probe.d.ts.map +1 -1
- package/dist/server/tools/value-probe.js +126 -1
- package/dist/server/tools/value-probe.js.map +1 -1
- package/dist/server/tools/widget-config-lint.d.ts +5 -3
- package/dist/server/tools/widget-config-lint.d.ts.map +1 -1
- package/dist/server/tools/widget-config-lint.js +74 -71
- package/dist/server/tools/widget-config-lint.js.map +1 -1
- package/dist/server/tools/widget-percentage.d.ts +63 -0
- package/dist/server/tools/widget-percentage.d.ts.map +1 -0
- package/dist/server/tools/widget-percentage.js +115 -0
- package/dist/server/tools/widget-percentage.js.map +1 -0
- package/dist/server/tools/widget-preflight.d.ts +8 -1
- package/dist/server/tools/widget-preflight.d.ts.map +1 -1
- package/dist/server/tools/widget-preflight.js +36 -5
- package/dist/server/tools/widget-preflight.js.map +1 -1
- package/dist/server/tools/widget-render-contract.d.ts.map +1 -1
- package/dist/server/tools/widget-render-contract.js +21 -9
- package/dist/server/tools/widget-render-contract.js.map +1 -1
- package/dist/types/jupiterone.d.ts +179 -0
- package/dist/types/jupiterone.d.ts.map +1 -1
- package/dist/utils/dashboard-variables.d.ts +8 -0
- package/dist/utils/dashboard-variables.d.ts.map +1 -0
- package/dist/utils/dashboard-variables.js +54 -0
- package/dist/utils/dashboard-variables.js.map +1 -0
- package/dist/utils/j1ql-filters.d.ts +15 -0
- package/dist/utils/j1ql-filters.d.ts.map +1 -1
- package/dist/utils/j1ql-filters.js +37 -16
- package/dist/utils/j1ql-filters.js.map +1 -1
- package/dist/utils/j1ql-validator.d.ts +1 -0
- package/dist/utils/j1ql-validator.d.ts.map +1 -1
- package/dist/utils/j1ql-validator.js +260 -19
- package/dist/utils/j1ql-validator.js.map +1 -1
- package/node_modules/dtrace-provider/build/Makefile +1 -1
- package/package.json +3 -3
|
@@ -1,28 +1,307 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PHASE_META_KEY = void 0;
|
|
3
4
|
exports.redactJ1ql = redactJ1ql;
|
|
5
|
+
exports.redactErrorText = redactErrorText;
|
|
4
6
|
exports.truncateReason = truncateReason;
|
|
5
7
|
exports.summarizeInput = summarizeInput;
|
|
6
8
|
exports.summarizeResult = summarizeResult;
|
|
9
|
+
const query_language_parser_1 = require("@jupiterone/query-language-parser");
|
|
7
10
|
const expires_on_js_1 = require("../../utils/expires-on.js");
|
|
11
|
+
const j1ql_validator_js_1 = require("../../utils/j1ql-validator.js");
|
|
12
|
+
const reference_js_1 = require("./reference.js");
|
|
13
|
+
const widget_percentage_js_1 = require("./widget-percentage.js");
|
|
14
|
+
/**
|
|
15
|
+
* Where a compliance error carries its phase report: result `_meta`, not `structuredContent`,
|
|
16
|
+
* which an SDK 1.x client validates against the schema it cached, and the schemas cached from
|
|
17
|
+
* 2.6.1 require keys an error does not have (PR #59 review).
|
|
18
|
+
*/
|
|
19
|
+
exports.PHASE_META_KEY = 'jupiterone.io/phase';
|
|
20
|
+
/** A string literal in either quote style; an escaped quote stays inside its literal. */
|
|
21
|
+
const QUOTED_LITERAL = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g;
|
|
22
|
+
/**
|
|
23
|
+
* A comparison operator: `=`, `!=`, `~=`, `^=`, `$=` and their `!` forms, `<`, `>`, `<=`, `>=`. A
|
|
24
|
+
* `!` counts only with its `=` (`THAT !HAS` negates a verb), and a doubled `<<` / `>>` is a
|
|
25
|
+
* relationship direction, not a comparison.
|
|
26
|
+
*/
|
|
27
|
+
const COMPARISON = String.raw `!?[~^$]?=|[<>]=|(?<![<>])[<>](?![<>])`;
|
|
28
|
+
/** A word of an unquoted value: it ends at whitespace, a quote, a bracket, a comma, `|`, `=<>`. */
|
|
29
|
+
const BARE_WORD = String.raw `[^\s'"()[\],|=<>]+`;
|
|
30
|
+
const BARE_RUN = String.raw `${BARE_WORD}(?:[ \t]+${BARE_WORD})*`;
|
|
31
|
+
/** A value already replaced, read as one token so a second pass changes nothing. */
|
|
32
|
+
const PLACEHOLDER = String.raw `\[REDACTED\]`;
|
|
33
|
+
/** The inside of a value list, up to its close; a quoted literal or placeholder is read whole. */
|
|
34
|
+
const LIST_BODY = String.raw `(?:${QUOTED_LITERAL.source}|${PLACEHOLDER}|[^)\]\n'"])*`;
|
|
35
|
+
/**
|
|
36
|
+
* What follows a comparison: a value list opened by `(` or `[`, or a run of bare words. A run
|
|
37
|
+
* never starts with `/` (a regex literal, already redacted), and a `[REDACTED]` placeholder is not
|
|
38
|
+
* a list.
|
|
39
|
+
*/
|
|
40
|
+
const COMPARED_VALUE = new RegExp(String.raw `(${COMPARISON})(\s*)(?:(?!${PLACEHOLDER})([([])(${LIST_BODY})|(?!\/)(${BARE_RUN}))`, 'g');
|
|
41
|
+
const LIST_ITEM = new RegExp(`${QUOTED_LITERAL.source}|${PLACEHOLDER}|${BARE_RUN}`, 'g');
|
|
42
|
+
const NUMBER = /^[-+]?\d+(?:\.\d+)?$/;
|
|
43
|
+
const VALUE_LITERAL = /^(?:true|false|null|undefined)$/i;
|
|
44
|
+
const NO_LETTER_OR_DIGIT = /^[^\p{L}\p{N}]*$/u;
|
|
45
|
+
const DATE_UNIT = String.raw `(?:${query_language_parser_1.DateUnits.join('|')})s?`;
|
|
46
|
+
/** `date.now`, `date.now-7days`, `7days`, `days`: the date arithmetic J1QL accepts. */
|
|
47
|
+
const DATE_WORD = new RegExp(String.raw `^(?:date\.now(?:[-+]\d+(?:${DATE_UNIT})?)?|\d+${DATE_UNIT}|${DATE_UNIT})$`, 'i');
|
|
48
|
+
/** A dashboard variable, in either form a widget query accepts (`${name}`, `{{name}}`). */
|
|
49
|
+
const VARIABLE = /^(?:\$\{[^}]*\}|\{\{[^}]*\}\})$/;
|
|
50
|
+
const SELECTOR_HEAD = /^([A-Za-z_]\w*)\./;
|
|
51
|
+
const ALIAS_DECLARATION = /\bAS\s+([A-Za-z_]\w*)/gi;
|
|
52
|
+
/**
|
|
53
|
+
* A word that can stand after a comparison without being the caller's data: a number, a boolean,
|
|
54
|
+
* `null` or `undefined`, an operator, date arithmetic, a dashboard variable, or a property of an
|
|
55
|
+
* alias the same text declares (`WHERE h.owner = d.name`). `name = acme.corp` declares no `acme`,
|
|
56
|
+
* so its value is not one.
|
|
57
|
+
*/
|
|
58
|
+
function isQueryWord(word, aliases) {
|
|
59
|
+
if (NUMBER.test(word) || VALUE_LITERAL.test(word) || NO_LETTER_OR_DIGIT.test(word))
|
|
60
|
+
return true;
|
|
61
|
+
if (DATE_WORD.test(word) || VARIABLE.test(word))
|
|
62
|
+
return true;
|
|
63
|
+
const head = SELECTOR_HEAD.exec(word)?.[1];
|
|
64
|
+
return head !== undefined && aliases.has(head.toLowerCase());
|
|
65
|
+
}
|
|
66
|
+
function isReserved(word) {
|
|
67
|
+
return j1ql_validator_js_1.RESERVED_WORDS.has(word.toLowerCase());
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* An unquoted item of a value list, each stretch between keywords judged on its own: kept when
|
|
71
|
+
* every word is query, one `[REDACTED]` otherwise (`= (acme OR beta corp)`).
|
|
72
|
+
*/
|
|
73
|
+
function redactListItem(item, aliases) {
|
|
74
|
+
const words = item.split(/[ \t]+/);
|
|
75
|
+
const out = [];
|
|
76
|
+
let stretch = [];
|
|
77
|
+
const close = () => {
|
|
78
|
+
if (stretch.length === 0)
|
|
79
|
+
return;
|
|
80
|
+
out.push(stretch.every((word) => isQueryWord(word, aliases)) ? stretch.join(' ') : '[REDACTED]');
|
|
81
|
+
stretch = [];
|
|
82
|
+
};
|
|
83
|
+
for (const word of words) {
|
|
84
|
+
if (isReserved(word)) {
|
|
85
|
+
close();
|
|
86
|
+
out.push(word);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
stretch.push(word);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
close();
|
|
93
|
+
const rebuilt = out.join(' ');
|
|
94
|
+
return rebuilt === words.join(' ') ? item : rebuilt;
|
|
95
|
+
}
|
|
96
|
+
/** The keywords J1QL takes straight after a compared value. */
|
|
97
|
+
const VALUE_FOLLOWERS = new Set([
|
|
98
|
+
'and',
|
|
99
|
+
'or',
|
|
100
|
+
'with',
|
|
101
|
+
'where',
|
|
102
|
+
'that',
|
|
103
|
+
'as',
|
|
104
|
+
'return',
|
|
105
|
+
'order',
|
|
106
|
+
'limit',
|
|
107
|
+
'skip',
|
|
108
|
+
]);
|
|
109
|
+
/** Keywords that open a filter: a property and its comparison follow, or a group. */
|
|
110
|
+
const FILTER_KEYWORDS = new Set(['and', 'or', 'with', 'where']);
|
|
111
|
+
/**
|
|
112
|
+
* Whether the words after a filter keyword open the comparison the run stopped at (`next`): one
|
|
113
|
+
* property before `=`, `<` or `>` (`AND name =`, `AND name !=`), or nothing before a group or a
|
|
114
|
+
* bracketed property (`AND (`, `AND ['tag.x']`).
|
|
115
|
+
*/
|
|
116
|
+
function opensFilter(words, next) {
|
|
117
|
+
const property = words
|
|
118
|
+
.join(' ')
|
|
119
|
+
.replace(/[!~^$]+$/, '')
|
|
120
|
+
.trim();
|
|
121
|
+
if (property === '')
|
|
122
|
+
return next === '(' || next === '[';
|
|
123
|
+
return !/\s/.test(property) && /^[=<>]$/.test(next);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Whether the words from a keyword on read as query rather than more of a value: each keyword takes
|
|
127
|
+
* at most one word (`AS a`, `BY total`, `LIMIT 250`), `THAT` two (`THAT HAS User`), and a filter
|
|
128
|
+
* keyword must come last, opening the comparison the run stopped at.
|
|
129
|
+
*/
|
|
130
|
+
function isQueryTail(tail, next) {
|
|
131
|
+
const segments = [];
|
|
132
|
+
for (const word of tail) {
|
|
133
|
+
if (isReserved(word))
|
|
134
|
+
segments.push([word]);
|
|
135
|
+
else
|
|
136
|
+
segments.at(-1)?.push(word);
|
|
137
|
+
}
|
|
138
|
+
return segments.every(([keyword, ...words], index) => {
|
|
139
|
+
const lower = keyword.toLowerCase();
|
|
140
|
+
if (FILTER_KEYWORDS.has(lower)) {
|
|
141
|
+
return index === segments.length - 1 && opensFilter(words, next);
|
|
142
|
+
}
|
|
143
|
+
return words.length <= (lower === 'that' ? 2 : 1);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The unquoted value after a comparison, which runs on until the rest of the run reads as query.
|
|
148
|
+
* In `= Acme Corp THAT HAS User` the value is `Acme Corp`; in `= Acme AND Sons Production AS a
|
|
149
|
+
* RETURN a` it is `Acme AND Sons Production`, because no comparison follows `AND Sons` (PR #60
|
|
150
|
+
* review: ending the value at the first keyword logged `Sons Production`). The value is kept up to
|
|
151
|
+
* its first word that is not query (`= true AND x =` whole, `= true ANDD name` as `true
|
|
152
|
+
* [REDACTED]`), and one `[REDACTED]` replaces the rest. `next` is the character the run stopped at.
|
|
153
|
+
*/
|
|
154
|
+
function redactComparedRun(run, aliases, next) {
|
|
155
|
+
const words = run.split(/[ \t]+/);
|
|
156
|
+
const end = words.findIndex((word, index) => index > 0 && VALUE_FOLLOWERS.has(word.toLowerCase()) && isQueryTail(words.slice(index), next));
|
|
157
|
+
const value = end < 0 ? words : words.slice(0, end);
|
|
158
|
+
const data = value.findIndex((word) => !isQueryWord(word, aliases));
|
|
159
|
+
if (data < 0)
|
|
160
|
+
return run;
|
|
161
|
+
return [...value.slice(0, data), '[REDACTED]', ...(end < 0 ? [] : words.slice(end))].join(' ');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Unquoted values after a comparison, which the parser rejects and quotes back in its excerpt.
|
|
165
|
+
*
|
|
166
|
+
* `email = alice@acme.com`, `name = acme-payroll-exports` and `displayName = Acme Corp Production`
|
|
167
|
+
* reached `errorMessage` and `input.query` whole (PR #60 review simulation, 2026-10-30): the
|
|
168
|
+
* literal rules look for quotes and slashes, and these values have neither. Inside `( … OR … )` or
|
|
169
|
+
* `[ … , … ]` after a comparison, each item is judged on its own.
|
|
170
|
+
*/
|
|
171
|
+
function redactBareValues(query) {
|
|
172
|
+
const aliases = new Set([...query.matchAll(ALIAS_DECLARATION)].map((declaration) => declaration[1].toLowerCase()));
|
|
173
|
+
return query.replace(COMPARED_VALUE, (match, operator, gap, opener, list, run, offset) => {
|
|
174
|
+
if (opener !== undefined && list !== undefined) {
|
|
175
|
+
const items = list.replace(LIST_ITEM, (item) => /^['"[]/.test(item) ? item : redactListItem(item, aliases));
|
|
176
|
+
return `${operator}${gap}${opener}${items}`;
|
|
177
|
+
}
|
|
178
|
+
if (run === undefined)
|
|
179
|
+
return match;
|
|
180
|
+
const next = /^[ \t]*(.?)/.exec(query.slice(offset + match.length))?.[1] ?? '';
|
|
181
|
+
return `${operator}${gap}${redactComparedRun(run, aliases, next)}`;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
8
184
|
/**
|
|
9
185
|
* Redacts literal values in a J1QL query, preserving structure (entity types, operators,
|
|
10
186
|
* property names) so query *shape* is captured for usage analytics without literal values.
|
|
11
187
|
*
|
|
12
188
|
* Ported from query-engine's `redactCypher` (sdk-graph/src/cypher/redact.ts), adapted for J1QL
|
|
13
189
|
* (single- and double-quoted literals). The patterns span escaped quotes (`\'` / `\"`) so a
|
|
14
|
-
* literal is always replaced in full
|
|
190
|
+
* literal is always replaced in full. Both quote styles are matched in one left-to-right scan: in
|
|
191
|
+
* two passes a quote of one kind inside a literal of the other opened a match across the boundary,
|
|
192
|
+
* and `name = "O'Brien" AND email = 'alice@corp.com'` kept the email (PR #60 review).
|
|
15
193
|
*
|
|
16
194
|
* A regex literal is a value too, and `WITH email = /alice@corp\.com/i` used to reach telemetry
|
|
17
195
|
* verbatim. Its pattern is replaced and the flags are kept: the flags say how the match behaves
|
|
18
196
|
* without carrying any of the account's data. Strings are redacted FIRST, so a slash inside a
|
|
19
197
|
* quoted literal is already gone and cannot open a regex that swallows the rest of the query.
|
|
198
|
+
*
|
|
199
|
+
* Unquoted values go last (`redactBareValues`), once every quoted and regex literal is a
|
|
200
|
+
* placeholder that cannot be mistaken for one.
|
|
20
201
|
*/
|
|
21
202
|
function redactJ1ql(query) {
|
|
22
|
-
|
|
23
|
-
.replace(
|
|
24
|
-
.replace(/"(?:[^"\\]|\\.)*"/g, '"[REDACTED]"')
|
|
203
|
+
const literalsRedacted = query
|
|
204
|
+
.replace(QUOTED_LITERAL, (literal) => `${literal[0]}[REDACTED]${literal[0]}`)
|
|
25
205
|
.replace(/\/(?:[^/\\\n]|\\.)+\/([A-Za-z]*)/g, '/[REDACTED]/$1');
|
|
206
|
+
return redactBareValues(literalsRedacted);
|
|
207
|
+
}
|
|
208
|
+
/** A line that quotes the query back: a code-frame gutter (`> 1 |`, ` |`) or an indented excerpt. */
|
|
209
|
+
const EXCERPT_LINE = /^\s*>?\s*\d*\s*\|/;
|
|
210
|
+
const INDENTED_LINE = /^\s{2,}\S/;
|
|
211
|
+
/**
|
|
212
|
+
* Where a J1QL literal sits: after a comparison, an opening bracket or a comma, or after OR / AND
|
|
213
|
+
* and a space — without the space, the parser's own `"OR"` token would read as one.
|
|
214
|
+
*/
|
|
215
|
+
const LITERAL_POSITION = /(?:(?:[=~^$!<>]=?|\(|\[|,)\s*|\b(?:OR|AND)\s+)$/;
|
|
216
|
+
/**
|
|
217
|
+
* A quoted string on a prose line, both styles in one scan. A single quote between two word
|
|
218
|
+
* characters is an apostrophe (`don't`), not the start of a value.
|
|
219
|
+
*/
|
|
220
|
+
const PROSE_QUOTED = /(?<!\w)'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g;
|
|
221
|
+
/** A regex literal outside a URL: the opening slash follows neither `:`, `/` nor a word character. */
|
|
222
|
+
const REGEX_LITERAL_IN_PROSE = /(?<![:/\w])\/(?:[^/\\\s]|\\.)(?:[^/\\\n]|\\.)*\/([A-Za-z]*)/g;
|
|
223
|
+
/**
|
|
224
|
+
* Everything from an unclosed string or regex literal to the line end.
|
|
225
|
+
*
|
|
226
|
+
* A literal the frame cut off leaves its opening delimiter unclosed. Found by walking the line and
|
|
227
|
+
* honouring backslash escapes inside a literal: counting quotes was fooled by an escaped apostrophe
|
|
228
|
+
* (`'O\'Brien@corp`), and an escaped slash (`= /tenant\/private.corp`) or a cut through an escape
|
|
229
|
+
* kept a regex open (PR #60 review). A slash opens a regex only after `=`, the one place J1QL takes
|
|
230
|
+
* one. Run after the query redactor, so every closed literal is already `[REDACTED]`.
|
|
231
|
+
*/
|
|
232
|
+
function cutUnterminated(line) {
|
|
233
|
+
let openAt = -1;
|
|
234
|
+
let closer = '';
|
|
235
|
+
for (let index = 0; index < line.length; index++) {
|
|
236
|
+
const character = line[index];
|
|
237
|
+
if (openAt >= 0) {
|
|
238
|
+
if (character === '\\')
|
|
239
|
+
index++;
|
|
240
|
+
else if (character === closer)
|
|
241
|
+
openAt = -1;
|
|
242
|
+
}
|
|
243
|
+
else if (character === "'" || character === '"') {
|
|
244
|
+
openAt = index;
|
|
245
|
+
closer = character;
|
|
246
|
+
}
|
|
247
|
+
else if (character === '/' && /=\s*$/.test(line.slice(0, index))) {
|
|
248
|
+
openAt = index;
|
|
249
|
+
closer = '/';
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return openAt < 0 ? line : `${line.slice(0, openAt)}${closer}[REDACTED]`;
|
|
253
|
+
}
|
|
254
|
+
/** An excerpt line after the query redactor, with any cut-off string or regex literal removed. */
|
|
255
|
+
function redactExcerptLine(line) {
|
|
256
|
+
return cutUnterminated(redactJ1ql(line));
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Where the parser quotes the caller's own text back: the token it stopped at (`Unexpected token
|
|
260
|
+
* "Corp"` from `displayName = Acme Corp Production`, PR #60 review, 2026-10-30) and the selector it
|
|
261
|
+
* could not resolve in a filter (`Invalid filter selector: "acme"` from `name = acme.corp`). `Did
|
|
262
|
+
* you mean "X"` is not one: the parser draws X from its own fixed list of keywords.
|
|
263
|
+
*/
|
|
264
|
+
const PARSER_ECHO = /(?:Unexpected token|Invalid (?:filter|WHERE) selector:)\s*$/;
|
|
265
|
+
/** J1QL's own words and punctuation: the dashboard's rejection categories match on them. */
|
|
266
|
+
function isJ1qlToken(text) {
|
|
267
|
+
return j1ql_validator_js_1.RESERVED_WORDS.has(text.toLowerCase()) || NO_LETTER_OR_DIGIT.test(text);
|
|
268
|
+
}
|
|
269
|
+
function redactProseQuoted(literal, before) {
|
|
270
|
+
const quote = literal[0];
|
|
271
|
+
if (quote === '"' && PARSER_ECHO.test(before)) {
|
|
272
|
+
return isJ1qlToken(literal.slice(1, -1)) ? literal : '"[REDACTED]"';
|
|
273
|
+
}
|
|
274
|
+
const parserToken = quote === '"' && !/^"['"]/.test(literal) && !LITERAL_POSITION.test(before);
|
|
275
|
+
return parserToken ? literal : `${quote}[REDACTED]${quote}`;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* A prose line keeps J1QL's own quoted tokens (`Unexpected token "WITH"`, `Did you mean "with"?`)
|
|
279
|
+
* and the names the server and validator quote (`pinned to account "j1dev"`, `Invalid RETURN
|
|
280
|
+
* selector: "name"`) — the rejection categories in New Relic are read from them — and loses
|
|
281
|
+
* single-quoted values, regex patterns, double-quoted values in a literal's position, and a token
|
|
282
|
+
* the parser echoes that is not J1QL's own (`Unexpected token "Corp"`, `"'wp-'"`).
|
|
283
|
+
*/
|
|
284
|
+
function redactProseLine(line) {
|
|
285
|
+
return line
|
|
286
|
+
.replace(PROSE_QUOTED, (literal, offset) => redactProseQuoted(literal, line.slice(0, offset)))
|
|
287
|
+
.replace(REGEX_LITERAL_IN_PROSE, '/[REDACTED]/$1');
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Error text with the caller's literals taken out, for the telemetry `errorMessage`.
|
|
291
|
+
*
|
|
292
|
+
* Parser and backend errors quote the failing query back — a code frame (`> 1 | FIND … = 'x'`) or
|
|
293
|
+
* an indented excerpt under `invalid syntax at line…` — and returned envelopes can carry a
|
|
294
|
+
* corrected query. From core 1.1.1 to 2.6.1 the first 200 characters of that text reached New Relic
|
|
295
|
+
* verbatim, emails and AWS account ids included, while `input.query` beside it was redacted (seen in
|
|
296
|
+
* prod rows read 2026-10-29). Redact before truncating, so a cut can never expose half a literal.
|
|
297
|
+
*/
|
|
298
|
+
function redactErrorText(message) {
|
|
299
|
+
return message
|
|
300
|
+
.split('\n')
|
|
301
|
+
.map((line) => EXCERPT_LINE.test(line) || INDENTED_LINE.test(line)
|
|
302
|
+
? redactExcerptLine(line)
|
|
303
|
+
: redactProseLine(line))
|
|
304
|
+
.join('\n');
|
|
26
305
|
}
|
|
27
306
|
const REASON_MAX = 500;
|
|
28
307
|
function truncateReason(reason) {
|
|
@@ -35,7 +314,6 @@ function truncateReason(reason) {
|
|
|
35
314
|
const SAFE_INPUT_KEYS = [
|
|
36
315
|
'ruleId',
|
|
37
316
|
'dashboardId',
|
|
38
|
-
'integrationJobId',
|
|
39
317
|
'integrationInstanceId',
|
|
40
318
|
'jobId',
|
|
41
319
|
'definitionId',
|
|
@@ -52,6 +330,8 @@ const SAFE_INPUT_KEYS = [
|
|
|
52
330
|
'tag',
|
|
53
331
|
'includeConfig',
|
|
54
332
|
'includeDeleted',
|
|
333
|
+
'includeRequirements',
|
|
334
|
+
'format',
|
|
55
335
|
// The widget being updated. Without it, an upstream 500 on update-dashboard-widget (observed
|
|
56
336
|
// twice on dev, 2026-08-21) can be tied to a board but not to the widget that drew it.
|
|
57
337
|
'widgetId',
|
|
@@ -65,7 +345,6 @@ const SAFE_INPUT_KEYS = [
|
|
|
65
345
|
// out too: UPLOAD and JSON ids embed the customer's own control title (`ccm_c_JSON_A.5.1
|
|
66
346
|
// Policies`, the shape that broke apps' id regex on 2026-10-13), so only its source prefix is
|
|
67
347
|
// recorded, as `controlSource`.
|
|
68
|
-
'frameworkId',
|
|
69
348
|
'attestationId',
|
|
70
349
|
'states',
|
|
71
350
|
'effectiveness',
|
|
@@ -74,8 +353,13 @@ const SAFE_INPUT_KEYS = [
|
|
|
74
353
|
'sort',
|
|
75
354
|
'mitreTechniques',
|
|
76
355
|
'attestationsExpiringWithinDays',
|
|
77
|
-
//
|
|
78
|
-
|
|
356
|
+
// The authoring tools' enums and opaque ids (core 2.7.0). Their free text — title, controlName,
|
|
357
|
+
// testName, description, query, justification, framework, topic — stays out; the batch sizes
|
|
358
|
+
// and presence flags come from summarizeComplianceInput.
|
|
359
|
+
'targetState',
|
|
360
|
+
'fromStates',
|
|
361
|
+
'resultsAre',
|
|
362
|
+
'exemptionReason',
|
|
79
363
|
];
|
|
80
364
|
/**
|
|
81
365
|
* Named lifts out of a widget-write payload.
|
|
@@ -85,6 +369,10 @@ const SAFE_INPUT_KEYS = [
|
|
|
85
369
|
* TD-9016 were unmeasurable by construction. The chart type and the query *shape* are the two
|
|
86
370
|
* fields that make them diagnosable, and both are safe: the type is an enum, and the query goes
|
|
87
371
|
* through the same redactor as every other logged J1QL.
|
|
372
|
+
*
|
|
373
|
+
* Percentage mode adds two booleans. Before 2.6.2 the percentage widgets this server built divided
|
|
374
|
+
* by the wrong total and nothing in telemetry could say how many: `showAsPercentage` counts them,
|
|
375
|
+
* and `includeNumeratorInTotal` — absent when unset — says which total each one chose.
|
|
88
376
|
*/
|
|
89
377
|
function summarizeWidgetInput(input, out) {
|
|
90
378
|
if (!input || typeof input !== 'object' || Array.isArray(input))
|
|
@@ -92,6 +380,13 @@ function summarizeWidgetInput(input, out) {
|
|
|
92
380
|
const widget = input;
|
|
93
381
|
if (typeof widget.type === 'string')
|
|
94
382
|
out.widgetType = widget.type;
|
|
383
|
+
const percentage = (0, widget_percentage_js_1.percentageSettings)(typeof widget.type === 'string' ? widget.type : undefined, widget.config?.settings);
|
|
384
|
+
if (percentage) {
|
|
385
|
+
out.showAsPercentage = true;
|
|
386
|
+
if (typeof percentage.includeNumeratorInTotal === 'boolean') {
|
|
387
|
+
out.includeNumeratorInTotal = percentage.includeNumeratorInTotal;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
95
390
|
const queries = widget.config?.queries;
|
|
96
391
|
if (Array.isArray(queries)) {
|
|
97
392
|
const shapes = queries
|
|
@@ -120,6 +415,29 @@ function summarizeCveIds(params, out) {
|
|
|
120
415
|
if (Array.isArray(params.cveIds))
|
|
121
416
|
out.cveIds = params.cveIds.map(loggableCveId);
|
|
122
417
|
}
|
|
418
|
+
/**
|
|
419
|
+
* Ids the compliance and integration tools take, logged only when shaped like the opaque ids the
|
|
420
|
+
* API issues (a UUID, optionally behind a `ccm_f_J1_`-style prefix). The schemas accept any
|
|
421
|
+
* string, and the handlers reject a malformed one only after telemetry has captured it, so a title
|
|
422
|
+
* pasted into an id field reached New Relic verbatim (PR #59 review, 2026-10-30).
|
|
423
|
+
*/
|
|
424
|
+
const SHAPE_CHECKED_IDS = [
|
|
425
|
+
'frameworkId',
|
|
426
|
+
'requirementId',
|
|
427
|
+
'controlTestId',
|
|
428
|
+
'groupId',
|
|
429
|
+
'integrationJobId',
|
|
430
|
+
];
|
|
431
|
+
const OPAQUE_ID = /^(?:[A-Za-z0-9]+_){0,3}[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
432
|
+
const NOT_AN_ID = '[NOT_AN_ID]';
|
|
433
|
+
function summarizeIds(params, out) {
|
|
434
|
+
for (const key of SHAPE_CHECKED_IDS) {
|
|
435
|
+
const value = params[key];
|
|
436
|
+
if (value === undefined)
|
|
437
|
+
continue;
|
|
438
|
+
out[key] = typeof value === 'string' && OPAQUE_ID.test(value) ? value : NOT_AN_ID;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
123
441
|
const CONTROL_SOURCE_PREFIX = /^ccm_c_(J1|UCF|UPLOAD|JSON)_/i;
|
|
124
442
|
const EXPIRY_DAY_MS = 86_400_000;
|
|
125
443
|
function expiresInDaysBucket(days) {
|
|
@@ -165,6 +483,25 @@ function summarizeAttestationWrite(params, out) {
|
|
|
165
483
|
function summarizeComplianceInput(params, out) {
|
|
166
484
|
if (params.search !== undefined)
|
|
167
485
|
out.hasSearch = true;
|
|
486
|
+
// Coverage and authoring: what was asked for, as presence and size, never the words.
|
|
487
|
+
if (params.framework !== undefined)
|
|
488
|
+
out.hasFramework = true;
|
|
489
|
+
if (Array.isArray(params.frameworkIds))
|
|
490
|
+
out.frameworkIdsCount = params.frameworkIds.length;
|
|
491
|
+
if (typeof params.topic === 'string' && !('reason' in params && params.topic === params.reason)) {
|
|
492
|
+
out.hasTopic = true;
|
|
493
|
+
}
|
|
494
|
+
for (const key of ['requirements', 'controls', 'controlIds', 'entities', 'entityIds']) {
|
|
495
|
+
if (Array.isArray(params[key]))
|
|
496
|
+
out.batchSize = params[key].length;
|
|
497
|
+
}
|
|
498
|
+
if (typeof params.query === 'string' && params.controlId !== undefined)
|
|
499
|
+
out.hasQuery = true;
|
|
500
|
+
if (params.justification !== undefined)
|
|
501
|
+
out.hasJustification = true;
|
|
502
|
+
if (params.requirementIds !== undefined && typeof params.requirementIds === 'object') {
|
|
503
|
+
out.requirementIdsOp = Object.keys(params.requirementIds)[0] ?? null;
|
|
504
|
+
}
|
|
168
505
|
// A framework's name is the customer's text; `frameworkResolution` on the result says what it
|
|
169
506
|
// matched.
|
|
170
507
|
if (params.frameworkName !== undefined)
|
|
@@ -187,6 +524,9 @@ function summarizeComplianceInput(params, out) {
|
|
|
187
524
|
out.lookupBy = lookups[0];
|
|
188
525
|
}
|
|
189
526
|
/** Allowlisted, sanitized summary of tool inputs for usage telemetry. */
|
|
527
|
+
function isReferenceTopic(value) {
|
|
528
|
+
return reference_js_1.REFERENCE_TOPICS.includes(value);
|
|
529
|
+
}
|
|
190
530
|
function summarizeInput(params) {
|
|
191
531
|
const out = {};
|
|
192
532
|
for (const key of SAFE_INPUT_KEYS) {
|
|
@@ -195,11 +535,17 @@ function summarizeInput(params) {
|
|
|
195
535
|
}
|
|
196
536
|
if (typeof params.query === 'string')
|
|
197
537
|
out.query = redactJ1ql(params.query);
|
|
538
|
+
// `topic` is get-reference's manual id, which says which manuals agents read, and also
|
|
539
|
+
// check-compliance-coverage's free text ("root account MFA"): only a manual id is logged. The
|
|
540
|
+
// allowlist entry that logged both shipped a day of customer text to dev (2026-10-28).
|
|
541
|
+
if (typeof params.topic === 'string' && isReferenceTopic(params.topic))
|
|
542
|
+
out.topic = params.topic;
|
|
198
543
|
// The cursor is an opaque pagination token — record only that paging was requested.
|
|
199
544
|
if (params.cursor !== undefined)
|
|
200
545
|
out.hasCursor = true;
|
|
201
546
|
summarizeWidgetInput(params.input, out);
|
|
202
547
|
summarizeCveIds(params, out);
|
|
548
|
+
summarizeIds(params, out);
|
|
203
549
|
summarizeComplianceInput(params, out);
|
|
204
550
|
return out;
|
|
205
551
|
}
|
|
@@ -244,6 +590,11 @@ function summarizeWidgetResult(obj, out) {
|
|
|
244
590
|
// this the only way to separate a slow API from a slow probe is to compare release versions.
|
|
245
591
|
if (typeof preflight.preflightMs === 'number')
|
|
246
592
|
out.preflightMs = preflight.preflightMs;
|
|
593
|
+
// The figure a percentage widget draws, so a run of 100% or 0% draws — the degenerate totals —
|
|
594
|
+
// is countable after the fact.
|
|
595
|
+
const percentage = preflight.percentage;
|
|
596
|
+
if (typeof percentage?.value === 'number')
|
|
597
|
+
out.percentageValue = percentage.value;
|
|
247
598
|
}
|
|
248
599
|
// Present only when the fill placed something, so the field is its firing rate: the direct
|
|
249
600
|
// measure of the default-position failure it was built for, otherwise prose in configNotes.
|
|
@@ -283,6 +634,12 @@ function summarizeDiagnosis(obj, out) {
|
|
|
283
634
|
.filter((verdict) => typeof verdict === 'string');
|
|
284
635
|
if (verdicts.length > 0)
|
|
285
636
|
out.diagnosisVerdicts = [...new Set(verdicts)];
|
|
637
|
+
// The `~=` findings, added in 2.6.2: without the count a contains finding and an equality finding
|
|
638
|
+
// are the same verdict in New Relic, and whether the new probe ever fires cannot be read.
|
|
639
|
+
const contains = entries.filter((entry) => entry.operator === '~=' &&
|
|
640
|
+
(entry.verdict === 'case-mismatch' || entry.verdict === 'partial-case-match')).length;
|
|
641
|
+
if (contains > 0)
|
|
642
|
+
out.containsDiagnosisCount = contains;
|
|
286
643
|
// Reported as false when the probes ran and offered nothing, because the offer rate needs its
|
|
287
644
|
// denominator: a diagnosis with no fix and no diagnosis at all are different events. Keyed on a
|
|
288
645
|
// string rather than the key's presence — a verdict that could not build one still carries the
|
|
@@ -402,6 +759,15 @@ function tally(entries, key) {
|
|
|
402
759
|
function summarizeComplianceResult(obj, out) {
|
|
403
760
|
if (typeof obj.statusExplanation === 'string')
|
|
404
761
|
out.statusExplanation = obj.statusExplanation;
|
|
762
|
+
// Why a delete was refused (an enum), and the status of a test that was deleted.
|
|
763
|
+
if (obj.outcome === 'not_deletable' && typeof obj.reason === 'string') {
|
|
764
|
+
out.notDeletableReason = obj.reason;
|
|
765
|
+
}
|
|
766
|
+
if (typeof obj.deletedTestStatus === 'string')
|
|
767
|
+
out.deletedTestStatus = obj.deletedTestStatus;
|
|
768
|
+
// Earlier exemptions a create-exemptions filing overwrote; who made them stays in the payload.
|
|
769
|
+
if (Array.isArray(obj.replaced))
|
|
770
|
+
out.replacedCount = obj.replaced.length;
|
|
405
771
|
if (typeof obj.passingWithoutData === 'boolean') {
|
|
406
772
|
out.passingWithoutData = obj.passingWithoutData;
|
|
407
773
|
}
|
|
@@ -417,6 +783,9 @@ function summarizeComplianceResult(obj, out) {
|
|
|
417
783
|
}
|
|
418
784
|
if (typeof obj.evaluationLookupMs === 'number')
|
|
419
785
|
out.evaluationLookupMs = obj.evaluationLookupMs;
|
|
786
|
+
if (typeof obj.failedEvaluationTests === 'number') {
|
|
787
|
+
out.failedEvaluationTests = obj.failedEvaluationTests;
|
|
788
|
+
}
|
|
420
789
|
if (typeof obj.expiringAttestationsScope === 'string') {
|
|
421
790
|
out.expiringAttestationsScope = obj.expiringAttestationsScope;
|
|
422
791
|
}
|
|
@@ -443,6 +812,15 @@ function summarizeComplianceResult(obj, out) {
|
|
|
443
812
|
}
|
|
444
813
|
if (typeof obj.ouResolution === 'string')
|
|
445
814
|
out.ouResolution = obj.ouResolution;
|
|
815
|
+
if (typeof obj.testNameSearch === 'string')
|
|
816
|
+
out.testNameSearch = obj.testNameSearch;
|
|
817
|
+
if (Array.isArray(obj.testNameMatches))
|
|
818
|
+
out.testNameMatchCount = obj.testNameMatches.length;
|
|
819
|
+
if (Array.isArray(obj.controls)) {
|
|
820
|
+
const reasons = tally(obj.controls, 'failReason');
|
|
821
|
+
if (Object.keys(reasons).length > 0)
|
|
822
|
+
out.failReasonCounts = reasons;
|
|
823
|
+
}
|
|
446
824
|
// resultCount counts the candidates returned, which stop at 25; this is how many matched.
|
|
447
825
|
if (typeof obj.candidateCount === 'number')
|
|
448
826
|
out.candidateCount = obj.candidateCount;
|
|
@@ -453,9 +831,74 @@ function summarizeComplianceResult(obj, out) {
|
|
|
453
831
|
if (typeof obj.frameworkResolution === 'string') {
|
|
454
832
|
out.frameworkResolution = obj.frameworkResolution;
|
|
455
833
|
}
|
|
834
|
+
if (Array.isArray(obj.importJobs))
|
|
835
|
+
out.importJobsCount = obj.importJobs.length;
|
|
836
|
+
if (Array.isArray(obj.tests)) {
|
|
837
|
+
const exempt = obj.tests.reduce((sum, test) => sum +
|
|
838
|
+
(Array.isArray(test?.exemptions)
|
|
839
|
+
? test.exemptions.length
|
|
840
|
+
: 0), 0);
|
|
841
|
+
if (exempt > 0)
|
|
842
|
+
out.testExemptionCount = exempt;
|
|
843
|
+
}
|
|
844
|
+
if (Array.isArray(obj.frameworkIdsNotFound)) {
|
|
845
|
+
out.frameworkIdsNotFoundCount = obj.frameworkIdsNotFound.length;
|
|
846
|
+
}
|
|
847
|
+
summarizeAuthoringResult(obj, out);
|
|
456
848
|
summarizeFrameworkDrill(obj.framework, out);
|
|
457
849
|
summarizeTimings(obj.timingsMs, out);
|
|
458
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* What an authoring call did (core 2.7.0): the coverage verdict, batch outcomes by kind, what the
|
|
853
|
+
* budget did not reach, and whether the live-controls limit was hit. Counts and enums only.
|
|
854
|
+
*/
|
|
855
|
+
function summarizeAuthoringResult(obj, out) {
|
|
856
|
+
if (typeof obj.verdict === 'string')
|
|
857
|
+
out.verdict = obj.verdict;
|
|
858
|
+
if (Array.isArray(obj.importable))
|
|
859
|
+
out.importableCount = obj.importable.length;
|
|
860
|
+
if (typeof obj.draftCount === 'number')
|
|
861
|
+
out.draftCount = obj.draftCount;
|
|
862
|
+
if (Array.isArray(obj.items))
|
|
863
|
+
out.itemOutcomeCounts = tally(obj.items, 'outcome');
|
|
864
|
+
for (const key of ['transitioned', 'interrupted', 'skipped', 'refused']) {
|
|
865
|
+
if (Array.isArray(obj[key]))
|
|
866
|
+
out[`${key}Count`] = obj[key].length;
|
|
867
|
+
}
|
|
868
|
+
// `transitioned` holds one entry per hop; a DRAFT->LIVE control is two. The control count beside
|
|
869
|
+
// it is what showed 180 hops for ~45 controls on dev (2026-10-28).
|
|
870
|
+
if (Array.isArray(obj.transitioned)) {
|
|
871
|
+
out.controlsTransitionedCount = new Set(obj.transitioned.map((move) => move.id)).size;
|
|
872
|
+
}
|
|
873
|
+
if (typeof obj.replannedCount === 'number')
|
|
874
|
+
out.replannedCount = obj.replannedCount;
|
|
875
|
+
if (typeof obj.remaining === 'number')
|
|
876
|
+
out.remaining = obj.remaining;
|
|
877
|
+
if (typeof obj.liveLimitHit === 'boolean')
|
|
878
|
+
out.liveLimitHit = obj.liveLimitHit;
|
|
879
|
+
if (typeof obj.queuedCount === 'number')
|
|
880
|
+
out.queuedCount = obj.queuedCount;
|
|
881
|
+
if (typeof obj.unknownEntityType === 'boolean')
|
|
882
|
+
out.unknownEntityType = obj.unknownEntityType;
|
|
883
|
+
// A filed group carries its groupId; a revoke reports `revoked` and the count withdrawn, which
|
|
884
|
+
// a groupId-only test dropped for every revoke (PR #59 review).
|
|
885
|
+
if (typeof obj.count === 'number' &&
|
|
886
|
+
(typeof obj.groupId === 'string' || obj.outcome === 'revoked'))
|
|
887
|
+
out.exemptionCount = obj.count;
|
|
888
|
+
const preflight = obj.preflight;
|
|
889
|
+
if (preflight && typeof preflight.queryRun === 'string') {
|
|
890
|
+
out.preflightQueryRun = preflight.queryRun;
|
|
891
|
+
if (typeof preflight.rows === 'number')
|
|
892
|
+
out.preflightRows = preflight.rows;
|
|
893
|
+
}
|
|
894
|
+
const job = obj.job;
|
|
895
|
+
if (job && typeof job.status === 'string')
|
|
896
|
+
out.jobStatus = job.status;
|
|
897
|
+
if (typeof obj.testsRan === 'number') {
|
|
898
|
+
out.testsRan = obj.testsRan;
|
|
899
|
+
out.testsFailing = obj.testsFailing;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
459
902
|
const TIMED_PHASES = [
|
|
460
903
|
'frameworks',
|
|
461
904
|
'stats',
|
|
@@ -470,6 +913,29 @@ const TIMED_PHASES = [
|
|
|
470
913
|
'account',
|
|
471
914
|
'passingWithoutData',
|
|
472
915
|
'drillGraph',
|
|
916
|
+
'requirementList',
|
|
917
|
+
'testNames',
|
|
918
|
+
'confirm',
|
|
919
|
+
// Authoring (core 2.7.0).
|
|
920
|
+
'library',
|
|
921
|
+
'topicSearch',
|
|
922
|
+
'jobs',
|
|
923
|
+
'import',
|
|
924
|
+
'create',
|
|
925
|
+
'dedup',
|
|
926
|
+
'requirement',
|
|
927
|
+
'linked',
|
|
928
|
+
'link',
|
|
929
|
+
'update',
|
|
930
|
+
'delete',
|
|
931
|
+
'selection',
|
|
932
|
+
'transitions',
|
|
933
|
+
'evaluate',
|
|
934
|
+
'test',
|
|
935
|
+
'preflight',
|
|
936
|
+
'evaluation',
|
|
937
|
+
'eligibility',
|
|
938
|
+
'revoke',
|
|
473
939
|
];
|
|
474
940
|
/**
|
|
475
941
|
* Per-phase wall time of a compliance read, as `timings<Phase>Ms` numbers. Only known phase names
|
|
@@ -515,6 +981,11 @@ function summarizeFrameworkDrill(framework, out) {
|
|
|
515
981
|
}
|
|
516
982
|
if (typeof drill.drillSource === 'string')
|
|
517
983
|
out.drillSource = drill.drillSource;
|
|
984
|
+
if (Array.isArray(drill.requirementList))
|
|
985
|
+
out.requirementListCount = drill.requirementList.length;
|
|
986
|
+
if (typeof drill.requirementListSkipped === 'string') {
|
|
987
|
+
out.requirementListSkipped = drill.requirementListSkipped;
|
|
988
|
+
}
|
|
518
989
|
if (typeof drill.passingWithoutDataSkipped === 'string') {
|
|
519
990
|
out.passingWithoutDataSkipped = drill.passingWithoutDataSkipped;
|
|
520
991
|
}
|
|
@@ -532,8 +1003,19 @@ function summarizeFrameworkDrill(framework, out) {
|
|
|
532
1003
|
* The tool name is read for exactly one lift — the created board's id, below — because a
|
|
533
1004
|
* top-level `id` means a different thing on every tool that returns one.
|
|
534
1005
|
*/
|
|
1006
|
+
/** A thrown compliance error's phase report (see complianceErrorResponse). */
|
|
1007
|
+
function summarizePhase(phase, out) {
|
|
1008
|
+
if (typeof phase.failedPhase === 'string')
|
|
1009
|
+
out.failedPhase = phase.failedPhase;
|
|
1010
|
+
if (Array.isArray(phase.runningPhases))
|
|
1011
|
+
out.runningPhaseCount = phase.runningPhases.length;
|
|
1012
|
+
summarizeTimings(phase.timingsMs, out);
|
|
1013
|
+
}
|
|
535
1014
|
function summarizeResult(result, toolName) {
|
|
536
1015
|
const out = { isError: !!result.isError };
|
|
1016
|
+
const phase = result._meta?.[exports.PHASE_META_KEY];
|
|
1017
|
+
if (phase && typeof phase === 'object')
|
|
1018
|
+
summarizePhase(phase, out);
|
|
537
1019
|
const sc = result.structuredContent;
|
|
538
1020
|
if (!sc || typeof sc !== 'object' || Array.isArray(sc))
|
|
539
1021
|
return out;
|