@reticlehq/core 3.8.0 → 3.8.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/dist/artifacts/drive-script.d.ts +84 -1217
- package/dist/artifacts/drive-script.js +1 -1
- package/dist/artifacts/flow-expect-flat.d.ts +8 -192
- package/dist/artifacts/flow-expect-flat.js +2 -2
- package/dist/artifacts/flow-results.d.ts +15 -0
- package/dist/artifacts/flow-types.d.ts +202 -2331
- package/dist/artifacts/flow-types.js +2 -2
- package/dist/artifacts/harness-map.d.ts +8 -69
- package/dist/artifacts/harness-map.js +1 -1
- package/dist/artifacts/hud-notices.d.ts +8 -82
- package/dist/artifacts/hud-notices.js +1 -1
- package/dist/artifacts/impact.d.ts +80 -1638
- package/dist/artifacts/impact.js +4 -4
- package/dist/artifacts/journal.d.ts +12 -247
- package/dist/artifacts/journal.js +2 -2
- package/dist/artifacts/prompt-context.d.ts +5 -43
- package/dist/artifacts/prompt-context.js +1 -1
- package/dist/artifacts/screenshot-upload.d.ts +3 -26
- package/dist/artifacts/screenshot-upload.js +1 -1
- package/dist/hooks/hook-events.d.ts +15 -171
- package/dist/hooks/hook-events.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/onboarding.d.ts +8 -58
- package/dist/onboarding.js +1 -1
- package/dist/registry/daemon-registry.d.ts +2 -14
- package/dist/registry/daemon-registry.js +1 -1
- package/dist/registry/dev-server-registry.d.ts +2 -31
- package/dist/registry/dev-server-registry.js +1 -1
- package/dist/registry/project-registry.d.ts +4 -32
- package/dist/registry/project-registry.js +1 -1
- package/dist/schema/command-message.json +65 -68
- package/dist/schema/command-name.json +29 -33
- package/dist/schema/command-result.json +25 -30
- package/dist/schema/event-message.json +104 -103
- package/dist/schema/event-payloads.json +142 -119
- package/dist/schema/event-type.json +47 -50
- package/dist/schema/hello-message.json +150 -154
- package/dist/schema/reticle-event.json +98 -96
- package/dist/schema/reticle-message.json +338 -333
- package/dist/telemetry-bug.d.ts +4 -75
- package/dist/telemetry-bug.js +1 -1
- package/dist/telemetry-feedback.d.ts +11 -99
- package/dist/telemetry-feedback.js +1 -1
- package/dist/telemetry-refusal.d.ts +4 -31
- package/dist/telemetry-refusal.js +1 -1
- package/dist/telemetry-session.d.ts +39 -633
- package/dist/telemetry-session.js +10 -8
- package/dist/telemetry-signals.d.ts +58 -151
- package/dist/telemetry-signals.js +12 -1
- package/dist/telemetry.d.ts +137 -1814
- package/dist/telemetry.js +1 -1
- package/dist/verdict/compare-source.d.ts +1 -1
- package/dist/verdict/compare-source.js +1 -1
- package/dist/verdict/disparity.d.ts +8 -56
- package/dist/verdict/disparity.js +1 -1
- package/dist/verdict/instrumentation-coverage.d.ts +3 -3
- package/dist/verdict/instrumentation-coverage.js +1 -1
- package/dist/verdict/instrumentation-gap.d.ts +3 -10
- package/dist/verdict/instrumentation-gap.js +1 -1
- package/dist/verdict/intent.d.ts +25 -224
- package/dist/verdict/intent.js +1 -1
- package/dist/verdict/predicate.d.ts +1 -1
- package/dist/verdict/predicate.js +5 -5
- package/dist/verdict/property-assertion.d.ts +23 -101
- package/dist/verdict/property-assertion.js +1 -1
- package/dist/verdict/run-report.d.ts +13 -108
- package/dist/verdict/run-report.js +1 -1
- package/dist/verdict/security.d.ts +12 -0
- package/dist/verdict/security.js +94 -7
- package/dist/verdict/verification-run.d.ts +112 -1668
- package/dist/verdict/verification-run.js +4 -4
- package/dist/verdict/verify-progress.d.ts +22 -64
- package/dist/verdict/verify-progress.js +1 -1
- package/dist/wire/click-input.d.ts +15 -0
- package/dist/wire/click-input.js +42 -0
- package/dist/wire/constants/event-types.d.ts +2 -0
- package/dist/wire/constants/event-types.js +2 -0
- package/dist/wire/constants/response-body-reason.d.ts +4 -4
- package/dist/wire/constants/response-body-reason.js +4 -4
- package/dist/wire/constants/reticle-env.d.ts +2 -0
- package/dist/wire/constants/reticle-env.js +2 -0
- package/dist/wire/event-payloads.d.ts +108 -678
- package/dist/wire/event-payloads.js +24 -7
- package/dist/wire/event-priority.js +1 -0
- package/dist/wire/messages.d.ts +66 -755
- package/dist/wire/messages.js +3 -3
- package/dist/wire/next-step.d.ts +11 -51
- package/dist/wire/next-step.js +1 -1
- package/dist/wire/platform-link.js +2 -2
- package/dist/wire/production/production-policy.d.ts +37 -83
- package/dist/wire/production/production-policy.js +1 -1
- package/dist/wire/types.d.ts +75 -698
- package/dist/wire/types.js +5 -5
- package/dist/words/upgrade.d.ts +3 -13
- package/dist/words/upgrade.js +1 -1
- package/package.json +4 -5
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Split out of the engine with the rest of the predicate contract, and for the same reason: a saved
|
|
9
9
|
* flow carries one of these now, so core has to be able to parse what it reads.
|
|
10
10
|
*/
|
|
11
|
-
import
|
|
11
|
+
import * as z from 'zod';
|
|
12
12
|
import { MeasureOp } from 'open-verification';
|
|
13
13
|
export type PropertyAssertion =
|
|
14
14
|
/** Produced something at all — the honest floor for any generated output. */
|
|
@@ -63,129 +63,51 @@ export interface Baseline {
|
|
|
63
63
|
readonly taken: true;
|
|
64
64
|
readonly value: unknown;
|
|
65
65
|
}
|
|
66
|
-
export declare const propertyAssertionSchema: z.ZodDiscriminatedUnion<
|
|
66
|
+
export declare const propertyAssertionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
67
67
|
property: z.ZodLiteral<"nonEmpty">;
|
|
68
|
-
},
|
|
69
|
-
property: "nonEmpty";
|
|
70
|
-
}, {
|
|
71
|
-
property: "nonEmpty";
|
|
72
|
-
}>, z.ZodObject<{
|
|
68
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
73
69
|
property: z.ZodLiteral<"oneOf">;
|
|
74
|
-
values: z.ZodArray<z.ZodUnknown
|
|
75
|
-
},
|
|
76
|
-
values: unknown[];
|
|
77
|
-
property: "oneOf";
|
|
78
|
-
}, {
|
|
79
|
-
values: unknown[];
|
|
80
|
-
property: "oneOf";
|
|
81
|
-
}>, z.ZodObject<{
|
|
70
|
+
values: z.ZodArray<z.ZodUnknown>;
|
|
71
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
82
72
|
property: z.ZodLiteral<"withinTolerance">;
|
|
83
73
|
of: z.ZodNumber;
|
|
84
74
|
tolerance: z.ZodNumber;
|
|
85
|
-
},
|
|
86
|
-
tolerance: number;
|
|
87
|
-
property: "withinTolerance";
|
|
88
|
-
of: number;
|
|
89
|
-
}, {
|
|
90
|
-
tolerance: number;
|
|
91
|
-
property: "withinTolerance";
|
|
92
|
-
of: number;
|
|
93
|
-
}>, z.ZodObject<{
|
|
75
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
94
76
|
property: z.ZodLiteral<"matchesPattern">;
|
|
95
77
|
pattern: z.ZodString;
|
|
96
|
-
},
|
|
97
|
-
pattern: string;
|
|
98
|
-
property: "matchesPattern";
|
|
99
|
-
}, {
|
|
100
|
-
pattern: string;
|
|
101
|
-
property: "matchesPattern";
|
|
102
|
-
}>, z.ZodObject<{
|
|
78
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
103
79
|
property: z.ZodLiteral<"type">;
|
|
104
|
-
is: z.ZodEnum<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}>, z.ZodObject<{
|
|
80
|
+
is: z.ZodEnum<{
|
|
81
|
+
string: "string";
|
|
82
|
+
number: "number";
|
|
83
|
+
boolean: "boolean";
|
|
84
|
+
object: "object";
|
|
85
|
+
array: "array";
|
|
86
|
+
}>;
|
|
87
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
112
88
|
property: z.ZodLiteral<"changed">;
|
|
113
|
-
},
|
|
114
|
-
property: "changed";
|
|
115
|
-
}, {
|
|
116
|
-
property: "changed";
|
|
117
|
-
}>, z.ZodObject<{
|
|
89
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
118
90
|
property: z.ZodLiteral<"unchanged">;
|
|
119
|
-
},
|
|
120
|
-
property: "unchanged";
|
|
121
|
-
}, {
|
|
122
|
-
property: "unchanged";
|
|
123
|
-
}>, z.ZodObject<{
|
|
91
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
124
92
|
property: z.ZodLiteral<"increased">;
|
|
125
93
|
by: z.ZodOptional<z.ZodObject<{
|
|
126
|
-
op: z.
|
|
94
|
+
op: z.ZodEnum<{
|
|
127
95
|
readonly EQUALS: "equals";
|
|
128
96
|
readonly AT_LEAST: "at-least";
|
|
129
97
|
readonly AT_MOST: "at-most";
|
|
130
98
|
}>;
|
|
131
99
|
value: z.ZodNumber;
|
|
132
|
-
/** Never negative — a negative tolerance NARROWS the band, which is a different claim by accident. */
|
|
133
100
|
tolerance: z.ZodOptional<z.ZodNumber>;
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
op: "equals" | "at-least" | "at-most";
|
|
137
|
-
tolerance?: number | undefined;
|
|
138
|
-
}, {
|
|
139
|
-
value: number;
|
|
140
|
-
op: "equals" | "at-least" | "at-most";
|
|
141
|
-
tolerance?: number | undefined;
|
|
142
|
-
}>>;
|
|
143
|
-
}, "strict", z.ZodTypeAny, {
|
|
144
|
-
property: "increased";
|
|
145
|
-
by?: {
|
|
146
|
-
value: number;
|
|
147
|
-
op: "equals" | "at-least" | "at-most";
|
|
148
|
-
tolerance?: number | undefined;
|
|
149
|
-
} | undefined;
|
|
150
|
-
}, {
|
|
151
|
-
property: "increased";
|
|
152
|
-
by?: {
|
|
153
|
-
value: number;
|
|
154
|
-
op: "equals" | "at-least" | "at-most";
|
|
155
|
-
tolerance?: number | undefined;
|
|
156
|
-
} | undefined;
|
|
157
|
-
}>, z.ZodObject<{
|
|
101
|
+
}, z.core.$strict>>;
|
|
102
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
158
103
|
property: z.ZodLiteral<"decreased">;
|
|
159
104
|
by: z.ZodOptional<z.ZodObject<{
|
|
160
|
-
op: z.
|
|
105
|
+
op: z.ZodEnum<{
|
|
161
106
|
readonly EQUALS: "equals";
|
|
162
107
|
readonly AT_LEAST: "at-least";
|
|
163
108
|
readonly AT_MOST: "at-most";
|
|
164
109
|
}>;
|
|
165
110
|
value: z.ZodNumber;
|
|
166
|
-
/** Never negative — a negative tolerance NARROWS the band, which is a different claim by accident. */
|
|
167
111
|
tolerance: z.ZodOptional<z.ZodNumber>;
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
op: "equals" | "at-least" | "at-most";
|
|
171
|
-
tolerance?: number | undefined;
|
|
172
|
-
}, {
|
|
173
|
-
value: number;
|
|
174
|
-
op: "equals" | "at-least" | "at-most";
|
|
175
|
-
tolerance?: number | undefined;
|
|
176
|
-
}>>;
|
|
177
|
-
}, "strict", z.ZodTypeAny, {
|
|
178
|
-
property: "decreased";
|
|
179
|
-
by?: {
|
|
180
|
-
value: number;
|
|
181
|
-
op: "equals" | "at-least" | "at-most";
|
|
182
|
-
tolerance?: number | undefined;
|
|
183
|
-
} | undefined;
|
|
184
|
-
}, {
|
|
185
|
-
property: "decreased";
|
|
186
|
-
by?: {
|
|
187
|
-
value: number;
|
|
188
|
-
op: "equals" | "at-least" | "at-most";
|
|
189
|
-
tolerance?: number | undefined;
|
|
190
|
-
} | undefined;
|
|
191
|
-
}>]>;
|
|
112
|
+
}, z.core.$strict>>;
|
|
113
|
+
}, z.core.$strict>], "property">;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Split out of the engine with the rest of the predicate contract, and for the same reason: a saved
|
|
9
9
|
* flow carries one of these now, so core has to be able to parse what it reads.
|
|
10
10
|
*/
|
|
11
|
-
import
|
|
11
|
+
import * as z from 'zod';
|
|
12
12
|
import { MeasureOp } from 'open-verification';
|
|
13
13
|
const deltaSchema = z
|
|
14
14
|
.object({
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* summarise it into a pass. Every number here was counted during the run. A number that was not
|
|
7
7
|
* measured is left out, never shown as a zero.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import * as z from 'zod';
|
|
10
10
|
/** The output field that carries the report. */
|
|
11
11
|
export declare const RUN_REPORT_FIELD = "runReport";
|
|
12
12
|
/** What the agent does with the report. One sentence, said with the report every time. */
|
|
@@ -20,147 +20,52 @@ export declare const CLOUD_DASHBOARD_URL = "https://app.reticle.sh";
|
|
|
20
20
|
*/
|
|
21
21
|
export declare const CLOUD_VALUE_LINE: string;
|
|
22
22
|
export declare const RunReportClaimSchema: z.ZodObject<{
|
|
23
|
-
/** The claim, in the words the agent wrote. */
|
|
24
23
|
claim: z.ZodString;
|
|
25
|
-
verified: z.
|
|
24
|
+
verified: z.ZodEnum<{
|
|
26
25
|
readonly YES: "yes";
|
|
27
26
|
readonly NO: "no";
|
|
28
27
|
readonly UNKNOWN: "unknown";
|
|
29
28
|
readonly NO_FAULT: "no-fault";
|
|
30
29
|
}>;
|
|
31
|
-
/** One piece of evidence: what the check saw, or the source line it drove. */
|
|
32
30
|
evidence: z.ZodOptional<z.ZodString>;
|
|
33
|
-
},
|
|
34
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
35
|
-
claim: string;
|
|
36
|
-
evidence?: string | undefined;
|
|
37
|
-
}, {
|
|
38
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
39
|
-
claim: string;
|
|
40
|
-
evidence?: string | undefined;
|
|
41
|
-
}>;
|
|
31
|
+
}, z.core.$strip>;
|
|
42
32
|
export type RunReportClaim = z.infer<typeof RunReportClaimSchema>;
|
|
43
33
|
export declare const RunReportSchema: z.ZodObject<{
|
|
44
|
-
|
|
45
|
-
verified: z.ZodNativeEnum<{
|
|
34
|
+
verified: z.ZodEnum<{
|
|
46
35
|
readonly YES: "yes";
|
|
47
36
|
readonly NO: "no";
|
|
48
37
|
readonly UNKNOWN: "unknown";
|
|
49
38
|
readonly NO_FAULT: "no-fault";
|
|
50
39
|
}>;
|
|
51
40
|
claims: z.ZodArray<z.ZodObject<{
|
|
52
|
-
/** The claim, in the words the agent wrote. */
|
|
53
41
|
claim: z.ZodString;
|
|
54
|
-
verified: z.
|
|
42
|
+
verified: z.ZodEnum<{
|
|
55
43
|
readonly YES: "yes";
|
|
56
44
|
readonly NO: "no";
|
|
57
45
|
readonly UNKNOWN: "unknown";
|
|
58
46
|
readonly NO_FAULT: "no-fault";
|
|
59
47
|
}>;
|
|
60
|
-
/** One piece of evidence: what the check saw, or the source line it drove. */
|
|
61
48
|
evidence: z.ZodOptional<z.ZodString>;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
claim: string;
|
|
65
|
-
evidence?: string | undefined;
|
|
66
|
-
}, {
|
|
67
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
68
|
-
claim: string;
|
|
69
|
-
evidence?: string | undefined;
|
|
70
|
-
}>, "many">;
|
|
71
|
-
/** Claims the agent expected to hold that Reticle found false. */
|
|
72
|
-
caught: z.ZodArray<z.ZodString, "many">;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
caught: z.ZodArray<z.ZodString>;
|
|
73
51
|
flows: z.ZodObject<{
|
|
74
|
-
saved: z.ZodArray<z.ZodString
|
|
52
|
+
saved: z.ZodArray<z.ZodString>;
|
|
75
53
|
replayed: z.ZodArray<z.ZodObject<{
|
|
76
54
|
name: z.ZodString;
|
|
77
|
-
verified: z.
|
|
55
|
+
verified: z.ZodEnum<{
|
|
78
56
|
readonly YES: "yes";
|
|
79
57
|
readonly NO: "no";
|
|
80
58
|
readonly UNKNOWN: "unknown";
|
|
81
59
|
readonly NO_FAULT: "no-fault";
|
|
82
60
|
}>;
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
86
|
-
}, {
|
|
87
|
-
name: string;
|
|
88
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
89
|
-
}>, "many">;
|
|
90
|
-
}, "strip", z.ZodTypeAny, {
|
|
91
|
-
saved: string[];
|
|
92
|
-
replayed: {
|
|
93
|
-
name: string;
|
|
94
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
95
|
-
}[];
|
|
96
|
-
}, {
|
|
97
|
-
saved: string[];
|
|
98
|
-
replayed: {
|
|
99
|
-
name: string;
|
|
100
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
101
|
-
}[];
|
|
102
|
-
}>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
103
63
|
memory: z.ZodObject<{
|
|
104
|
-
/** Notes and statements written for the next run. */
|
|
105
64
|
written: z.ZodNumber;
|
|
106
|
-
/** Notes and statements from earlier runs that this run was given. */
|
|
107
65
|
read: z.ZodNumber;
|
|
108
|
-
},
|
|
109
|
-
read: number;
|
|
110
|
-
written: number;
|
|
111
|
-
}, {
|
|
112
|
-
read: number;
|
|
113
|
-
written: number;
|
|
114
|
-
}>;
|
|
115
|
-
/** From the run's first Reticle call to this report. */
|
|
66
|
+
}, z.core.$strip>;
|
|
116
67
|
wallMs: z.ZodNumber;
|
|
117
|
-
/** From the run's first Reticle call to its first decided claim or replay. Absent when none. */
|
|
118
68
|
firstVerdictMs: z.ZodOptional<z.ZodNumber>;
|
|
119
|
-
/** `CLOUD_VALUE_LINE`, only when the project is not linked. */
|
|
120
69
|
cloud: z.ZodOptional<z.ZodString>;
|
|
121
|
-
},
|
|
122
|
-
flows: {
|
|
123
|
-
saved: string[];
|
|
124
|
-
replayed: {
|
|
125
|
-
name: string;
|
|
126
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
127
|
-
}[];
|
|
128
|
-
};
|
|
129
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
130
|
-
claims: {
|
|
131
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
132
|
-
claim: string;
|
|
133
|
-
evidence?: string | undefined;
|
|
134
|
-
}[];
|
|
135
|
-
caught: string[];
|
|
136
|
-
memory: {
|
|
137
|
-
read: number;
|
|
138
|
-
written: number;
|
|
139
|
-
};
|
|
140
|
-
wallMs: number;
|
|
141
|
-
firstVerdictMs?: number | undefined;
|
|
142
|
-
cloud?: string | undefined;
|
|
143
|
-
}, {
|
|
144
|
-
flows: {
|
|
145
|
-
saved: string[];
|
|
146
|
-
replayed: {
|
|
147
|
-
name: string;
|
|
148
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
149
|
-
}[];
|
|
150
|
-
};
|
|
151
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
152
|
-
claims: {
|
|
153
|
-
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
154
|
-
claim: string;
|
|
155
|
-
evidence?: string | undefined;
|
|
156
|
-
}[];
|
|
157
|
-
caught: string[];
|
|
158
|
-
memory: {
|
|
159
|
-
read: number;
|
|
160
|
-
written: number;
|
|
161
|
-
};
|
|
162
|
-
wallMs: number;
|
|
163
|
-
firstVerdictMs?: number | undefined;
|
|
164
|
-
cloud?: string | undefined;
|
|
165
|
-
}>;
|
|
70
|
+
}, z.core.$strip>;
|
|
166
71
|
export type RunReport = z.infer<typeof RunReportSchema>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* summarise it into a pass. Every number here was counted during the run. A number that was not
|
|
7
7
|
* measured is left out, never shown as a zero.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import * as z from 'zod';
|
|
10
10
|
import { Verified } from './verified-constants.js';
|
|
11
11
|
/** The output field that carries the report. */
|
|
12
12
|
export const RUN_REPORT_FIELD = 'runReport';
|
|
@@ -29,6 +29,18 @@ export declare const OPAQUE_ORIGIN = "null";
|
|
|
29
29
|
* pairing token, exactly as they do for a request that omits `Origin` entirely.
|
|
30
30
|
*/
|
|
31
31
|
export declare function isOpaqueOrigin(origin: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Strip filename-like tokens from text before the text is classified.
|
|
34
|
+
* Callers apply this to a control's name, text and value only: an href or a form action is a
|
|
35
|
+
* target, not words on the control, and its destination must be read whole.
|
|
36
|
+
*
|
|
37
|
+
* The scan walks each maximal run of filename characters once and checks that run's dots
|
|
38
|
+
* once, so a label costs time in proportion to its length. The one-pattern version this
|
|
39
|
+
* replaces took about 97 seconds on a 100,000 hyphen label in a local check; the scan
|
|
40
|
+
* takes milliseconds on the same label, and a fuzz comparison over 20,000 generated
|
|
41
|
+
* labels found no difference in what it strips.
|
|
42
|
+
*/
|
|
43
|
+
export declare function withoutFilenameTokens(text: string): string;
|
|
32
44
|
/**
|
|
33
45
|
* Best-effort classifier for labels and tool names that can trigger irreversible effects.
|
|
34
46
|
*
|
package/dist/verdict/security.js
CHANGED
|
@@ -66,14 +66,16 @@ const IPV4_OCTET_MAX = 255;
|
|
|
66
66
|
*/
|
|
67
67
|
export function isLoopbackHostname(hostname) {
|
|
68
68
|
const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
69
|
-
if (LOOPBACK_HOSTNAMES.includes(normalized))
|
|
69
|
+
if (LOOPBACK_HOSTNAMES.includes(normalized)) {
|
|
70
70
|
return true;
|
|
71
|
+
}
|
|
71
72
|
const octets = normalized.split('.');
|
|
72
73
|
return (IPV4_OCTET_COUNT === octets.length &&
|
|
73
74
|
IPV4_LOOPBACK_FIRST_OCTET === octets[0] &&
|
|
74
75
|
octets.every((octet) => {
|
|
75
|
-
if (!/^\d{1,3}$/.test(octet))
|
|
76
|
+
if (!/^\d{1,3}$/.test(octet)) {
|
|
76
77
|
return false;
|
|
78
|
+
}
|
|
77
79
|
const value = Number(octet);
|
|
78
80
|
return value >= 0 && value <= IPV4_OCTET_MAX;
|
|
79
81
|
}));
|
|
@@ -104,8 +106,9 @@ const LOCAL_APP_PROTOCOLS = ['file:', 'app:', 'tauri:'];
|
|
|
104
106
|
*/
|
|
105
107
|
export function isLocalPage(protocol, hostname) {
|
|
106
108
|
// `isLocalhostSubdomain` also covers `tauri.localhost`, the http origin Tauri v2 uses on Windows.
|
|
107
|
-
if (isLoopbackHostname(hostname) || isLocalhostSubdomain(hostname))
|
|
109
|
+
if (isLoopbackHostname(hostname) || isLocalhostSubdomain(hostname)) {
|
|
108
110
|
return true;
|
|
111
|
+
}
|
|
109
112
|
return LOCAL_APP_PROTOCOLS.includes(protocol.toLowerCase());
|
|
110
113
|
}
|
|
111
114
|
/**
|
|
@@ -127,6 +130,86 @@ export function isOpaqueOrigin(origin) {
|
|
|
127
130
|
return true;
|
|
128
131
|
}
|
|
129
132
|
}
|
|
133
|
+
/** The extensions a filename token can end in, as a set for the scan below. */
|
|
134
|
+
const FILENAME_EXTENSIONS = new Set([
|
|
135
|
+
'webm',
|
|
136
|
+
'mp4',
|
|
137
|
+
'mov',
|
|
138
|
+
'mkv',
|
|
139
|
+
'avi',
|
|
140
|
+
'mp3',
|
|
141
|
+
'wav',
|
|
142
|
+
'ogg',
|
|
143
|
+
'flac',
|
|
144
|
+
'png',
|
|
145
|
+
'jpg',
|
|
146
|
+
'jpeg',
|
|
147
|
+
'gif',
|
|
148
|
+
'webp',
|
|
149
|
+
'svg',
|
|
150
|
+
'avif',
|
|
151
|
+
'bmp',
|
|
152
|
+
'pdf',
|
|
153
|
+
'zip',
|
|
154
|
+
'tar',
|
|
155
|
+
'gz',
|
|
156
|
+
'txt',
|
|
157
|
+
'csv',
|
|
158
|
+
'json',
|
|
159
|
+
'xml',
|
|
160
|
+
'doc',
|
|
161
|
+
'docx',
|
|
162
|
+
'xls',
|
|
163
|
+
'xlsx',
|
|
164
|
+
'ppt',
|
|
165
|
+
'pptx',
|
|
166
|
+
]);
|
|
167
|
+
/** One maximal run of filename characters in a label: a token, or a token with a tail. */
|
|
168
|
+
const FILENAME_RUN = /[\w.-]+/g;
|
|
169
|
+
/** One character of a file extension. Extensions are letters and digits: `mp4`, `mp3`. */
|
|
170
|
+
const EXTENSION_CHARACTER = /[a-zA-Z0-9]/;
|
|
171
|
+
/**
|
|
172
|
+
* The end of the filename token at the start of `run`, or 0 when the run starts with no
|
|
173
|
+
* filename token. Try the last dot first, the way a greedy match does: the longest name
|
|
174
|
+
* part that still ends in a known extension wins. The extension must end at a word
|
|
175
|
+
* boundary: the end of the run, a dot, or a hyphen. So `report.pdf.backup` starts with
|
|
176
|
+
* the token `report.pdf`, and its tail stays in the text.
|
|
177
|
+
*/
|
|
178
|
+
function filenameTokenEnd(run) {
|
|
179
|
+
for (let dot = run.lastIndexOf('.'); 1 <= dot; dot = run.lastIndexOf('.', dot - 1)) {
|
|
180
|
+
let end = dot + 1;
|
|
181
|
+
let extension = '';
|
|
182
|
+
while (end < run.length && EXTENSION_CHARACTER.test(run.charAt(end))) {
|
|
183
|
+
extension += run.charAt(end).toLowerCase();
|
|
184
|
+
end += 1;
|
|
185
|
+
}
|
|
186
|
+
if (!FILENAME_EXTENSIONS.has(extension)) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const after = run.charAt(end);
|
|
190
|
+
if ('' === after || '.' === after || '-' === after) {
|
|
191
|
+
return end;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Strip filename-like tokens from text before the text is classified.
|
|
198
|
+
* Callers apply this to a control's name, text and value only: an href or a form action is a
|
|
199
|
+
* target, not words on the control, and its destination must be read whole.
|
|
200
|
+
*
|
|
201
|
+
* The scan walks each maximal run of filename characters once and checks that run's dots
|
|
202
|
+
* once, so a label costs time in proportion to its length. The one-pattern version this
|
|
203
|
+
* replaces took about 97 seconds on a 100,000 hyphen label in a local check; the scan
|
|
204
|
+
* takes milliseconds on the same label, and a fuzz comparison over 20,000 generated
|
|
205
|
+
* labels found no difference in what it strips.
|
|
206
|
+
*/
|
|
207
|
+
export function withoutFilenameTokens(text) {
|
|
208
|
+
return text.replace(FILENAME_RUN, (run) => {
|
|
209
|
+
const end = filenameTokenEnd(run);
|
|
210
|
+
return 0 === end ? run : ` ${run.slice(end)}`;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
130
213
|
/**
|
|
131
214
|
* Best-effort classifier for labels and tool names that can trigger irreversible effects.
|
|
132
215
|
*
|
|
@@ -135,8 +218,9 @@ export function isOpaqueOrigin(origin) {
|
|
|
135
218
|
* role (a tool name, a click with no role on the descriptor) omit it and the text decides.
|
|
136
219
|
*/
|
|
137
220
|
export function isDangerousActionText(text, role) {
|
|
138
|
-
if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase()))
|
|
221
|
+
if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase())) {
|
|
139
222
|
return false;
|
|
223
|
+
}
|
|
140
224
|
return DANGEROUS_ACTION.test(text.replace(WORD_JOINERS, ' '));
|
|
141
225
|
}
|
|
142
226
|
/**
|
|
@@ -240,8 +324,9 @@ const PAYMENT_FIELD_WORDS = /card ?(?:number|no\b)|\bcc ?num|\b(?:cvc|cvv|csc|cv
|
|
|
240
324
|
* too); it travels in the facts so a numeric field named "cvv" still reads as one.
|
|
241
325
|
*/
|
|
242
326
|
export function isPaymentField(facts) {
|
|
243
|
-
if (CARD_AUTOCOMPLETE.test(facts.autocomplete ?? ''))
|
|
327
|
+
if (CARD_AUTOCOMPLETE.test(facts.autocomplete ?? '')) {
|
|
244
328
|
return true;
|
|
329
|
+
}
|
|
245
330
|
const words = [facts.name, facts.id, facts.label]
|
|
246
331
|
.map((w) => (w ?? '').replace(/([a-z])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' '))
|
|
247
332
|
.join(' ');
|
|
@@ -254,10 +339,12 @@ export function isPaymentField(facts) {
|
|
|
254
339
|
* that points at a payment provider. `PAY` stays in the journey vocabulary, so "she pays" allows it.
|
|
255
340
|
*/
|
|
256
341
|
export function outwardActionOf(text, role) {
|
|
257
|
-
if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase()))
|
|
342
|
+
if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase())) {
|
|
258
343
|
return undefined;
|
|
259
|
-
|
|
344
|
+
}
|
|
345
|
+
if (text.split(/\s+/).some(isPaymentProviderUrl)) {
|
|
260
346
|
return OutwardAction.PAY;
|
|
347
|
+
}
|
|
261
348
|
const words = text.replace(/[_-]+/g, ' ');
|
|
262
349
|
return OUTWARD_WORDS.find(([action, pattern]) => action !== OutwardAction.PAY && pattern.test(words))?.[0];
|
|
263
350
|
}
|