@ai-ecoverse/slicc-browsers 1.44.0 → 1.46.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.
Binary file
@@ -81,11 +81,25 @@ function route(req, url, send, html, redirects) {
81
81
  'blob-nav',
82
82
  `<p>blob-nav ${escape(p.get('n') ?? '')}</p><script>const b=URL.createObjectURL(new Blob(['<!doctype html><title>blob</title><p>blob ${escape(p.get('n') ?? '')}</p>'],{type:'text/html'}));location.replace(b);</script>`
83
83
  ),
84
- '/credential': () =>
85
- html(
86
- 'credential',
87
- `<p>credential ${escape(p.get('n') ?? '')}</p><form><input name="u" /><button type="button">go</button></form>`
88
- ),
84
+ '/ordinary-cookie': () => {
85
+ const tag = encodeURIComponent(p.get('n') ?? '');
86
+ const received = new Set((req.headers.cookie ?? '').split(/;\s*/));
87
+ const pair = (name) => name + '-' + tag + '=' + tag;
88
+ const status = Object.fromEntries(
89
+ ['ordinary', 'batch', 'response', 'keep'].map((name) => [name, received.has(pair(name))])
90
+ );
91
+ const headers = p.has('inspect')
92
+ ? {}
93
+ : {
94
+ 'set-cookie': ['ordinary', 'response', 'keep'].map(
95
+ (name) => pair(name) + '; Path=/; HttpOnly'
96
+ ),
97
+ };
98
+ return send(200, JSON.stringify(status), 'application/json', {
99
+ 'cache-control': 'no-store',
100
+ ...headers,
101
+ });
102
+ },
89
103
  '/blank': () => html('blank', `<p>blank ${escape(p.get('n') ?? '')}</p>`),
90
104
  '/blank-open': () => html('blank-open', `<p>blank-open ${escape(p.get('n') ?? '')}</p>`),
91
105
  '/os/': () => html('os', `<p>os ${escape(p.get('n') ?? '')}</p>`),
package/guard-driver.mjs CHANGED
@@ -13,6 +13,7 @@ export const knownOrigins = [
13
13
  'vault',
14
14
  'vault-x',
15
15
  'apex',
16
+ 'preview',
16
17
  'own',
17
18
  'client',
18
19
  'plain',
@@ -277,8 +278,8 @@ export function result(vector, run) {
277
278
  };
278
279
  if (vector.kind === 'text')
279
280
  return { ...row, control: 'not-run', guarded: 'not-run', live: 'not-run' };
280
- if (vector.skip?.target === run.target)
281
- return { ...row, control: 'skip', guarded: 'skip', live: 'skip', reason: vector.skip.reason };
281
+ const reason = declaredSkip(vector, run.target);
282
+ if (reason) return { ...row, control: 'skip', guarded: 'skip', live: 'skip', reason };
282
283
  const missing = (vector.requires ?? []).find(
283
284
  (cap) => Array.isArray(run.capabilities) && !run.capabilities.includes(cap)
284
285
  );
@@ -374,9 +375,22 @@ function originReason(vector, row, reason) {
374
375
  ].includes(origin);
375
376
  }
376
377
 
378
+ export function removedStepReason(vector) {
379
+ for (const step of flatten([...(vector?.setup ?? []), ...(vector?.trigger ?? [])])) {
380
+ if (step.credentialExport === true) return 'not-applicable:removed-credential-export';
381
+ if (step.cookiePlant === 'credential' || step.cookiePlant === 'credential-set-cookie')
382
+ return 'not-applicable:removed-credential-cookie-plant';
383
+ }
384
+ return null;
385
+ }
386
+
387
+ const declaredSkip = (vector, target) =>
388
+ removedStepReason(vector) ?? (vector.skip?.target === target ? vector.skip.reason : null);
389
+
377
390
  export const skipReason = (vector, target, scope) => {
378
391
  if (!vector) return null;
379
- if (vector.skip?.target === target) return vector.skip.reason;
392
+ const declared = declaredSkip(vector, target);
393
+ if (declared) return declared;
380
394
  if (vector.observable?.[target] === false) return 'not-applicable';
381
395
  return vector.scope !== 'any' && vector.scope !== scope ? 'not-applicable' : null;
382
396
  };
package/guard-runner.mjs CHANGED
@@ -5,7 +5,6 @@ export { fixtureClient };
5
5
  import { bfcacheRestore } from './bfcache-restore.mjs';
6
6
  import { closeProtectedShape } from './close-protected-shape.mjs';
7
7
  import { cookiePlant } from './cookie-plant.mjs';
8
- import { credentialExport } from './credential-export.mjs';
9
8
  import { extensionFrame, protectedRefusal } from './extension-frame.mjs';
10
9
  import { DEFAULT_EXTENSION_WORLD_ID, extensionWorld } from './extension-world.mjs';
11
10
  import { frameRead } from './frame-read.mjs';
@@ -28,6 +27,7 @@ import {
28
27
  owned,
29
28
  parseURL,
30
29
  refusalError,
30
+ removedStepReason,
31
31
  summary as report,
32
32
  result,
33
33
  skipReason,
@@ -397,6 +397,16 @@ const callNames = (check) =>
397
397
  ].filter((name) => typeof name === 'string');
398
398
  const storageLeg = (step, capabilities) =>
399
399
  `${step.as ?? step.cdp}: ${step.cdp} ran on the ${browserStorageStep(step, capabilities) ? 'browser' : 'page'} session`;
400
+ const dotted = (domain) => `.${domain.replace(/^\.+/, '')}`;
401
+ const domainStates = (check) =>
402
+ !check || typeof check !== 'object'
403
+ ? []
404
+ : [
405
+ ...(check.state?.domain ? [check.state] : []),
406
+ ...[...(check.all ?? []), ...(check.any ?? []), ...(check.not ? [check.not] : [])].flatMap(
407
+ domainStates
408
+ ),
409
+ ];
400
410
  const stateCheck = (check) =>
401
411
  check?.state ||
402
412
  [...(check?.all ?? []), ...(check?.any ?? []), ...(check?.not ? [check.not] : [])]
@@ -647,7 +657,11 @@ class Execution {
647
657
  if (!spec || !this.reader) return;
648
658
  const state = expand(spec, this.vars);
649
659
  await this.reader.send('Storage.setCookies', {
650
- cookies: [{ name: state.cookie, value: state.value, url: state.origin }],
660
+ cookies: [
661
+ state.domain
662
+ ? { name: state.cookie, value: state.value, domain: dotted(state.domain), path: '/' }
663
+ : { name: state.cookie, value: state.value, url: state.origin },
664
+ ],
651
665
  ...(this.vars.context ? { browserContextId: this.vars.context } : {}),
652
666
  });
653
667
  if (!state.storage) return;
@@ -685,7 +699,9 @@ class Execution {
685
699
  const cookie = cookies.find(
686
700
  (entry) =>
687
701
  entry.name === state.cookie &&
688
- entry.domain.replace(/^\./, '') === new URL(state.origin).hostname
702
+ (state.domain
703
+ ? entry.domain === dotted(state.domain)
704
+ : entry.domain.replace(/^\./, '') === new URL(state.origin).hostname)
689
705
  );
690
706
  if (cookie?.value !== state.value) return false;
691
707
  if (!state.storage) return true;
@@ -1181,7 +1197,6 @@ class Execution {
1181
1197
  'errorPage',
1182
1198
  'closeProtectedShape',
1183
1199
  'protectedParentIframes',
1184
- 'credentialExport',
1185
1200
  'signInHold',
1186
1201
  'cookiePlant',
1187
1202
  'extensionWorld',
@@ -1196,7 +1211,6 @@ class Execution {
1196
1211
  'errorPage',
1197
1212
  'closeProtectedShape',
1198
1213
  'protectedParentIframes',
1199
- 'credentialExport',
1200
1214
  'signInHold',
1201
1215
  'cookiePlant',
1202
1216
  'redirectSecret',
@@ -1315,7 +1329,6 @@ class Execution {
1315
1329
  step.errorPage ||
1316
1330
  step.closeProtectedShape ||
1317
1331
  step.protectedParentIframes ||
1318
- step.credentialExport ||
1319
1332
  step.signInHold ||
1320
1333
  step.cookiePlant ||
1321
1334
  step.spawnWorker ||
@@ -1471,7 +1484,6 @@ class Execution {
1471
1484
  if (step.redirectSecret || step.errorPage) return this.originProbe(step, session);
1472
1485
  if (step.closeProtectedShape) return this.runCloseProtectedShape(step);
1473
1486
  if (step.protectedParentIframes) return this.runProtectedParentIframes(step);
1474
- if (step.credentialExport) return this.runCredentialExport(step);
1475
1487
  if (step.signInHold) return this.runSignInHold(step);
1476
1488
  if (step.cookiePlant) return this.runCookiePlant(step);
1477
1489
  if (step.spawnWorker) return this.spawnWorker(step);
@@ -1560,25 +1572,6 @@ class Execution {
1560
1572
  return out;
1561
1573
  }
1562
1574
 
1563
- runCredentialExport(step) {
1564
- return outcome(
1565
- credentialExport({
1566
- client: this.client,
1567
- reader: this.reader,
1568
- credentialOrigin: this.vars.idp ?? this.options.targets?.idp ?? this.vars.target,
1569
- ordinary: this.vars.plain ?? this.vars.ordinary,
1570
- tag: this.vars.tag,
1571
- internalSessions: this.internalSessions,
1572
- notes: this.notes,
1573
- budget: this.bound(8000),
1574
- refusalPrefix:
1575
- this.options.credentialOrigins?.refusal ??
1576
- this.options.catalog?.credentialOrigins?.refusal ??
1577
- 'slicc: refused:',
1578
- })
1579
- );
1580
- }
1581
-
1582
1575
  async runSignInHold(step) {
1583
1576
  const out = await outcome(
1584
1577
  signInHold({
@@ -1608,14 +1601,12 @@ class Execution {
1608
1601
  client: this.client,
1609
1602
  reader: this.reader,
1610
1603
  protectedOrigin: this.vars.protectedTarget,
1611
- credentialOrigin: this.vars.idp ?? this.options.targets?.idp ?? this.vars.protectedTarget,
1612
1604
  ordinary: this.vars.ordinary,
1613
1605
  tag: this.vars.tag,
1614
1606
  internalSessions: this.internalSessions,
1615
1607
  notes: this.notes,
1616
1608
  budget: this.bound(5000),
1617
1609
  control: this.side === 'control',
1618
- mode: step.cookiePlant,
1619
1610
  fixtureLog: () => this.options.fixture.log(),
1620
1611
  blockedMarkers: this.vector.blockedMarkers ?? [],
1621
1612
  onlyPaths: this.options.cookiePlantOnlyPaths ?? null,
@@ -2916,7 +2907,25 @@ class Execution {
2916
2907
  }
2917
2908
  }
2918
2909
 
2910
+ async cleanupDomainCookies() {
2911
+ if (!this.reader || this.vars.context) return;
2912
+ const cookies = [
2913
+ ...domainStates(this.vector.liveCheck),
2914
+ ...Object.values(this.vector.observe ?? {}).flatMap((o) => domainStates(o.check)),
2915
+ ]
2916
+ .map((state) => expand(state, this.vars))
2917
+ .map((state) => ({
2918
+ name: state.cookie,
2919
+ value: '',
2920
+ domain: dotted(state.domain),
2921
+ path: '/',
2922
+ expires: 1,
2923
+ }));
2924
+ if (cookies.length) await outcome(this.reader.send('Storage.setCookies', { cookies }));
2925
+ }
2926
+
2919
2927
  async cleanupLeg() {
2928
+ await this.cleanupDomainCookies();
2920
2929
  if (this.discovering)
2921
2930
  await this.answered(this.client.send('Target.setDiscoverTargets', { discover: false }));
2922
2931
  if (this.watch)
@@ -3007,7 +3016,6 @@ const needsObserver = (vector) =>
3007
3016
  step.spawnWorker ||
3008
3017
  step.closeProtectedShape ||
3009
3018
  step.protectedParentIframes ||
3010
- step.credentialExport ||
3011
3019
  step.signInHold ||
3012
3020
  step.cookiePlant ||
3013
3021
  step.rawTarget
@@ -3103,6 +3111,8 @@ function variables(targets, target, side, slot, index) {
3103
3111
  vars.protectedTarget = targets[target];
3104
3112
  vars.target = side === 'control' ? vars.plain : targets[target];
3105
3113
  vars.targetHost = new URL(vars.target).hostname;
3114
+ vars.targetParent =
3115
+ side === 'control' ? vars.targetHost : vars.targetHost.slice(vars.targetHost.indexOf('.') + 1);
3106
3116
  vars.idp = ['idp', 'idp-stg'].includes(target)
3107
3117
  ? targets[target]
3108
3118
  : (targets.idp ?? targets[target]);
@@ -3273,6 +3283,8 @@ async function executeRow(job, opts, made, set, slot, index, flights) {
3273
3283
  via: vector.control.via,
3274
3284
  transportVariant: clients.transportVariant === true,
3275
3285
  };
3286
+ const removed = removedStepReason(job.vector);
3287
+ if (removed) return skipRow(base, removed);
3276
3288
  const unavailable = scoped.missing;
3277
3289
  if (unavailable)
3278
3290
  return {