@burdenoff/ui-engine 2026.1127.4 → 2026.1129.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -4
- package/dist/analyze/analyze.d.ts +19 -0
- package/dist/analyze/context.d.ts +40 -0
- package/dist/analyze/index.d.ts +10 -0
- package/dist/analyze/messages.d.ts +46 -0
- package/dist/analyze/rules/fixed-wait.d.ts +6 -0
- package/dist/analyze/rules/hardware-input.d.ts +2 -0
- package/dist/analyze/rules/heal-consequential.d.ts +2 -0
- package/dist/analyze/rules/index.d.ts +3 -0
- package/dist/analyze/rules/inline-target.d.ts +2 -0
- package/dist/analyze/rules/masked-value.d.ts +8 -0
- package/dist/analyze/rules/no-cleanup.d.ts +2 -0
- package/dist/analyze/rules/plain-text-secret.d.ts +2 -0
- package/dist/analyze/rules/popup-handler-loop.d.ts +2 -0
- package/dist/analyze/rules/rule.d.ts +15 -0
- package/dist/analyze/rules/secret-origin.d.ts +7 -0
- package/dist/analyze/rules/sensitive-screenshot.d.ts +2 -0
- package/dist/analyze/rules/single-method-target.d.ts +2 -0
- package/dist/analyze/rules/unknown-variable.d.ts +2 -0
- package/dist/analyze/rules/unused-value.d.ts +2 -0
- package/dist/analyze/sensitive.d.ts +14 -0
- package/dist/analyze/types.d.ts +89 -0
- package/dist/analyze.d.ts +2 -0
- package/dist/analyze.js +26 -0
- package/dist/dom-runtime.iife.js +1 -1
- package/dist/dom-runtime.js +2 -2
- package/dist/drivers.js +13 -9
- package/dist/heal/answer.d.ts +26 -0
- package/dist/heal/consequence.d.ts +74 -0
- package/dist/heal/index.d.ts +19 -0
- package/dist/heal/modes.d.ts +25 -0
- package/dist/heal/popup-limits.d.ts +11 -0
- package/dist/heal/popup.d.ts +48 -0
- package/dist/heal/question.d.ts +41 -0
- package/dist/heal/target-from-node.d.ts +9 -0
- package/dist/heal/types.d.ts +134 -0
- package/dist/heal/verify-rules.d.ts +19 -0
- package/dist/heal/verify.d.ts +52 -0
- package/dist/heal.d.ts +2 -0
- package/dist/heal.js +106 -0
- package/dist/index-20bbwwc9.js +37 -0
- package/dist/{index-pm13mvvc.js → index-2g060ryg.js} +3 -196
- package/dist/index-6h7ah1dw.js +328 -0
- package/dist/{index-h88y5qgv.js → index-6kva2gvd.js} +6 -4
- package/dist/{index-ct2xctrq.js → index-70vm0qz8.js} +2 -2
- package/dist/{index-3f1j8386.js → index-8w31tpfq.js} +38 -19
- package/dist/{index-zzhysbkj.js → index-eff47v1g.js} +436 -20
- package/dist/{index-3jymbm5t.js → index-g7724awk.js} +1 -92
- package/dist/index-gvavb597.js +195 -0
- package/dist/index-hw5npwsv.js +63 -0
- package/dist/{index-ycs2bz1a.js → index-mhv6a02p.js} +11 -166
- package/dist/index-p5823rpv.js +0 -0
- package/dist/{index-5k26keah.js → index-qg9yfr7r.js} +16 -67
- package/dist/{index-895kscx3.js → index-qmv3ar39.js} +7 -5
- package/dist/index-t55wvhvh.js +229 -0
- package/dist/{index-77pcz6n3.js → index-vnv9tp11.js} +4 -2
- package/dist/index-w9jc25y9.js +306 -0
- package/dist/index-xdtanv9b.js +843 -0
- package/dist/{index-vg8r40y7.js → index-yc0jgph6.js} +7 -0
- package/dist/index-zhbwhdya.js +407 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +156 -26
- package/dist/interpret/driver.d.ts +14 -0
- package/dist/interpret/errors.d.ts +11 -2
- package/dist/interpret/events.d.ts +4 -0
- package/dist/interpret/run.d.ts +33 -0
- package/dist/interpret.js +5 -4
- package/dist/script.js +29 -23
- package/dist/target/index.d.ts +2 -0
- package/dist/target/roles.d.ts +11 -0
- package/dist/target/snapshot-mask.d.ts +49 -0
- package/dist/target/snapshot-tree.d.ts +65 -0
- package/dist/target/snapshot-url.d.ts +6 -0
- package/dist/target/snapshot.d.ts +1 -6
- package/dist/target.js +55 -13
- package/dist/testing.js +2 -2
- package/package.json +11 -3
|
@@ -0,0 +1,843 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describeTarget2
|
|
3
|
+
} from "./index-gvavb597.js";
|
|
4
|
+
import {
|
|
5
|
+
UI_FLOW_ACTIONS2,
|
|
6
|
+
walkSteps2,
|
|
7
|
+
stepTargets2,
|
|
8
|
+
stepExpressions2,
|
|
9
|
+
visitExpression2
|
|
10
|
+
} from "./index-g7724awk.js";
|
|
11
|
+
|
|
12
|
+
// src/heal/consequence.ts
|
|
13
|
+
var MAX_HEAL_KEYWORDS2 = 50;
|
|
14
|
+
var MAX_HEAL_KEYWORD_LENGTH2 = 100;
|
|
15
|
+
var CONSEQUENCE_KEYWORDS2 = Object.freeze({
|
|
16
|
+
payment: [
|
|
17
|
+
"pay",
|
|
18
|
+
"pay now",
|
|
19
|
+
"payment",
|
|
20
|
+
"payments",
|
|
21
|
+
"checkout",
|
|
22
|
+
"check out",
|
|
23
|
+
"purchase",
|
|
24
|
+
"buy",
|
|
25
|
+
"buy now",
|
|
26
|
+
"place order",
|
|
27
|
+
"order now",
|
|
28
|
+
"confirm order",
|
|
29
|
+
"submit order",
|
|
30
|
+
"complete order",
|
|
31
|
+
"complete purchase",
|
|
32
|
+
"subscribe",
|
|
33
|
+
"donate",
|
|
34
|
+
"transfer",
|
|
35
|
+
"send money",
|
|
36
|
+
"wire",
|
|
37
|
+
"charge",
|
|
38
|
+
"billing",
|
|
39
|
+
"top up",
|
|
40
|
+
"add funds",
|
|
41
|
+
"withdraw",
|
|
42
|
+
"refund",
|
|
43
|
+
"invoice payment"
|
|
44
|
+
],
|
|
45
|
+
delete: [
|
|
46
|
+
"delete",
|
|
47
|
+
"remove",
|
|
48
|
+
"erase",
|
|
49
|
+
"destroy",
|
|
50
|
+
"discard",
|
|
51
|
+
"trash",
|
|
52
|
+
"purge",
|
|
53
|
+
"wipe",
|
|
54
|
+
"deactivate",
|
|
55
|
+
"terminate",
|
|
56
|
+
"close account",
|
|
57
|
+
"cancel subscription",
|
|
58
|
+
"cancel account",
|
|
59
|
+
"cancel order",
|
|
60
|
+
"unsubscribe",
|
|
61
|
+
"clear all",
|
|
62
|
+
"permanently"
|
|
63
|
+
],
|
|
64
|
+
send_external: [
|
|
65
|
+
"send",
|
|
66
|
+
"submit",
|
|
67
|
+
"publish",
|
|
68
|
+
"post",
|
|
69
|
+
"share",
|
|
70
|
+
"email",
|
|
71
|
+
"reply",
|
|
72
|
+
"forward",
|
|
73
|
+
"invite",
|
|
74
|
+
"broadcast",
|
|
75
|
+
"notify",
|
|
76
|
+
"message",
|
|
77
|
+
"tweet",
|
|
78
|
+
"upload",
|
|
79
|
+
"file return"
|
|
80
|
+
],
|
|
81
|
+
security: [
|
|
82
|
+
"password",
|
|
83
|
+
"change password",
|
|
84
|
+
"reset password",
|
|
85
|
+
"two factor",
|
|
86
|
+
"2fa",
|
|
87
|
+
"mfa",
|
|
88
|
+
"security",
|
|
89
|
+
"permission",
|
|
90
|
+
"permissions",
|
|
91
|
+
"grant",
|
|
92
|
+
"revoke",
|
|
93
|
+
"api key",
|
|
94
|
+
"access token",
|
|
95
|
+
"authorize",
|
|
96
|
+
"authorise",
|
|
97
|
+
"allow access",
|
|
98
|
+
"make admin",
|
|
99
|
+
"admin",
|
|
100
|
+
"sign out everywhere",
|
|
101
|
+
"log out everywhere"
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
var ORDER = ["payment", "delete", "security", "send_external"];
|
|
105
|
+
var ACTING_ACTIONS = new Set(["click", "doubleClick", "check", "select", "pressKey"]);
|
|
106
|
+
function keywordWords2(text) {
|
|
107
|
+
return text.replace(/([a-z])([A-Z])/g, "$1 $2").normalize("NFKC").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
108
|
+
}
|
|
109
|
+
function containsPhrase(words, phrase) {
|
|
110
|
+
if (phrase.length === 0 || phrase.length > words.length)
|
|
111
|
+
return false;
|
|
112
|
+
for (let start = 0;start + phrase.length <= words.length; start += 1) {
|
|
113
|
+
let all = true;
|
|
114
|
+
for (let offset = 0;offset < phrase.length; offset += 1) {
|
|
115
|
+
if (words[start + offset] !== phrase[offset]) {
|
|
116
|
+
all = false;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (all)
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
var BUILT_IN = ORDER.map((consequence) => [consequence, CONSEQUENCE_KEYWORDS2[consequence].map(keywordWords2)]);
|
|
126
|
+
function builtInClass(words) {
|
|
127
|
+
for (const [consequence, phrases] of BUILT_IN) {
|
|
128
|
+
if (phrases.some((phrase) => containsPhrase(words, phrase)))
|
|
129
|
+
return consequence;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
function usableKeywords2(keywords) {
|
|
134
|
+
const usable = [];
|
|
135
|
+
for (const keyword of (keywords ?? []).slice(0, MAX_HEAL_KEYWORDS2)) {
|
|
136
|
+
if (typeof keyword !== "string")
|
|
137
|
+
continue;
|
|
138
|
+
const trimmed = keyword.trim();
|
|
139
|
+
if (trimmed.length === 0 || trimmed.length > MAX_HEAL_KEYWORD_LENGTH2)
|
|
140
|
+
continue;
|
|
141
|
+
usable.push(trimmed);
|
|
142
|
+
}
|
|
143
|
+
return usable;
|
|
144
|
+
}
|
|
145
|
+
function isActingStep(step) {
|
|
146
|
+
return ACTING_ACTIONS.has(step.action) || step.action === "type" && step.pressEnter === true;
|
|
147
|
+
}
|
|
148
|
+
function isSubmitControl(element) {
|
|
149
|
+
const tag = element.tag?.toLowerCase();
|
|
150
|
+
const type = element.type?.toLowerCase();
|
|
151
|
+
if (tag === "button")
|
|
152
|
+
return type === undefined || type === "" || type === "submit";
|
|
153
|
+
return tag === "input" && (type === "submit" || type === "image");
|
|
154
|
+
}
|
|
155
|
+
function classifyConsequence2(element, step, extraKeywords) {
|
|
156
|
+
if (!isActingStep(step))
|
|
157
|
+
return { consequence: null, keyword: null };
|
|
158
|
+
const own = [element.name ?? "", element.href ?? "", ...element.hints ?? []].flatMap(keywordWords2);
|
|
159
|
+
const formWords = keywordWords2(element.formWords ?? "");
|
|
160
|
+
const submits = isSubmitControl(element) || step.action === "type" || step.action === "pressKey";
|
|
161
|
+
const words = submits ? [...own, ...formWords] : own;
|
|
162
|
+
const consequence = builtInClass(words);
|
|
163
|
+
let keyword = null;
|
|
164
|
+
for (const phrase of usableKeywords2(extraKeywords)) {
|
|
165
|
+
if (containsPhrase(words, keywordWords2(phrase))) {
|
|
166
|
+
keyword = phrase;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return { consequence, keyword };
|
|
171
|
+
}
|
|
172
|
+
function elementInfoFromTarget2(target, elementName) {
|
|
173
|
+
const names = elementName ? [elementName] : [];
|
|
174
|
+
const hints = [];
|
|
175
|
+
let role;
|
|
176
|
+
for (const method of target.methods) {
|
|
177
|
+
switch (method.kind) {
|
|
178
|
+
case "role":
|
|
179
|
+
role ??= method.role;
|
|
180
|
+
names.push(method.name);
|
|
181
|
+
break;
|
|
182
|
+
case "fuzzy":
|
|
183
|
+
if (method.role)
|
|
184
|
+
role ??= method.role;
|
|
185
|
+
names.push(method.name);
|
|
186
|
+
break;
|
|
187
|
+
case "text":
|
|
188
|
+
names.push(method.text);
|
|
189
|
+
break;
|
|
190
|
+
case "anchor":
|
|
191
|
+
break;
|
|
192
|
+
case "testId":
|
|
193
|
+
hints.push(method.value);
|
|
194
|
+
break;
|
|
195
|
+
case "css":
|
|
196
|
+
hints.push(method.selector);
|
|
197
|
+
break;
|
|
198
|
+
case "xpath":
|
|
199
|
+
hints.push(method.xpath);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return { ...role === undefined ? {} : { role }, name: names.join(" "), hints };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/analyze/context.ts
|
|
207
|
+
function stepNumber2(path) {
|
|
208
|
+
return path.split(".").filter((part) => part !== "then" && part !== "steps").map((part) => /^\d+$/.test(part) ? String(Number(part) + 1) : part).join(".");
|
|
209
|
+
}
|
|
210
|
+
function createContext(script, options) {
|
|
211
|
+
const elements = script.elements ?? {};
|
|
212
|
+
const steps = [];
|
|
213
|
+
const disabledBlocks = [];
|
|
214
|
+
let order = 0;
|
|
215
|
+
for (const { step, path } of walkSteps2(script)) {
|
|
216
|
+
const index = order;
|
|
217
|
+
order += 1;
|
|
218
|
+
if (disabledBlocks.some((prefix) => path.startsWith(prefix)))
|
|
219
|
+
continue;
|
|
220
|
+
if (step.disabled === true) {
|
|
221
|
+
disabledBlocks.push(`${path}.`);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
steps.push({ step, path, number: stepNumber2(path), order: index });
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
script,
|
|
228
|
+
options,
|
|
229
|
+
elements,
|
|
230
|
+
steps,
|
|
231
|
+
totalSteps: order,
|
|
232
|
+
targetOf: (ref) => ("element" in ref) ? elements[ref.element]?.target : ref,
|
|
233
|
+
describeTarget: (ref) => describeTarget2(ref, elements)
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function variablesRead(expression) {
|
|
237
|
+
const names = [];
|
|
238
|
+
visitExpression2(expression, (node) => {
|
|
239
|
+
if (node !== null && typeof node === "object" && "var" in node)
|
|
240
|
+
names.push(node.var);
|
|
241
|
+
});
|
|
242
|
+
return names;
|
|
243
|
+
}
|
|
244
|
+
function stepVariablesRead(step) {
|
|
245
|
+
return stepExpressions2(step).flatMap(([, expression]) => variablesRead(expression));
|
|
246
|
+
}
|
|
247
|
+
function stepVariablesSet(step) {
|
|
248
|
+
const names = [];
|
|
249
|
+
if (step.saveAs !== undefined)
|
|
250
|
+
names.push(step.saveAs);
|
|
251
|
+
if (step.action === "set")
|
|
252
|
+
names.push(step.name);
|
|
253
|
+
if (step.action === "forEach") {
|
|
254
|
+
names.push(step.as);
|
|
255
|
+
if (step.index !== undefined)
|
|
256
|
+
names.push(step.index);
|
|
257
|
+
}
|
|
258
|
+
return names;
|
|
259
|
+
}
|
|
260
|
+
function signsIn(step) {
|
|
261
|
+
return step.action === "login" || step.action === "typeSecret";
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// src/analyze/messages.ts
|
|
265
|
+
var UI_SCRIPT_PROBLEM_KEY_PREFIX2 = "fluidgrids.builder.uiScript.problem.";
|
|
266
|
+
var UI_SCRIPT_PROBLEM_MESSAGES2 = {
|
|
267
|
+
fixedWait: "Step {{step}} waits a fixed {{milliseconds}} ms. Wait for an element, a text or an address instead, so the step neither fails on a slow page nor wastes time on a fast one.",
|
|
268
|
+
singleMethodTarget: "Step {{step}} finds {{target}} by one method only. Add another method so a page change does not break the step.",
|
|
269
|
+
noEnabledMethod: "Step {{step}} has every method of {{target}} switched off, so it can never find the element. Switch a method on.",
|
|
270
|
+
hardwareInput: "Step {{step}} uses hardware input, which needs the browser window in front and the screen unlocked. Use automatic input unless the page refuses it.",
|
|
271
|
+
hardwareInputSettings: "The script uses hardware input for every step, which needs the browser window in front and the screen unlocked. Use automatic input unless a page refuses it.",
|
|
272
|
+
unknownVariable: "Step {{step}} reads {{name}}, but no step sets it and the script does not declare it, so it is empty when the step runs.",
|
|
273
|
+
unknownVariableOutput: "The output {{output}} reads {{name}}, but no step sets it and the script does not declare it, so the output is always empty.",
|
|
274
|
+
unknownVariableInitial: "The initial value of the variable {{variable}} reads {{name}}, but no step sets it and the script does not declare it, so it reads as empty.",
|
|
275
|
+
unknownVariableDefault: "The default of the input {{input}} reads {{name}}, but no step sets it and the script does not declare it, so it reads as empty.",
|
|
276
|
+
maskedValue: "Step {{step}} types a value that was hidden during recording. Give it a value, such as a workflow input, or the run stops at this step.",
|
|
277
|
+
typeWithoutValue: "Step {{step}} has no value to type, so it types nothing. Give it a value or remove the step.",
|
|
278
|
+
noCleanup: "The script signs in at step {{step}} but has no clean-up steps. Add clean-up steps that sign out or close the tab, so a failed run does not leave the session open.",
|
|
279
|
+
plainTextSecret: "Step {{step}} types into {{target}}, which looks like a password or code field, with a plain Type step. Use Type secret with a connection so the value is never stored or shown.",
|
|
280
|
+
secretOrigin: "Step {{step}} types a secret without an expected site. Set the site the secret may be typed into, so it is never typed into another page.",
|
|
281
|
+
sensitiveScreenshot: "Step {{step}} signs in or types a secret and takes a screenshot every time it runs. Take screenshots of this step on failure only.",
|
|
282
|
+
sensitiveScreenshotSettings: "The script takes a screenshot of every step, including step {{step}}, which signs in or types a secret. Take screenshots on failure only, or turn them off for that step.",
|
|
283
|
+
inlineTarget: "Step {{step}} uses an inline target. Add it to the Element library so other workflows can reuse it.",
|
|
284
|
+
unusedValue: "Step {{step}} stores {{name}}, but no step, output or later node reads it.",
|
|
285
|
+
unusedVariable: "The variable {{name}} is declared, but no step reads it.",
|
|
286
|
+
healConsequential: "Step {{step}} acts on {{target}}, which looks like a {{consequence}} control. If healing finds a new target for it, a person must approve the change before the step runs.",
|
|
287
|
+
healAlwaysAskKeyword: "Step {{step}} acts on {{target}}, which matches the always-ask phrase {{keyword}}. If healing finds a new target for it, a person must approve the change before the step runs.",
|
|
288
|
+
popupHandlerFlow: "Pop-up handler step {{step}} is a {{action}} block. A handler is a short, straight list of steps, so it can never loop.",
|
|
289
|
+
popupHandlerAction: "Pop-up handler step {{step}} uses {{action}}. A handler may only click, check, press keys, hover, scroll or wait.",
|
|
290
|
+
popupHandlerConsequential: "Pop-up handler step {{step}} acts on {{target}}, which looks like a {{consequence}} control. A handler never acts on such a control.",
|
|
291
|
+
popupHandlerWait: "Pop-up handler step {{step}} waits {{milliseconds}} ms. A handler step waits at most 5,000 ms, so a pop-up never holds up a run.",
|
|
292
|
+
popupHandlerNoAction: "The pop-up handler has no step that clicks, checks or presses a key, so it cannot clear the pop-up."
|
|
293
|
+
};
|
|
294
|
+
function problemMessageKey2(name) {
|
|
295
|
+
return `${UI_SCRIPT_PROBLEM_KEY_PREFIX2}${name}`;
|
|
296
|
+
}
|
|
297
|
+
function problemMessage2(name, vars) {
|
|
298
|
+
return UI_SCRIPT_PROBLEM_MESSAGES2[name].replace(/\{\{(\w+)\}\}/g, (_match, variable) => String(vars[variable] ?? ""));
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// src/analyze/rules/rule.ts
|
|
302
|
+
function stepFinding(active, message, vars = {}, field) {
|
|
303
|
+
return {
|
|
304
|
+
message,
|
|
305
|
+
vars: { step: active.number, ...vars },
|
|
306
|
+
path: active.path,
|
|
307
|
+
stepId: active.step.id,
|
|
308
|
+
...field === undefined ? {} : { field },
|
|
309
|
+
order: active.order
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// src/analyze/rules/fixed-wait.ts
|
|
314
|
+
var fixedWaitRule = {
|
|
315
|
+
id: "fixedWait",
|
|
316
|
+
group: "reliability",
|
|
317
|
+
severity: "warning",
|
|
318
|
+
description: "A Wait step that waits a fixed time instead of for an element, a text or an address.",
|
|
319
|
+
check: (context) => context.steps.flatMap((active) => active.step.action === "waitFor" && active.step.milliseconds !== undefined ? [stepFinding(active, "fixedWait", { milliseconds: active.step.milliseconds }, "milliseconds")] : [])
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/analyze/rules/hardware-input.ts
|
|
323
|
+
var FLOW_ACTIONS = new Set(UI_FLOW_ACTIONS2);
|
|
324
|
+
var hardwareInputRule = {
|
|
325
|
+
id: "hardwareInput",
|
|
326
|
+
group: "reliability",
|
|
327
|
+
severity: "warning",
|
|
328
|
+
description: "Hardware input, set for the whole script or for one step.",
|
|
329
|
+
check: (context) => {
|
|
330
|
+
const findings = [];
|
|
331
|
+
const scriptWide = context.script.settings?.inputMethod === "hardware" && context.steps.some((active) => !FLOW_ACTIONS.has(active.step.action) && active.step.inputMethod === undefined);
|
|
332
|
+
if (scriptWide) {
|
|
333
|
+
findings.push({ message: "hardwareInputSettings", vars: {}, field: "settings.inputMethod", order: -1 });
|
|
334
|
+
}
|
|
335
|
+
for (const active of context.steps) {
|
|
336
|
+
if (active.step.inputMethod === "hardware" && !scriptWide) {
|
|
337
|
+
findings.push(stepFinding(active, "hardwareInput", {}, "inputMethod"));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return findings;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
// src/heal/verify-rules.ts
|
|
345
|
+
var HEALABLE_ACTIONS2 = new Set([
|
|
346
|
+
"click",
|
|
347
|
+
"doubleClick",
|
|
348
|
+
"hover",
|
|
349
|
+
"type",
|
|
350
|
+
"clear",
|
|
351
|
+
"check",
|
|
352
|
+
"select",
|
|
353
|
+
"getText",
|
|
354
|
+
"getValue",
|
|
355
|
+
"getAttribute",
|
|
356
|
+
"waitFor"
|
|
357
|
+
]);
|
|
358
|
+
var CLICKABLE = [
|
|
359
|
+
"button",
|
|
360
|
+
"link",
|
|
361
|
+
"checkbox",
|
|
362
|
+
"menuitem",
|
|
363
|
+
"menuitemcheckbox",
|
|
364
|
+
"menuitemradio",
|
|
365
|
+
"tab",
|
|
366
|
+
"option",
|
|
367
|
+
"radio",
|
|
368
|
+
"switch",
|
|
369
|
+
"treeitem",
|
|
370
|
+
"combobox",
|
|
371
|
+
"gridcell"
|
|
372
|
+
];
|
|
373
|
+
var TYPEABLE = ["textbox", "searchbox", "combobox", "spinbutton"];
|
|
374
|
+
var ROLES_BY_ACTION = {
|
|
375
|
+
click: new Set(CLICKABLE),
|
|
376
|
+
doubleClick: new Set(CLICKABLE),
|
|
377
|
+
hover: new Set([...CLICKABLE, "img"]),
|
|
378
|
+
type: new Set(TYPEABLE),
|
|
379
|
+
clear: new Set(TYPEABLE),
|
|
380
|
+
check: new Set(["checkbox", "radio", "switch", "menuitemcheckbox", "menuitemradio"]),
|
|
381
|
+
select: new Set(["combobox", "listbox"])
|
|
382
|
+
};
|
|
383
|
+
function compatibleRoles2(action) {
|
|
384
|
+
return ROLES_BY_ACTION[action];
|
|
385
|
+
}
|
|
386
|
+
var VALUE_ACTIONS2 = new Set(["type", "clear", "select"]);
|
|
387
|
+
var ACTIONABLE_ROLES = new Set([
|
|
388
|
+
...CLICKABLE,
|
|
389
|
+
...TYPEABLE,
|
|
390
|
+
"listbox",
|
|
391
|
+
"slider",
|
|
392
|
+
"spinbutton"
|
|
393
|
+
]);
|
|
394
|
+
|
|
395
|
+
// src/analyze/rules/heal-consequential.ts
|
|
396
|
+
var CONSEQUENCE_WORDS = {
|
|
397
|
+
payment: "payment",
|
|
398
|
+
delete: "delete",
|
|
399
|
+
send_external: "send-outside",
|
|
400
|
+
security: "security"
|
|
401
|
+
};
|
|
402
|
+
var healConsequentialRule = {
|
|
403
|
+
id: "healConsequential",
|
|
404
|
+
group: "security",
|
|
405
|
+
severity: "info",
|
|
406
|
+
description: "A step that acts on a payment, delete, send or security control, or on an always-ask phrase.",
|
|
407
|
+
check: (context) => {
|
|
408
|
+
const healing = context.options.healing;
|
|
409
|
+
if (!healing)
|
|
410
|
+
return [];
|
|
411
|
+
const alwaysAsk = new Set(healing.alwaysAskStepIds ?? []);
|
|
412
|
+
const findings = [];
|
|
413
|
+
for (const active of context.steps) {
|
|
414
|
+
const step = active.step;
|
|
415
|
+
if (!HEALABLE_ACTIONS2.has(step.action) || alwaysAsk.has(step.id) || !("target" in step) || !step.target)
|
|
416
|
+
continue;
|
|
417
|
+
const target = context.targetOf(step.target);
|
|
418
|
+
if (!target)
|
|
419
|
+
continue;
|
|
420
|
+
const name = "element" in step.target ? context.elements[step.target.element]?.name : undefined;
|
|
421
|
+
const verdict = classifyConsequence2(elementInfoFromTarget2(target, name), { action: step.action, ...step.action === "type" && step.pressEnter === true ? { pressEnter: true } : {} }, healing.keywords);
|
|
422
|
+
const vars = { target: context.describeTarget(step.target) };
|
|
423
|
+
if (verdict.consequence) {
|
|
424
|
+
findings.push(stepFinding(active, "healConsequential", { ...vars, consequence: CONSEQUENCE_WORDS[verdict.consequence] }, "target"));
|
|
425
|
+
} else if (verdict.keyword) {
|
|
426
|
+
findings.push(stepFinding(active, "healAlwaysAskKeyword", { ...vars, keyword: `"${verdict.keyword}"` }, "target"));
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return findings;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
// src/analyze/rules/inline-target.ts
|
|
434
|
+
var inlineTargetRule = {
|
|
435
|
+
id: "inlineTarget",
|
|
436
|
+
group: "maintainability",
|
|
437
|
+
severity: "info",
|
|
438
|
+
description: "A step that holds its target inline instead of using an Element library element.",
|
|
439
|
+
check: (context) => context.steps.flatMap((active) => {
|
|
440
|
+
const inline = stepTargets2(active.step).find(([, ref]) => !("element" in ref));
|
|
441
|
+
if (!inline)
|
|
442
|
+
return [];
|
|
443
|
+
const [field, ref] = inline;
|
|
444
|
+
return [stepFinding(active, "inlineTarget", { target: context.describeTarget(ref) }, field)];
|
|
445
|
+
})
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/analyze/rules/masked-value.ts
|
|
449
|
+
var maskedValueRule = {
|
|
450
|
+
id: "maskedValue",
|
|
451
|
+
group: "reliability",
|
|
452
|
+
severity: "warning",
|
|
453
|
+
description: "A Type step whose value was masked during recording, or that has no value at all.",
|
|
454
|
+
check: (context) => context.steps.flatMap((active) => {
|
|
455
|
+
const step = active.step;
|
|
456
|
+
if (step.action !== "type" || step.text !== undefined)
|
|
457
|
+
return [];
|
|
458
|
+
return [stepFinding(active, step.masked === true ? "maskedValue" : "typeWithoutValue", {}, "text")];
|
|
459
|
+
})
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
// src/analyze/rules/no-cleanup.ts
|
|
463
|
+
var noCleanupRule = {
|
|
464
|
+
id: "noCleanup",
|
|
465
|
+
group: "reliability",
|
|
466
|
+
severity: "warning",
|
|
467
|
+
description: "A script that signs in or types a secret but has no clean-up step that runs.",
|
|
468
|
+
check: (context) => {
|
|
469
|
+
const hasCleanup = context.steps.some((active) => active.path.startsWith("cleanup."));
|
|
470
|
+
if (hasCleanup)
|
|
471
|
+
return [];
|
|
472
|
+
const first = context.steps.find((active) => signsIn(active.step));
|
|
473
|
+
return first ? [stepFinding(first, "noCleanup")] : [];
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// src/analyze/sensitive.ts
|
|
478
|
+
var SECRET_FIELD = /password|passcode|passwd|\bpin\b|\botp\b|one[\s-]?time|\bverification\b|security code|auth(?:entication)? code|\bcvv\b|\bcvc\b|card number|\bsecrets?\b|\btokens?\b|\brecovery\b/i;
|
|
479
|
+
var PASSWORD_TYPE = /type\s*=\s*["']?password/i;
|
|
480
|
+
function words(text) {
|
|
481
|
+
return text.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
482
|
+
}
|
|
483
|
+
function readsLikeSecret(text) {
|
|
484
|
+
return PASSWORD_TYPE.test(text) || SECRET_FIELD.test(words(text));
|
|
485
|
+
}
|
|
486
|
+
function targetWords(target) {
|
|
487
|
+
const texts = [];
|
|
488
|
+
for (const method of target.methods) {
|
|
489
|
+
switch (method.kind) {
|
|
490
|
+
case "role":
|
|
491
|
+
case "fuzzy":
|
|
492
|
+
texts.push(method.name);
|
|
493
|
+
break;
|
|
494
|
+
case "css":
|
|
495
|
+
texts.push(method.selector);
|
|
496
|
+
break;
|
|
497
|
+
case "testId":
|
|
498
|
+
texts.push(method.value);
|
|
499
|
+
break;
|
|
500
|
+
case "xpath":
|
|
501
|
+
texts.push(method.xpath);
|
|
502
|
+
break;
|
|
503
|
+
case "anchor":
|
|
504
|
+
texts.push(method.anchor.kind === "text" ? method.anchor.text : method.anchor.name);
|
|
505
|
+
break;
|
|
506
|
+
default:
|
|
507
|
+
texts.push(method.text);
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return texts;
|
|
512
|
+
}
|
|
513
|
+
function looksLikeSecretField(target, elementName) {
|
|
514
|
+
if (elementName !== undefined && readsLikeSecret(elementName))
|
|
515
|
+
return true;
|
|
516
|
+
return target !== undefined && targetWords(target).some(readsLikeSecret);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// src/analyze/rules/plain-text-secret.ts
|
|
520
|
+
var plainTextSecretRule = {
|
|
521
|
+
id: "plainTextSecret",
|
|
522
|
+
group: "security",
|
|
523
|
+
severity: "warning",
|
|
524
|
+
description: "A plain Type step into a field that looks like a password or code field.",
|
|
525
|
+
check: (context) => context.steps.flatMap((active) => {
|
|
526
|
+
const step = active.step;
|
|
527
|
+
if (step.action !== "type" || !step.target)
|
|
528
|
+
return [];
|
|
529
|
+
const name = "element" in step.target ? context.elements[step.target.element]?.name : undefined;
|
|
530
|
+
if (!looksLikeSecretField(context.targetOf(step.target), name))
|
|
531
|
+
return [];
|
|
532
|
+
return [stepFinding(active, "plainTextSecret", { target: context.describeTarget(step.target) }, "target")];
|
|
533
|
+
})
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// src/heal/popup-limits.ts
|
|
537
|
+
var MAX_POPUP_HANDLERS_PER_STEP2 = 2;
|
|
538
|
+
var MAX_POPUP_HANDLERS_PER_APPLICATION2 = 50;
|
|
539
|
+
var MAX_POPUP_HANDLER_STEPS2 = 10;
|
|
540
|
+
var MAX_POPUP_URL_PATTERN2 = 500;
|
|
541
|
+
var POPUP_HANDLER_STEP_WAIT_MS2 = 5000;
|
|
542
|
+
|
|
543
|
+
// src/analyze/rules/popup-handler-loop.ts
|
|
544
|
+
var FLOW = new Set(["if", "forEach", "while", "retryScope", "call"]);
|
|
545
|
+
var ALLOWED = new Set(["click", "doubleClick", "hover", "check", "pressKey", "scroll", "waitFor"]);
|
|
546
|
+
var CLEARING = new Set(["click", "doubleClick", "check", "pressKey"]);
|
|
547
|
+
var CONSEQUENCE_WORDS2 = {
|
|
548
|
+
payment: "payment",
|
|
549
|
+
delete: "delete",
|
|
550
|
+
send_external: "send-outside",
|
|
551
|
+
security: "security"
|
|
552
|
+
};
|
|
553
|
+
var popupHandlerLoopRule = {
|
|
554
|
+
id: "popupHandlerLoop",
|
|
555
|
+
group: "reliability",
|
|
556
|
+
severity: "warning",
|
|
557
|
+
description: "A pop-up handler that could loop, leave the page, type, or press a consequential control.",
|
|
558
|
+
check: (context) => {
|
|
559
|
+
if (!context.options.popupHandler)
|
|
560
|
+
return [];
|
|
561
|
+
const findings = [];
|
|
562
|
+
let clears = false;
|
|
563
|
+
for (const active of context.steps) {
|
|
564
|
+
const step = active.step;
|
|
565
|
+
if (FLOW.has(step.action)) {
|
|
566
|
+
findings.push(stepFinding(active, "popupHandlerFlow", { action: step.action }, "action"));
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
if (!ALLOWED.has(step.action)) {
|
|
570
|
+
findings.push(stepFinding(active, "popupHandlerAction", { action: step.action }, "action"));
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
if (CLEARING.has(step.action))
|
|
574
|
+
clears = true;
|
|
575
|
+
const wait = step.action === "waitFor" && step.milliseconds !== undefined ? step.milliseconds : step.timeoutMs;
|
|
576
|
+
if (wait !== undefined && wait > POPUP_HANDLER_STEP_WAIT_MS2) {
|
|
577
|
+
findings.push(stepFinding(active, "popupHandlerWait", { milliseconds: wait }, "timeoutMs"));
|
|
578
|
+
}
|
|
579
|
+
if (!("target" in step) || !step.target)
|
|
580
|
+
continue;
|
|
581
|
+
const target = context.targetOf(step.target);
|
|
582
|
+
if (!target)
|
|
583
|
+
continue;
|
|
584
|
+
const verdict = classifyConsequence2(elementInfoFromTarget2(target), { action: step.action });
|
|
585
|
+
if (verdict.consequence) {
|
|
586
|
+
findings.push(stepFinding(active, "popupHandlerConsequential", { target: context.describeTarget(step.target), consequence: CONSEQUENCE_WORDS2[verdict.consequence] }, "target"));
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (!clears)
|
|
590
|
+
findings.push({ message: "popupHandlerNoAction", vars: {}, order: -1 });
|
|
591
|
+
return findings;
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
// src/analyze/rules/secret-origin.ts
|
|
596
|
+
var secretOriginRule = {
|
|
597
|
+
id: "secretOrigin",
|
|
598
|
+
group: "security",
|
|
599
|
+
severity: "warning",
|
|
600
|
+
description: "A Type secret step without an expected site.",
|
|
601
|
+
check: (context) => context.steps.flatMap((active) => active.step.action === "typeSecret" && active.step.expectedOrigin === undefined ? [stepFinding(active, "secretOrigin", {}, "expectedOrigin")] : [])
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
// src/analyze/rules/sensitive-screenshot.ts
|
|
605
|
+
var sensitiveScreenshotRule = {
|
|
606
|
+
id: "sensitiveScreenshot",
|
|
607
|
+
group: "security",
|
|
608
|
+
severity: "warning",
|
|
609
|
+
description: "A step that signs in or types a secret and takes a screenshot every time it runs.",
|
|
610
|
+
check: (context) => {
|
|
611
|
+
const everyStep = context.script.settings?.screenshots === "everyStep";
|
|
612
|
+
const findings = [];
|
|
613
|
+
for (const active of context.steps) {
|
|
614
|
+
const step = active.step;
|
|
615
|
+
const sensitive = signsIn(step) || step.action === "type" && step.target !== undefined && looksLikeSecretField(context.targetOf(step.target), "element" in step.target ? context.elements[step.target.element]?.name : undefined);
|
|
616
|
+
if (!sensitive)
|
|
617
|
+
continue;
|
|
618
|
+
if (step.screenshot === "always")
|
|
619
|
+
findings.push(stepFinding(active, "sensitiveScreenshot", {}, "screenshot"));
|
|
620
|
+
else if (step.screenshot === undefined && everyStep) {
|
|
621
|
+
findings.push(stepFinding(active, "sensitiveScreenshotSettings", {}, "settings.screenshots"));
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return findings;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
// src/analyze/rules/single-method-target.ts
|
|
629
|
+
var singleMethodTargetRule = {
|
|
630
|
+
id: "singleMethodTarget",
|
|
631
|
+
group: "reliability",
|
|
632
|
+
severity: "warning",
|
|
633
|
+
description: "A target with only one method switched on, or with none.",
|
|
634
|
+
check: (context) => {
|
|
635
|
+
const findings = [];
|
|
636
|
+
const seenElements = new Set;
|
|
637
|
+
for (const active of context.steps) {
|
|
638
|
+
for (const [field, ref] of stepTargets2(active.step)) {
|
|
639
|
+
if ("element" in ref) {
|
|
640
|
+
if (seenElements.has(ref.element))
|
|
641
|
+
continue;
|
|
642
|
+
seenElements.add(ref.element);
|
|
643
|
+
}
|
|
644
|
+
const target = context.targetOf(ref);
|
|
645
|
+
if (!target)
|
|
646
|
+
continue;
|
|
647
|
+
const enabled = target.methods.filter((method) => method.enabled !== false).length;
|
|
648
|
+
if (enabled > 1)
|
|
649
|
+
continue;
|
|
650
|
+
findings.push(stepFinding(active, enabled === 0 ? "noEnabledMethod" : "singleMethodTarget", { target: context.describeTarget(ref) }, field));
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return findings;
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
// src/analyze/rules/unknown-variable.ts
|
|
658
|
+
var unknownVariableRule = {
|
|
659
|
+
id: "unknownVariable",
|
|
660
|
+
group: "reliability",
|
|
661
|
+
severity: "warning",
|
|
662
|
+
description: "A variable that a step, an output, a variable initial value or an input default reads, but that no step sets and the script does not declare.",
|
|
663
|
+
check: (context) => {
|
|
664
|
+
const { script } = context;
|
|
665
|
+
const known = new Set((script.variables ?? []).map((variable) => variable.name));
|
|
666
|
+
for (const active of context.steps)
|
|
667
|
+
for (const name of stepVariablesSet(active.step))
|
|
668
|
+
known.add(name);
|
|
669
|
+
const unknown = (expression) => [...new Set(variablesRead(expression))].filter((name) => !known.has(name));
|
|
670
|
+
const findings = [];
|
|
671
|
+
script.inputs?.forEach((input, index) => {
|
|
672
|
+
if (input.default === undefined)
|
|
673
|
+
return;
|
|
674
|
+
for (const name of unknown(input.default)) {
|
|
675
|
+
findings.push({
|
|
676
|
+
message: "unknownVariableDefault",
|
|
677
|
+
vars: { input: input.name, name },
|
|
678
|
+
field: `inputs.${index}.default`,
|
|
679
|
+
order: -1
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
script.variables?.forEach((variable, index) => {
|
|
684
|
+
if (variable.initial === undefined)
|
|
685
|
+
return;
|
|
686
|
+
for (const name of unknown(variable.initial)) {
|
|
687
|
+
findings.push({
|
|
688
|
+
message: "unknownVariableInitial",
|
|
689
|
+
vars: { variable: variable.name, name },
|
|
690
|
+
field: `variables.${index}.initial`,
|
|
691
|
+
order: -1
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
for (const active of context.steps) {
|
|
696
|
+
for (const name of new Set(stepVariablesRead(active.step))) {
|
|
697
|
+
if (!known.has(name))
|
|
698
|
+
findings.push(stepFinding(active, "unknownVariable", { name }));
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
script.outputs?.forEach((output, index) => {
|
|
702
|
+
for (const name of unknown(output.value)) {
|
|
703
|
+
findings.push({
|
|
704
|
+
message: "unknownVariableOutput",
|
|
705
|
+
vars: { output: output.name, name },
|
|
706
|
+
field: `outputs.${index}.value`,
|
|
707
|
+
order: context.totalSteps + index
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
return findings;
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
// src/analyze/rules/unused-value.ts
|
|
716
|
+
var LOCAL_PREFIX = "__";
|
|
717
|
+
var unusedValueRule = {
|
|
718
|
+
id: "unusedValue",
|
|
719
|
+
group: "maintainability",
|
|
720
|
+
severity: "info",
|
|
721
|
+
description: "A stored value or a declared variable that nothing reads.",
|
|
722
|
+
check: (context) => {
|
|
723
|
+
const { script, options } = context;
|
|
724
|
+
const read = new Set(options.externalReads ?? []);
|
|
725
|
+
for (const active of context.steps)
|
|
726
|
+
for (const name of stepVariablesRead(active.step))
|
|
727
|
+
read.add(name);
|
|
728
|
+
for (const output of script.outputs ?? [])
|
|
729
|
+
for (const name of variablesRead(output.value))
|
|
730
|
+
read.add(name);
|
|
731
|
+
for (const variable of script.variables ?? []) {
|
|
732
|
+
if (variable.initial !== undefined)
|
|
733
|
+
for (const name of variablesRead(variable.initial))
|
|
734
|
+
read.add(name);
|
|
735
|
+
}
|
|
736
|
+
for (const input of script.inputs ?? []) {
|
|
737
|
+
if (input.default !== undefined)
|
|
738
|
+
for (const name of variablesRead(input.default))
|
|
739
|
+
read.add(name);
|
|
740
|
+
}
|
|
741
|
+
const reportable = (name) => !read.has(name) && (options.externalReads !== undefined || name.startsWith(LOCAL_PREFIX));
|
|
742
|
+
const findings = [];
|
|
743
|
+
const setByStep = new Set;
|
|
744
|
+
for (const active of context.steps) {
|
|
745
|
+
const step = active.step;
|
|
746
|
+
if (step.action === "set") {
|
|
747
|
+
setByStep.add(step.name);
|
|
748
|
+
if (reportable(step.name))
|
|
749
|
+
findings.push(stepFinding(active, "unusedValue", { name: step.name }, "name"));
|
|
750
|
+
}
|
|
751
|
+
if (step.saveAs !== undefined) {
|
|
752
|
+
setByStep.add(step.saveAs);
|
|
753
|
+
if (reportable(step.saveAs))
|
|
754
|
+
findings.push(stepFinding(active, "unusedValue", { name: step.saveAs }, "saveAs"));
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
script.variables?.forEach((variable, index) => {
|
|
758
|
+
if (read.has(variable.name) || setByStep.has(variable.name))
|
|
759
|
+
return;
|
|
760
|
+
findings.push({
|
|
761
|
+
message: "unusedVariable",
|
|
762
|
+
vars: { name: variable.name },
|
|
763
|
+
field: `variables.${index}`,
|
|
764
|
+
order: -1
|
|
765
|
+
});
|
|
766
|
+
});
|
|
767
|
+
return findings;
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
// src/analyze/rules/index.ts
|
|
772
|
+
var UI_ANALYZER_RULES2 = [
|
|
773
|
+
fixedWaitRule,
|
|
774
|
+
singleMethodTargetRule,
|
|
775
|
+
hardwareInputRule,
|
|
776
|
+
unknownVariableRule,
|
|
777
|
+
maskedValueRule,
|
|
778
|
+
noCleanupRule,
|
|
779
|
+
plainTextSecretRule,
|
|
780
|
+
secretOriginRule,
|
|
781
|
+
sensitiveScreenshotRule,
|
|
782
|
+
inlineTargetRule,
|
|
783
|
+
unusedValueRule,
|
|
784
|
+
healConsequentialRule,
|
|
785
|
+
popupHandlerLoopRule
|
|
786
|
+
];
|
|
787
|
+
|
|
788
|
+
// src/analyze/types.ts
|
|
789
|
+
var UI_PROBLEM_SEVERITIES2 = ["warning", "info"];
|
|
790
|
+
var UI_ANALYZER_RULE_GROUPS2 = ["reliability", "security", "maintainability"];
|
|
791
|
+
var UI_ANALYZER_RULE_IDS2 = [
|
|
792
|
+
"fixedWait",
|
|
793
|
+
"singleMethodTarget",
|
|
794
|
+
"hardwareInput",
|
|
795
|
+
"unknownVariable",
|
|
796
|
+
"maskedValue",
|
|
797
|
+
"noCleanup",
|
|
798
|
+
"plainTextSecret",
|
|
799
|
+
"secretOrigin",
|
|
800
|
+
"sensitiveScreenshot",
|
|
801
|
+
"inlineTarget",
|
|
802
|
+
"unusedValue",
|
|
803
|
+
"healConsequential",
|
|
804
|
+
"popupHandlerLoop"
|
|
805
|
+
];
|
|
806
|
+
|
|
807
|
+
// src/analyze/analyze.ts
|
|
808
|
+
var UI_ANALYZER_DEFAULT_SEVERITY2 = Object.freeze(Object.fromEntries(UI_ANALYZER_RULES2.map((rule) => [rule.id, rule.severity])));
|
|
809
|
+
function severitySetting(setting, fallback) {
|
|
810
|
+
if (setting === "off")
|
|
811
|
+
return "off";
|
|
812
|
+
return UI_PROBLEM_SEVERITIES2.find((severity) => severity === setting) ?? fallback;
|
|
813
|
+
}
|
|
814
|
+
function analyzeUiScript2(script, options = {}) {
|
|
815
|
+
const context = createContext(script, options);
|
|
816
|
+
const found = [];
|
|
817
|
+
UI_ANALYZER_RULES2.forEach((rule, rank) => {
|
|
818
|
+
const setting = severitySetting(options.severity?.[rule.id], rule.severity);
|
|
819
|
+
if (setting === "off")
|
|
820
|
+
return;
|
|
821
|
+
for (const finding of rule.check(context)) {
|
|
822
|
+
found.push({
|
|
823
|
+
problem: {
|
|
824
|
+
rule: rule.id,
|
|
825
|
+
group: rule.group,
|
|
826
|
+
severity: setting,
|
|
827
|
+
messageKey: problemMessageKey2(finding.message),
|
|
828
|
+
vars: finding.vars,
|
|
829
|
+
message: problemMessage2(finding.message, finding.vars),
|
|
830
|
+
...finding.path === undefined ? {} : { path: finding.path },
|
|
831
|
+
...finding.stepId === undefined ? {} : { stepId: finding.stepId },
|
|
832
|
+
...finding.field === undefined ? {} : { field: finding.field }
|
|
833
|
+
},
|
|
834
|
+
order: finding.order,
|
|
835
|
+
rank,
|
|
836
|
+
seq: found.length
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
return found.sort((a, b) => a.order - b.order || a.rank - b.rank || a.seq - b.seq).map(({ problem }) => problem);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
export { MAX_HEAL_KEYWORDS2, MAX_HEAL_KEYWORD_LENGTH2, CONSEQUENCE_KEYWORDS2, keywordWords2, usableKeywords2, isActingStep, classifyConsequence2, elementInfoFromTarget2, stepNumber2, UI_SCRIPT_PROBLEM_KEY_PREFIX2, UI_SCRIPT_PROBLEM_MESSAGES2, problemMessageKey2, problemMessage2, HEALABLE_ACTIONS2, compatibleRoles2, VALUE_ACTIONS2, ACTIONABLE_ROLES, MAX_POPUP_HANDLERS_PER_STEP2, MAX_POPUP_HANDLERS_PER_APPLICATION2, MAX_POPUP_HANDLER_STEPS2, MAX_POPUP_URL_PATTERN2, POPUP_HANDLER_STEP_WAIT_MS2, UI_ANALYZER_RULES2, UI_PROBLEM_SEVERITIES2, UI_ANALYZER_RULE_GROUPS2, UI_ANALYZER_RULE_IDS2, UI_ANALYZER_DEFAULT_SEVERITY2, analyzeUiScript2 };
|