@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,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refuse a filter or order on a field the table does not have.
|
|
3
|
+
*
|
|
4
|
+
* ServiceNow drops a condition on a column it does not know, unless the
|
|
5
|
+
* instance sets glide.invalid_query.returns_no_rows (off by default and not a
|
|
6
|
+
* setting this server can rely on). A misspelt field therefore does not match
|
|
7
|
+
* nothing: the rest of the query runs and unrelated rows come back.
|
|
8
|
+
*
|
|
9
|
+
* The check costs no request. A column named in sysparm_fields that the table
|
|
10
|
+
* does not have, or that the integration user may not read, is left out of
|
|
11
|
+
* every row, so the filter's own fields are asked for on the read that is
|
|
12
|
+
* made anyway and the rows that come back show which of them exist.
|
|
13
|
+
*
|
|
14
|
+
* - A field counts as present when any returned row carries the key, not only
|
|
15
|
+
* the first: a field-level rule that depends on the record can hide a real
|
|
16
|
+
* column on some rows, never on a column that is absent from the table.
|
|
17
|
+
* - An existing column with no value is still returned (as an empty string),
|
|
18
|
+
* so an empty field is never mistaken for a missing one.
|
|
19
|
+
* - With no rows there is nothing to check. That is harmless: a read returns
|
|
20
|
+
* nothing, and a step that acts on the rows has nothing to act on.
|
|
21
|
+
* - Raw encoded queries are not parsed. They are only accepted through an
|
|
22
|
+
* owner-written policy rule that pins the query and its field names, so
|
|
23
|
+
* there is no caller-typed field to verify.
|
|
24
|
+
*
|
|
25
|
+
* The extra columns are asked for only when the caller's own field list does
|
|
26
|
+
* not already hold them, and callers drop them from the result.
|
|
27
|
+
*/
|
|
28
|
+
export interface FilterFieldEcho {
|
|
29
|
+
/** The sysparm_fields value to send; undefined keeps "every column". */
|
|
30
|
+
readonly sysparmFields: string | undefined;
|
|
31
|
+
/** The fields whose presence in the returned rows is checked. */
|
|
32
|
+
readonly probe: readonly string[];
|
|
33
|
+
/** True when the request asks for columns the caller did not select. */
|
|
34
|
+
readonly extended: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The sysparm_fields to send, and the fields to look for in the rows.
|
|
38
|
+
*
|
|
39
|
+
* `requested` is the caller's own selection, comma separated, or undefined
|
|
40
|
+
* when the read asks for every column. A read for every column already
|
|
41
|
+
* returns each column of the table, so nothing is added; a dot-walked name is
|
|
42
|
+
* not returned by such a read, so it cannot be checked there and is skipped.
|
|
43
|
+
*/
|
|
44
|
+
export declare function echoFilterFields(requested: string | undefined, referenced: readonly string[]): FilterFieldEcho;
|
|
45
|
+
/**
|
|
46
|
+
* The first probed field that no returned row carries, or undefined when
|
|
47
|
+
* every field is present or there is no row to look at.
|
|
48
|
+
*/
|
|
49
|
+
export declare function firstMissingFilterField(rows: unknown, probe: readonly string[]): string | undefined;
|
|
50
|
+
/** True when the request was extended for the check and then came back too large. */
|
|
51
|
+
export declare function isFilterEchoTooLarge(error: unknown, echo: FilterFieldEcho): boolean;
|
|
52
|
+
//# sourceMappingURL=unknown-filter-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknown-filter-fields.d.ts","sourceRoot":"","sources":["../src/unknown-filter-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,eAAe,CAkBjB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,GAAG,SAAS,CAcpB;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAEnF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Refuse a filter or order on a field the table does not have.
|
|
4
|
+
*
|
|
5
|
+
* ServiceNow drops a condition on a column it does not know, unless the
|
|
6
|
+
* instance sets glide.invalid_query.returns_no_rows (off by default and not a
|
|
7
|
+
* setting this server can rely on). A misspelt field therefore does not match
|
|
8
|
+
* nothing: the rest of the query runs and unrelated rows come back.
|
|
9
|
+
*
|
|
10
|
+
* The check costs no request. A column named in sysparm_fields that the table
|
|
11
|
+
* does not have, or that the integration user may not read, is left out of
|
|
12
|
+
* every row, so the filter's own fields are asked for on the read that is
|
|
13
|
+
* made anyway and the rows that come back show which of them exist.
|
|
14
|
+
*
|
|
15
|
+
* - A field counts as present when any returned row carries the key, not only
|
|
16
|
+
* the first: a field-level rule that depends on the record can hide a real
|
|
17
|
+
* column on some rows, never on a column that is absent from the table.
|
|
18
|
+
* - An existing column with no value is still returned (as an empty string),
|
|
19
|
+
* so an empty field is never mistaken for a missing one.
|
|
20
|
+
* - With no rows there is nothing to check. That is harmless: a read returns
|
|
21
|
+
* nothing, and a step that acts on the rows has nothing to act on.
|
|
22
|
+
* - Raw encoded queries are not parsed. They are only accepted through an
|
|
23
|
+
* owner-written policy rule that pins the query and its field names, so
|
|
24
|
+
* there is no caller-typed field to verify.
|
|
25
|
+
*
|
|
26
|
+
* The extra columns are asked for only when the caller's own field list does
|
|
27
|
+
* not already hold them, and callers drop them from the result.
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.echoFilterFields = echoFilterFields;
|
|
31
|
+
exports.firstMissingFilterField = firstMissingFilterField;
|
|
32
|
+
exports.isFilterEchoTooLarge = isFilterEchoTooLarge;
|
|
33
|
+
const client_js_1 = require("./client.js");
|
|
34
|
+
const tool_error_js_1 = require("./tool-error.js");
|
|
35
|
+
const CANONICAL_FIELD = tool_error_js_1.CANONICAL_FIELD_PATTERN;
|
|
36
|
+
/**
|
|
37
|
+
* The sysparm_fields to send, and the fields to look for in the rows.
|
|
38
|
+
*
|
|
39
|
+
* `requested` is the caller's own selection, comma separated, or undefined
|
|
40
|
+
* when the read asks for every column. A read for every column already
|
|
41
|
+
* returns each column of the table, so nothing is added; a dot-walked name is
|
|
42
|
+
* not returned by such a read, so it cannot be checked there and is skipped.
|
|
43
|
+
*/
|
|
44
|
+
function echoFilterFields(requested, referenced) {
|
|
45
|
+
const names = [...new Set(referenced)].filter((field) => CANONICAL_FIELD.test(field));
|
|
46
|
+
if (requested === undefined) {
|
|
47
|
+
return {
|
|
48
|
+
sysparmFields: undefined,
|
|
49
|
+
probe: Object.freeze(names.filter((field) => !field.includes("."))),
|
|
50
|
+
extended: false,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const listed = new Set(requested.split(","));
|
|
54
|
+
const extra = names.filter((field) => !listed.has(field));
|
|
55
|
+
return {
|
|
56
|
+
sysparmFields: extra.length === 0 ? requested : `${requested},${extra.join(",")}`,
|
|
57
|
+
probe: Object.freeze(names),
|
|
58
|
+
extended: extra.length > 0,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The first probed field that no returned row carries, or undefined when
|
|
63
|
+
* every field is present or there is no row to look at.
|
|
64
|
+
*/
|
|
65
|
+
function firstMissingFilterField(rows, probe) {
|
|
66
|
+
if (!Array.isArray(rows) || rows.length === 0 || probe.length === 0) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const pending = new Set(probe);
|
|
70
|
+
for (const row of rows) {
|
|
71
|
+
if (typeof row !== "object" || row === null)
|
|
72
|
+
continue;
|
|
73
|
+
for (const field of pending) {
|
|
74
|
+
if (Object.hasOwn(row, field))
|
|
75
|
+
pending.delete(field);
|
|
76
|
+
}
|
|
77
|
+
if (pending.size === 0)
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
// Set order is insertion order, so this is the first field in probe order.
|
|
81
|
+
return pending.values().next().value;
|
|
82
|
+
}
|
|
83
|
+
/** True when the request was extended for the check and then came back too large. */
|
|
84
|
+
function isFilterEchoTooLarge(error, echo) {
|
|
85
|
+
return echo.extended && (0, client_js_1.isServiceNowResponseTooLarge)(error);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=unknown-filter-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknown-filter-fields.js","sourceRoot":"","sources":["../src/unknown-filter-fields.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;AAwBH,4CAqBC;AAMD,0DAiBC;AAGD,oDAEC;AAvED,2CAA2D;AAC3D,mDAA0D;AAE1D,MAAM,eAAe,GAAG,uCAAuB,CAAC;AAWhD;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC9B,SAA6B,EAC7B,UAA6B;IAE7B,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CACtD,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAC5B,CAAC;IACF,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO;YACL,aAAa,EAAE,SAAS;YACxB,KAAK,EAAE,MAAM,CAAC,MAAM,CA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KAAK,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;IAC3C,CAAC;IACD,2EAA2E;IAC3E,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;AACvC,CAAC;AAED,qFAAqF;AACrF,SAAgB,oBAAoB,CAAC,KAAc,EAAE,IAAqB;IACxE,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAA,wCAA4B,EAAC,KAAK,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential-literal patterns for update-set payloads.
|
|
3
|
+
*
|
|
4
|
+
* One set of patterns serves two callers: the evaluator's SEC005 rule, which
|
|
5
|
+
* only needs to know that a pattern matched, and the payload view, which masks
|
|
6
|
+
* each matched value before it shows the text. Neither caller may echo what
|
|
7
|
+
* matched, so the results here carry pattern ids and offsets, never text, and
|
|
8
|
+
* the patterns themselves are not exported.
|
|
9
|
+
*
|
|
10
|
+
* Linear time by construction. Payloads come from other instances and the scan
|
|
11
|
+
* runs on the event loop every HTTP tenant shares, so no pattern may
|
|
12
|
+
* backtrack without bound:
|
|
13
|
+
* - each rule finds an anchor with a regular expression that starts with a
|
|
14
|
+
* literal, and whose quantifiers are all bounded (at most 40);
|
|
15
|
+
* - a hand-written reader then reads the secret value forward, one pass;
|
|
16
|
+
* - an anchor's look-behind excludes every character its reader consumes,
|
|
17
|
+
* so no anchor can start inside a value its rule has already read;
|
|
18
|
+
* - scanning resumes after whatever the reader consumed.
|
|
19
|
+
* Every rule is one linear pass, and a scan is one pass per rule.
|
|
20
|
+
*/
|
|
21
|
+
/** Stable ids, in scan order. Findings and counters name these, nothing else. */
|
|
22
|
+
export declare const SECRET_PATTERN_IDS: readonly ["basic_auth_call", "authorization_basic", "bearer_token", "key_header", "credential_assignment", "url_credentials", "url_query_secret", "private_key_block", "aws_access_key_id", "github_token", "slack_token", "slack_webhook", "google_api_key", "stripe_secret_key", "jwt"];
|
|
23
|
+
export type SecretPatternId = (typeof SECRET_PATTERN_IDS)[number];
|
|
24
|
+
/** What a masked value is replaced with. */
|
|
25
|
+
export declare const SECRET_MASK = "[masked]";
|
|
26
|
+
/**
|
|
27
|
+
* The longest text a scan accepts, in UTF-16 code units. The evaluator caps a
|
|
28
|
+
* payload at 256 kB and the payload view's text at 200 kB, so 1 Mi leaves room
|
|
29
|
+
* for either without letting a caller hand over an unbounded string.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SECRET_SCAN_MAX_CHARS = 1048576;
|
|
32
|
+
/** One match: the pattern, and the half-open span of the secret value. */
|
|
33
|
+
export interface SecretMatch {
|
|
34
|
+
readonly id: SecretPatternId;
|
|
35
|
+
readonly start: number;
|
|
36
|
+
readonly end: number;
|
|
37
|
+
}
|
|
38
|
+
export interface SecretScanOptions {
|
|
39
|
+
/** Stop after this many matches (default and ceiling: no limit below the text length). */
|
|
40
|
+
readonly maxMatches?: number;
|
|
41
|
+
}
|
|
42
|
+
export type SecretScanResult = {
|
|
43
|
+
readonly status: "ok";
|
|
44
|
+
/** Sorted by start offset, then by pattern order. Spans may overlap across patterns. */
|
|
45
|
+
readonly matches: readonly SecretMatch[];
|
|
46
|
+
/** True when `maxMatches` stopped the scan early. */
|
|
47
|
+
readonly truncated: boolean;
|
|
48
|
+
} | {
|
|
49
|
+
readonly status: "too_large";
|
|
50
|
+
};
|
|
51
|
+
export type SecretMaskResult = {
|
|
52
|
+
readonly status: "ok";
|
|
53
|
+
readonly text: string;
|
|
54
|
+
/** Masked spans after overlapping matches are merged. */
|
|
55
|
+
readonly masked: number;
|
|
56
|
+
/** The patterns that matched, in `SECRET_PATTERN_IDS` order. */
|
|
57
|
+
readonly ids: readonly SecretPatternId[];
|
|
58
|
+
} | {
|
|
59
|
+
readonly status: "too_large";
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Finds credential literals in `text`. Returns pattern ids and offsets only.
|
|
63
|
+
* Text longer than `SECRET_SCAN_MAX_CHARS` is refused (`too_large`) rather
|
|
64
|
+
* than scanned in part. A caller that shows a capped excerpt masks the whole
|
|
65
|
+
* text first and cuts it afterwards, so no value is split at the cut; text
|
|
66
|
+
* too large to mask is not shown.
|
|
67
|
+
*/
|
|
68
|
+
export declare function scanSecrets(text: string, options?: SecretScanOptions): SecretScanResult;
|
|
69
|
+
/**
|
|
70
|
+
* Replaces every matched secret value with `SECRET_MASK`. The text around a
|
|
71
|
+
* value (the call, the key, the quotes) is kept, so the masked text still
|
|
72
|
+
* reads as code. Masking is idempotent.
|
|
73
|
+
*/
|
|
74
|
+
export declare function maskSecrets(text: string): SecretMaskResult;
|
|
75
|
+
//# sourceMappingURL=secret-patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-patterns.d.ts","sourceRoot":"","sources":["../../src/update-set-eval/secret-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,2RAgBpB,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,4CAA4C;AAC5C,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,UAAY,CAAC;AAU/C,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,eAAe,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,MAAM,gBAAgB,GACxB;IACE,QAAQ,CAAC,MAAM,EAAE,IAAI,C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