@onlyflows/servicenow-mcp 2.3.0-rc.1 → 2.3.0-rc.3
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 +788 -3
- package/README.md +446 -41
- package/dist/atf-policy.d.ts +1 -1
- package/dist/atf-policy.d.ts.map +1 -1
- package/dist/atf-policy.js +2 -0
- package/dist/atf-policy.js.map +1 -1
- package/dist/call-metrics.d.ts +42 -0
- package/dist/call-metrics.d.ts.map +1 -0
- package/dist/call-metrics.js +89 -0
- package/dist/call-metrics.js.map +1 -0
- package/dist/client.d.ts +18 -14
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +51 -36
- package/dist/client.js.map +1 -1
- package/dist/code-search-snippet.d.ts +25 -0
- package/dist/code-search-snippet.d.ts.map +1 -0
- package/dist/code-search-snippet.js +67 -0
- package/dist/code-search-snippet.js.map +1 -0
- package/dist/code-search-targets.d.ts +66 -0
- package/dist/code-search-targets.d.ts.map +1 -0
- package/dist/code-search-targets.js +82 -0
- package/dist/code-search-targets.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/credential-tables.d.ts +32 -0
- package/dist/credential-tables.d.ts.map +1 -0
- package/dist/credential-tables.js +58 -0
- package/dist/credential-tables.js.map +1 -0
- package/dist/encoded-query-policy.d.ts +9 -0
- package/dist/encoded-query-policy.d.ts.map +1 -1
- package/dist/encoded-query-policy.js +27 -2
- package/dist/encoded-query-policy.js.map +1 -1
- package/dist/execution-context.d.ts +14 -0
- package/dist/execution-context.d.ts.map +1 -1
- package/dist/execution-context.js +8 -0
- package/dist/execution-context.js.map +1 -1
- package/dist/field-policy.d.ts +44 -1
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +623 -35
- package/dist/field-policy.js.map +1 -1
- package/dist/hidden-values.d.ts +225 -0
- package/dist/hidden-values.d.ts.map +1 -0
- package/dist/hidden-values.js +748 -0
- package/dist/hidden-values.js.map +1 -0
- package/dist/http-entrypoint.d.ts.map +1 -1
- package/dist/http-entrypoint.js +7 -0
- package/dist/http-entrypoint.js.map +1 -1
- package/dist/http-observability.js +1 -0
- package/dist/http-observability.js.map +1 -1
- package/dist/http-runtime.js +16 -0
- package/dist/http-runtime.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/metadata-cache.d.ts +135 -7
- package/dist/metadata-cache.d.ts.map +1 -1
- package/dist/metadata-cache.js +357 -21
- package/dist/metadata-cache.js.map +1 -1
- package/dist/policy-card.d.ts +16 -1
- package/dist/policy-card.d.ts.map +1 -1
- package/dist/policy-card.js +15 -2
- package/dist/policy-card.js.map +1 -1
- package/dist/profile-admin.d.ts +18 -0
- package/dist/profile-admin.d.ts.map +1 -1
- package/dist/profile-admin.js +26 -1
- package/dist/profile-admin.js.map +1 -1
- package/dist/profile-manager.d.ts +13 -1
- package/dist/profile-manager.d.ts.map +1 -1
- package/dist/profile-manager.js +23 -1
- package/dist/profile-manager.js.map +1 -1
- package/dist/response-too-large.d.ts +23 -0
- package/dist/response-too-large.d.ts.map +1 -0
- package/dist/response-too-large.js +42 -0
- package/dist/response-too-large.js.map +1 -0
- package/dist/risky-grants.d.ts +6 -2
- package/dist/risky-grants.d.ts.map +1 -1
- package/dist/risky-grants.js +58 -5
- package/dist/risky-grants.js.map +1 -1
- package/dist/setup-prompts.js +1 -1
- package/dist/setup-prompts.js.map +1 -1
- package/dist/setup.d.ts +4 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +176 -68
- package/dist/setup.js.map +1 -1
- package/dist/structured-query.d.ts +61 -2
- package/dist/structured-query.d.ts.map +1 -1
- package/dist/structured-query.js +382 -36
- package/dist/structured-query.js.map +1 -1
- package/dist/table-policy.d.ts +75 -2
- package/dist/table-policy.d.ts.map +1 -1
- package/dist/table-policy.js +184 -15
- package/dist/table-policy.js.map +1 -1
- package/dist/tool-error.d.ts +47 -4
- package/dist/tool-error.d.ts.map +1 -1
- package/dist/tool-error.js +104 -4
- package/dist/tool-error.js.map +1 -1
- package/dist/tool-table-access.d.ts +9 -2
- package/dist/tool-table-access.d.ts.map +1 -1
- package/dist/tool-table-access.js +118 -36
- package/dist/tool-table-access.js.map +1 -1
- package/dist/tools/aggregate.js +2 -2
- package/dist/tools/aggregate.js.map +1 -1
- package/dist/tools/all-fields-cap.d.ts.map +1 -1
- package/dist/tools/all-fields-cap.js +29 -7
- package/dist/tools/all-fields-cap.js.map +1 -1
- package/dist/tools/atf-author-module.d.ts +1 -7
- package/dist/tools/atf-author-module.d.ts.map +1 -1
- package/dist/tools/atf-author-module.js +16 -7
- package/dist/tools/atf-author-module.js.map +1 -1
- package/dist/tools/atf-contracts.d.ts +69 -4
- package/dist/tools/atf-contracts.d.ts.map +1 -1
- package/dist/tools/atf-contracts.js +32 -2
- package/dist/tools/atf-contracts.js.map +1 -1
- package/dist/tools/atf-renderers.js +2 -1
- package/dist/tools/atf-renderers.js.map +1 -1
- package/dist/tools/atf-results-module.d.ts.map +1 -1
- package/dist/tools/atf-results-module.js +5 -3
- package/dist/tools/atf-results-module.js.map +1 -1
- package/dist/tools/atf-run-module.js +3 -2
- package/dist/tools/atf-run-module.js.map +1 -1
- package/dist/tools/atf-shared.d.ts +6 -0
- package/dist/tools/atf-shared.d.ts.map +1 -1
- package/dist/tools/atf-shared.js +49 -10
- package/dist/tools/atf-shared.js.map +1 -1
- package/dist/tools/atf-step-catalog.d.ts +13 -8
- package/dist/tools/atf-step-catalog.d.ts.map +1 -1
- package/dist/tools/atf-step-catalog.js +169 -5
- package/dist/tools/atf-step-catalog.js.map +1 -1
- package/dist/tools/batch.d.ts.map +1 -1
- package/dist/tools/batch.js +25 -7
- package/dist/tools/batch.js.map +1 -1
- package/dist/tools/catalog.d.ts.map +1 -1
- package/dist/tools/catalog.js +2 -1
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/codesearch.d.ts +2 -2
- package/dist/tools/codesearch.d.ts.map +1 -1
- package/dist/tools/codesearch.js +536 -67
- package/dist/tools/codesearch.js.map +1 -1
- package/dist/tools/flow-view-contracts.d.ts +59 -3
- package/dist/tools/flow-view-contracts.d.ts.map +1 -1
- package/dist/tools/flow-view-contracts.js +34 -2
- package/dist/tools/flow-view-contracts.js.map +1 -1
- package/dist/tools/flow-view-graph.d.ts +14 -0
- package/dist/tools/flow-view-graph.d.ts.map +1 -1
- package/dist/tools/flow-view-graph.js +43 -1
- package/dist/tools/flow-view-graph.js.map +1 -1
- package/dist/tools/flow-view-module.js +2 -2
- package/dist/tools/flow-view-module.js.map +1 -1
- package/dist/tools/flow-view-policy.d.ts +3 -3
- package/dist/tools/flow-view-policy.d.ts.map +1 -1
- package/dist/tools/flow-view-policy.js +5 -4
- package/dist/tools/flow-view-policy.js.map +1 -1
- package/dist/tools/flow-view-renderers.d.ts.map +1 -1
- package/dist/tools/flow-view-renderers.js +9 -21
- package/dist/tools/flow-view-renderers.js.map +1 -1
- package/dist/tools/get-module.js +1 -1
- package/dist/tools/get-module.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +116 -25
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/platform-view-contracts.d.ts +189 -0
- package/dist/tools/platform-view-contracts.d.ts.map +1 -0
- package/dist/tools/platform-view-contracts.js +353 -0
- package/dist/tools/platform-view-contracts.js.map +1 -0
- package/dist/tools/platform-view-evaluate.d.ts +219 -0
- package/dist/tools/platform-view-evaluate.d.ts.map +1 -0
- package/dist/tools/platform-view-evaluate.js +1346 -0
- package/dist/tools/platform-view-evaluate.js.map +1 -0
- package/dist/tools/platform-view-module.d.ts +28 -0
- package/dist/tools/platform-view-module.d.ts.map +1 -0
- package/dist/tools/platform-view-module.js +111 -0
- package/dist/tools/platform-view-module.js.map +1 -0
- package/dist/tools/platform-view-scan.d.ts +57 -0
- package/dist/tools/platform-view-scan.d.ts.map +1 -0
- package/dist/tools/platform-view-scan.js +375 -0
- package/dist/tools/platform-view-scan.js.map +1 -0
- package/dist/tools/platform-view-upgrades.d.ts +152 -0
- package/dist/tools/platform-view-upgrades.d.ts.map +1 -0
- package/dist/tools/platform-view-upgrades.js +545 -0
- package/dist/tools/platform-view-upgrades.js.map +1 -0
- package/dist/tools/profile.d.ts.map +1 -1
- package/dist/tools/profile.js +1 -0
- package/dist/tools/profile.js.map +1 -1
- package/dist/tools/query-module.d.ts.map +1 -1
- package/dist/tools/query-module.js +231 -64
- package/dist/tools/query-module.js.map +1 -1
- package/dist/tools/record-write-shared.d.ts.map +1 -1
- package/dist/tools/record-write-shared.js +4 -3
- package/dist/tools/record-write-shared.js.map +1 -1
- package/dist/tools/result-envelope.d.ts +429 -38
- package/dist/tools/result-envelope.d.ts.map +1 -1
- package/dist/tools/result-envelope.js +372 -36
- package/dist/tools/result-envelope.js.map +1 -1
- package/dist/tools/schema-module.d.ts.map +1 -1
- package/dist/tools/schema-module.js +1 -1
- package/dist/tools/schema-module.js.map +1 -1
- package/dist/tools/syslog-cursor.d.ts +61 -0
- package/dist/tools/syslog-cursor.d.ts.map +1 -0
- package/dist/tools/syslog-cursor.js +146 -0
- package/dist/tools/syslog-cursor.js.map +1 -0
- package/dist/tools/syslog.d.ts +2 -0
- package/dist/tools/syslog.d.ts.map +1 -1
- package/dist/tools/syslog.js +126 -2
- package/dist/tools/syslog.js.map +1 -1
- package/dist/tools/truncation-hint.d.ts +125 -0
- package/dist/tools/truncation-hint.d.ts.map +1 -0
- package/dist/tools/truncation-hint.js +298 -0
- package/dist/tools/truncation-hint.js.map +1 -0
- package/dist/unknown-filter-fields.d.ts +52 -0
- package/dist/unknown-filter-fields.d.ts.map +1 -0
- package/dist/unknown-filter-fields.js +87 -0
- package/dist/unknown-filter-fields.js.map +1 -0
- package/dist/update-set-eval/engine.d.ts +29 -0
- package/dist/update-set-eval/engine.d.ts.map +1 -0
- package/dist/update-set-eval/engine.js +405 -0
- package/dist/update-set-eval/engine.js.map +1 -0
- package/dist/update-set-eval/prepare.d.ts +72 -0
- package/dist/update-set-eval/prepare.d.ts.map +1 -0
- package/dist/update-set-eval/prepare.js +216 -0
- package/dist/update-set-eval/prepare.js.map +1 -0
- package/dist/update-set-eval/rules.d.ts +126 -0
- package/dist/update-set-eval/rules.d.ts.map +1 -0
- package/dist/update-set-eval/rules.js +927 -0
- package/dist/update-set-eval/rules.js.map +1 -0
- package/dist/update-set-eval/script-scan.d.ts +65 -0
- package/dist/update-set-eval/script-scan.d.ts.map +1 -0
- package/dist/update-set-eval/script-scan.js +378 -0
- package/dist/update-set-eval/script-scan.js.map +1 -0
- package/dist/update-set-eval/secret-patterns.d.ts +75 -0
- package/dist/update-set-eval/secret-patterns.d.ts.map +1 -0
- package/dist/update-set-eval/secret-patterns.js +570 -0
- package/dist/update-set-eval/secret-patterns.js.map +1 -0
- package/dist/update-set-eval/types.d.ts +181 -0
- package/dist/update-set-eval/types.d.ts.map +1 -0
- package/dist/update-set-eval/types.js +20 -0
- package/dist/update-set-eval/types.js.map +1 -0
- package/dist/update-set-eval/xml-reader.d.ts +117 -0
- package/dist/update-set-eval/xml-reader.d.ts.map +1 -0
- package/dist/update-set-eval/xml-reader.js +561 -0
- package/dist/update-set-eval/xml-reader.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/CLIENT-SETUP.md +30 -7
- package/docs/FLOW-VIEW.md +14 -5
- package/docs/PRODUCTION-SECURITY.md +84 -1
- package/docs/PROFILE-CREDENTIALS.md +10 -4
- package/docs/V2-MIGRATION.md +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/field-policy.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
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.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.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
17
|
exports.fieldPolicyDenialMessage = fieldPolicyDenialMessage;
|
|
18
18
|
exports.isFieldPolicyError = isFieldPolicyError;
|
|
19
19
|
exports.snapshotPlainDataArguments = snapshotPlainDataArguments;
|
|
@@ -29,14 +29,21 @@ exports.filterReadableRecord = filterReadableRecord;
|
|
|
29
29
|
exports.filterSchemaEntries = filterSchemaEntries;
|
|
30
30
|
exports.filterAggregateResult = filterAggregateResult;
|
|
31
31
|
exports.runWithFieldPolicyConfiguration = runWithFieldPolicyConfiguration;
|
|
32
|
+
exports.currentFieldPolicyConfiguration = currentFieldPolicyConfiguration;
|
|
32
33
|
exports.isAllFieldSelection = isAllFieldSelection;
|
|
33
34
|
exports.fieldSelectionToSysparmFields = fieldSelectionToSysparmFields;
|
|
34
35
|
exports.isSensitiveFieldName = isSensitiveFieldName;
|
|
36
|
+
exports.typeHiddenFieldNames = typeHiddenFieldNames;
|
|
37
|
+
exports.queryDeniedFields = queryDeniedFields;
|
|
38
|
+
exports.queryDeniedForSelection = queryDeniedForSelection;
|
|
39
|
+
exports.readableSelectionForTable = readableSelectionForTable;
|
|
35
40
|
exports.describeFieldPolicy = describeFieldPolicy;
|
|
36
41
|
exports.validateFieldPolicyConfiguration = validateFieldPolicyConfiguration;
|
|
37
42
|
exports.fieldPolicyInputFromEnvironment = fieldPolicyInputFromEnvironment;
|
|
38
43
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
39
44
|
const node_util_1 = require("node:util");
|
|
45
|
+
const hidden_values_js_1 = require("./hidden-values.js");
|
|
46
|
+
const table_policy_js_1 = require("./table-policy.js");
|
|
40
47
|
const FIELD_NAME = /^[a-z][a-z0-9_]{0,79}$/u;
|
|
41
48
|
/** @deprecated Field authorization no longer caps the number of selected fields. */
|
|
42
49
|
exports.MAX_FIELDS_PER_OPERATION = 10_000;
|
|
@@ -91,6 +98,115 @@ const EXPLICIT_WRITE_FIELDS = new Set([
|
|
|
91
98
|
"sys_domain",
|
|
92
99
|
"sys_domain_path",
|
|
93
100
|
]);
|
|
101
|
+
/**
|
|
102
|
+
* Record payload columns: per table, the columns that carry other records'
|
|
103
|
+
* content (whole records as XML, diffs, serialized queue and replication
|
|
104
|
+
* messages, change payloads, flow snapshots) or other packaged content.
|
|
105
|
+
*
|
|
106
|
+
* A wildcard never covers these columns, for reads or writes: not the
|
|
107
|
+
* built-in default, a `"*"` table entry, a profile's `"*"` field entry, or
|
|
108
|
+
* `"*"` on the table's own entry. A column is read only where the profile's
|
|
109
|
+
* own entry for that exact table lists it in `readable`, and written only
|
|
110
|
+
* where that entry lists it in `writable`. Until listed, a column is refused
|
|
111
|
+
* by name (to return, filter, order, group, aggregate or write) and dropped
|
|
112
|
+
* from every wildcard, default, detailed, all-fields and write-response
|
|
113
|
+
* projection. Columns a given release lacks are listed anyway, harmlessly.
|
|
114
|
+
*/
|
|
115
|
+
const RECORD_PAYLOAD_COLUMNS = new Map([
|
|
116
|
+
// Customer updates and their versions, previews and diffs, team
|
|
117
|
+
// development previews, application metadata, the upgrade log, and
|
|
118
|
+
// deleted, archived or clone-preserved records.
|
|
119
|
+
["sys_update_xml", ["payload", "payload_diff"]],
|
|
120
|
+
["sys_update_version", ["payload", "payload_diff"]],
|
|
121
|
+
["sys_update_preview_xml", ["payload", "payload_diff"]],
|
|
122
|
+
["sys_update_diff", ["payload", "payload_diff"]],
|
|
123
|
+
["sys_sync_preview_remote", ["payload", "payload_diff"]],
|
|
124
|
+
["sys_upgrade_history_log", ["payload", "payload_diff"]],
|
|
125
|
+
["sys_metadata_link", ["payload", "payload_diff"]],
|
|
126
|
+
["sys_metadata_delete", ["payload", "payload_diff"]],
|
|
127
|
+
["sys_audit_delete", ["payload", "payload_diff"]],
|
|
128
|
+
["sys_archive_log", ["payload", "payload_diff"]],
|
|
129
|
+
["clone_preserved_data", ["payload", "payload_diff"]],
|
|
130
|
+
// MID Server, replication and change-data-capture queues.
|
|
131
|
+
["ecc_queue", ["payload"]],
|
|
132
|
+
["sys_replication_queue", ["payload", "payload_short"]],
|
|
133
|
+
["data_replication_queue", ["payload"]],
|
|
134
|
+
["cdc_queue_ih", ["payload", "previous_payload"]],
|
|
135
|
+
["cdc_queue_par", ["payload", "previous_payload"]],
|
|
136
|
+
["cdc_queue_uxa_user_props", ["payload", "previous_payload"]],
|
|
137
|
+
["sys_rt_change_log", ["payload"]],
|
|
138
|
+
// Flow snapshots and versions.
|
|
139
|
+
["sys_hub_snapshot", ["payload"]],
|
|
140
|
+
["sys_hub_snapshot_chunk", ["data"]],
|
|
141
|
+
["sys_hub_flow_version", ["payload"]],
|
|
142
|
+
// Certificate management.
|
|
143
|
+
["sn_disco_certmgmt_certificate_ca_credentials", ["encoded_keystore"]],
|
|
144
|
+
].map(([table, columns]) => [
|
|
145
|
+
table,
|
|
146
|
+
Object.freeze(new Set(columns)),
|
|
147
|
+
]));
|
|
148
|
+
/**
|
|
149
|
+
* Tables the platform rotates into numbered shards (`ecc_queue0003`,
|
|
150
|
+
* `sys_replication_queue5`), each a separate table that a `"*"` grant reaches
|
|
151
|
+
* by name. A shard is the base name followed by digits only.
|
|
152
|
+
*/
|
|
153
|
+
const ROTATION_SHARD_BASES = new Set([
|
|
154
|
+
"ecc_queue",
|
|
155
|
+
"sys_replication_queue",
|
|
156
|
+
"data_replication_queue",
|
|
157
|
+
"cdc_queue_ih",
|
|
158
|
+
"cdc_queue_par",
|
|
159
|
+
"cdc_queue_uxa_user_props",
|
|
160
|
+
]);
|
|
161
|
+
/**
|
|
162
|
+
* Change-data-capture queues are created per consumer (`cdc_queue_<consumer>`,
|
|
163
|
+
* with or without a shard suffix). Every table under this prefix carries the
|
|
164
|
+
* CDC payload columns, except the consumer-state tables (`cdc_queue_state_*`).
|
|
165
|
+
*/
|
|
166
|
+
const CDC_QUEUE_PREFIX = "cdc_queue_";
|
|
167
|
+
const CDC_QUEUE_STATE_PREFIX = "cdc_queue_state_";
|
|
168
|
+
const CDC_QUEUE_COLUMNS = RECORD_PAYLOAD_COLUMNS.get("cdc_queue_ih");
|
|
169
|
+
const NO_FIELDS = Object.freeze([]);
|
|
170
|
+
/**
|
|
171
|
+
* `table` without its trailing digits, or undefined when it has none or is
|
|
172
|
+
* all digits. A single backward scan, so it is linear in the name's length.
|
|
173
|
+
*/
|
|
174
|
+
function withoutShardSuffix(table) {
|
|
175
|
+
let end = table.length;
|
|
176
|
+
while (end > 0) {
|
|
177
|
+
const code = table.charCodeAt(end - 1);
|
|
178
|
+
if (code < 48 || code > 57)
|
|
179
|
+
break;
|
|
180
|
+
end -= 1;
|
|
181
|
+
}
|
|
182
|
+
return end === table.length || end === 0 ? undefined : table.slice(0, end);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The record payload columns of `table` (a normalized name), or undefined.
|
|
186
|
+
* A rotation shard takes its base table's columns, and a CDC queue takes the
|
|
187
|
+
* CDC columns. Lookups and fixed rules only: nothing is stored per name, so
|
|
188
|
+
* arbitrary names never grow any state.
|
|
189
|
+
*/
|
|
190
|
+
function recordPayloadColumns(table) {
|
|
191
|
+
const exact = RECORD_PAYLOAD_COLUMNS.get(table);
|
|
192
|
+
if (exact !== undefined)
|
|
193
|
+
return exact;
|
|
194
|
+
if (table.length > CDC_QUEUE_PREFIX.length &&
|
|
195
|
+
table.startsWith(CDC_QUEUE_PREFIX) &&
|
|
196
|
+
!table.startsWith(CDC_QUEUE_STATE_PREFIX)) {
|
|
197
|
+
return CDC_QUEUE_COLUMNS;
|
|
198
|
+
}
|
|
199
|
+
const base = withoutShardSuffix(table);
|
|
200
|
+
return base !== undefined && ROTATION_SHARD_BASES.has(base) ? RECORD_PAYLOAD_COLUMNS.get(base) : undefined;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Each base table and the columns its own entry must list. A rotation shard
|
|
204
|
+
* (see ROTATION_SHARD_BASE_NAMES) has its base table's columns, and every
|
|
205
|
+
* `cdc_queue_*` table except `cdc_queue_state_*` has the CDC queue columns.
|
|
206
|
+
*/
|
|
207
|
+
exports.EXPLICIT_READ_FIELD_NAMES = Object.freeze(Object.fromEntries([...RECORD_PAYLOAD_COLUMNS].map(([table, columns]) => [table, Object.freeze([...columns])])));
|
|
208
|
+
/** The base tables whose numbered rotation shards share their columns. */
|
|
209
|
+
exports.ROTATION_SHARD_BASE_NAMES = Object.freeze([...ROTATION_SHARD_BASES]);
|
|
94
210
|
const INCIDENT_DEFAULTS = [
|
|
95
211
|
"sys_id",
|
|
96
212
|
"number",
|
|
@@ -513,31 +629,42 @@ const POLICY_DEFINITIONS = {
|
|
|
513
629
|
],
|
|
514
630
|
writable: [],
|
|
515
631
|
},
|
|
632
|
+
// The code tables list by identity and metadata, never by script body. A body
|
|
633
|
+
// runs to kilobytes, so a default read that carried it filled the response
|
|
634
|
+
// budget after a handful of rows. `script` stays readable: name it in
|
|
635
|
+
// `fields` (or ask for `fields: "all"`) to read it.
|
|
516
636
|
sys_script: {
|
|
517
|
-
defaults: ["sys_id", "name", "
|
|
637
|
+
defaults: ["sys_id", "name", "collection", "when", "active", "sys_updated_on"],
|
|
518
638
|
readable: ["sys_id", "name", "script", "active", "collection", "filter", "when", "order", "sys_updated_on"],
|
|
519
639
|
writable: [],
|
|
520
640
|
},
|
|
521
641
|
sys_script_include: {
|
|
522
|
-
defaults: ["sys_id", "name", "
|
|
642
|
+
defaults: ["sys_id", "name", "api_name", "active", "sys_updated_on"],
|
|
523
643
|
readable: ["sys_id", "name", "script", "active", "api_name", "client_callable", "access", "sys_updated_on"],
|
|
524
644
|
writable: [],
|
|
525
645
|
},
|
|
526
646
|
sys_ui_script: {
|
|
527
|
-
defaults: ["sys_id", "name", "
|
|
647
|
+
defaults: ["sys_id", "name", "global", "active", "sys_updated_on"],
|
|
528
648
|
readable: ["sys_id", "name", "script", "active", "global", "sys_updated_on"],
|
|
529
649
|
writable: [],
|
|
530
650
|
},
|
|
531
651
|
sys_script_client: {
|
|
532
|
-
defaults: ["sys_id", "name", "
|
|
652
|
+
defaults: ["sys_id", "name", "table", "type", "active", "sys_updated_on"],
|
|
533
653
|
readable: ["sys_id", "name", "script", "active", "table", "type", "condition", "sys_updated_on"],
|
|
534
654
|
writable: [],
|
|
535
655
|
},
|
|
536
656
|
sys_ws_operation: {
|
|
537
|
-
defaults: ["sys_id", "name", "
|
|
657
|
+
defaults: ["sys_id", "name", "http_method", "relative_path", "active", "sys_updated_on"],
|
|
538
658
|
readable: ["sys_id", "name", "operation_script", "active", "http_method", "relative_path", "sys_updated_on"],
|
|
539
659
|
writable: [],
|
|
540
660
|
},
|
|
661
|
+
// ES modules: the script is `content`, and a module is named by its `path`
|
|
662
|
+
// (the table has no `name` column of its own).
|
|
663
|
+
sys_module: {
|
|
664
|
+
defaults: ["sys_id", "path", "sys_updated_on"],
|
|
665
|
+
readable: ["sys_id", "path", "content", "sys_updated_on"],
|
|
666
|
+
writable: [],
|
|
667
|
+
},
|
|
541
668
|
sys_db_object: {
|
|
542
669
|
defaults: ["sys_id", "name", "label", "super_class", "sys_scope", "is_extendable"],
|
|
543
670
|
readable: ["sys_id", "name", "label", "super_class", "sys_scope", "is_extendable"],
|
|
@@ -625,6 +752,114 @@ const POLICY_DEFINITIONS = {
|
|
|
625
752
|
readable: ["sys_id", "name", "status", "browser_name", "browser_version", "os_name", "os_version", "sys_updated_on"],
|
|
626
753
|
writable: [],
|
|
627
754
|
},
|
|
755
|
+
// The named-only tables (NAMED_ONLY_TABLES in table-policy.ts). A "*" table
|
|
756
|
+
// grant never covers them: a profile reaches them only by naming them in
|
|
757
|
+
// tableAccess. For field policy they belong to the profile, like the ITSM
|
|
758
|
+
// tables, so a profile's "*" field entry narrows them. Each default
|
|
759
|
+
// projection names the record and field a row is about and leaves the value
|
|
760
|
+
// columns to be asked for by name.
|
|
761
|
+
//
|
|
762
|
+
// The audit and journal tables hold the old and new values of other tables'
|
|
763
|
+
// fields, and their comments and work notes (oldvalue, newvalue, value).
|
|
764
|
+
sys_audit: {
|
|
765
|
+
defaults: ["sys_id", "tablename", "documentkey", "fieldname", "user", "sys_created_on"],
|
|
766
|
+
readable: ["sys_id", "tablename", "documentkey", "fieldname", "oldvalue", "newvalue", "user", "reason", "sys_created_on"],
|
|
767
|
+
writable: [],
|
|
768
|
+
},
|
|
769
|
+
sys_journal_field: {
|
|
770
|
+
defaults: ["sys_id", "name", "element_id", "element", "sys_created_by", "sys_created_on"],
|
|
771
|
+
readable: ["sys_id", "name", "element_id", "element", "value", "sys_created_by", "sys_created_on"],
|
|
772
|
+
writable: [],
|
|
773
|
+
},
|
|
774
|
+
// The history built from audit for a record's history view. Value columns:
|
|
775
|
+
// old, new, old_value, new_value. user_id and email name the actor and stay
|
|
776
|
+
// out of the default projection.
|
|
777
|
+
sys_history_line: {
|
|
778
|
+
defaults: ["sys_id", "set", "field", "label", "update", "update_time", "type"],
|
|
779
|
+
readable: ["sys_id", "set", "field", "label", "update", "update_time", "type", "user_name", "old", "new", "old_value", "new_value", "sys_created_on"],
|
|
780
|
+
writable: [],
|
|
781
|
+
},
|
|
782
|
+
// A deleted record, kept whole. Value column: payload (the record's XML).
|
|
783
|
+
sys_audit_delete: {
|
|
784
|
+
defaults: ["sys_id", "tablename", "documentkey", "display_value", "sys_created_on", "sys_created_by"],
|
|
785
|
+
readable: ["sys_id", "tablename", "documentkey", "display_value", "payload", "sys_created_on", "sys_created_by"],
|
|
786
|
+
writable: [],
|
|
787
|
+
},
|
|
788
|
+
// Attachment content, in chunks. Value column: data. sn_attach does not read
|
|
789
|
+
// this table: it uses the Attachment API, under the grants of sys_attachment
|
|
790
|
+
// and the parent table.
|
|
791
|
+
sys_attachment_doc: {
|
|
792
|
+
defaults: ["sys_id", "sys_attachment", "position", "length", "sys_created_on"],
|
|
793
|
+
readable: ["sys_id", "sys_attachment", "position", "length", "data", "sys_created_on"],
|
|
794
|
+
writable: [],
|
|
795
|
+
},
|
|
796
|
+
// Notification copies. Content columns: body, body_text, subject,
|
|
797
|
+
// recipients, copied, blind_copied, reply_to, headers, error_string.
|
|
798
|
+
sys_email: {
|
|
799
|
+
defaults: ["sys_id", "type", "state", "target_table", "instance", "sys_created_on"],
|
|
800
|
+
readable: [
|
|
801
|
+
"sys_id", "type", "state", "notification_type", "target_table", "instance", "mailbox",
|
|
802
|
+
"subject", "body", "body_text", "recipients", "copied", "blind_copied", "reply_to",
|
|
803
|
+
"headers", "error_string", "sys_created_on",
|
|
804
|
+
],
|
|
805
|
+
writable: [],
|
|
806
|
+
},
|
|
807
|
+
// The platform tables (PLATFORM_BUILT_INS): customer updates, the upgrade
|
|
808
|
+
// log and Instance Scan. A "*" table grant covers them like any table, and
|
|
809
|
+
// for field policy they belong to the profile, so a profile's "*" field
|
|
810
|
+
// entry narrows them. Each default projection names the row and leaves out
|
|
811
|
+
// the columns that carry script, XML or matched code; those are read only
|
|
812
|
+
// when asked for by name.
|
|
813
|
+
//
|
|
814
|
+
// A customer update. Never in the default projection: payload (the record's
|
|
815
|
+
// XML, scripts included).
|
|
816
|
+
sys_update_xml: {
|
|
817
|
+
defaults: ["sys_id", "name", "type", "target_name", "table", "action", "update_set", "application", "sys_updated_on"],
|
|
818
|
+
readable: [
|
|
819
|
+
"sys_id", "name", "type", "target_name", "table", "action", "update_set", "application",
|
|
820
|
+
"replace_on_upgrade", "remote_update_set", "update_guid", "payload", "payload_hash",
|
|
821
|
+
"sys_updated_by", "sys_updated_on", "sys_created_on",
|
|
822
|
+
],
|
|
823
|
+
writable: [],
|
|
824
|
+
},
|
|
825
|
+
// One file of an upgrade or app-install run. Never in the default
|
|
826
|
+
// projection: payload and payload_diff (the file's XML and its diff).
|
|
827
|
+
sys_upgrade_history_log: {
|
|
828
|
+
defaults: ["sys_id", "upgrade_history", "file_name", "type", "target_name", "disposition", "resolution_status", "change_type", "plugin"],
|
|
829
|
+
readable: [
|
|
830
|
+
"sys_id", "upgrade_history", "file_name", "type", "target_name", "disposition",
|
|
831
|
+
"resolution_status", "change_type", "plugin", "payload", "payload_diff", "sys_created_on",
|
|
832
|
+
],
|
|
833
|
+
writable: [],
|
|
834
|
+
},
|
|
835
|
+
// An Instance Scan finding. Never in the default projection:
|
|
836
|
+
// finding_details (it can hold the matched code), task and user.
|
|
837
|
+
scan_finding: {
|
|
838
|
+
defaults: ["sys_id", "result", "check", "source_table", "source", "count", "muted", "sys_created_on"],
|
|
839
|
+
readable: [
|
|
840
|
+
"sys_id", "result", "check", "source_table", "source", "count", "muted", "finding_details",
|
|
841
|
+
"task", "user", "check_version", "product_family", "scan_mute_rule", "sys_created_on",
|
|
842
|
+
],
|
|
843
|
+
writable: [],
|
|
844
|
+
},
|
|
845
|
+
// An Instance Scan run. Never in the default projection: message.
|
|
846
|
+
scan_result: {
|
|
847
|
+
defaults: ["sys_id", "number", "state", "finding_count", "scan_type", "sys_created_on"],
|
|
848
|
+
readable: [
|
|
849
|
+
"sys_id", "number", "state", "finding_count", "scan_type", "execution_time", "message",
|
|
850
|
+
"sys_created_on",
|
|
851
|
+
],
|
|
852
|
+
writable: [],
|
|
853
|
+
},
|
|
854
|
+
// An Instance Scan check. Never in the default projection: script.
|
|
855
|
+
scan_check: {
|
|
856
|
+
defaults: ["sys_id", "name", "category", "priority", "short_description", "active"],
|
|
857
|
+
readable: [
|
|
858
|
+
"sys_id", "name", "category", "priority", "short_description", "description", "active",
|
|
859
|
+
"finding_type", "script", "sys_updated_on",
|
|
860
|
+
],
|
|
861
|
+
writable: [],
|
|
862
|
+
},
|
|
628
863
|
};
|
|
629
864
|
/**
|
|
630
865
|
* The policy base.
|
|
@@ -641,9 +876,10 @@ const POLICY_DEFINITIONS = {
|
|
|
641
876
|
* a granted custom table needs no field-policy entry to be usable.
|
|
642
877
|
*
|
|
643
878
|
* A profile's own "*" entry reaches further: it also covers the ITSM tables
|
|
644
|
-
* (ITSM_TABLES)
|
|
645
|
-
*
|
|
646
|
-
*
|
|
879
|
+
* (ITSM_TABLES), the named-only tables (NAMED_ONLY_BUILT_INS), the platform
|
|
880
|
+
* tables (PLATFORM_BUILT_INS) and every table the profile names, key by key,
|
|
881
|
+
* wherever the table's own entry is silent.
|
|
882
|
+
* Only the system tables (SYSTEM_TABLES) are never covered by a "*" entry.
|
|
647
883
|
*/
|
|
648
884
|
const FIELD_POLICY_BASE = Object.freeze({
|
|
649
885
|
...Object.fromEntries(Object.entries(POLICY_DEFINITIONS).map(([table, definition]) => [
|
|
@@ -689,8 +925,9 @@ const ITSM_TABLES = new Set([
|
|
|
689
925
|
*
|
|
690
926
|
* This list is written out rather than derived as "built-in minus ITSM", so
|
|
691
927
|
* a new built-in entry never escapes every profile's "*" entry by default.
|
|
692
|
-
* Each built-in entry must be in exactly one of ITSM_TABLES
|
|
693
|
-
*
|
|
928
|
+
* Each built-in entry must be in exactly one of ITSM_TABLES, SYSTEM_TABLES,
|
|
929
|
+
* NAMED_ONLY_BUILT_INS and PLATFORM_BUILT_INS; a test enforces this through
|
|
930
|
+
* BUILT_IN_TABLE_CLASSES.
|
|
694
931
|
*/
|
|
695
932
|
const SYSTEM_TABLES = new Set([
|
|
696
933
|
"sys_user",
|
|
@@ -702,6 +939,7 @@ const SYSTEM_TABLES = new Set([
|
|
|
702
939
|
"sys_ui_script",
|
|
703
940
|
"sys_script_client",
|
|
704
941
|
"sys_ws_operation",
|
|
942
|
+
"sys_module",
|
|
705
943
|
"sys_db_object",
|
|
706
944
|
"sys_app",
|
|
707
945
|
"sys_store_app",
|
|
@@ -717,6 +955,33 @@ const SYSTEM_TABLES = new Set([
|
|
|
717
955
|
"sys_atf_test_result_step",
|
|
718
956
|
"sys_atf_agent",
|
|
719
957
|
]);
|
|
958
|
+
/**
|
|
959
|
+
* Built-in tables that a "*" table grant never covers (NAMED_ONLY_TABLES, in
|
|
960
|
+
* table-policy.ts, the one list). For field policy they are profile-owned like
|
|
961
|
+
* the ITSM tables: `readable` and `writable` resolve from the profile's own
|
|
962
|
+
* entry for the table, then its "*" entry, then the built-in "*" (open), so a
|
|
963
|
+
* profile that narrows reads with "*" narrows these too. Their built-in
|
|
964
|
+
* `defaults` leave out the value columns and are clamped to the effective
|
|
965
|
+
* readable set. A table's own entry still narrows or widens it.
|
|
966
|
+
*/
|
|
967
|
+
const NAMED_ONLY_BUILT_INS = new Set(table_policy_js_1.NAMED_ONLY_TABLES);
|
|
968
|
+
/**
|
|
969
|
+
* The platform tables: customer updates, the upgrade log and Instance Scan.
|
|
970
|
+
* A "*" table grant covers them, as it covers any table. For field policy
|
|
971
|
+
* they are profile-owned like the ITSM and named-only tables: `readable` and
|
|
972
|
+
* `writable` resolve from the profile's own entry for the table, then its "*"
|
|
973
|
+
* entry, then the built-in "*" (open), so a profile that narrows reads with
|
|
974
|
+
* "*" narrows these too, whether or not it names them. Their built-in
|
|
975
|
+
* `defaults` leave out the script, XML and matched-code columns and are
|
|
976
|
+
* clamped to the effective readable set.
|
|
977
|
+
*/
|
|
978
|
+
const PLATFORM_BUILT_INS = new Set([
|
|
979
|
+
"sys_update_xml",
|
|
980
|
+
"sys_upgrade_history_log",
|
|
981
|
+
"scan_finding",
|
|
982
|
+
"scan_result",
|
|
983
|
+
"scan_check",
|
|
984
|
+
]);
|
|
720
985
|
/**
|
|
721
986
|
* The built-in tables and how each is classified for a profile's "*" entry.
|
|
722
987
|
* Frozen copies for tests; the policy reads the sets above.
|
|
@@ -725,7 +990,16 @@ exports.BUILT_IN_TABLE_CLASSES = Object.freeze({
|
|
|
725
990
|
builtIn: Object.freeze(Object.keys(POLICY_DEFINITIONS)),
|
|
726
991
|
itsm: Object.freeze([...ITSM_TABLES]),
|
|
727
992
|
system: Object.freeze([...SYSTEM_TABLES]),
|
|
993
|
+
namedOnly: Object.freeze([...NAMED_ONLY_BUILT_INS]),
|
|
994
|
+
platform: Object.freeze([...PLATFORM_BUILT_INS]),
|
|
728
995
|
});
|
|
996
|
+
/**
|
|
997
|
+
* Every built-in table a profile's "*" entry covers: each one that is not a
|
|
998
|
+
* system table, whatever its class. Derived rather than listed by class, so a
|
|
999
|
+
* built-in entry or class added later is covered by a narrowing "*" entry
|
|
1000
|
+
* without touching the merge.
|
|
1001
|
+
*/
|
|
1002
|
+
const PROFILE_OWNED_BUILT_INS = Object.freeze(Object.keys(POLICY_DEFINITIONS).filter((table) => !SYSTEM_TABLES.has(table)));
|
|
729
1003
|
const GENERIC_RECORD_TABLES = new Set([
|
|
730
1004
|
"incident",
|
|
731
1005
|
"change_request",
|
|
@@ -806,15 +1080,31 @@ function fieldPolicyDenialMessage(error) {
|
|
|
806
1080
|
`fieldPolicy.${table}, or a fieldPolicy."*" fallback, to allow it.`
|
|
807
1081
|
: "Access denied by policy: the requested table has no field policy entry.";
|
|
808
1082
|
case "sensitive_field":
|
|
1083
|
+
// The same text for a name and a type denial: saying which would tell
|
|
1084
|
+
// the caller a field's type, which is what the type rule keeps back.
|
|
809
1085
|
return "Access denied by policy: a requested field is denied by name as sensitive and cannot be granted by configuration.";
|
|
1086
|
+
case "field_types_unavailable":
|
|
1087
|
+
return hidden_values_js_1.FIELD_TYPES_UNAVAILABLE_MESSAGE;
|
|
810
1088
|
case "explicit_field_required":
|
|
811
|
-
// Only
|
|
812
|
-
// name that passed FIELD_NAME.
|
|
1089
|
+
// Only EXPLICIT_WRITE_FIELDS and record payload column names reach this
|
|
1090
|
+
// case; each is a fixed name that passed FIELD_NAME.
|
|
1091
|
+
if (table && field && !EXPLICIT_WRITE_FIELDS.has(field)) {
|
|
1092
|
+
return (`Write denied by policy: field "${field}" on "${table}" holds record payloads, ` +
|
|
1093
|
+
"so a writable wildcard never covers it. List it explicitly in " +
|
|
1094
|
+
`fieldPolicy.${table}.writable to allow this write.`);
|
|
1095
|
+
}
|
|
813
1096
|
return table && field
|
|
814
1097
|
? `Write denied by policy: field "${field}" on "${table}" changes the record's ` +
|
|
815
1098
|
"class or domain, so a writable wildcard never covers it. List it explicitly " +
|
|
816
1099
|
`in fieldPolicy.${table}.writable to allow this write.`
|
|
817
|
-
: "Write denied by policy: a
|
|
1100
|
+
: "Write denied by policy: a field that a writable wildcard never covers must be listed explicitly in the writable set.";
|
|
1101
|
+
case "explicit_read_required":
|
|
1102
|
+
// Only record payload column names reach this case, on a fixed table.
|
|
1103
|
+
return table && field
|
|
1104
|
+
? `Read denied by policy: field "${field}" on "${table}" holds record payloads, ` +
|
|
1105
|
+
"so a readable wildcard never covers it. List it explicitly in " +
|
|
1106
|
+
`fieldPolicy.${table}.readable to allow this read.`
|
|
1107
|
+
: "Read denied by policy: a record payload field must be listed explicitly in its table's readable set.";
|
|
818
1108
|
case "unsupported_field_path":
|
|
819
1109
|
// The key itself is not echoed: as a whole it did not pass FIELD_NAME.
|
|
820
1110
|
return (`Write denied by policy: write keys${table ? ` on "${table}"` : ""} must be plain field names. ` +
|
|
@@ -865,15 +1155,18 @@ function resolveReadableFields(tableCandidate, input = {}) {
|
|
|
865
1155
|
const canonicalInput = snapshotPlainDataArguments(input);
|
|
866
1156
|
const responseFormat = normalizeResponseFormat(canonicalInput.responseFormat);
|
|
867
1157
|
const requested = canonicalInput.fields;
|
|
1158
|
+
const hidden = readHiddenFields(policy.table);
|
|
1159
|
+
const explicitDenied = explicitReadDeniedFields(policy.table);
|
|
1160
|
+
const queryDenied = canonicalInput.purpose === "query" ? (0, hidden_values_js_1.rowValueRule)(policy.table)?.queryDenied : undefined;
|
|
868
1161
|
if (requested === undefined) {
|
|
869
|
-
return requireNonEmptySelection(responseFormat === "detailed" ? readableSelection(policy) : policy.defaults);
|
|
1162
|
+
return visibleSelection(policy.table, requireNonEmptySelection(responseFormat === "detailed" ? readableSelection(policy) : policy.defaults));
|
|
870
1163
|
}
|
|
871
1164
|
if (typeof requested !== "string") {
|
|
872
1165
|
throw new FieldPolicyError("invalid_field_selection");
|
|
873
1166
|
}
|
|
874
1167
|
const trimmed = requested.trim();
|
|
875
1168
|
if (trimmed.toLowerCase() === "all") {
|
|
876
|
-
return requireNonEmptySelection(readableSelection(policy));
|
|
1169
|
+
return visibleSelection(policy.table, requireNonEmptySelection(readableSelection(policy)));
|
|
877
1170
|
}
|
|
878
1171
|
if (!trimmed)
|
|
879
1172
|
throw new FieldPolicyError("invalid_field_selection");
|
|
@@ -883,7 +1176,16 @@ function resolveReadableFields(tableCandidate, input = {}) {
|
|
|
883
1176
|
const field = normalizeFieldName(candidate);
|
|
884
1177
|
if (seen.has(field))
|
|
885
1178
|
throw new FieldPolicyError("invalid_field_selection");
|
|
886
|
-
|
|
1179
|
+
// A record payload column the profile's own entry for the table does
|
|
1180
|
+
// not list. Checked first: unlike a hidden-typed field, configuration can
|
|
1181
|
+
// open it, so the refusal says how.
|
|
1182
|
+
if (explicitDenied.has(field)) {
|
|
1183
|
+
throw new FieldPolicyError("explicit_read_required", { table: policy.table, field });
|
|
1184
|
+
}
|
|
1185
|
+
// A hidden-typed field is refused exactly like a sensitive name, with the
|
|
1186
|
+
// same message, before the readable check, so the refusal says nothing
|
|
1187
|
+
// about the field's type or whether a configuration could grant it.
|
|
1188
|
+
if (isSensitiveFieldName(field) || hidden.has(field) || queryDenied?.has(field)) {
|
|
887
1189
|
throw new FieldPolicyError("sensitive_field", { table: policy.table });
|
|
888
1190
|
}
|
|
889
1191
|
if (!fieldSetAllows(policy.readable, policy.allowAnyReadable, field)) {
|
|
@@ -892,7 +1194,7 @@ function resolveReadableFields(tableCandidate, input = {}) {
|
|
|
892
1194
|
seen.add(field);
|
|
893
1195
|
selected.push(field);
|
|
894
1196
|
}
|
|
895
|
-
return
|
|
1197
|
+
return boundSelection(policy.table, selected);
|
|
896
1198
|
}
|
|
897
1199
|
/** Validate and clone one Table API write map using the separate write set. */
|
|
898
1200
|
function validateWritableFields(tableCandidate, payloadCandidate) {
|
|
@@ -920,7 +1222,7 @@ function validateWritableFields(tableCandidate, payloadCandidate) {
|
|
|
920
1222
|
if (Object.hasOwn(output, field)) {
|
|
921
1223
|
throw new FieldPolicyError("invalid_write_payload");
|
|
922
1224
|
}
|
|
923
|
-
if (isSensitiveFieldName(field)) {
|
|
1225
|
+
if (isSensitiveFieldName(field) || typeHiddenFields(policy.table).has(field)) {
|
|
924
1226
|
throw new FieldPolicyError("sensitive_field", { table: policy.table });
|
|
925
1227
|
}
|
|
926
1228
|
// policy.writable holds only explicitly listed names; it is empty when
|
|
@@ -928,6 +1230,10 @@ function validateWritableFields(tableCandidate, payloadCandidate) {
|
|
|
928
1230
|
if (EXPLICIT_WRITE_FIELDS.has(field) && !policy.writable.includes(field)) {
|
|
929
1231
|
throw new FieldPolicyError("explicit_field_required", { table: policy.table, field });
|
|
930
1232
|
}
|
|
1233
|
+
// A record payload column is written only where the table's own entry lists it.
|
|
1234
|
+
if (recordPayloadColumns(policy.table)?.has(field) && !policy.explicitWritable.includes(field)) {
|
|
1235
|
+
throw new FieldPolicyError("explicit_field_required", { table: policy.table, field });
|
|
1236
|
+
}
|
|
931
1237
|
if (!fieldSetAllows(policy.writable, policy.allowAnyWritable, field)) {
|
|
932
1238
|
throw new FieldPolicyError("non_writable_field", { table: policy.table, field });
|
|
933
1239
|
}
|
|
@@ -1012,7 +1318,8 @@ function preparedReadableFields(args, tableCandidate) {
|
|
|
1012
1318
|
if (!Array.isArray(fields) || !Object.isFrozen(fields))
|
|
1013
1319
|
return undefined;
|
|
1014
1320
|
if (isAllFieldSelection(fields)) {
|
|
1015
|
-
|
|
1321
|
+
// The entry's own wildcard, which carries its table's hidden fields.
|
|
1322
|
+
return policy.allowAnyReadable ? fields : undefined;
|
|
1016
1323
|
}
|
|
1017
1324
|
if (fields.some((field) => typeof field !== "string" ||
|
|
1018
1325
|
!fieldSetAllows(policy.readable, policy.allowAnyReadable, field))) {
|
|
@@ -1028,12 +1335,12 @@ function preparedReadableFields(args, tableCandidate) {
|
|
|
1028
1335
|
function filterReadableRecord(candidate, readableFields) {
|
|
1029
1336
|
if (node_util_1.types.isProxy(readableFields))
|
|
1030
1337
|
return null;
|
|
1338
|
+
const context = selectionContext(readableFields);
|
|
1031
1339
|
const state = responseTraversalState();
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
return filterRecordNode(candidate, approved, state, 0);
|
|
1340
|
+
const filtered = isAllFieldSelection(readableFields)
|
|
1341
|
+
? sanitizeNestedValue(candidate, state, 0)
|
|
1342
|
+
: filterRecordNode(candidate, new Set(readableFields.map(normalizeFieldName)), state, 0);
|
|
1343
|
+
return context === undefined ? filtered : applyHiddenRules(filtered, context);
|
|
1037
1344
|
}
|
|
1038
1345
|
/** Remove metadata entries for fields the caller is not permitted to discover. */
|
|
1039
1346
|
function filterSchemaEntries(candidate, readableFields) {
|
|
@@ -1094,15 +1401,26 @@ function filterSchemaEntries(candidate, readableFields) {
|
|
|
1094
1401
|
function filterAggregateResult(candidate, readableFields) {
|
|
1095
1402
|
if (node_util_1.types.isProxy(readableFields))
|
|
1096
1403
|
return null;
|
|
1404
|
+
const hidden = selectionContext(readableFields)?.hidden ?? EMPTY_FIELDS;
|
|
1097
1405
|
const state = responseTraversalState();
|
|
1098
1406
|
if (isAllFieldSelection(readableFields)) {
|
|
1099
|
-
|
|
1407
|
+
const sanitized = sanitizeNestedValue(candidate, state, 0);
|
|
1408
|
+
return hidden.size === 0 ? sanitized : withoutAggregateFields(sanitized, hidden, 0);
|
|
1100
1409
|
}
|
|
1101
|
-
const approved = new Set(readableFields.map(normalizeFieldName));
|
|
1410
|
+
const approved = new Set(readableFields.map(normalizeFieldName).filter((field) => !hidden.has(field)));
|
|
1102
1411
|
return filterAggregateNode(candidate, approved, state, 0);
|
|
1103
1412
|
}
|
|
1104
1413
|
function runWithFieldPolicyConfiguration(configuration, callback) {
|
|
1105
|
-
return FIELD_POLICY_CONFIGURATION_SCOPE.run(configuration ??
|
|
1414
|
+
return FIELD_POLICY_CONFIGURATION_SCOPE.run(configuration ?? NO_FIELD_POLICY_CONFIGURATION, callback);
|
|
1415
|
+
}
|
|
1416
|
+
const NO_FIELD_POLICY_CONFIGURATION = Object.freeze({});
|
|
1417
|
+
/**
|
|
1418
|
+
* The field-policy configuration in force, as an identity: two preparations
|
|
1419
|
+
* that see the same object were checked against the same policy. Undefined
|
|
1420
|
+
* outside a configuration scope.
|
|
1421
|
+
*/
|
|
1422
|
+
function currentFieldPolicyConfiguration() {
|
|
1423
|
+
return FIELD_POLICY_CONFIGURATION_SCOPE.getStore();
|
|
1106
1424
|
}
|
|
1107
1425
|
/** True when a field selection means ServiceNow should return all fields. */
|
|
1108
1426
|
function isAllFieldSelection(selection) {
|
|
@@ -1122,6 +1440,254 @@ function isSensitiveFieldName(candidate) {
|
|
|
1122
1440
|
return (/(?:^|_)(?:password|passwd|credential|credentials|secret|token|api_key|private_key|encryption_key|ssn)(?:_|$)/u.test(normalized) ||
|
|
1123
1441
|
normalized === "social_security_number");
|
|
1124
1442
|
}
|
|
1443
|
+
const EMPTY_FIELDS = Object.freeze(new Set());
|
|
1444
|
+
/**
|
|
1445
|
+
* Type hiding. The dispatcher resolves each table's hidden-typed fields
|
|
1446
|
+
* (`hidden-values.ts`) before a call's plan is prepared and runs the plan and
|
|
1447
|
+
* the handler inside that scope. Every check above then treats a hidden-typed
|
|
1448
|
+
* field like a sensitive name: refused when named (with the same message),
|
|
1449
|
+
* dropped from a wildcard or configured projection, never written, and never
|
|
1450
|
+
* used to filter, order or group. Outside a dispatched call there is no scope
|
|
1451
|
+
* and only names are checked.
|
|
1452
|
+
*/
|
|
1453
|
+
function typeHiddenFields(table) {
|
|
1454
|
+
const scope = (0, hidden_values_js_1.currentHiddenFieldScope)();
|
|
1455
|
+
if (scope === undefined)
|
|
1456
|
+
return EMPTY_FIELDS;
|
|
1457
|
+
const hidden = scope.tables.get(table);
|
|
1458
|
+
if (hidden !== undefined)
|
|
1459
|
+
return hidden;
|
|
1460
|
+
if (scope.unresolved === "names_only")
|
|
1461
|
+
return EMPTY_FIELDS;
|
|
1462
|
+
// A table outside the call's resolved plan has unknown types: refuse.
|
|
1463
|
+
throw new FieldPolicyError("field_types_unavailable", { table });
|
|
1464
|
+
}
|
|
1465
|
+
/** The hidden-typed fields of `table` in the running call; empty outside one. */
|
|
1466
|
+
function typeHiddenFieldNames(tableCandidate) {
|
|
1467
|
+
return typeHiddenFields(normalizeTableName(tableCandidate));
|
|
1468
|
+
}
|
|
1469
|
+
/** Per policy map, the closed record payload columns of each table it names. */
|
|
1470
|
+
const EXPLICIT_READ_DENIED = new WeakMap();
|
|
1471
|
+
/**
|
|
1472
|
+
* The record payload columns of `table` that the current policy does not
|
|
1473
|
+
* open: every one, unless the profile's own entry for the table lists it in
|
|
1474
|
+
* `readable`. With nothing listed the answer is the table's fixed column set,
|
|
1475
|
+
* so nothing is stored; a partial opening is cached per policy map and table,
|
|
1476
|
+
* and only tables the configuration names can reach that cache.
|
|
1477
|
+
*/
|
|
1478
|
+
function explicitReadDeniedFields(table) {
|
|
1479
|
+
const fields = recordPayloadColumns(table);
|
|
1480
|
+
if (fields === undefined)
|
|
1481
|
+
return EMPTY_FIELDS;
|
|
1482
|
+
let policies;
|
|
1483
|
+
try {
|
|
1484
|
+
policies = currentTableFieldPolicies();
|
|
1485
|
+
}
|
|
1486
|
+
catch {
|
|
1487
|
+
return fields;
|
|
1488
|
+
}
|
|
1489
|
+
// A table with no entry of its own resolves through "*", which lists none.
|
|
1490
|
+
const listed = policies.get(table)?.explicitReadable ?? NO_FIELDS;
|
|
1491
|
+
if (listed.length === 0)
|
|
1492
|
+
return fields;
|
|
1493
|
+
let byTable = EXPLICIT_READ_DENIED.get(policies);
|
|
1494
|
+
if (!byTable)
|
|
1495
|
+
EXPLICIT_READ_DENIED.set(policies, (byTable = new Map()));
|
|
1496
|
+
const cached = byTable.get(table);
|
|
1497
|
+
if (cached !== undefined)
|
|
1498
|
+
return cached;
|
|
1499
|
+
const denied = Object.freeze(new Set([...fields].filter((field) => !listed.includes(field))));
|
|
1500
|
+
byTable.set(table, denied);
|
|
1501
|
+
return denied;
|
|
1502
|
+
}
|
|
1503
|
+
const READ_HIDDEN_UNIONS = new WeakMap();
|
|
1504
|
+
/**
|
|
1505
|
+
* Every field a read of `table` treats as hidden: its hidden-typed fields and
|
|
1506
|
+
* the record payload columns its policy leaves closed. Writes check types
|
|
1507
|
+
* here and record payload columns in validateWritableFields.
|
|
1508
|
+
*/
|
|
1509
|
+
function readHiddenFields(table) {
|
|
1510
|
+
const typed = typeHiddenFields(table);
|
|
1511
|
+
const explicit = explicitReadDeniedFields(table);
|
|
1512
|
+
if (explicit.size === 0)
|
|
1513
|
+
return typed;
|
|
1514
|
+
if (typed.size === 0)
|
|
1515
|
+
return explicit;
|
|
1516
|
+
let byExplicit = READ_HIDDEN_UNIONS.get(typed);
|
|
1517
|
+
if (!byExplicit)
|
|
1518
|
+
READ_HIDDEN_UNIONS.set(typed, (byExplicit = new WeakMap()));
|
|
1519
|
+
let union = byExplicit.get(explicit);
|
|
1520
|
+
if (!union) {
|
|
1521
|
+
union = Object.freeze(new Set([...typed, ...explicit]));
|
|
1522
|
+
byExplicit.set(explicit, union);
|
|
1523
|
+
}
|
|
1524
|
+
return union;
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Fields of `table` that may never filter, order, group or aggregate a read:
|
|
1528
|
+
* its hidden-typed fields, the record payload columns its policy leaves closed,
|
|
1529
|
+
* and its row rule's value field. The sensitive-name check applies on top,
|
|
1530
|
+
* wherever a caller checks names.
|
|
1531
|
+
*/
|
|
1532
|
+
function queryDeniedFields(tableCandidate) {
|
|
1533
|
+
const table = normalizeTableName(tableCandidate);
|
|
1534
|
+
const hidden = readHiddenFields(table);
|
|
1535
|
+
const rule = (0, hidden_values_js_1.rowValueRule)(table);
|
|
1536
|
+
return rule === undefined ? hidden : new Set([...hidden, ...rule.queryDenied]);
|
|
1537
|
+
}
|
|
1538
|
+
/** {@link queryDeniedFields} for the table a selection was resolved on. */
|
|
1539
|
+
function queryDeniedForSelection(selection) {
|
|
1540
|
+
const context = selectionContext(selection);
|
|
1541
|
+
if (context === undefined)
|
|
1542
|
+
return EMPTY_FIELDS;
|
|
1543
|
+
return context.rule === undefined
|
|
1544
|
+
? context.hidden
|
|
1545
|
+
: new Set([...context.hidden, ...context.rule.queryDenied]);
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Bind a projection the caller built itself (the bounded all-fields list) to
|
|
1549
|
+
* its table, without its hidden-typed fields, so the response filter applies
|
|
1550
|
+
* the table's rules to it.
|
|
1551
|
+
*/
|
|
1552
|
+
function readableSelectionForTable(tableCandidate, fields,
|
|
1553
|
+
/** A selection this one extends; fields it added to fetch a type stay removed. */
|
|
1554
|
+
extending) {
|
|
1555
|
+
const table = normalizeTableName(tableCandidate);
|
|
1556
|
+
const inherited = extending === undefined ? undefined : SELECTION_CONTEXTS.get(extending)?.companions;
|
|
1557
|
+
return preparedSelection(table, fields, readHiddenFields(table), inherited);
|
|
1558
|
+
}
|
|
1559
|
+
const SELECTION_CONTEXTS = new WeakMap();
|
|
1560
|
+
/** A frozen selection that remembers its table's hidden fields and row rule. */
|
|
1561
|
+
function boundSelection(table, fields, hidden = readHiddenFields(table), companions = EMPTY_FIELDS) {
|
|
1562
|
+
const selection = Object.freeze([...fields]);
|
|
1563
|
+
const rule = (0, hidden_values_js_1.rowValueRule)(table);
|
|
1564
|
+
SELECTION_CONTEXTS.set(selection, Object.freeze({ hidden, ...(rule === undefined ? {} : { rule }), companions }));
|
|
1565
|
+
return selection;
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Bound copies of policy-chosen projections, per source list, table and
|
|
1569
|
+
* hidden set, so repeated resolutions in one scope return the same frozen
|
|
1570
|
+
* object (as they did before selections were bound).
|
|
1571
|
+
*/
|
|
1572
|
+
const VISIBLE_SELECTIONS = new WeakMap();
|
|
1573
|
+
/** A policy-chosen projection (defaults, or "all") without hidden-typed fields. */
|
|
1574
|
+
function visibleSelection(table, selection) {
|
|
1575
|
+
const hidden = readHiddenFields(table);
|
|
1576
|
+
let byTable = VISIBLE_SELECTIONS.get(selection);
|
|
1577
|
+
if (!byTable)
|
|
1578
|
+
VISIBLE_SELECTIONS.set(selection, (byTable = new Map()));
|
|
1579
|
+
let byHidden = byTable.get(table);
|
|
1580
|
+
if (!byHidden)
|
|
1581
|
+
byTable.set(table, (byHidden = new WeakMap()));
|
|
1582
|
+
const cached = byHidden.get(hidden);
|
|
1583
|
+
if (cached)
|
|
1584
|
+
return cached;
|
|
1585
|
+
const bound = isAllFieldSelection(selection)
|
|
1586
|
+
? boundSelection(table, ALL_FIELDS_SELECTION, hidden)
|
|
1587
|
+
: boundSelection(table, requireNonEmptySelection(selection.filter((field) => !hidden.has(field))), hidden);
|
|
1588
|
+
byHidden.set(hidden, bound);
|
|
1589
|
+
return bound;
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* The projection a prepared marker carries: hidden-typed fields removed, and
|
|
1593
|
+
* a row rule's type field added when its value field is selected, so each
|
|
1594
|
+
* row's type comes back to decide the value (the type is dropped from the
|
|
1595
|
+
* output again).
|
|
1596
|
+
*/
|
|
1597
|
+
function preparedSelection(table, readableFields, hidden, inheritedCompanions = EMPTY_FIELDS) {
|
|
1598
|
+
if (isAllFieldSelection(readableFields)) {
|
|
1599
|
+
return boundSelection(table, ALL_FIELDS_SELECTION, hidden);
|
|
1600
|
+
}
|
|
1601
|
+
let fields = readableFields.filter((field) => !hidden.has(field));
|
|
1602
|
+
if (fields.length === 0)
|
|
1603
|
+
fields = [...WRITE_ONLY_RESPONSE_FIELDS];
|
|
1604
|
+
const rule = (0, hidden_values_js_1.rowValueRule)(table);
|
|
1605
|
+
if (rule !== undefined &&
|
|
1606
|
+
fields.includes(rule.valueField) &&
|
|
1607
|
+
!fields.includes(rule.typeField) &&
|
|
1608
|
+
!hidden.has(rule.typeField) &&
|
|
1609
|
+
typeFieldReadable(table, rule.typeField)) {
|
|
1610
|
+
return boundSelection(table, [...fields, rule.typeField], hidden, new Set([...inheritedCompanions, rule.typeField]));
|
|
1611
|
+
}
|
|
1612
|
+
return boundSelection(table, fields, hidden, inheritedCompanions);
|
|
1613
|
+
}
|
|
1614
|
+
function typeFieldReadable(table, field) {
|
|
1615
|
+
try {
|
|
1616
|
+
const policy = requirePolicy(table);
|
|
1617
|
+
return (!isSensitiveFieldName(field) &&
|
|
1618
|
+
fieldSetAllows(policy.readable, policy.allowAnyReadable, field));
|
|
1619
|
+
}
|
|
1620
|
+
catch {
|
|
1621
|
+
return false;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* The rules for a selection: its own table's when it was resolved here, else,
|
|
1626
|
+
* inside a dispatched call, the union over the call's tables (a projection
|
|
1627
|
+
* built elsewhere is held to what any table of the call hides).
|
|
1628
|
+
*/
|
|
1629
|
+
function selectionContext(selection) {
|
|
1630
|
+
if (typeof selection === "object" && selection !== null) {
|
|
1631
|
+
const bound = SELECTION_CONTEXTS.get(selection);
|
|
1632
|
+
if (bound !== undefined)
|
|
1633
|
+
return bound;
|
|
1634
|
+
}
|
|
1635
|
+
const scope = (0, hidden_values_js_1.currentHiddenFieldScope)();
|
|
1636
|
+
if (scope === undefined)
|
|
1637
|
+
return undefined;
|
|
1638
|
+
const hidden = new Set();
|
|
1639
|
+
let rule;
|
|
1640
|
+
for (const [table, fields] of scope.tables) {
|
|
1641
|
+
for (const field of fields)
|
|
1642
|
+
hidden.add(field);
|
|
1643
|
+
for (const field of explicitReadDeniedFields(table))
|
|
1644
|
+
hidden.add(field);
|
|
1645
|
+
rule ??= (0, hidden_values_js_1.rowValueRule)(table);
|
|
1646
|
+
}
|
|
1647
|
+
return { hidden, ...(rule === undefined ? {} : { rule }), companions: EMPTY_FIELDS };
|
|
1648
|
+
}
|
|
1649
|
+
/** Drop hidden-typed fields, apply the row rule, drop companions: per record. */
|
|
1650
|
+
function applyHiddenRules(filtered, context) {
|
|
1651
|
+
if (context.hidden.size === 0 && context.rule === undefined && context.companions.size === 0) {
|
|
1652
|
+
return filtered;
|
|
1653
|
+
}
|
|
1654
|
+
return Array.isArray(filtered)
|
|
1655
|
+
? filtered.map((record) => hideInRecord(record, context))
|
|
1656
|
+
: hideInRecord(filtered, context);
|
|
1657
|
+
}
|
|
1658
|
+
function hideInRecord(record, context) {
|
|
1659
|
+
if (typeof record !== "object" || record === null || Array.isArray(record))
|
|
1660
|
+
return record;
|
|
1661
|
+
const output = (0, hidden_values_js_1.withoutFields)(record, context.hidden);
|
|
1662
|
+
const rule = context.rule;
|
|
1663
|
+
if (rule !== undefined && Object.hasOwn(output, rule.valueField) && (0, hidden_values_js_1.rowValueHidden)(rule, output)) {
|
|
1664
|
+
Reflect.deleteProperty(output, rule.valueField);
|
|
1665
|
+
}
|
|
1666
|
+
for (const companion of context.companions)
|
|
1667
|
+
Reflect.deleteProperty(output, companion);
|
|
1668
|
+
return output;
|
|
1669
|
+
}
|
|
1670
|
+
/** Remove hidden fields from already-sanitized aggregate data, at any depth. */
|
|
1671
|
+
function withoutAggregateFields(candidate, hidden, depth) {
|
|
1672
|
+
if (typeof candidate !== "object" || candidate === null || depth > exports.MAX_FIELD_VALUE_DEPTH) {
|
|
1673
|
+
return candidate;
|
|
1674
|
+
}
|
|
1675
|
+
if (Array.isArray(candidate)) {
|
|
1676
|
+
return candidate
|
|
1677
|
+
.filter((entry) => {
|
|
1678
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry))
|
|
1679
|
+
return true;
|
|
1680
|
+
const field = entry.field;
|
|
1681
|
+
return typeof field !== "string" || !hidden.has(field.trim().toLowerCase());
|
|
1682
|
+
})
|
|
1683
|
+
.map((entry) => withoutAggregateFields(entry, hidden, depth + 1));
|
|
1684
|
+
}
|
|
1685
|
+
const output = {};
|
|
1686
|
+
for (const [key, value] of Object.entries((0, hidden_values_js_1.withoutFields)(candidate, hidden))) {
|
|
1687
|
+
safeDefine(output, key, withoutAggregateFields(value, hidden, depth + 1));
|
|
1688
|
+
}
|
|
1689
|
+
return output;
|
|
1690
|
+
}
|
|
1125
1691
|
/** Names the writable wildcard never covers; a profile must list each one. */
|
|
1126
1692
|
exports.EXPLICIT_WRITE_FIELD_NAMES = Object.freeze([
|
|
1127
1693
|
...EXPLICIT_WRITE_FIELDS,
|
|
@@ -1223,14 +1789,15 @@ function isDeepFrozen(candidate, depth) {
|
|
|
1223
1789
|
}
|
|
1224
1790
|
function mergeFieldPolicyDefinitions(base, configured) {
|
|
1225
1791
|
const merged = { ...base };
|
|
1226
|
-
// A profile's "*" entry also covers
|
|
1227
|
-
//
|
|
1792
|
+
// A profile's "*" entry also covers every built-in table that is not a
|
|
1793
|
+
// system table (the ITSM, named-only and platform tables) when the profile
|
|
1794
|
+
// does not name it, so each is merged even without an entry of its own.
|
|
1228
1795
|
const profileWildcard = Object.hasOwn(configured, FIELD_POLICY_WILDCARD)
|
|
1229
1796
|
? configured[FIELD_POLICY_WILDCARD]
|
|
1230
1797
|
: undefined;
|
|
1231
1798
|
const tables = new Set(Object.keys(configured));
|
|
1232
1799
|
if (profileWildcard !== undefined) {
|
|
1233
|
-
for (const table of
|
|
1800
|
+
for (const table of PROFILE_OWNED_BUILT_INS)
|
|
1234
1801
|
tables.add(table);
|
|
1235
1802
|
}
|
|
1236
1803
|
for (const table of tables) {
|
|
@@ -1238,7 +1805,7 @@ function mergeFieldPolicyDefinitions(base, configured) {
|
|
|
1238
1805
|
? configured[table]
|
|
1239
1806
|
: {};
|
|
1240
1807
|
const existing = merged[table];
|
|
1241
|
-
// Every table but the system tables (ITSM and custom alike) resolves each
|
|
1808
|
+
// Every table but the system tables (ITSM, named-only, platform and custom alike) resolves each
|
|
1242
1809
|
// set from its own entry, then the profile's "*" entry, then the base. A
|
|
1243
1810
|
// named custom table therefore cannot escape a narrowing "*" by stating
|
|
1244
1811
|
// only the other key. System tables never take the "*" entry.
|
|
@@ -1264,6 +1831,10 @@ function mergeFieldPolicyDefinitions(base, configured) {
|
|
|
1264
1831
|
// writes has not asked for a restriction, and tableAccess already
|
|
1265
1832
|
// decided whether this table is reachable at all.
|
|
1266
1833
|
writable: definition.writable ?? fallback?.writable ?? existing?.writable,
|
|
1834
|
+
// Only the table's own entry can list a record payload column; the "*"
|
|
1835
|
+
// entry and the base never do.
|
|
1836
|
+
...(definition.readable === undefined ? {} : { ownReadable: definition.readable }),
|
|
1837
|
+
...(definition.writable === undefined ? {} : { ownWritable: definition.writable }),
|
|
1267
1838
|
};
|
|
1268
1839
|
}
|
|
1269
1840
|
return merged;
|
|
@@ -1337,6 +1908,7 @@ function buildFieldPolicyMap(definitions, root) {
|
|
|
1337
1908
|
}
|
|
1338
1909
|
}
|
|
1339
1910
|
}
|
|
1911
|
+
const payloadColumns = recordPayloadColumns(table);
|
|
1340
1912
|
return [
|
|
1341
1913
|
table,
|
|
1342
1914
|
Object.freeze({
|
|
@@ -1346,10 +1918,26 @@ function buildFieldPolicyMap(definitions, root) {
|
|
|
1346
1918
|
writable: writableFields,
|
|
1347
1919
|
allowAnyReadable: readable === FIELD_POLICY_WILDCARD,
|
|
1348
1920
|
allowAnyWritable: writable === FIELD_POLICY_WILDCARD,
|
|
1921
|
+
explicitReadable: listedPayloadColumns(payloadColumns, definition.ownReadable, definition.readable, readable),
|
|
1922
|
+
explicitWritable: listedPayloadColumns(payloadColumns, definition.ownWritable, definition.writable, writable),
|
|
1349
1923
|
}),
|
|
1350
1924
|
];
|
|
1351
1925
|
}));
|
|
1352
1926
|
}
|
|
1927
|
+
/**
|
|
1928
|
+
* The record payload columns an own-entry list names. The merge passes the own
|
|
1929
|
+
* list through as the resolved list, so its normalized form is reused rather
|
|
1930
|
+
* than normalized twice. A wildcard own list names nothing.
|
|
1931
|
+
*/
|
|
1932
|
+
function listedPayloadColumns(columns, own, resolvedSource, resolved) {
|
|
1933
|
+
if (columns === undefined || own === undefined)
|
|
1934
|
+
return NO_FIELDS;
|
|
1935
|
+
const normalized = own === resolvedSource ? resolved : normalizePolicyFieldSet(own);
|
|
1936
|
+
if (normalized === FIELD_POLICY_WILDCARD)
|
|
1937
|
+
return NO_FIELDS;
|
|
1938
|
+
const listed = normalized.filter((field) => columns.has(field));
|
|
1939
|
+
return listed.length === 0 ? NO_FIELDS : Object.freeze(listed);
|
|
1940
|
+
}
|
|
1353
1941
|
/**
|
|
1354
1942
|
* A malformed field-policy configuration, raised when a profile is loaded.
|
|
1355
1943
|
*
|
|
@@ -1768,11 +2356,11 @@ function normalizePolicyFields(candidates, location) {
|
|
|
1768
2356
|
function issuePreparedAccess(args, table, readableFields) {
|
|
1769
2357
|
const normalizedTable = normalizeTableName(table);
|
|
1770
2358
|
const previous = issuedPreparedEntries(args).filter((entry) => entry.table !== normalizedTable);
|
|
2359
|
+
const hidden = readHiddenFields(normalizedTable);
|
|
1771
2360
|
const entry = Object.freeze({
|
|
1772
2361
|
table: normalizedTable,
|
|
1773
|
-
readableFields:
|
|
1774
|
-
|
|
1775
|
-
: Object.freeze([...readableFields]),
|
|
2362
|
+
readableFields: preparedSelection(normalizedTable, readableFields, hidden),
|
|
2363
|
+
hiddenFields: Object.freeze([...hidden].sort()),
|
|
1776
2364
|
});
|
|
1777
2365
|
const marker = Object.freeze({
|
|
1778
2366
|
entries: Object.freeze([...previous, entry]),
|