@onlyflows/servicenow-mcp 2.3.0 → 2.4.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +206 -22
- package/dist/atf-result-cache.d.ts +2 -2
- package/dist/call-metrics.d.ts +11 -1
- package/dist/call-metrics.d.ts.map +1 -1
- package/dist/call-metrics.js +2 -0
- package/dist/call-metrics.js.map +1 -1
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +31 -3
- package/dist/client.js.map +1 -1
- package/dist/execution-context.d.ts +3 -3
- package/dist/execution-context.d.ts.map +1 -1
- package/dist/execution-context.js +7 -2
- package/dist/execution-context.js.map +1 -1
- package/dist/field-policy.d.ts +8 -0
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +239 -46
- package/dist/field-policy.js.map +1 -1
- package/dist/hidden-values.d.ts +368 -21
- package/dist/hidden-values.d.ts.map +1 -1
- package/dist/hidden-values.js +1050 -101
- package/dist/hidden-values.js.map +1 -1
- package/dist/http-observability.js +3 -1
- package/dist/http-observability.js.map +1 -1
- package/dist/inert-text.d.ts +27 -0
- package/dist/inert-text.d.ts.map +1 -0
- package/dist/inert-text.js +57 -0
- package/dist/inert-text.js.map +1 -0
- package/dist/policy-card.d.ts +1 -1
- package/dist/policy-card.d.ts.map +1 -1
- package/dist/policy-card.js +3 -1
- package/dist/policy-card.js.map +1 -1
- package/dist/setup-prompts.js +1 -0
- package/dist/setup-prompts.js.map +1 -1
- package/dist/setup.js +6 -0
- package/dist/setup.js.map +1 -1
- package/dist/tool-error.d.ts +39 -3
- package/dist/tool-error.d.ts.map +1 -1
- package/dist/tool-error.js +101 -2
- package/dist/tool-error.js.map +1 -1
- package/dist/tool-table-access.d.ts.map +1 -1
- package/dist/tool-table-access.js +5 -0
- package/dist/tool-table-access.js.map +1 -1
- package/dist/tools/aggregate.d.ts +8 -0
- package/dist/tools/aggregate.d.ts.map +1 -1
- package/dist/tools/aggregate.js +70 -11
- package/dist/tools/aggregate.js.map +1 -1
- package/dist/tools/atf-contracts.d.ts +9 -9
- package/dist/tools/catalog.d.ts +2 -2
- package/dist/tools/catalog.d.ts.map +1 -1
- package/dist/tools/catalog.js +9 -0
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/envelope-text-fit.d.ts +20 -0
- package/dist/tools/envelope-text-fit.d.ts.map +1 -0
- package/dist/tools/envelope-text-fit.js +33 -0
- package/dist/tools/envelope-text-fit.js.map +1 -0
- package/dist/tools/flow-view-mermaid.d.ts.map +1 -1
- package/dist/tools/flow-view-mermaid.js +6 -13
- package/dist/tools/flow-view-mermaid.js.map +1 -1
- package/dist/tools/flow-view-module.js +1 -1
- package/dist/tools/get-module.js +1 -1
- package/dist/tools/history-contracts.d.ts +198 -0
- package/dist/tools/history-contracts.d.ts.map +1 -0
- package/dist/tools/history-contracts.js +317 -0
- package/dist/tools/history-contracts.js.map +1 -0
- package/dist/tools/history-module.d.ts +158 -0
- package/dist/tools/history-module.d.ts.map +1 -0
- package/dist/tools/history-module.js +937 -0
- package/dist/tools/history-module.js.map +1 -0
- package/dist/tools/history-renderers.d.ts +32 -0
- package/dist/tools/history-renderers.d.ts.map +1 -0
- package/dist/tools/history-renderers.js +154 -0
- package/dist/tools/history-renderers.js.map +1 -0
- package/dist/tools/index.d.ts +3 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +31 -14
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/platform-view-contracts.d.ts +4 -4
- package/dist/tools/platform-view-contracts.d.ts.map +1 -1
- package/dist/tools/platform-view-contracts.js +3 -0
- package/dist/tools/platform-view-contracts.js.map +1 -1
- package/dist/tools/platform-view-evaluate.d.ts +7 -2
- package/dist/tools/platform-view-evaluate.d.ts.map +1 -1
- package/dist/tools/platform-view-evaluate.js +44 -130
- package/dist/tools/platform-view-evaluate.js.map +1 -1
- package/dist/tools/platform-view-module.d.ts +12 -3
- package/dist/tools/platform-view-module.d.ts.map +1 -1
- package/dist/tools/platform-view-module.js +61 -16
- package/dist/tools/platform-view-module.js.map +1 -1
- package/dist/tools/platform-view-payload.d.ts +101 -0
- package/dist/tools/platform-view-payload.d.ts.map +1 -0
- package/dist/tools/platform-view-payload.js +302 -0
- package/dist/tools/platform-view-payload.js.map +1 -0
- package/dist/tools/platform-view-update-sets.d.ts +129 -0
- package/dist/tools/platform-view-update-sets.d.ts.map +1 -0
- package/dist/tools/platform-view-update-sets.js +1060 -0
- package/dist/tools/platform-view-update-sets.js.map +1 -0
- package/dist/tools/query-module.js +1 -1
- package/dist/tools/relationships-map.d.ts +59 -0
- package/dist/tools/relationships-map.d.ts.map +1 -0
- package/dist/tools/relationships-map.js +162 -0
- package/dist/tools/relationships-map.js.map +1 -0
- package/dist/tools/relationships-renderer.d.ts +22 -0
- package/dist/tools/relationships-renderer.d.ts.map +1 -0
- package/dist/tools/relationships-renderer.js +90 -0
- package/dist/tools/relationships-renderer.js.map +1 -0
- package/dist/tools/relationships.d.ts +37 -2
- package/dist/tools/relationships.d.ts.map +1 -1
- package/dist/tools/relationships.js +602 -183
- package/dist/tools/relationships.js.map +1 -1
- package/dist/tools/result-envelope.d.ts +314 -15
- package/dist/tools/result-envelope.d.ts.map +1 -1
- package/dist/tools/result-envelope.js +120 -19
- package/dist/tools/result-envelope.js.map +1 -1
- package/dist/tools/syslog.d.ts +1 -1
- package/dist/tools/table-hierarchy.d.ts +17 -0
- package/dist/tools/table-hierarchy.d.ts.map +1 -1
- package/dist/tools/table-hierarchy.js +41 -0
- package/dist/tools/table-hierarchy.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/docs/CLIENT-SETUP.md +2 -2
- package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +2 -2
- package/docs/PRODUCTION-SECURITY.md +145 -2
- package/docs/RELEASE-VALIDATION.md +2 -2
- package/docs/TESTING-OAUTH.md +1 -1
- package/package.json +2 -2
- package/server.json +2 -2
package/dist/field-policy.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* @module field-policy
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.FieldPolicyConfigurationError = exports.EXPLICIT_WRITE_FIELD_NAMES = exports.FieldPolicyError = exports.SAFE_DEFAULT_FIELDS = exports.BUILT_IN_TABLE_CLASSES = exports.ROTATION_SHARD_BASE_NAMES = exports.EXPLICIT_READ_FIELD_NAMES = exports.MAX_TOOL_ARGUMENT_OWN_KEYS = exports.MAX_FIELD_OBJECT_OWN_KEYS = exports.MAX_FIELD_ARRAY_LENGTH = exports.MAX_FIELD_VALUE_NODES = exports.MAX_FIELD_VALUE_DEPTH = exports.MAX_FIELDS_PER_OPERATION = void 0;
|
|
16
|
+
exports.FieldPolicyConfigurationError = exports.EXPLICIT_WRITE_FIELD_NAMES = exports.FieldPolicyError = exports.SAFE_DEFAULT_FIELDS = exports.BUILT_IN_TABLE_CLASSES = exports.ROTATION_SHARD_BASE_NAMES = exports.EXPLICIT_READ_FIELD_NAMES = exports.COMMAND_LINE_ANY_TABLE_FIELD_NAMES = exports.MAX_TOOL_ARGUMENT_OWN_KEYS = exports.MAX_FIELD_OBJECT_OWN_KEYS = exports.MAX_FIELD_ARRAY_LENGTH = exports.MAX_FIELD_VALUE_NODES = exports.MAX_FIELD_VALUE_DEPTH = exports.MAX_FIELDS_PER_OPERATION = void 0;
|
|
17
|
+
exports.explicitReadColumns = explicitReadColumns;
|
|
17
18
|
exports.fieldPolicyDenialMessage = fieldPolicyDenialMessage;
|
|
18
19
|
exports.isFieldPolicyError = isFieldPolicyError;
|
|
19
20
|
exports.snapshotPlainDataArguments = snapshotPlainDataArguments;
|
|
@@ -145,6 +146,81 @@ const RECORD_PAYLOAD_COLUMNS = new Map([
|
|
|
145
146
|
table,
|
|
146
147
|
Object.freeze(new Set(columns)),
|
|
147
148
|
]));
|
|
149
|
+
/**
|
|
150
|
+
* Process command-line columns: per table, the columns that hold the command
|
|
151
|
+
* line a process was started with, or its arguments. They follow the same
|
|
152
|
+
* rules as the record payload columns above: no wildcard covers them, for
|
|
153
|
+
* reads or writes, and a column is read or written only where the profile's
|
|
154
|
+
* own entry for that table lists it in `readable` or `writable`. A table that
|
|
155
|
+
* extends one of these tables has the same columns, wherever its chain is
|
|
156
|
+
* known (see {@link explicitReadColumns}). One line per table adds a table.
|
|
157
|
+
*/
|
|
158
|
+
const COMMAND_LINE_COLUMNS = new Map([
|
|
159
|
+
// Running processes, and what discovery copies from them to the
|
|
160
|
+
// application CI (inherited by every application class).
|
|
161
|
+
["cmdb_running_process", ["command", "parameters", "key_parameters"]],
|
|
162
|
+
["cmdb_ci_appl", ["running_process_command", "running_process_key_parameters"]],
|
|
163
|
+
// Connections, containers and images.
|
|
164
|
+
["cmdb_tcp_connection", ["command"]],
|
|
165
|
+
["cmdb_tcp_half", ["command"]],
|
|
166
|
+
["cmdb_ci_docker_container", ["command"]],
|
|
167
|
+
["cmdb_ci_oslv_image", ["command"]],
|
|
168
|
+
// The out-of-the-box table that extends one of the above, listed by name
|
|
169
|
+
// so it is guarded when its chain is not known (see closedColumns).
|
|
170
|
+
["cmdb_ci_docker_image", ["command"]],
|
|
171
|
+
// Application and endpoint classes with their own command-line column.
|
|
172
|
+
["cmdb_ci_appl_rabbitmq_cluster", ["command_line"]],
|
|
173
|
+
["cmdb_ci_appl_mongo_config_serv", ["command_line"]],
|
|
174
|
+
["cmdb_ci_appl_ca_id_man", ["command_line"]],
|
|
175
|
+
["cmdb_ci_appl_generic", ["command_line"]],
|
|
176
|
+
["cmdb_ci_appl_rabbitmq", ["command_line"]],
|
|
177
|
+
["cmdb_ci_appl_ca_ent_man", ["command_line"]],
|
|
178
|
+
["cmdb_ci_appl_dot_net", ["command_line"]],
|
|
179
|
+
["cmdb_ci_appl_mongos", ["command_line"]],
|
|
180
|
+
["cmdb_ci_appl_ca_dir_server", ["command_line"]],
|
|
181
|
+
["cmdb_ci_endpoint_mq_mem", ["cmd_line"]],
|
|
182
|
+
["cmdb_ci_endpoint_wmb_depend", ["cmd_line"]],
|
|
183
|
+
["cmdb_ci_endpoint_storf", ["args"]],
|
|
184
|
+
["cmdb_ci_endpoint_xenapp_citrx", ["args"]],
|
|
185
|
+
["cmdb_ci_endpoint_app", ["args"]],
|
|
186
|
+
["cmdb_ci_appl_citrix_app", ["app_args"]],
|
|
187
|
+
// The out-of-the-box database views that join the tables above: each
|
|
188
|
+
// joined table's columns under its prefix. Listed by name so they are
|
|
189
|
+
// guarded when the view's joined tables are not known (see closedColumns).
|
|
190
|
+
["related_servers", ["rp_command", "rp_parameters", "rp_key_parameters"]],
|
|
191
|
+
[
|
|
192
|
+
"classified_apps",
|
|
193
|
+
[
|
|
194
|
+
"p_command",
|
|
195
|
+
"p_parameters",
|
|
196
|
+
"p_key_parameters",
|
|
197
|
+
"a_running_process_command",
|
|
198
|
+
"a_running_process_key_parameters",
|
|
199
|
+
],
|
|
200
|
+
],
|
|
201
|
+
["application_on_servers", ["appl_running_process_command", "appl_running_process_key_parameters"]],
|
|
202
|
+
["samp_lrb_to_instances_view", ["appl_running_process_command", "appl_running_process_key_parameters"]],
|
|
203
|
+
].map(([table, columns]) => [
|
|
204
|
+
table,
|
|
205
|
+
Object.freeze(new Set(columns)),
|
|
206
|
+
]));
|
|
207
|
+
/**
|
|
208
|
+
* Command-line columns guarded by name on every table, whatever its chain:
|
|
209
|
+
* the names are specific, a custom table can define them outside the
|
|
210
|
+
* application classes, and the chain is not known when a profile sets
|
|
211
|
+
* `"fieldTypes": { "dictionary": "not_required" }`.
|
|
212
|
+
*/
|
|
213
|
+
const COMMAND_LINE_ANY_TABLE_COLUMNS = Object.freeze(new Set(["running_process_command", "running_process_key_parameters"]));
|
|
214
|
+
/** The columns guarded by name on every table (for documentation and tests). */
|
|
215
|
+
exports.COMMAND_LINE_ANY_TABLE_FIELD_NAMES = Object.freeze([
|
|
216
|
+
...COMMAND_LINE_ANY_TABLE_COLUMNS,
|
|
217
|
+
]);
|
|
218
|
+
/** Names that mark a column as a command-line column in a denial message. */
|
|
219
|
+
const COMMAND_LINE_FIELD_NAMES = new Set([
|
|
220
|
+
...[...COMMAND_LINE_COLUMNS.values()].flatMap((columns) => [...columns]),
|
|
221
|
+
...COMMAND_LINE_ANY_TABLE_COLUMNS,
|
|
222
|
+
]);
|
|
223
|
+
const PAYLOAD_FIELD_NAMES = new Set([...RECORD_PAYLOAD_COLUMNS.values()].flatMap((columns) => [...columns]));
|
|
148
224
|
/**
|
|
149
225
|
* Tables the platform rotates into numbered shards (`ecc_queue0003`,
|
|
150
226
|
* `sys_replication_queue5`), each a separate table that a `"*"` grant reaches
|
|
@@ -182,13 +258,13 @@ function withoutShardSuffix(table) {
|
|
|
182
258
|
return end === table.length || end === 0 ? undefined : table.slice(0, end);
|
|
183
259
|
}
|
|
184
260
|
/**
|
|
185
|
-
* The
|
|
186
|
-
* A rotation shard takes its base table's columns, and a CDC queue
|
|
187
|
-
* CDC columns. Lookups and fixed rules only: nothing is stored per
|
|
188
|
-
* arbitrary names never grow any state.
|
|
261
|
+
* The closed columns of `table` (a normalized name) by its own name, or
|
|
262
|
+
* undefined. A rotation shard takes its base table's columns, and a CDC queue
|
|
263
|
+
* takes the CDC columns. Lookups and fixed rules only: nothing is stored per
|
|
264
|
+
* name, so arbitrary names never grow any state.
|
|
189
265
|
*/
|
|
190
|
-
function
|
|
191
|
-
const exact = RECORD_PAYLOAD_COLUMNS.get(table);
|
|
266
|
+
function tableClosedColumns(table) {
|
|
267
|
+
const exact = RECORD_PAYLOAD_COLUMNS.get(table) ?? COMMAND_LINE_COLUMNS.get(table);
|
|
192
268
|
if (exact !== undefined)
|
|
193
269
|
return exact;
|
|
194
270
|
if (table.length > CDC_QUEUE_PREFIX.length &&
|
|
@@ -199,12 +275,115 @@ function recordPayloadColumns(table) {
|
|
|
199
275
|
const base = withoutShardSuffix(table);
|
|
200
276
|
return base !== undefined && ROTATION_SHARD_BASES.has(base) ? RECORD_PAYLOAD_COLUMNS.get(base) : undefined;
|
|
201
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* The columns of `table` that no wildcard covers: the ones guarded by name on
|
|
280
|
+
* every table, its own (see {@link tableClosedColumns}) and, inside a call,
|
|
281
|
+
* those of every ancestor that has any. Ancestors come from the extension
|
|
282
|
+
* chains the dispatcher resolved for the call's tables; a table whose chain
|
|
283
|
+
* is not known has only its own columns. Returns a shared, frozen set, so
|
|
284
|
+
* callers may key on it: a static set itself when one applies, else a union
|
|
285
|
+
* kept per combination (the combinations are fixed by the lists above, never
|
|
286
|
+
* by input).
|
|
287
|
+
*/
|
|
288
|
+
function closedColumns(table) {
|
|
289
|
+
const own = tableClosedColumns(table);
|
|
290
|
+
const scope = (0, hidden_values_js_1.currentHiddenFieldScope)();
|
|
291
|
+
const view = scope?.views?.get(table);
|
|
292
|
+
if (view !== undefined)
|
|
293
|
+
return viewClosedColumns(scope.views, table, view, own);
|
|
294
|
+
const hierarchy = scope?.hierarchies?.get(table);
|
|
295
|
+
if (hierarchy === undefined || hierarchy.length < 2) {
|
|
296
|
+
return own === undefined ? COMMAND_LINE_ANY_TABLE_COLUMNS : unionOf([own, COMMAND_LINE_ANY_TABLE_COLUMNS]);
|
|
297
|
+
}
|
|
298
|
+
const sets = [COMMAND_LINE_ANY_TABLE_COLUMNS];
|
|
299
|
+
if (own !== undefined)
|
|
300
|
+
sets.push(own);
|
|
301
|
+
for (let index = 1; index < hierarchy.length; index += 1) {
|
|
302
|
+
const inherited = tableClosedColumns(hierarchy[index]);
|
|
303
|
+
if (inherited !== undefined && !sets.includes(inherited))
|
|
304
|
+
sets.push(inherited);
|
|
305
|
+
}
|
|
306
|
+
return unionOf(sets);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* A database view's closed columns: each joined table's closed columns (its
|
|
310
|
+
* chain's, and the ones guarded everywhere) under the view's column prefix for
|
|
311
|
+
* that table, plus the view's own. Built once per view for the call's resolved
|
|
312
|
+
* views, so the returned set is the same object for every check in the call.
|
|
313
|
+
*/
|
|
314
|
+
function viewClosedColumns(views, table, sources, own) {
|
|
315
|
+
let byView = VIEW_CLOSED_COLUMNS.get(views);
|
|
316
|
+
if (byView === undefined)
|
|
317
|
+
VIEW_CLOSED_COLUMNS.set(views, (byView = new Map()));
|
|
318
|
+
const known = byView.get(table);
|
|
319
|
+
if (known !== undefined)
|
|
320
|
+
return known;
|
|
321
|
+
const names = new Set(COMMAND_LINE_ANY_TABLE_COLUMNS);
|
|
322
|
+
for (const column of own ?? [])
|
|
323
|
+
names.add(column);
|
|
324
|
+
for (const source of sources) {
|
|
325
|
+
const sets = [COMMAND_LINE_ANY_TABLE_COLUMNS];
|
|
326
|
+
for (const name of source.hierarchy) {
|
|
327
|
+
const columns = tableClosedColumns(name);
|
|
328
|
+
if (columns !== undefined)
|
|
329
|
+
sets.push(columns);
|
|
330
|
+
}
|
|
331
|
+
for (const columns of sets) {
|
|
332
|
+
for (const column of columns) {
|
|
333
|
+
const prefixed = `${source.prefix}_${column}`;
|
|
334
|
+
if (FIELD_NAME.test(prefixed))
|
|
335
|
+
names.add(prefixed);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
const closed = Object.freeze(names);
|
|
340
|
+
byView.set(table, closed);
|
|
341
|
+
return closed;
|
|
342
|
+
}
|
|
343
|
+
const VIEW_CLOSED_COLUMNS = new WeakMap();
|
|
344
|
+
const CLOSED_COLUMN_SET_IDS = new WeakMap();
|
|
345
|
+
const CLOSED_COLUMN_UNIONS = new Map();
|
|
346
|
+
/** The union of static column sets, one shared frozen set per combination. */
|
|
347
|
+
function unionOf(sets) {
|
|
348
|
+
if (sets.length === 1)
|
|
349
|
+
return sets[0];
|
|
350
|
+
const ids = sets.map((columns) => {
|
|
351
|
+
let id = CLOSED_COLUMN_SET_IDS.get(columns);
|
|
352
|
+
if (id === undefined)
|
|
353
|
+
CLOSED_COLUMN_SET_IDS.set(columns, (id = nextSetId++));
|
|
354
|
+
return id;
|
|
355
|
+
});
|
|
356
|
+
const key = [...new Set(ids)].sort((left, right) => left - right).join(",");
|
|
357
|
+
let union = CLOSED_COLUMN_UNIONS.get(key);
|
|
358
|
+
if (union === undefined) {
|
|
359
|
+
union = Object.freeze(new Set(sets.flatMap((columns) => [...columns])));
|
|
360
|
+
CLOSED_COLUMN_UNIONS.set(key, union);
|
|
361
|
+
}
|
|
362
|
+
return union;
|
|
363
|
+
}
|
|
364
|
+
let nextSetId = 1;
|
|
365
|
+
/**
|
|
366
|
+
* The columns of the table `tableCandidate` that a read or write must have
|
|
367
|
+
* listed by name (see {@link closedColumns}), or undefined for a name that is
|
|
368
|
+
* not a table.
|
|
369
|
+
*/
|
|
370
|
+
function explicitReadColumns(tableCandidate) {
|
|
371
|
+
try {
|
|
372
|
+
return closedColumns(normalizeTableName(tableCandidate));
|
|
373
|
+
}
|
|
374
|
+
catch {
|
|
375
|
+
return undefined;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
202
378
|
/**
|
|
203
379
|
* Each base table and the columns its own entry must list. A rotation shard
|
|
204
380
|
* (see ROTATION_SHARD_BASE_NAMES) has its base table's columns, and every
|
|
205
381
|
* `cdc_queue_*` table except `cdc_queue_state_*` has the CDC queue columns.
|
|
206
382
|
*/
|
|
207
|
-
exports.EXPLICIT_READ_FIELD_NAMES = Object.freeze(Object.fromEntries([...RECORD_PAYLOAD_COLUMNS].map(([table, columns]) => [
|
|
383
|
+
exports.EXPLICIT_READ_FIELD_NAMES = Object.freeze(Object.fromEntries([...RECORD_PAYLOAD_COLUMNS, ...COMMAND_LINE_COLUMNS].map(([table, columns]) => [
|
|
384
|
+
table,
|
|
385
|
+
Object.freeze([...columns]),
|
|
386
|
+
])));
|
|
208
387
|
/** The base tables whose numbered rotation shards share their columns. */
|
|
209
388
|
exports.ROTATION_SHARD_BASE_NAMES = Object.freeze([...ROTATION_SHARD_BASES]);
|
|
210
389
|
const INCIDENT_DEFAULTS = [
|
|
@@ -1045,6 +1224,15 @@ class FieldPolicyError extends Error {
|
|
|
1045
1224
|
}
|
|
1046
1225
|
}
|
|
1047
1226
|
exports.FieldPolicyError = FieldPolicyError;
|
|
1227
|
+
/** What a closed column holds, for its denial message. */
|
|
1228
|
+
function closedColumnContent(field) {
|
|
1229
|
+
// A database view's column is the joined table's column under a prefix
|
|
1230
|
+
// (`rp_command`), so a name also matches by its ending.
|
|
1231
|
+
const named = (names) => names.has(field) || [...names].some((name) => field.endsWith(`_${name}`));
|
|
1232
|
+
return named(COMMAND_LINE_FIELD_NAMES) && !named(PAYLOAD_FIELD_NAMES)
|
|
1233
|
+
? "process command lines"
|
|
1234
|
+
: "record payloads";
|
|
1235
|
+
}
|
|
1048
1236
|
/**
|
|
1049
1237
|
* Operator-facing explanation for a field-policy denial.
|
|
1050
1238
|
*
|
|
@@ -1084,12 +1272,14 @@ function fieldPolicyDenialMessage(error) {
|
|
|
1084
1272
|
// the caller a field's type, which is what the type rule keeps back.
|
|
1085
1273
|
return "Access denied by policy: a requested field is denied by name as sensitive and cannot be granted by configuration.";
|
|
1086
1274
|
case "field_types_unavailable":
|
|
1087
|
-
|
|
1275
|
+
// A table outside the call's resolved plan: this server's own plan
|
|
1276
|
+
// decided it, not an instance read (those refusals are the dispatcher's).
|
|
1277
|
+
return (0, hidden_values_js_1.fieldTypesPlanDenialText)(table);
|
|
1088
1278
|
case "explicit_field_required":
|
|
1089
|
-
// Only EXPLICIT_WRITE_FIELDS and
|
|
1090
|
-
//
|
|
1279
|
+
// Only EXPLICIT_WRITE_FIELDS and closed column names reach this case;
|
|
1280
|
+
// each is a fixed name that passed FIELD_NAME.
|
|
1091
1281
|
if (table && field && !EXPLICIT_WRITE_FIELDS.has(field)) {
|
|
1092
|
-
return (`Write denied by policy: field "${field}" on "${table}" holds
|
|
1282
|
+
return (`Write denied by policy: field "${field}" on "${table}" holds ${closedColumnContent(field)}, ` +
|
|
1093
1283
|
"so a writable wildcard never covers it. List it explicitly in " +
|
|
1094
1284
|
`fieldPolicy.${table}.writable to allow this write.`);
|
|
1095
1285
|
}
|
|
@@ -1099,12 +1289,12 @@ function fieldPolicyDenialMessage(error) {
|
|
|
1099
1289
|
`in fieldPolicy.${table}.writable to allow this write.`
|
|
1100
1290
|
: "Write denied by policy: a field that a writable wildcard never covers must be listed explicitly in the writable set.";
|
|
1101
1291
|
case "explicit_read_required":
|
|
1102
|
-
// Only
|
|
1292
|
+
// Only closed column names reach this case.
|
|
1103
1293
|
return table && field
|
|
1104
|
-
? `Read denied by policy: field "${field}" on "${table}" holds
|
|
1294
|
+
? `Read denied by policy: field "${field}" on "${table}" holds ${closedColumnContent(field)}, ` +
|
|
1105
1295
|
"so a readable wildcard never covers it. List it explicitly in " +
|
|
1106
1296
|
`fieldPolicy.${table}.readable to allow this read.`
|
|
1107
|
-
: "Read denied by policy: a
|
|
1297
|
+
: "Read denied by policy: a field a readable wildcard never covers must be listed explicitly in its table's readable set.";
|
|
1108
1298
|
case "unsupported_field_path":
|
|
1109
1299
|
// The key itself is not echoed: as a whole it did not pass FIELD_NAME.
|
|
1110
1300
|
return (`Write denied by policy: write keys${table ? ` on "${table}"` : ""} must be plain field names. ` +
|
|
@@ -1230,8 +1420,8 @@ function validateWritableFields(tableCandidate, payloadCandidate) {
|
|
|
1230
1420
|
if (EXPLICIT_WRITE_FIELDS.has(field) && !policy.writable.includes(field)) {
|
|
1231
1421
|
throw new FieldPolicyError("explicit_field_required", { table: policy.table, field });
|
|
1232
1422
|
}
|
|
1233
|
-
// A
|
|
1234
|
-
if (
|
|
1423
|
+
// A closed column is written only where the table's own entry lists it.
|
|
1424
|
+
if (closedColumns(policy.table).has(field) && !policy.ownWritable.includes(field)) {
|
|
1235
1425
|
throw new FieldPolicyError("explicit_field_required", { table: policy.table, field });
|
|
1236
1426
|
}
|
|
1237
1427
|
if (!fieldSetAllows(policy.writable, policy.allowAnyWritable, field)) {
|
|
@@ -1466,38 +1656,37 @@ function typeHiddenFields(table) {
|
|
|
1466
1656
|
function typeHiddenFieldNames(tableCandidate) {
|
|
1467
1657
|
return typeHiddenFields(normalizeTableName(tableCandidate));
|
|
1468
1658
|
}
|
|
1469
|
-
/** Per policy map, the closed
|
|
1659
|
+
/** Per policy map, the closed columns of each table it names that its entry partly opens. */
|
|
1470
1660
|
const EXPLICIT_READ_DENIED = new WeakMap();
|
|
1471
1661
|
/**
|
|
1472
|
-
* The
|
|
1473
|
-
* open: every one, unless the profile's own entry for the
|
|
1474
|
-
* `readable`. With nothing listed the answer is the table's
|
|
1475
|
-
* so nothing is stored; a partial opening is cached per
|
|
1476
|
-
* and only tables the configuration names can reach
|
|
1662
|
+
* The closed columns of `table` (see {@link closedColumns}) that the current
|
|
1663
|
+
* policy does not open: every one, unless the profile's own entry for the
|
|
1664
|
+
* table lists it in `readable`. With nothing listed the answer is the table's
|
|
1665
|
+
* column set itself, so nothing is stored; a partial opening is cached per
|
|
1666
|
+
* policy map and table, and only tables the configuration names can reach
|
|
1667
|
+
* that cache.
|
|
1477
1668
|
*/
|
|
1478
1669
|
function explicitReadDeniedFields(table) {
|
|
1479
|
-
const
|
|
1480
|
-
if (fields === undefined)
|
|
1481
|
-
return EMPTY_FIELDS;
|
|
1670
|
+
const columns = closedColumns(table);
|
|
1482
1671
|
let policies;
|
|
1483
1672
|
try {
|
|
1484
1673
|
policies = currentTableFieldPolicies();
|
|
1485
1674
|
}
|
|
1486
1675
|
catch {
|
|
1487
|
-
return
|
|
1676
|
+
return columns;
|
|
1488
1677
|
}
|
|
1489
1678
|
// A table with no entry of its own resolves through "*", which lists none.
|
|
1490
|
-
const listed = policies.get(table)?.
|
|
1491
|
-
if (listed.length === 0)
|
|
1492
|
-
return
|
|
1679
|
+
const listed = policies.get(table)?.ownReadable ?? NO_FIELDS;
|
|
1680
|
+
if (listed.length === 0 || !listed.some((field) => columns.has(field)))
|
|
1681
|
+
return columns;
|
|
1493
1682
|
let byTable = EXPLICIT_READ_DENIED.get(policies);
|
|
1494
1683
|
if (!byTable)
|
|
1495
1684
|
EXPLICIT_READ_DENIED.set(policies, (byTable = new Map()));
|
|
1496
1685
|
const cached = byTable.get(table);
|
|
1497
|
-
if (cached !== undefined)
|
|
1498
|
-
return cached;
|
|
1499
|
-
const denied = Object.freeze(new Set([...
|
|
1500
|
-
byTable.set(table, denied);
|
|
1686
|
+
if (cached !== undefined && cached.columns === columns)
|
|
1687
|
+
return cached.denied;
|
|
1688
|
+
const denied = Object.freeze(new Set([...columns].filter((field) => !listed.includes(field))));
|
|
1689
|
+
byTable.set(table, { columns, denied });
|
|
1501
1690
|
return denied;
|
|
1502
1691
|
}
|
|
1503
1692
|
const READ_HIDDEN_UNIONS = new WeakMap();
|
|
@@ -1658,6 +1847,13 @@ function applyHiddenRules(filtered, context) {
|
|
|
1658
1847
|
function hideInRecord(record, context) {
|
|
1659
1848
|
if (typeof record !== "object" || record === null || Array.isArray(record))
|
|
1660
1849
|
return record;
|
|
1850
|
+
// A row with nothing to hide and no row rule is returned as it is: the
|
|
1851
|
+
// response filter has already copied it, and most rows hold no hidden name.
|
|
1852
|
+
if (context.rule === undefined &&
|
|
1853
|
+
context.companions.size === 0 &&
|
|
1854
|
+
!Object.keys(record).some((key) => context.hidden.has(key.trim().toLowerCase()))) {
|
|
1855
|
+
return record;
|
|
1856
|
+
}
|
|
1661
1857
|
const output = (0, hidden_values_js_1.withoutFields)(record, context.hidden);
|
|
1662
1858
|
const rule = context.rule;
|
|
1663
1859
|
if (rule !== undefined && Object.hasOwn(output, rule.valueField) && (0, hidden_values_js_1.rowValueHidden)(rule, output)) {
|
|
@@ -1908,7 +2104,6 @@ function buildFieldPolicyMap(definitions, root) {
|
|
|
1908
2104
|
}
|
|
1909
2105
|
}
|
|
1910
2106
|
}
|
|
1911
|
-
const payloadColumns = recordPayloadColumns(table);
|
|
1912
2107
|
return [
|
|
1913
2108
|
table,
|
|
1914
2109
|
Object.freeze({
|
|
@@ -1918,25 +2113,23 @@ function buildFieldPolicyMap(definitions, root) {
|
|
|
1918
2113
|
writable: writableFields,
|
|
1919
2114
|
allowAnyReadable: readable === FIELD_POLICY_WILDCARD,
|
|
1920
2115
|
allowAnyWritable: writable === FIELD_POLICY_WILDCARD,
|
|
1921
|
-
|
|
1922
|
-
|
|
2116
|
+
ownReadable: ownListedFields(table, definition.ownReadable, definition.readable, readable),
|
|
2117
|
+
ownWritable: ownListedFields(table, definition.ownWritable, definition.writable, writable),
|
|
1923
2118
|
}),
|
|
1924
2119
|
];
|
|
1925
2120
|
}));
|
|
1926
2121
|
}
|
|
1927
2122
|
/**
|
|
1928
|
-
* The
|
|
1929
|
-
*
|
|
1930
|
-
*
|
|
2123
|
+
* The field names an own-entry list states. The merge passes the own list
|
|
2124
|
+
* through as the resolved list, so its normalized form is reused rather than
|
|
2125
|
+
* normalized twice. A wildcard own list names nothing, and neither does the
|
|
2126
|
+
* "*" entry, which no table's closed columns resolve through.
|
|
1931
2127
|
*/
|
|
1932
|
-
function
|
|
1933
|
-
if (
|
|
2128
|
+
function ownListedFields(table, own, resolvedSource, resolved) {
|
|
2129
|
+
if (own === undefined || table === FIELD_POLICY_WILDCARD)
|
|
1934
2130
|
return NO_FIELDS;
|
|
1935
2131
|
const normalized = own === resolvedSource ? resolved : normalizePolicyFieldSet(own);
|
|
1936
|
-
|
|
1937
|
-
return NO_FIELDS;
|
|
1938
|
-
const listed = normalized.filter((field) => columns.has(field));
|
|
1939
|
-
return listed.length === 0 ? NO_FIELDS : Object.freeze(listed);
|
|
2132
|
+
return normalized === FIELD_POLICY_WILDCARD || normalized.length === 0 ? NO_FIELDS : normalized;
|
|
1940
2133
|
}
|
|
1941
2134
|
/**
|
|
1942
2135
|
* A malformed field-policy configuration, raised when a profile is loaded.
|