@ai-ecoverse/slicc-browsers 1.28.5 → 1.29.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 +1 -0
- package/cookie-plant.mjs +4353 -0
- package/fixture-server.mjs +10 -0
- package/guard-runner.mjs +61 -10
- package/guard-vectors.json +5503 -1140
- package/package.json +4 -3
- package/schema/guard-vectors.schema.json +42 -2
package/fixture-server.mjs
CHANGED
|
@@ -304,6 +304,16 @@ export async function fixtureServer({ host = '127.0.0.1', port = 0, tls, latency
|
|
|
304
304
|
port: address.port,
|
|
305
305
|
origin: `${scheme}://${host}:${address.port}`,
|
|
306
306
|
log: () => structuredClone(entries),
|
|
307
|
+
record: (url) => {
|
|
308
|
+
const entry = {
|
|
309
|
+
time: Date.now(),
|
|
310
|
+
url: String(url ?? ''),
|
|
311
|
+
method: 'GET',
|
|
312
|
+
headers: {},
|
|
313
|
+
};
|
|
314
|
+
entries.push(entry);
|
|
315
|
+
history.push(entry);
|
|
316
|
+
},
|
|
307
317
|
reset: () => {
|
|
308
318
|
entries = [];
|
|
309
319
|
},
|
package/guard-runner.mjs
CHANGED
|
@@ -4,6 +4,7 @@ export { fixtureClient };
|
|
|
4
4
|
|
|
5
5
|
import { bfcacheRestore } from './bfcache-restore.mjs';
|
|
6
6
|
import { closeProtectedShape } from './close-protected-shape.mjs';
|
|
7
|
+
import { cookiePlant } from './cookie-plant.mjs';
|
|
7
8
|
import { credentialExport } from './credential-export.mjs';
|
|
8
9
|
import { extensionFrame } from './extension-frame.mjs';
|
|
9
10
|
import { DEFAULT_EXTENSION_WORLD_ID, extensionWorld } from './extension-world.mjs';
|
|
@@ -98,6 +99,22 @@ const declared = (capability, capabilities) =>
|
|
|
98
99
|
const gatedOut = (observation, capabilities) =>
|
|
99
100
|
!supported(observation?.requires, capabilities) ||
|
|
100
101
|
(observation?.unless ?? []).some((capability) => declared(capability, capabilities));
|
|
102
|
+
const withCookiePlantCaps = (capabilities, probe) => {
|
|
103
|
+
const asObject = Array.isArray(capabilities)
|
|
104
|
+
? Object.fromEntries(capabilities.map((name) => [name, true]))
|
|
105
|
+
: { ...capabilities };
|
|
106
|
+
if (!declared('requestInterception', asObject)) return capabilities;
|
|
107
|
+
if (!probe) return capabilities;
|
|
108
|
+
if (probe.fetch === true && asObject.fetchInterception !== false)
|
|
109
|
+
asObject.fetchInterception = true;
|
|
110
|
+
else delete asObject.fetchInterception;
|
|
111
|
+
if (probe.legacy === true && asObject.legacyInterception === true)
|
|
112
|
+
asObject.legacyInterception = true;
|
|
113
|
+
else delete asObject.legacyInterception;
|
|
114
|
+
return Array.isArray(capabilities)
|
|
115
|
+
? Object.keys(asObject).filter((name) => asObject[name] === true)
|
|
116
|
+
: asObject;
|
|
117
|
+
};
|
|
101
118
|
const matches = (value, predicate) => {
|
|
102
119
|
if (predicate === null || typeof predicate !== 'object') return value === predicate;
|
|
103
120
|
return Object.entries(predicate).every(([key, want]) => {
|
|
@@ -138,8 +155,10 @@ const stateCheck = (check) =>
|
|
|
138
155
|
[...(check?.all ?? []), ...(check?.any ?? []), ...(check?.not ? [check.not] : [])]
|
|
139
156
|
.map(stateCheck)
|
|
140
157
|
.find(Boolean);
|
|
141
|
-
const refusedOut = (step, out) =>
|
|
142
|
-
step.refusable
|
|
158
|
+
const refusedOut = (step, out, gone = false) =>
|
|
159
|
+
step.refusable
|
|
160
|
+
? isRefusal(out, step)
|
|
161
|
+
: !gone && /refused/.test(String(out.error?.message ?? out.error));
|
|
143
162
|
|
|
144
163
|
function pageExpression(step, url) {
|
|
145
164
|
let expression;
|
|
@@ -875,7 +894,7 @@ class Execution {
|
|
|
875
894
|
}
|
|
876
895
|
|
|
877
896
|
record(step, out, session, phase, gone) {
|
|
878
|
-
const refused =
|
|
897
|
+
const refused = refusedOut(step, out, gone);
|
|
879
898
|
this.trace.push({
|
|
880
899
|
phase,
|
|
881
900
|
declared: Boolean(step.refusable),
|
|
@@ -908,6 +927,7 @@ class Execution {
|
|
|
908
927
|
'protectedParentIframes',
|
|
909
928
|
'credentialExport',
|
|
910
929
|
'signInHold',
|
|
930
|
+
'cookiePlant',
|
|
911
931
|
'extensionWorld',
|
|
912
932
|
'extensionFrame',
|
|
913
933
|
'frameRead',
|
|
@@ -922,6 +942,7 @@ class Execution {
|
|
|
922
942
|
'protectedParentIframes',
|
|
923
943
|
'credentialExport',
|
|
924
944
|
'signInHold',
|
|
945
|
+
'cookiePlant',
|
|
925
946
|
'redirectSecret',
|
|
926
947
|
'extensionFrame',
|
|
927
948
|
'frameRead',
|
|
@@ -1029,6 +1050,7 @@ class Execution {
|
|
|
1029
1050
|
step.protectedParentIframes ||
|
|
1030
1051
|
step.credentialExport ||
|
|
1031
1052
|
step.signInHold ||
|
|
1053
|
+
step.cookiePlant ||
|
|
1032
1054
|
step.spawnWorker ||
|
|
1033
1055
|
step.probeSessions
|
|
1034
1056
|
)
|
|
@@ -1181,6 +1203,7 @@ class Execution {
|
|
|
1181
1203
|
if (step.protectedParentIframes) return this.runProtectedParentIframes(step);
|
|
1182
1204
|
if (step.credentialExport) return this.runCredentialExport(step);
|
|
1183
1205
|
if (step.signInHold) return this.runSignInHold(step);
|
|
1206
|
+
if (step.cookiePlant) return this.runCookiePlant(step);
|
|
1184
1207
|
if (step.spawnWorker) return this.spawnWorker(step);
|
|
1185
1208
|
return this.probeSessions(step);
|
|
1186
1209
|
}
|
|
@@ -1309,6 +1332,30 @@ class Execution {
|
|
|
1309
1332
|
return out;
|
|
1310
1333
|
}
|
|
1311
1334
|
|
|
1335
|
+
async runCookiePlant(step) {
|
|
1336
|
+
return outcome(
|
|
1337
|
+
cookiePlant({
|
|
1338
|
+
client: this.client,
|
|
1339
|
+
reader: this.reader,
|
|
1340
|
+
protectedOrigin: this.vars.protectedTarget,
|
|
1341
|
+
credentialOrigin: this.vars.idp ?? this.options.targets?.idp ?? this.vars.protectedTarget,
|
|
1342
|
+
ordinary: this.vars.ordinary,
|
|
1343
|
+
tag: this.vars.tag,
|
|
1344
|
+
internalSessions: this.internalSessions,
|
|
1345
|
+
notes: this.notes,
|
|
1346
|
+
budget: this.bound(5000),
|
|
1347
|
+
control: this.side === 'control',
|
|
1348
|
+
mode: step.cookiePlant,
|
|
1349
|
+
fixtureLog: () => this.options.fixture.log(),
|
|
1350
|
+
blockedMarkers: this.vector.blockedMarkers ?? [],
|
|
1351
|
+
onlyPaths: this.options.cookiePlantOnlyPaths ?? null,
|
|
1352
|
+
forcedRaw: this.options.cookiePlantForcedRaw ?? null,
|
|
1353
|
+
browserContextId: this.vars.context ?? null,
|
|
1354
|
+
browserContexts: supported(['browserContexts'], this.options.capabilities),
|
|
1355
|
+
})
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1312
1359
|
spawnWorkerKind() {
|
|
1313
1360
|
return allSteps([...(this.vector.setup ?? []), ...(this.vector.trigger ?? [])]).find(
|
|
1314
1361
|
(step) => step.spawnWorker
|
|
@@ -2131,10 +2178,11 @@ class Execution {
|
|
|
2131
2178
|
async observeAll(unseen) {
|
|
2132
2179
|
const observed = { ...this.refused };
|
|
2133
2180
|
const incomplete = [];
|
|
2181
|
+
const capabilities = withCookiePlantCaps(this.options.capabilities, this.calls.probe?.result);
|
|
2134
2182
|
let measured = 0;
|
|
2135
2183
|
let excused = 0;
|
|
2136
2184
|
for (const [name, observation] of Object.entries(this.vector.observe ?? {})) {
|
|
2137
|
-
if (gatedOut(observation,
|
|
2185
|
+
if (gatedOut(observation, capabilities)) {
|
|
2138
2186
|
observed[name] = 'not-supported';
|
|
2139
2187
|
continue;
|
|
2140
2188
|
}
|
|
@@ -2344,7 +2392,8 @@ const needsObserver = (vector) =>
|
|
|
2344
2392
|
step.closeProtectedShape ||
|
|
2345
2393
|
step.protectedParentIframes ||
|
|
2346
2394
|
step.credentialExport ||
|
|
2347
|
-
step.signInHold
|
|
2395
|
+
step.signInHold ||
|
|
2396
|
+
step.cookiePlant
|
|
2348
2397
|
) ||
|
|
2349
2398
|
vector.control.via === 'unguarded' ||
|
|
2350
2399
|
observerRequired(vector.liveCheck) ||
|
|
@@ -2570,18 +2619,19 @@ async function watch(work, ms, snapshot) {
|
|
|
2570
2619
|
return stuck;
|
|
2571
2620
|
}
|
|
2572
2621
|
|
|
2573
|
-
async function timedOut(stuck, base, made, work, opts) {
|
|
2622
|
+
async function timedOut(stuck, base, made, work, opts, rowTimeoutMs) {
|
|
2574
2623
|
const close = made.close;
|
|
2575
2624
|
made.close = undefined;
|
|
2576
2625
|
await close?.call(made);
|
|
2577
2626
|
work.catch(() => {});
|
|
2627
|
+
const ms = rowTimeoutMs ?? opts.rowTimeoutMs;
|
|
2578
2628
|
const failed = {
|
|
2579
2629
|
...base,
|
|
2580
2630
|
control: 'fail',
|
|
2581
2631
|
guarded: 'fail',
|
|
2582
2632
|
live: 'fail',
|
|
2583
|
-
why: `row timed out after ${
|
|
2584
|
-
errors: [`row timed out after ${
|
|
2633
|
+
why: `row timed out after ${ms}ms`,
|
|
2634
|
+
errors: [`row timed out after ${ms}ms: ${JSON.stringify(stuck)}`],
|
|
2585
2635
|
inFlight: stuck,
|
|
2586
2636
|
};
|
|
2587
2637
|
opts.log?.(failed);
|
|
@@ -2661,12 +2711,13 @@ async function executeRow(job, opts, made, set, slot, index, flights) {
|
|
|
2661
2711
|
flights.add({ flight, base, clients });
|
|
2662
2712
|
opts.onStart?.(base);
|
|
2663
2713
|
const sides = runLegs({ vector, opts, clients, set, job, slot, index, legs, renewed });
|
|
2664
|
-
const
|
|
2714
|
+
const rowTimeoutMs = Number.isFinite(opts.rowTimeoutMs) ? opts.rowTimeoutMs : undefined;
|
|
2715
|
+
const stuck = await watch(sides, rowTimeoutMs, () => view(flight, base, clients));
|
|
2665
2716
|
for (const entry of flights) if (entry.flight === flight) flights.delete(entry);
|
|
2666
2717
|
await closeAll(renewed);
|
|
2667
2718
|
if (stuck) {
|
|
2668
2719
|
flight.abandoned = true;
|
|
2669
|
-
return timedOut(stuck, base, made, sides, opts);
|
|
2720
|
+
return timedOut(stuck, base, made, sides, opts, rowTimeoutMs);
|
|
2670
2721
|
}
|
|
2671
2722
|
if (legs.control.unsupported === 'trustedEmulation')
|
|
2672
2723
|
return skipRow(base, 'not-supported:trustedEmulation');
|