@onlyflows/servicenow-mcp 2.3.0-rc.1 → 2.3.0-rc.2
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 +732 -3
- package/README.md +418 -40
- 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 +34 -1
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +325 -30
- 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 +13 -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.map +1 -1
- package/dist/risky-grants.js +1 -0
- 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 +11 -0
- package/dist/tools/platform-view-evaluate.d.ts.map +1 -0
- package/dist/tools/platform-view-evaluate.js +19 -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/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/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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The error for a response that passed its byte limit, kept apart from the
|
|
4
|
+
* client so the error mapper can recognize it without importing the client.
|
|
5
|
+
*
|
|
6
|
+
* @module response-too-large
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ServiceNowResponseTooLargeError = void 0;
|
|
10
|
+
exports.isServiceNowResponseTooLarge = isServiceNowResponseTooLarge;
|
|
11
|
+
exports.isIssuedResponseTooLargeError = isIssuedResponseTooLargeError;
|
|
12
|
+
const ISSUED_TOO_LARGE_ERRORS = new WeakSet();
|
|
13
|
+
/**
|
|
14
|
+
* A response, or a request scope's cumulative upstream JSON, passed its byte
|
|
15
|
+
* limit. A RangeError, as before, so existing handling is unchanged; the
|
|
16
|
+
* class lets callers tell it apart from any other RangeError.
|
|
17
|
+
*/
|
|
18
|
+
class ServiceNowResponseTooLargeError extends RangeError {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "ServiceNowResponseTooLargeError";
|
|
22
|
+
ISSUED_TOO_LARGE_ERRORS.add(this);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ServiceNowResponseTooLargeError = ServiceNowResponseTooLargeError;
|
|
26
|
+
/** True when a request failed because a response or its scope passed a byte limit. */
|
|
27
|
+
function isServiceNowResponseTooLarge(error) {
|
|
28
|
+
return error instanceof ServiceNowResponseTooLargeError;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* True only for an error this module's class constructed. A WeakSet lookup
|
|
32
|
+
* runs no code of the candidate, so a hostile Proxy or getter-laden object
|
|
33
|
+
* cannot be mistaken for one or made to run while it is classified.
|
|
34
|
+
*/
|
|
35
|
+
function isIssuedResponseTooLargeError(candidate) {
|
|
36
|
+
if ((typeof candidate !== "object" && typeof candidate !== "function") ||
|
|
37
|
+
candidate === null) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return ISSUED_TOO_LARGE_ERRORS.has(candidate);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=response-too-large.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-too-large.js","sourceRoot":"","sources":["../src/response-too-large.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAkBH,oEAEC;AAOD,sEAQC;AAjCD,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAAU,CAAC;AAEtD;;;;GAIG;AACH,MAAa,+BAAgC,SAAQ,UAAU;IAC7D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAC;QAC9C,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AAND,0EAMC;AAED,sFAAsF;AACtF,SAAgB,4BAA4B,CAAC,KAAc;IACzD,OAAO,KAAK,YAAY,+BAA+B,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,SAAkB;IAC9D,IACE,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,UAAU,CAAC;QAClE,SAAS,KAAK,IAAI,EAClB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,uBAAuB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"risky-grants.d.ts","sourceRoot":"","sources":["../src/risky-grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"risky-grants.d.ts","sourceRoot":"","sources":["../src/risky-grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EA8B9C,CAAC;AAIH,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,CAGlF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAcpB"}
|
package/dist/risky-grants.js
CHANGED
package/dist/risky-grants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"risky-grants.js","sourceRoot":"","sources":["../src/risky-grants.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;
|
|
1
|
+
{"version":3,"file":"risky-grants.js","sourceRoot":"","sources":["../src/risky-grants.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAqCH,4CAGC;AAQD,8CAiBC;AA/DY,QAAA,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACjE,mBAAmB;IACnB,mBAAmB;IACnB,oBAAoB;IACpB,eAAe;IACf,wBAAwB;IACxB,mBAAmB;IACnB,kBAAkB;IAClB,uBAAuB;IACvB,sBAAsB;IACtB,mBAAmB;IACnB,iEAAiE;IACjE,YAAY;IACZ,oBAAoB;IACpB,gBAAgB;IAChB,aAAa;IACb,eAAe;IACf,mBAAmB;IACnB,kBAAkB;IAClB,YAAY;IACZ,eAAe;IACf,8CAA8C;IAC9C,gBAAgB;IAChB,UAAU;IACV,gBAAgB;IAChB,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,kBAAkB;IAClB,wBAAwB;CACzB,CAAC,CAAC;AAEH,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC,0BAAkB,CAAC,CAAC;AAEnE,sEAAsE;AACtE,SAAgB,gBAAgB,CAAC,WAA8B;IAC7D,IAAI,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,0BAAkB,CAAC;IACzD,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACnF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,OAA0B,EAC1B,OAAe;IAEf,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,CACL,yEAAyE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC3F,GAAG,QAAQ,CAAC,CAAC,CAAC,6DAA6D,CAAC,CAAC,CAAC,EAAE,KAAK;QACrF,2EAA2E;QAC3E,gFAAgF;QAChF,8EAA8E;QAC9E,2EAA2E;QAC3E,gFAAgF;QAChF,6DAA6D,OAAO,IAAI,CACzE,CAAC;AACJ,CAAC"}
|
package/dist/setup-prompts.js
CHANGED
|
@@ -72,7 +72,7 @@ function renderAddProfilePrompt(profile, instance, authType) {
|
|
|
72
72
|
grantCommand(profile),
|
|
73
73
|
"",
|
|
74
74
|
"Notes on step 2:",
|
|
75
|
-
"- Default tools are sn_query, sn_get, sn_aggregate, sn_schema for a read grant, plus sn_create and sn_update for a write grant. Add --tools to narrow further.",
|
|
75
|
+
"- Default tools are sn_query, sn_get, sn_aggregate, sn_schema, sn_codesearch for a read grant, plus sn_create and sn_update for a write grant. Add --tools to narrow further.",
|
|
76
76
|
"- sn_delete, sn_batch, sn_atf, sn_atf_run, and sn_atf_author are never granted implicitly; name them with --tools only if I ask.",
|
|
77
77
|
"- To view Flow Designer flows with sn_flow_view, add --flows only if I ask: it grants read on the 15 flow tables to sn_flow_view alone.",
|
|
78
78
|
"- If a table extends another (change_request and task, for example), add --related \"<table>=<parent>\".",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-prompts.js","sourceRoot":"","sources":["../src/setup-prompts.ts"],"names":[],"mappings":";AAAA,uDAAuD;;AA8BvD,oDA8BC;AA1DD,6BAAwB;AAIxB,MAAM,cAAc,GAAG,OAAC;KACrB,MAAM,EAAE;KACR,IAAI,EAAE;KACN,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,QAAQ,EAAE;KACV,QAAQ,CAAC,+DAA+D,CAAC,CAAC;AAE7E,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,EAAE;KACR,IAAI,EAAE;KACN,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,IAAI,CAAC;KACT,QAAQ,EAAE;KACV,QAAQ,CAAC,sEAAsE,CAAC,CAAC;AAEpF,MAAM,WAAW,GAAG,OAAC;KAClB,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;KAClC,QAAQ,EAAE;KACV,QAAQ,CAAC,kEAAkE,CAAC,CAAC;AAIhF,oFAAoF;AACpF,SAAgB,oBAAoB,CAAC,OAAsB;IACzD,OAAO,CAAC,cAAc,CACpB,4BAA4B,EAC5B;QACE,KAAK,EAAE,8BAA8B;QACrC,WAAW,EACT,yGAAyG;QAC3G,UAAU,EAAE;YACV,OAAO,EAAE,cAAc;YACvB,QAAQ,EAAE,WAAW;YACrB,S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AC;SAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC;AAC9C,CAAC"}
|
package/dist/setup.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export interface SetupCliDependencies {
|
|
|
58
58
|
export interface AskOptions {
|
|
59
59
|
readonly default?: string;
|
|
60
60
|
readonly choices?: readonly string[];
|
|
61
|
+
/** A short note shown beside a choice in the menu. Display only. */
|
|
62
|
+
readonly hints?: Readonly<Record<string, string>>;
|
|
61
63
|
/** Return a message to reject and re-prompt; return undefined to accept. */
|
|
62
64
|
readonly validate?: (value: string) => string | undefined;
|
|
63
65
|
}
|
|
@@ -83,6 +85,8 @@ export interface CredentialVerification {
|
|
|
83
85
|
readonly remedy?: string;
|
|
84
86
|
/** True when the instance authenticated us but denied the probe read. */
|
|
85
87
|
readonly authenticatedButDenied?: boolean;
|
|
88
|
+
/** True when the instance answered 401: it rejected the credential itself. */
|
|
89
|
+
readonly authenticationRejected?: boolean;
|
|
86
90
|
}
|
|
87
91
|
/** Raised when the operator aborts; nothing has been written to the profile. */
|
|
88
92
|
export declare class WizardAbort extends Error {
|
package/dist/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;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IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;CACpC;AAyBD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,CAmD1E;AAkBD,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAWrF"}
|
package/dist/setup.js
CHANGED
|
@@ -41,6 +41,7 @@ const profile_admin_js_1 = require("./profile-admin.js");
|
|
|
41
41
|
const profile_credentials_js_1 = require("./profile-credentials.js");
|
|
42
42
|
const profile_manager_js_1 = require("./profile-manager.js");
|
|
43
43
|
const policy_card_js_1 = require("./policy-card.js");
|
|
44
|
+
const hidden_values_js_1 = require("./hidden-values.js");
|
|
44
45
|
const risky_grants_js_1 = require("./risky-grants.js");
|
|
45
46
|
const tool_error_js_1 = require("./tool-error.js");
|
|
46
47
|
const table_policy_js_1 = require("./table-policy.js");
|
|
@@ -114,12 +115,24 @@ const CREDENTIAL_FOOTNOTE = "Nothing above carries a ServiceNow credential. The
|
|
|
114
115
|
"profile and its encryption key from ~/.servicenow-mcp, which is owner-only,\n" +
|
|
115
116
|
"so no secret reaches a client configuration file.\n";
|
|
116
117
|
const MINIMUM_NODE_MAJOR = 20;
|
|
117
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Tools bound to a table by a read grant when `--tools` is not given.
|
|
120
|
+
*
|
|
121
|
+
* `sn_codesearch` is authorized per code table it searches (sys_script,
|
|
122
|
+
* sys_script_include, sys_ui_script, sys_script_client, sys_ws_operation and
|
|
123
|
+
* sys_module), so binding it here is what lets a plain read grant on one of
|
|
124
|
+
* those tables run a code search on it. ATF step scripts are searched through
|
|
125
|
+
* three tables (sys_variable_value, sys_atf_step and sys_atf_test), and a plain
|
|
126
|
+
* read grant on all three allows that search the same way. On any other table
|
|
127
|
+
* it is inert: a search names only those tables, so the binding grants nothing
|
|
128
|
+
* there.
|
|
129
|
+
*/
|
|
118
130
|
const DEFAULT_READ_TOOLS = Object.freeze([
|
|
119
131
|
"sn_query",
|
|
120
132
|
"sn_get",
|
|
121
133
|
"sn_aggregate",
|
|
122
134
|
"sn_schema",
|
|
135
|
+
"sn_codesearch",
|
|
123
136
|
]);
|
|
124
137
|
/**
|
|
125
138
|
* Tables addressable by a write grant when `--tools` is not given.
|
|
@@ -226,66 +239,16 @@ async function runWizard(options, home, env, dependencies, out) {
|
|
|
226
239
|
}
|
|
227
240
|
const name = await askProfileName(prompter, existing);
|
|
228
241
|
const instance = await askInstance(prompter);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
// question adjacent to a credential prompt echoes the credential, so the
|
|
238
|
-
// last thing before the hidden prompts is deliberately not this question.
|
|
239
|
-
const mode = (await prompter.ask("How should the credential be stored?", {
|
|
240
|
-
default: "encrypted",
|
|
241
|
-
choices: ["encrypted", "reference"],
|
|
242
|
-
}));
|
|
243
|
-
const provider = mode === "reference"
|
|
244
|
-
? await prompter.ask("Secret provider", { default: "env", choices: ["env"] })
|
|
245
|
-
: undefined;
|
|
246
|
-
const profile = { instance, authType };
|
|
247
|
-
if (authType === "basic" || grantType === "password") {
|
|
248
|
-
profile.username = await prompter.ask("ServiceNow username", {
|
|
249
|
-
validate: (value) => value.trim() === "" ? "A username is required for this auth mode." : undefined,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
if (authType === "oauth") {
|
|
253
|
-
profile.grantType = grantType;
|
|
254
|
-
profile.clientId = await prompter.ask("OAuth client id (not a secret)", {
|
|
255
|
-
validate: (value) => value.trim() === "" ? "A client id is required for OAuth." : undefined,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
if (authType === "apikey") {
|
|
259
|
-
profile.apiKeyHeader = await prompter.ask("API key header", {
|
|
260
|
-
default: "x-sn-apikey",
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
const fields = (0, profile_admin_js_1.requiredSecretFields)(authType, grantType);
|
|
264
|
-
(0, profile_admin_js_1.validateCreateMetadata)(profile, fields);
|
|
265
|
-
// 3. Capture the secrets. Never echoed, never in argv, never logged.
|
|
266
|
-
prompter.note(mode === "reference"
|
|
267
|
-
? "\nEnter the NAME of the environment variable holding each secret.\n" +
|
|
268
|
-
"Input is hidden."
|
|
269
|
-
: "\nEnter each secret now. Input is hidden — nothing you type from here\n" +
|
|
270
|
-
"is displayed.");
|
|
271
|
-
const captured = [];
|
|
272
|
-
for (const field of fields) {
|
|
273
|
-
captured.push(Object.freeze({ field, mode, value: await prompter.secret(field) }));
|
|
274
|
-
}
|
|
275
|
-
// 4. Verify against the live instance before anything is persisted.
|
|
276
|
-
const config = wizardConfig(profile, captured, mode, env);
|
|
277
|
-
const verify = dependencies.verifyCredential ?? verifyCredentialAgainstInstance;
|
|
278
|
-
prompter.note("\nVerifying against the instance...");
|
|
279
|
-
let verification = await verify(config);
|
|
280
|
-
while (!verification.ok) {
|
|
281
|
-
prompter.note(`\n FAILED ${verification.detail}`);
|
|
282
|
-
if (verification.remedy)
|
|
283
|
-
prompter.note(` -> ${verification.remedy}`);
|
|
284
|
-
if (!(await prompter.confirm("\nRetry with the same settings?", true))) {
|
|
285
|
-
throw new WizardAbort();
|
|
286
|
-
}
|
|
287
|
-
verification = await verify(config);
|
|
242
|
+
// 3-4. Authentication, the credential, and its verification. Collected in
|
|
243
|
+
// one place so a Basic 401 can send the operator back to OAuth
|
|
244
|
+
// without re-asking the profile name or the instance.
|
|
245
|
+
let forcedAuthType;
|
|
246
|
+
let collected;
|
|
247
|
+
while (collected === undefined) {
|
|
248
|
+
collected = await collectVerifiedCredential(prompter, instance, env, dependencies, forcedAuthType);
|
|
249
|
+
forcedAuthType = "oauth";
|
|
288
250
|
}
|
|
251
|
+
const { profile, captured, mode, provider, config, verification } = collected;
|
|
289
252
|
prompter.note(` ok ${verification.detail}`);
|
|
290
253
|
if (verification.authenticatedButDenied) {
|
|
291
254
|
prompter.note(` note this account cannot read ${WIZARD_PROBE_TABLE}, so metadata\n` +
|
|
@@ -335,6 +298,99 @@ async function runWizard(options, home, env, dependencies, out) {
|
|
|
335
298
|
prompter.close();
|
|
336
299
|
}
|
|
337
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Ask for the authentication type and its credential, then verify it against
|
|
303
|
+
* the instance. Returns `undefined` when the operator, after a 401 on a Basic
|
|
304
|
+
* credential, chose to switch to OAuth: the caller asks again with OAuth
|
|
305
|
+
* forced. Nothing is persisted here, and a discarded Basic credential is not
|
|
306
|
+
* kept anywhere.
|
|
307
|
+
*/
|
|
308
|
+
async function collectVerifiedCredential(prompter, instance, env, dependencies, forcedAuthType) {
|
|
309
|
+
const authType = forcedAuthType ?? (await askAuthType(prompter));
|
|
310
|
+
if (authType === "oauth")
|
|
311
|
+
prompter.note(OAUTH_REQUIREMENTS_NOTE);
|
|
312
|
+
const grantType = authType === "oauth"
|
|
313
|
+
? (await prompter.ask("OAuth grant type", {
|
|
314
|
+
default: "client_credentials",
|
|
315
|
+
choices: ["client_credentials", "password"],
|
|
316
|
+
}))
|
|
317
|
+
: "client_credentials";
|
|
318
|
+
// Asked here, before any secret is in hand. A mistyped answer to a
|
|
319
|
+
// question adjacent to a credential prompt echoes the credential, so the
|
|
320
|
+
// last thing before the hidden prompts is deliberately not this question.
|
|
321
|
+
const mode = (await prompter.ask("How should the credential be stored?", {
|
|
322
|
+
default: "encrypted",
|
|
323
|
+
choices: ["encrypted", "reference"],
|
|
324
|
+
}));
|
|
325
|
+
const provider = mode === "reference"
|
|
326
|
+
? await prompter.ask("Secret provider", { default: "env", choices: ["env"] })
|
|
327
|
+
: undefined;
|
|
328
|
+
const profile = { instance, authType };
|
|
329
|
+
if (authType === "basic" || grantType === "password") {
|
|
330
|
+
profile.username = await prompter.ask("ServiceNow username", {
|
|
331
|
+
validate: (value) => value.trim() === "" ? "A username is required for this auth mode." : undefined,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (authType === "oauth") {
|
|
335
|
+
profile.grantType = grantType;
|
|
336
|
+
profile.clientId = await prompter.ask("OAuth client id (not a secret)", {
|
|
337
|
+
validate: (value) => value.trim() === "" ? "A client id is required for OAuth." : undefined,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (authType === "apikey") {
|
|
341
|
+
profile.apiKeyHeader = await prompter.ask("API key header", {
|
|
342
|
+
default: "x-sn-apikey",
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const fields = (0, profile_admin_js_1.requiredSecretFields)(authType, grantType);
|
|
346
|
+
(0, profile_admin_js_1.validateCreateMetadata)(profile, fields);
|
|
347
|
+
// Capture the secrets. Never echoed, never in argv, never logged.
|
|
348
|
+
prompter.note(mode === "reference"
|
|
349
|
+
? "\nEnter the NAME of the environment variable holding each secret.\n" +
|
|
350
|
+
"Input is hidden."
|
|
351
|
+
: "\nEnter each secret now. Input is hidden — nothing you type from here\n" +
|
|
352
|
+
"is displayed.");
|
|
353
|
+
const captured = [];
|
|
354
|
+
for (const field of fields) {
|
|
355
|
+
captured.push(Object.freeze({ field, mode, value: await prompter.secret(field) }));
|
|
356
|
+
}
|
|
357
|
+
// Verify against the live instance before anything is persisted.
|
|
358
|
+
const config = wizardConfig(profile, captured, mode, env);
|
|
359
|
+
const verify = dependencies.verifyCredential ?? verifyCredentialAgainstInstance;
|
|
360
|
+
prompter.note("\nVerifying against the instance...");
|
|
361
|
+
let verification = await verify(config);
|
|
362
|
+
while (!verification.ok) {
|
|
363
|
+
prompter.note(`\n FAILED ${verification.detail}`);
|
|
364
|
+
const offersSwitch = authType === "basic" && verification.authenticationRejected === true;
|
|
365
|
+
if (verification.remedy) {
|
|
366
|
+
prompter.note(` -> ${verification.remedy}${offersSwitch ? BASIC_AUTH_SWITCH_IN_WIZARD : ""}`);
|
|
367
|
+
}
|
|
368
|
+
if (offersSwitch) {
|
|
369
|
+
// A 401 on Basic often means the instance no longer accepts Basic for
|
|
370
|
+
// REST, which retrying cannot fix. Offer the way out next to the retry.
|
|
371
|
+
const next = await prompter.ask("\nWhat next?", {
|
|
372
|
+
default: "retry",
|
|
373
|
+
choices: ["retry", "oauth", "stop"],
|
|
374
|
+
hints: {
|
|
375
|
+
retry: "try the same settings again",
|
|
376
|
+
oauth: "discard this credential and set up OAuth client credentials",
|
|
377
|
+
stop: "cancel; nothing is saved",
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
if (next === "stop")
|
|
381
|
+
throw new WizardAbort();
|
|
382
|
+
if (next === "oauth") {
|
|
383
|
+
prompter.note("\nSwitching to OAuth. The Basic credential is discarded.");
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else if (!(await prompter.confirm("\nRetry with the same settings?", true))) {
|
|
388
|
+
throw new WizardAbort();
|
|
389
|
+
}
|
|
390
|
+
verification = await verify(config);
|
|
391
|
+
}
|
|
392
|
+
return { profile, captured, mode, provider, config, verification };
|
|
393
|
+
}
|
|
338
394
|
/**
|
|
339
395
|
* The checks that decide whether this install actually works.
|
|
340
396
|
*
|
|
@@ -421,10 +477,30 @@ function instanceProblem(value) {
|
|
|
421
477
|
"*.servicenowservices.com. For a self-hosted or custom-domain instance, set " +
|
|
422
478
|
"SN_ALLOWED_INSTANCE_HOSTS before running setup.");
|
|
423
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* OAuth client credentials is the default and listed first. Basic stays
|
|
482
|
+
* available for an instance that still accepts it, and is listed last and
|
|
483
|
+
* marked legacy: ServiceNow is retiring it for REST calls (KB3096078).
|
|
484
|
+
*/
|
|
485
|
+
const AUTH_TYPE_CHOICES = Object.freeze(["oauth", "apikey", "basic"]);
|
|
486
|
+
const AUTH_TYPE_HINTS = Object.freeze({
|
|
487
|
+
oauth: "client credentials, recommended",
|
|
488
|
+
apikey: "inbound API key",
|
|
489
|
+
basic: "legacy, not recommended: ServiceNow is retiring it",
|
|
490
|
+
});
|
|
491
|
+
/** What OAuth client credentials need on the instance. Fixed text, no secret. */
|
|
492
|
+
const OAUTH_REQUIREMENTS_NOTE = "\nOAuth client credentials need these on the instance:\n" +
|
|
493
|
+
" - an Application Registry entry (System OAuth > Application Registry)\n" +
|
|
494
|
+
" with a client ID and client secret\n" +
|
|
495
|
+
" - the client credentials grant enabled for it\n" +
|
|
496
|
+
" - an OAuth Application User: the integration user this server acts as,\n" +
|
|
497
|
+
" with only the roles it needs, not an administrator\n" +
|
|
498
|
+
"Steps: README, section Authentication > OAuth 2.0.\n";
|
|
424
499
|
async function askAuthType(prompter) {
|
|
425
500
|
return (await prompter.ask("Authentication", {
|
|
426
|
-
default: "
|
|
427
|
-
choices:
|
|
501
|
+
default: "oauth",
|
|
502
|
+
choices: AUTH_TYPE_CHOICES,
|
|
503
|
+
hints: AUTH_TYPE_HINTS,
|
|
428
504
|
}));
|
|
429
505
|
}
|
|
430
506
|
/** Build a throwaway config for verification. Never persisted. */
|
|
@@ -484,6 +560,26 @@ async function verifyCredentialAgainstInstance(config) {
|
|
|
484
560
|
return classifyVerificationFailure(error, config);
|
|
485
561
|
}
|
|
486
562
|
}
|
|
563
|
+
/** Wizard remedy for a 401 on a basic-auth profile. Fixed text only. */
|
|
564
|
+
const BASIC_AUTH_401_REMEDY = "Check the username and password. A ServiceNow account locked out or " +
|
|
565
|
+
"requiring a password reset also returns 401. If they are correct, this " +
|
|
566
|
+
"instance may be rejecting Basic Auth for REST API calls (KB3096078): " +
|
|
567
|
+
"current instances require the role snc_basic_auth_api_access for REST " +
|
|
568
|
+
"Basic auth, or a Web-Service-Access-Only account. ServiceNow is retiring " +
|
|
569
|
+
"Basic auth, so OAuth client credentials are recommended.";
|
|
570
|
+
/**
|
|
571
|
+
* How to act on the OAuth recommendation, which depends on where the advice is
|
|
572
|
+
* read. The wizard has a menu right below it; `doctor` has none, so it names
|
|
573
|
+
* the command instead. Kept out of the shared remedy so neither points at a
|
|
574
|
+
* choice that is not on the screen.
|
|
575
|
+
*/
|
|
576
|
+
const BASIC_AUTH_SWITCH_IN_WIZARD = " Choose oauth below to switch this profile.";
|
|
577
|
+
const BASIC_AUTH_SWITCH_IN_DOCTOR = " To switch this profile, re-run servicenow-mcp-setup and choose oauth.";
|
|
578
|
+
/** True for a 401 on a Basic credential, the case the OAuth advice is for. */
|
|
579
|
+
function isBasicAuthRejection(verification, config) {
|
|
580
|
+
return (verification.authenticationRejected === true &&
|
|
581
|
+
(config.authType === undefined || config.authType === "basic"));
|
|
582
|
+
}
|
|
487
583
|
/** Map a probe failure onto the thing the operator must actually change. */
|
|
488
584
|
function classifyVerificationFailure(error, config) {
|
|
489
585
|
const descriptor = (0, tool_error_js_1.trustedToolErrorDescriptor)(error);
|
|
@@ -519,10 +615,13 @@ function classifyVerificationFailure(error, config) {
|
|
|
519
615
|
if (descriptor?.category === "authentication") {
|
|
520
616
|
return Object.freeze({
|
|
521
617
|
ok: false,
|
|
618
|
+
authenticationRejected: true,
|
|
522
619
|
detail: `${host} rejected the credential (HTTP 401).`,
|
|
523
620
|
remedy: config.authType === "oauth"
|
|
524
621
|
? "Check the OAuth client id and secret, and that the client is active on the instance."
|
|
525
|
-
:
|
|
622
|
+
: config.authType === undefined || config.authType === "basic"
|
|
623
|
+
? BASIC_AUTH_401_REMEDY
|
|
624
|
+
: "Check the username and password. A ServiceNow account locked out or requiring a password reset also returns 401.",
|
|
526
625
|
});
|
|
527
626
|
}
|
|
528
627
|
if (descriptor?.category === "authorization") {
|
|
@@ -651,7 +750,9 @@ async function askTableSelection(prompter, operation, fallback) {
|
|
|
651
750
|
prompter.note(`\n "*" grants every table for ${operation.toLowerCase()}. ServiceNow's own\n` +
|
|
652
751
|
" per-user ACLs are then the only remaining boundary, so the integration\n" +
|
|
653
752
|
" account's roles become the whole control. It also skips the per-tool\n" +
|
|
654
|
-
" binding and the related-table closure check
|
|
753
|
+
" binding and the related-table closure check. It does not cover\n" +
|
|
754
|
+
` ${table_policy_js_1.NAMED_ONLY_TABLES.join(", ")};\n` +
|
|
755
|
+
" name them to allow them.\n");
|
|
655
756
|
return Object.freeze(["*"]);
|
|
656
757
|
}
|
|
657
758
|
return askCustomTableList(prompter, operation);
|
|
@@ -873,7 +974,8 @@ function renderQuestion(question, options) {
|
|
|
873
974
|
const lines = [`${question}:`];
|
|
874
975
|
options.choices.forEach((choice, index) => {
|
|
875
976
|
const marker = choice === options.default ? " (default)" : "";
|
|
876
|
-
|
|
977
|
+
const hint = options.hints?.[choice];
|
|
978
|
+
lines.push(` ${index + 1}) ${choice}${marker}${hint ? ` - ${hint}` : ""}`);
|
|
877
979
|
});
|
|
878
980
|
const defaultIndex = options.default ? options.choices.indexOf(options.default) + 1 : 0;
|
|
879
981
|
lines.push(defaultIndex > 0 ? `Choice [${defaultIndex}]: ` : "Choice: ");
|
|
@@ -1316,6 +1418,7 @@ function runPolicy(options, home, env, dependencies, out) {
|
|
|
1316
1418
|
},
|
|
1317
1419
|
encodedQueryAccess,
|
|
1318
1420
|
atf: manager.getAtfConfig(options.profile),
|
|
1421
|
+
fieldTypes: { dictionary: (0, hidden_values_js_1.dictionaryNotRequired)(profile.fieldTypes) ? "not_required" : "required" },
|
|
1319
1422
|
});
|
|
1320
1423
|
out(options.json
|
|
1321
1424
|
? `${JSON.stringify({ policy: card, note: encodedNote }, null, 2)}\n`
|
|
@@ -1370,11 +1473,14 @@ async function runLiveChecks(paths, home, dependencies, only) {
|
|
|
1370
1473
|
}
|
|
1371
1474
|
try {
|
|
1372
1475
|
const result = await verify(config);
|
|
1476
|
+
const remedy = result.remedy !== undefined && isBasicAuthRejection(result, config)
|
|
1477
|
+
? `${result.remedy}${BASIC_AUTH_SWITCH_IN_DOCTOR}`
|
|
1478
|
+
: result.remedy;
|
|
1373
1479
|
return {
|
|
1374
1480
|
name: `profile ${name}: live instance`,
|
|
1375
1481
|
ok: result.ok,
|
|
1376
1482
|
detail: result.detail,
|
|
1377
|
-
...(
|
|
1483
|
+
...(remedy === undefined ? {} : { remedy }),
|
|
1378
1484
|
};
|
|
1379
1485
|
}
|
|
1380
1486
|
catch {
|
|
@@ -2209,10 +2315,12 @@ function renderGrantHelp() {
|
|
|
2209
2315
|
" --read TABLES Comma-separated tables to allow for reads",
|
|
2210
2316
|
" --write TABLES Comma-separated tables to allow for writes",
|
|
2211
2317
|
" --atf Grant the ATF authoring tables to sn_atf_author only",
|
|
2212
|
-
" Does not enable execution or script-step authoring",
|
|
2318
|
+
" Does not enable execution or script-step authoring, or code",
|
|
2319
|
+
" search of ATF step scripts (see README, Code search)",
|
|
2213
2320
|
" --flows Grant read on the 15 sn_flow_view tables to sn_flow_view only",
|
|
2214
2321
|
" (see docs/FLOW-VIEW.md)",
|
|
2215
|
-
` --tools LIST Tools permitted on these targets`,
|
|
2322
|
+
` --tools LIST Tools permitted on these targets; adds to the tools a table`,
|
|
2323
|
+
` already has (for example --tools sn_codesearch)`,
|
|
2216
2324
|
` (default read: ${DEFAULT_READ_TOOLS.join(",")};`,
|
|
2217
2325
|
` default write adds: ${DEFAULT_WRITE_TOOLS.join(",")};`,
|
|
2218
2326
|
` default write on incident also adds:`,
|