@onlyflows/servicenow-mcp 2.3.0-rc.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/README.md +28 -1
  3. package/dist/field-policy.d.ts +13 -3
  4. package/dist/field-policy.d.ts.map +1 -1
  5. package/dist/field-policy.js +316 -23
  6. package/dist/field-policy.js.map +1 -1
  7. package/dist/policy-card.d.ts.map +1 -1
  8. package/dist/policy-card.js +2 -0
  9. package/dist/policy-card.js.map +1 -1
  10. package/dist/risky-grants.d.ts +6 -2
  11. package/dist/risky-grants.d.ts.map +1 -1
  12. package/dist/risky-grants.js +57 -5
  13. package/dist/risky-grants.js.map +1 -1
  14. package/dist/tools/platform-view-contracts.d.ts +2 -2
  15. package/dist/tools/platform-view-evaluate.d.ts +214 -6
  16. package/dist/tools/platform-view-evaluate.d.ts.map +1 -1
  17. package/dist/tools/platform-view-evaluate.js +1337 -10
  18. package/dist/tools/platform-view-evaluate.js.map +1 -1
  19. package/dist/update-set-eval/engine.d.ts +29 -0
  20. package/dist/update-set-eval/engine.d.ts.map +1 -0
  21. package/dist/update-set-eval/engine.js +405 -0
  22. package/dist/update-set-eval/engine.js.map +1 -0
  23. package/dist/update-set-eval/prepare.d.ts +72 -0
  24. package/dist/update-set-eval/prepare.d.ts.map +1 -0
  25. package/dist/update-set-eval/prepare.js +216 -0
  26. package/dist/update-set-eval/prepare.js.map +1 -0
  27. package/dist/update-set-eval/rules.d.ts +126 -0
  28. package/dist/update-set-eval/rules.d.ts.map +1 -0
  29. package/dist/update-set-eval/rules.js +927 -0
  30. package/dist/update-set-eval/rules.js.map +1 -0
  31. package/dist/update-set-eval/script-scan.d.ts +65 -0
  32. package/dist/update-set-eval/script-scan.d.ts.map +1 -0
  33. package/dist/update-set-eval/script-scan.js +378 -0
  34. package/dist/update-set-eval/script-scan.js.map +1 -0
  35. package/dist/update-set-eval/secret-patterns.js +2 -2
  36. package/dist/update-set-eval/secret-patterns.js.map +1 -1
  37. package/dist/update-set-eval/types.d.ts +181 -0
  38. package/dist/update-set-eval/types.d.ts.map +1 -0
  39. package/dist/update-set-eval/types.js +20 -0
  40. package/dist/update-set-eval/types.js.map +1 -0
  41. package/dist/version.d.ts +1 -1
  42. package/dist/version.d.ts.map +1 -1
  43. package/dist/version.js +1 -1
  44. package/dist/version.js.map +1 -1
  45. package/package.json +1 -1
  46. package/server.json +2 -2
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Prepares one `sys_update_xml` row for the rules, once.
3
+ *
4
+ * The payload is read once, every script element is tokenized once, and
5
+ * every element's text is scanned for credential literals once; all 32 rules
6
+ * share the result. A payload that is absent, too large or unreadable is
7
+ * marked so, and only metadata rules run on its row: it counts as not
8
+ * scanned, never as clean. A credential-table row keeps only an allowlist of
9
+ * metadata elements and is never scanned for scripts or values.
10
+ */
11
+ import { type SecretMatch } from "./secret-patterns.js";
12
+ import { type ScriptTokens } from "./script-scan.js";
13
+ import type { EvaluateContext, EvaluateUpdate, FindingUpdate } from "./types.js";
14
+ /** Matches kept per element: enough for SEC005 to look past excluded call shapes. */
15
+ export declare const SECRET_MATCHES_PER_FIELD = 64;
16
+ export declare const isTableName: (value: unknown) => value is string;
17
+ export declare const isFieldName: (value: string) => boolean;
18
+ export declare const isSysId: (value: unknown) => value is string;
19
+ export type ScriptSide = "server" | "client";
20
+ export interface PreparedRecord {
21
+ /** The element name, when it is a valid table name. */
22
+ readonly table: string | null;
23
+ /** The record's `action` attribute (`INSERT_OR_UPDATE`, `DELETE`, …). */
24
+ readonly action: string | null;
25
+ /** Each child element's own text, first occurrence. */
26
+ readonly fields: ReadonlyMap<string, string>;
27
+ /** Each child element's `display_value` attribute, when it has one. */
28
+ readonly displayValues: ReadonlyMap<string, string>;
29
+ }
30
+ export interface PreparedScript {
31
+ readonly record: number;
32
+ readonly field: string;
33
+ readonly side: ScriptSide;
34
+ readonly scan: ScriptTokens;
35
+ }
36
+ export interface PreparedSecrets {
37
+ readonly field: string;
38
+ /** The element's text, for the SEC005 call-shape check; never output. */
39
+ readonly text: string;
40
+ readonly matches: readonly SecretMatch[];
41
+ readonly truncated: boolean;
42
+ }
43
+ export type PayloadState = "read" | "absent" | "too_large" | "unreadable" | "credential";
44
+ export interface PreparedRow {
45
+ readonly update: EvaluateUpdate;
46
+ readonly finding: FindingUpdate;
47
+ /** The record's table: from the payload, then the `table` column, then the update name. */
48
+ readonly table: string | null;
49
+ readonly payload: PayloadState;
50
+ /** UTF-8 bytes of the payload that was read; 0 otherwise. */
51
+ readonly bytes: number;
52
+ /** The records in the payload, the main one first. Empty when the payload was not read. */
53
+ readonly records: readonly PreparedRecord[];
54
+ readonly scripts: readonly PreparedScript[];
55
+ readonly secrets: readonly PreparedSecrets[];
56
+ }
57
+ /** The row metadata a finding carries. Null when the row's ids are not valid sys_ids. */
58
+ export declare function findingUpdate(update: EvaluateUpdate): FindingUpdate | null;
59
+ export interface PrepareOptions {
60
+ readonly maxPayloadBytes: number;
61
+ /** Skip tokenizing scripts (no script rule will run). */
62
+ readonly scripts: boolean;
63
+ /** Skip the secret scan (SEC005 will not run). */
64
+ readonly secrets: boolean;
65
+ }
66
+ /**
67
+ * Prepares a row. `finding` must come from `findingUpdate` for the same row.
68
+ * Never throws on payload content. `context` must already fail closed (the
69
+ * engine wraps the caller's checks).
70
+ */
71
+ export declare function prepareRow(update: EvaluateUpdate, finding: FindingUpdate, payloadGranted: boolean, context: EvaluateContext, options: PrepareOptions): PreparedRow;
72
+ //# sourceMappingURL=prepare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../src/update-set-eval/prepare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,K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AAW,GAAG,YAAY,GAAG,YAAY,CAAC;AAEzF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAOD,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,GAAG,IAAI,CAS1E;AAkDD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,aAAa,EACtB,cAAc,EAAE,OAAO,EACvB,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,cAAc,GACtB,WAAW,CA6Eb"}
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ /**
3
+ * Prepares one `sys_update_xml` row for the rules, once.
4
+ *
5
+ * The payload is read once, every script element is tokenized once, and
6
+ * every element's text is scanned for credential literals once; all 32 rules
7
+ * share the result. A payload that is absent, too large or unreadable is
8
+ * marked so, and only metadata rules run on its row: it counts as not
9
+ * scanned, never as clean. A credential-table row keeps only an allowlist of
10
+ * metadata elements and is never scanned for scripts or values.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.isSysId = exports.isFieldName = exports.isTableName = exports.SECRET_MATCHES_PER_FIELD = void 0;
14
+ exports.findingUpdate = findingUpdate;
15
+ exports.prepareRow = prepareRow;
16
+ const secret_patterns_js_1 = require("./secret-patterns.js");
17
+ const script_scan_js_1 = require("./script-scan.js");
18
+ const xml_reader_js_1 = require("./xml-reader.js");
19
+ /** A table name the engine may put into a message or use as a key. */
20
+ const TABLE_NAME = /^[a-z][a-z0-9_]{0,79}$/u;
21
+ /** A payload element name the engine may report as a finding's `field`. */
22
+ const FIELD_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,79}$/u;
23
+ const SYS_ID = /^[0-9a-f]{32}$/u;
24
+ /** `<table>_<sys_id>`, the usual `sys_update_xml.name`. */
25
+ const UPDATE_NAME = /^([a-z][a-z0-9_]{0,79})_[0-9a-f]{32}$/u;
26
+ /** Row metadata is returned as data, capped so one row cannot bloat a result. */
27
+ const METADATA_MAX = 200;
28
+ /** Matches kept per element: enough for SEC005 to look past excluded call shapes. */
29
+ exports.SECRET_MATCHES_PER_FIELD = 64;
30
+ const isTableName = (value) => typeof value === "string" && TABLE_NAME.test(value);
31
+ exports.isTableName = isTableName;
32
+ const isFieldName = (value) => FIELD_NAME.test(value);
33
+ exports.isFieldName = isFieldName;
34
+ const isSysId = (value) => typeof value === "string" && SYS_ID.test(value);
35
+ exports.isSysId = isSysId;
36
+ /**
37
+ * Script elements per table. Any other table: `script` is server code,
38
+ * `client_script` is client code. A Map, because the key is instance text and
39
+ * a plain object would answer `constructor` from its prototype.
40
+ */
41
+ const SCRIPT_FIELDS = new Map(Object.entries({
42
+ sys_script: { server: ["script", "condition"] },
43
+ sys_script_include: { server: ["script"] },
44
+ sys_script_client: { client: ["script"] },
45
+ catalog_script_client: { client: ["script"] },
46
+ sys_ui_script: { client: ["script"] },
47
+ sys_ui_policy: { client: ["script_true", "script_false"] },
48
+ sys_ui_page: { server: ["processing_script"], client: ["client_script"] },
49
+ sp_widget: { server: ["script"], client: ["client_script", "link"] },
50
+ sys_ws_operation: { server: ["operation_script"] },
51
+ sys_processor: { server: ["script"] },
52
+ sysauto_script: { server: ["script"] },
53
+ sys_script_fix: { server: ["script"] },
54
+ sysevent_script_action: { server: ["script"] },
55
+ sys_security_acl: { server: ["script"] },
56
+ sys_transform_script: { server: ["script"] },
57
+ sys_transform_map: { server: ["script"] },
58
+ sys_transform_entry: { server: ["source_script"] },
59
+ sys_script_email: { server: ["script"] },
60
+ sysevent_email_action: { server: ["advanced_condition"] },
61
+ }));
62
+ /** On a credential-table row, only these elements are kept: metadata, never values. */
63
+ const CREDENTIAL_ROW_FIELDS = new Map([["sys_properties", ["name", "type"]]]);
64
+ function cap(value) {
65
+ if (typeof value !== "string")
66
+ return null;
67
+ return value.length > METADATA_MAX ? value.slice(0, METADATA_MAX) : value;
68
+ }
69
+ /** The row metadata a finding carries. Null when the row's ids are not valid sys_ids. */
70
+ function findingUpdate(update) {
71
+ if (!(0, exports.isSysId)(update.sys_id) || !(0, exports.isSysId)(update.update_set))
72
+ return null;
73
+ return {
74
+ sys_id: update.sys_id,
75
+ name: cap(update.name) ?? "",
76
+ type: cap(update.type),
77
+ target_name: cap(update.target_name),
78
+ update_set: update.update_set,
79
+ };
80
+ }
81
+ function metadataTable(update) {
82
+ if ((0, exports.isTableName)(update.table))
83
+ return update.table;
84
+ const match = typeof update.name === "string" ? UPDATE_NAME.exec(update.name) : null;
85
+ return match ? match[1] : null;
86
+ }
87
+ /**
88
+ * Reads a record's fields, or returns null when its shape is one the rules
89
+ * could not cover: a field name that repeats (which copy the platform applies
90
+ * is not the reader's call) or a field that holds elements (no rule reads
91
+ * nested content). The row is then not scanned, rather than half scanned.
92
+ */
93
+ function readRecord(element, keep) {
94
+ const fields = new Map();
95
+ const displayValues = new Map();
96
+ const seen = new Set();
97
+ for (const child of (0, xml_reader_js_1.childElements)(element)) {
98
+ if (seen.has(child.name) || child.children.some((node) => node.kind === "element"))
99
+ return null;
100
+ seen.add(child.name);
101
+ if (keep !== null && !keep.includes(child.name))
102
+ continue;
103
+ fields.set(child.name, (0, xml_reader_js_1.textContent)(child));
104
+ const display = (0, xml_reader_js_1.getAttribute)(child, "display_value");
105
+ if (display !== undefined)
106
+ displayValues.set(child.name, display);
107
+ }
108
+ return {
109
+ table: (0, exports.isTableName)(element.name) ? element.name : null,
110
+ action: (0, xml_reader_js_1.getAttribute)(element, "action") ?? null,
111
+ fields,
112
+ displayValues,
113
+ };
114
+ }
115
+ function scriptFields(table, record) {
116
+ const known = table === null ? undefined : SCRIPT_FIELDS.get(table);
117
+ const out = [];
118
+ if (known) {
119
+ for (const field of known.server ?? [])
120
+ out.push({ field, side: "server" });
121
+ for (const field of known.client ?? [])
122
+ out.push({ field, side: "client" });
123
+ }
124
+ else if (table === "sys_ui_action") {
125
+ // A UI action's script runs in the browser when `client` is true; its condition runs on the server.
126
+ out.push({ field: "script", side: record.fields.get("client") === "true" ? "client" : "server" });
127
+ out.push({ field: "condition", side: "server" });
128
+ }
129
+ else {
130
+ out.push({ field: "script", side: "server" }, { field: "client_script", side: "client" });
131
+ }
132
+ return out.filter(({ field }) => (record.fields.get(field) ?? "").trim().length > 0);
133
+ }
134
+ /**
135
+ * Prepares a row. `finding` must come from `findingUpdate` for the same row.
136
+ * Never throws on payload content. `context` must already fail closed (the
137
+ * engine wraps the caller's checks).
138
+ */
139
+ function prepareRow(update, finding, payloadGranted, context, options) {
140
+ const fallbackTable = metadataTable(update);
141
+ const base = { update, finding, bytes: 0, records: [], scripts: [], secrets: [] };
142
+ const credential = fallbackTable !== null && context.isCredentialTable(fallbackTable);
143
+ if (!payloadGranted || typeof update.payload !== "string" || update.payload.length === 0) {
144
+ return { ...base, table: fallbackTable, payload: credential ? "credential" : "absent" };
145
+ }
146
+ const read = (0, xml_reader_js_1.readXml)(update.payload, { maxBytes: options.maxPayloadBytes });
147
+ if (!read.ok) {
148
+ return {
149
+ ...base,
150
+ table: fallbackTable,
151
+ payload: credential ? "credential" : read.code === "too_large" ? "too_large" : "unreadable",
152
+ };
153
+ }
154
+ const unreadable = (table) => ({
155
+ ...base,
156
+ table,
157
+ payload: credential ? "credential" : "unreadable",
158
+ bytes: read.document.bytes,
159
+ });
160
+ // A payload is <record_update table="…"> around its records; any other root is not read.
161
+ const root = read.document.root;
162
+ if (root.name !== "record_update")
163
+ return unreadable(fallbackTable);
164
+ const elements = (0, xml_reader_js_1.childElements)(root);
165
+ const rootTable = (0, xml_reader_js_1.getAttribute)(root, "table");
166
+ const first = elements[0]?.name;
167
+ // A root table that names another table than the record element would send
168
+ // the record to the wrong script fields.
169
+ if (rootTable !== undefined && first !== undefined && rootTable !== first)
170
+ return unreadable(fallbackTable);
171
+ const table = (0, exports.isTableName)(rootTable) ? rootTable : (0, exports.isTableName)(first) ? first : fallbackTable;
172
+ // A credential row: the column, the root, or any record element is a credential table.
173
+ const isCredential = credential ||
174
+ (table !== null && context.isCredentialTable(table)) ||
175
+ elements.some((element) => (0, exports.isTableName)(element.name) && context.isCredentialTable(element.name));
176
+ if (isCredential) {
177
+ const keep = (table !== null ? CREDENTIAL_ROW_FIELDS.get(table) : undefined) ?? [];
178
+ const records = elements.map((element) => readRecord(element, keep));
179
+ return {
180
+ ...base,
181
+ table,
182
+ payload: "credential",
183
+ bytes: read.document.bytes,
184
+ records: records.every((r) => r !== null) ? records : [],
185
+ };
186
+ }
187
+ const parsed = elements.map((element) => readRecord(element, null));
188
+ if (!parsed.every((r) => r !== null))
189
+ return unreadable(table);
190
+ const records = parsed;
191
+ const scripts = [];
192
+ if (options.scripts) {
193
+ records.forEach((record, index) => {
194
+ const recordTable = index === 0 ? table : record.table;
195
+ for (const { field, side } of scriptFields(recordTable, record)) {
196
+ scripts.push({ record: index, field, side, scan: (0, script_scan_js_1.tokenize)(record.fields.get(field) ?? "") });
197
+ }
198
+ });
199
+ }
200
+ const secrets = [];
201
+ if (options.secrets) {
202
+ for (const record of records) {
203
+ for (const [field, text] of record.fields) {
204
+ if (text.length === 0)
205
+ continue;
206
+ const scan = (0, secret_patterns_js_1.scanSecrets)(text, { maxMatches: exports.SECRET_MATCHES_PER_FIELD + 1 });
207
+ // A field over the scan cap cannot be over the payload cap, which is lower.
208
+ if (scan.status === "ok" && scan.matches.length > 0) {
209
+ secrets.push({ field, text, matches: scan.matches, truncated: scan.truncated });
210
+ }
211
+ }
212
+ }
213
+ }
214
+ return { ...base, table, payload: "read", bytes: read.document.bytes, records, scripts, secrets };
215
+ }
216
+ //# sourceMappingURL=prepare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/update-set-eval/prepare.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA0GH,sCASC;AA+DD,gCAmFC;AAnQD,6DAAqE;AACrE,qDAA+D;AAE/D,mDAAqG;AAErG,sEAAsE;AACtE,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAC7C,2EAA2E;AAC3E,MAAM,UAAU,GAAG,gCAAgC,CAAC;AACpD,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACjC,2DAA2D;AAC3D,MAAM,WAAW,GAAG,wCAAwC,CAAC;AAE7D,iFAAiF;AACjF,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,qFAAqF;AACxE,QAAA,wBAAwB,GAAG,EAAE,CAAC;AAEpC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAAvG,QAAA,WAAW,eAA4F;AAC7G,MAAM,WAAW,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAAjE,QAAA,WAAW,eAAsD;AACvE,MAAM,OAAO,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,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AE,CAAC;AACpG,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * The evaluator's 32 rules.
3
+ *
4
+ * Row rules run once per prepared row, and set rules once per call. Every
5
+ * rule reads the shared preparation (the parsed records, tokenized scripts
6
+ * and secret matches) and never rescans payload text. Messages are fixed
7
+ * sentences with no instance text; SEC011's table is a separate field.
8
+ * SEC005 and SEC010 findings carry no field and no line.
9
+ *
10
+ * The rules are heuristics, and a clean result is not an approval. Known limits:
11
+ * - Script rules read only the script elements listed for each table (see
12
+ * `prepare.ts`). Script elsewhere is not examined: `g:evaluate` and other
13
+ * Jelly in UI pages and macros, `javascript:` default values, reference
14
+ * qualifiers and conditions, and Flow Designer inline scripts.
15
+ * - The tokenizer does not parse. Code inside a template literal's `${…}` is
16
+ * part of the literal; a regular expression is told from a division by the
17
+ * token before it, so `{} / eval(x) / 1` hides the call; PERF001 sees only
18
+ * braced loop bodies; PERF002 treats a variable as script-wide.
19
+ * - SEC004 sees `eval(`, `gs.eval(`, `new Function(`, the evaluator classes,
20
+ * unicode-escaped spellings of those names, and bracket access with a
21
+ * constant name (`gs['eval']`). It does not see computed names
22
+ * (`this['ev' + 'al']`) or aliases (`var e = eval; e(x)`).
23
+ * - SEC009 sees `setWorkflow` and `autoSysFields` called with `false`, `0`
24
+ * or `!1`; not with a variable or another falsy expression.
25
+ * - SEC005 scans the decoded text of every element of every record that is
26
+ * not on a credential table: script and non-script fields alike, comments
27
+ * and `${…}` included. It finds what `secret-patterns.ts` matches: a
28
+ * literal assigned to or passed with a credential-named key, credentials in
29
+ * URLs, headers and connection strings, private keys and vendor token
30
+ * shapes. It does not follow a secret through a variable, rebuild a
31
+ * concatenation that does not start with a literal, or decode base64.
32
+ */
33
+ import { type PreparedRow } from "./prepare.js";
34
+ import type { Confidence, EvaluateSet, EvaluationInput, RuleGroup, Severity } from "./types.js";
35
+ export declare const RULES_VERSION = "1";
36
+ export declare const RULE_IDS: readonly ["PERF001", "PERF002", "PERF003", "PERF004", "PERF005", "PERF006", "PERF007", "PERF008", "PERF009", "SEC001", "SEC002", "SEC003", "SEC004", "SEC005", "SEC006", "SEC007", "SEC008", "SEC009", "SEC010", "SEC011", "BP001", "BP002", "BP003", "BP004", "BP005", "BP006", "BP007", "BP008", "BP009", "BP010", "BP011", "BP012"];
37
+ export type RuleId = (typeof RULE_IDS)[number];
38
+ export declare function ruleGroup(id: RuleId): RuleGroup;
39
+ /** Fixed messages. None holds instance text: SEC011's table goes in the finding's `table` field. */
40
+ export declare const RULE_MESSAGES: Readonly<{
41
+ readonly PERF001: "A query runs inside a loop over query results (N+1 queries).";
42
+ readonly PERF002: "A GlideRecord query runs with no filter or limit (full-table scan).";
43
+ readonly PERF003: "getRowCount() counts rows by reading them; use GlideAggregate.";
44
+ readonly PERF004: "A business rule runs on every query of its table.";
45
+ readonly PERF004_QUERY: "A business rule runs on every query of its table and itself queries.";
46
+ readonly PERF005: "A client script makes a synchronous server round trip.";
47
+ readonly PERF006: "A business rule that is not async makes an outbound call the user waits on.";
48
+ readonly PERF007: "A business rule calls current.update(), which writes twice and can recurse.";
49
+ readonly PERF008: "A script sleeps or busy-waits, holding a worker.";
50
+ readonly PERF009: "The set has more than 1,000 updates, which slows preview and commit.";
51
+ readonly PERF009_HIGH: "The set has more than 5,000 updates, which slows preview and commit.";
52
+ readonly PERF009_BATCH: "The batch has more than 1,000 updates, which slows preview and commit.";
53
+ readonly PERF009_BATCH_HIGH: "The batch has more than 5,000 updates, which slows preview and commit.";
54
+ readonly SEC001: "An access control rule changes.";
55
+ readonly SEC001_HIGH: "An access control rule is deleted, always grants access, or has no role, condition or script.";
56
+ readonly SEC002: "A role or role containment changes.";
57
+ readonly SEC002_CRITICAL: "A role or role containment change involves an elevated role.";
58
+ readonly SEC003: "A script include is callable from the browser.";
59
+ readonly SEC003_HIGH: "A script include is callable from the browser and its isPublic() returns true.";
60
+ readonly SEC004: "A script evaluates dynamic code.";
61
+ readonly SEC005: "A script or value holds what looks like a credential literal.";
62
+ readonly SEC006: "A system property changes.";
63
+ readonly SEC006_HIGH: "A security-related or password-typed system property changes.";
64
+ readonly SEC007: "A cross-scope access is allowed, or a script include is public across scopes.";
65
+ readonly SEC008: "An unauthenticated entry point is added or changed.";
66
+ readonly SEC009: "A script turns off business rules or system-field updates for its writes.";
67
+ readonly SEC010: "The update carries credentials to the target instance.";
68
+ readonly SEC011: "The update writes a data record, on a table that does not extend sys_metadata, which overwrites data on the target instance.";
69
+ readonly BP001: "The set is the Default update set, which cannot be promoted.";
70
+ readonly BP002: "The set's updates belong to more than one application, or to another application than the set.";
71
+ readonly BP003: "The update deletes a record, which is hard to back out.";
72
+ readonly BP004: "A preview problem is not resolved, so the commit is blocked.";
73
+ readonly BP004_LOCAL: "Another open update set holds the same update; the last writer wins.";
74
+ readonly BP005: "The update changes a baseline record, so upgrades will skip it.";
75
+ readonly BP006: "The set has no description.";
76
+ readonly BP007: "A batch member's state differs from its root's (partial promotion).";
77
+ readonly BP008: "The same update is in more than one set of the batch; the result depends on order.";
78
+ readonly BP009: "The set is empty.";
79
+ readonly BP010: "A script holds a hard-coded sys_id, which differs between instances.";
80
+ readonly BP011: "Server code logs with gs.log, gs.print or console.log.";
81
+ readonly BP012: "The update is marked replace on upgrade.";
82
+ }>;
83
+ export interface RuleFinding {
84
+ readonly rule_id: RuleId;
85
+ readonly severity: Severity;
86
+ readonly confidence: Confidence;
87
+ readonly message: string;
88
+ readonly field?: string;
89
+ readonly line?: number;
90
+ readonly table?: string;
91
+ }
92
+ export type Emit = (finding: RuleFinding) => void;
93
+ /** Counters a rule bumps when it needs a fact the caller did not supply. */
94
+ export interface RuleNotes {
95
+ unavailable: number;
96
+ }
97
+ export interface RowRule {
98
+ readonly id: RuleId;
99
+ /** Runs only when the payload was read (and, for script rules, not on credential rows). */
100
+ readonly needs: "payload" | "metadata";
101
+ readonly run: (row: PreparedRow, input: EvaluationInput, emit: Emit, notes: RuleNotes) => void;
102
+ }
103
+ /**
104
+ * The call a matched value is an argument of: `g_form.setMandatory('password', '…')`
105
+ * or `gr.addEncodedQuery('…key=…')`. Every backward read is bounded, so a
106
+ * check costs a constant; null when the shape is anything else.
107
+ */
108
+ export declare function callBefore(text: string, start: number): {
109
+ receiver: string;
110
+ method: string;
111
+ } | null;
112
+ export declare const ROW_RULES: readonly RowRule[];
113
+ /** Preview-problem statuses that no longer block a commit; anything else, empty included, blocks. */
114
+ export declare const RESOLVED_PROBLEM_STATUS: ReadonlySet<string>;
115
+ export type SetEmit = (set: EvaluateSet, finding: RuleFinding) => void;
116
+ export interface SetRule {
117
+ readonly id: RuleId;
118
+ readonly run: (input: EvaluationInput, emit: SetEmit, notes: RuleNotes) => void;
119
+ }
120
+ export declare const SET_RULES: readonly SetRule[];
121
+ /**
122
+ * BP008 needs every row of the batch at once: the same update name in more
123
+ * than one set. It reports each row whose name another set also holds.
124
+ */
125
+ export declare function duplicateNamesAcrossSets(input: EvaluationInput): ReadonlySet<string>;
126
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/update-set-eval/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAYH,OAAO,EAAiD,KAAK,WAAW,EAAwC,MAAM,cAAc,CAAC;AACrI,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEhG,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,eAAO,MAAM,QAAQ,wUAIV,CAAC;AACZ,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAE/C;AAED,oGAAoG;AACpG,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Cf,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