tagreeve 0.5.0-rc.1 → 0.5.0-rc.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/README.md +7 -5
- package/dist/cli.js +415 -145
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
Agent-first testing for tags and consent. Tagreeve plays a visitor in a real browser, records every tracking hit the site sends, and checks the result against what you expect. Tag-firing reports (which tags fired) are planned.
|
|
11
11
|
|
|
12
|
-
> **Status: 0.5 (`0.5.0-rc.
|
|
12
|
+
> **Status: 0.5 (`0.5.0-rc.2`).** Tagreeve plays a visitor in Chromium, records and decodes hits, answers the consent banner, checks YAML expectations and writes a JSONL record. 0.3 adds rules on payload fields and cookies, a `deniedIdentifiers` check, `tagreeve suite`, an HTML report, a Done control for handoff steps, role-based locators and a `select` step. 0.4 adds handoffs that end by themselves, an opt-in test payment step, baselines, a viewport option and fake identities by country. 0.5 adds `--server-container`, which runs your own server container in Docker and records what it sends to each vendor, a Conversions API decoder, several stores in one suite and platform hosts for Shopify. The rest of this README describes where Tagreeve is going, and marks what is not built yet. The design is in [docs/design.md](docs/design.md). Feedback is welcome in issues.
|
|
13
13
|
>
|
|
14
14
|
> **In 0.1:** `tagreeve run` with `stub` and `live` network modes; consent epochs, with withdrawals labelled apart from first rejects; seeded fake identities, hash checks and leak detection; decoders for GA4, Google Ads, Meta, Stape custom loader and a minimal server-container data client; banner handling through autoconsent; expectations; JSONL output.
|
|
15
15
|
>
|
|
@@ -17,7 +17,9 @@ Agent-first testing for tags and consent. Tagreeve plays a visitor in a real bro
|
|
|
17
17
|
>
|
|
18
18
|
> **In 0.3:** `body.has` and `body.only` rules on the field names of a hit; `cookie` rules; a `deniedIdentifiers` check that fails when an identifier goes out on a denied hit; `tagreeve suite` runs a folder of scenarios against several GTM builds; `tagreeve report` writes an HTML report of one run or a suite; a Done button in the handoff window; `click` and `wait` by role and name or from a list of selectors; a `select` step; the `server` network mode; record schema version 2. `deniedIdentifiers` fails by default, so a run that passed in 0.2 can exit 1. See [CHANGELOG.md](CHANGELOG.md).
|
|
19
19
|
>
|
|
20
|
-
> **In 0.5.0-rc.
|
|
20
|
+
> **In 0.5.0-rc.2** (install with `npm i -g tagreeve@next` until 0.5.0): the `payment` step finds Shopify card fields by `name` or `autocomplete` and frame path; a server container call just after a handoff is stored without its body and query values; summaries show query names only; hit and cookie rules take `from: <step label>`; every command has its own `--help`; and `--by-page` masks more value-like path segments. What is still open is in [CHANGELOG.md](CHANGELOG.md) under "Known in 0.5.0-rc.2".
|
|
21
|
+
>
|
|
22
|
+
> **In 0.5.0-rc.1** (install with `npm i -g tagreeve@next` until 0.5.0): `run` and `suite` take `--server-container` and `--server-container-config`, which run your own published server container in Docker, route the browser's requests for your `serverHosts` to it, and record every call it makes to a vendor, decoded and checked like browser hits; `tagreeve server-container build` builds the image; a `meta-capi` decoder; `suite --stores` runs each scenario against several stores; `platformHost` flags Shopify infrastructure requests; `unloadGap` also covers the end of a run; `--by-page` keys mask value-like path segments; and the old command alias is gone.
|
|
21
23
|
>
|
|
22
24
|
> **In 0.4.0-rc.3:** the `payment` step types into the exact card frame it checked, and the declaration hint names the failed step's provider. 0.4.0-rc.2 added test-mode declarations for payment hosts, the `earlyIdentifiers` check and better baselines.
|
|
23
25
|
>
|
|
@@ -43,7 +45,7 @@ Tagreeve is built so that a coding agent, a CI job or a person can answer these
|
|
|
43
45
|
|
|
44
46
|
1. **Plays a visitor.** A Playwright browser opens your site, answers the consent banner (accept, reject, or no answer), visits pages, fills forms with a fake identity and adds to cart. Steps that a tool must not do, such as paying or logging in, are handoff steps: a person acts in a visible window while recording continues.
|
|
45
47
|
2. **Records requests** from the page and from all iframes, including sandboxed iframes such as Shopify custom pixels. Capture from service workers works in Chromium only, and requests to the collector origin from dedicated workers are captured too. Each run reports which sources it covered.
|
|
46
|
-
3. **Decodes hits.** Vendor plugins turn raw requests into readable hits: GA4 events and consent state, Google Ads, Meta and Stape server-container traffic. Pinterest is decoded in 0.2. Hosts on the tracker list, such as LinkedIn, Microsoft UET and Reddit, give minimal hits with the vendor name. A full Microsoft UET decoder is not built yet.
|
|
48
|
+
3. **Decodes hits.** Vendor plugins turn raw requests into readable hits: GA4 events and consent state, Google Ads, Meta, Meta Conversions API and Stape server-container traffic. Pinterest is decoded in 0.2. Hosts on the tracker list, such as LinkedIn, Microsoft UET and Reddit, give minimal hits with the vendor name. A full Microsoft UET decoder is not built yet.
|
|
47
49
|
4. **Reports tag firing (not built yet).** An optional GTM template reports which tags fired or failed for each event, in the web container and the server container. Agents get this without a Google sign-in. Given the container's tag list, Tagreeve also reports which expected tags did not fire.
|
|
48
50
|
5. **Checks expectations.** Each scenario lists what must and must not happen, for example "no Meta request before consent" or "GA4 hits after a reject carry no user ID". Tagreeve reports pass or fail, with the evidence. A scenario that names a vendor Tagreeve does not know is rejected when it is parsed.
|
|
49
51
|
6. **Checks hashing.** Because Tagreeve knows the fake identity it typed, it can check that the hashed email and phone sent to Google and Meta are correct.
|
|
@@ -103,7 +105,7 @@ Node 22.18 or later. `npm i -g tagreeve@next` installs the newest 0.5 release ca
|
|
|
103
105
|
|
|
104
106
|
`consent: none` needs a banner that autoconsent detects. If none is shown, the run stops with "banner not shown" and exit code 2. Vendor keys are `ga4`, `google-ads`, `meta`, `meta-capi`, `pinterest`, `sgtm`, and every vendor on the tracker list (`linkedin`, `microsoft-uet`, `reddit`) or in a `--tracker-list` file. A scenario that names any other vendor is rejected when it is parsed.
|
|
105
107
|
|
|
106
|
-
Stub mode is the default: known collection endpoints are recorded and answered locally. Unknown destinations still receive hits and are flagged as `unknownDestination`, which fails the run. The registrable domain of `--site` is first party: for `--site https://www.shop.co.uk`, `shop.co.uk` and every `*.shop.co.uk` host are not unknown. Data-carrying requests to those subdomains that no decoder matches, such as server-side GTM on `sgtm.shop.co.uk/collect`, are listed as `firstPartySubdomain` flags, grouped by host. They do not fail the run. Hosts without a registrable domain, such as IP addresses and `localhost`, are first party only as the exact `--site` host. If a site serves its own assets from another domain, list it under `options: { firstPartyHosts: ['i.example-cdn.com', '*.example-static.com'] }`. To accept specific unknown hosts without calling them first party, use `options: { allowUnknownDestination: ['tracker.example.net'] }`; every other unknown destination still fails. `allowUnknownDestination: true` allows all of them, and the summary still lists them. Requests to Shopify's CDN and telemetry hosts (`cdn.shopify.com`, `monorail-edge.shopifysvc.com`) are flagged `platformHost` instead. They are listed but never fail the run. `options: { platformHosts: false }` flags them as `unknownDestination` again. A request sent while a sandboxed `srcdoc` iframe is loading can escape stubbing and recording (see [design §5.3](docs/design.md)). Use `--network live` to let everything through. Tagreeve decodes GA4, Google Ads, Meta, Pinterest and Stape traffic, and stubs the hosts on the tracker list. Hits to other vendors, such as TikTok, are not stubbed unless you add them with `--tracker-list`: they pass through and can only show up as `unknownDestination` flags.
|
|
108
|
+
Stub mode is the default: known collection endpoints are recorded and answered locally. Unknown destinations still receive hits and are flagged as `unknownDestination`, which fails the run. The registrable domain of `--site` is first party: for `--site https://www.shop.co.uk`, `shop.co.uk` and every `*.shop.co.uk` host are not unknown. Data-carrying requests to those subdomains that no decoder matches, such as server-side GTM on `sgtm.shop.co.uk/collect`, are listed as `firstPartySubdomain` flags, grouped by host. They do not fail the run. Hosts without a registrable domain, such as IP addresses and `localhost`, are first party only as the exact `--site` host. If a site serves its own assets from another domain, list it under `options: { firstPartyHosts: ['i.example-cdn.com', '*.example-static.com'] }`. To accept specific unknown hosts without calling them first party, use `options: { allowUnknownDestination: ['tracker.example.net'] }`; every other unknown destination still fails. `allowUnknownDestination: true` allows all of them, and the summary still lists them. Requests to Shopify's CDN and telemetry hosts (`cdn.shopify.com`, `monorail-edge.shopifysvc.com`) are flagged `platformHost` instead. They are listed but never fail the run. `options: { platformHosts: false }` flags them as `unknownDestination` again. A request sent while a sandboxed `srcdoc` iframe is loading can escape stubbing and recording (see [design §5.3](docs/design.md)). Use `--network live` to let everything through. Tagreeve decodes GA4, Google Ads, Meta, Meta Conversions API, Pinterest and Stape traffic, and stubs the hosts on the tracker list. Hits to other vendors, such as TikTok, are not stubbed unless you add them with `--tracker-list`: they pass through and can only show up as `unknownDestination` flags.
|
|
107
109
|
|
|
108
110
|
## Override and diff quick start
|
|
109
111
|
|
|
@@ -184,7 +186,7 @@ tagreeve run scenario.yml --site https://staging.example.com --tracker-list trac
|
|
|
184
186
|
|
|
185
187
|
## Safe by default
|
|
186
188
|
|
|
187
|
-
- **Known collection endpoints are stubbed by default.** Scripts load normally, but requests to known collection endpoints are recorded and answered locally. Unknown destinations pass through, so test hits can still reach vendors that way. Requests to hosts outside the site's registrable domain are flagged when they are `fetch`, `xhr`, `ping` or `beacon` requests, or images or other requests that carry a query or a body. They are flagged as `unknownDestination
|
|
189
|
+
- **Known collection endpoints are stubbed by default.** Scripts load normally, but requests to known collection endpoints are recorded and answered locally. Unknown destinations pass through, so test hits can still reach vendors that way. Requests to hosts outside the site's registrable domain are flagged when they are `fetch`, `xhr`, `ping` or `beacon` requests, or images or other requests that carry a query or a body. They are flagged as `unknownDestination`, except requests to known Shopify platform hosts, which get the flag `platformHost` and never fail a run. Scripts, stylesheets, fonts and documents are not flagged. Requests a sandboxed `srcdoc` iframe sends while it loads can escape stubbing and recording (design §5.3). Tagreeve lets them through because blocking by host would stop vendor scripts from loading and make a broken setup look compliant. Use `--network live` to let everything through.
|
|
188
190
|
- **Fake identities.** Every run uses a generated test identity. Tagreeve flags any email, phone number or hashed identifier in a recording that does not belong to that identity.
|
|
189
191
|
- **No log-ins, and payments only as an opt-in test.** On a hosted site a log-in is always a handoff step for a person, who should use test accounts. A payment is a handoff step too, except for the opt-in `payment` step, which types a provider's documented test card after three checks: `--allow-test-payment <host>`, the host in your allowlist file, and the provider's test mode, which you declare for the host in that file or which the page shows inside the card form. Only loopback hosts, such as the fixture shop, may be automated through a fake payment form.
|
|
190
192
|
- **You own the data.** There is no Tagreeve-hosted service. Everything runs on your machine. The opt-in server container feature runs your own container in your Docker, and the container downloads its own configuration from Google as it always does.
|
package/dist/cli.js
CHANGED
|
@@ -391,13 +391,14 @@ var utf8Lenient = new TextDecoder("utf-8");
|
|
|
391
391
|
var EDGE = 4;
|
|
392
392
|
var MIN_BYTES_FOR_EDGES = 12;
|
|
393
393
|
function binaryShare(text2) {
|
|
394
|
-
|
|
394
|
+
let total2 = 0;
|
|
395
395
|
let binary = 0;
|
|
396
|
-
for (
|
|
397
|
-
|
|
396
|
+
for (const ch of text2) {
|
|
397
|
+
total2++;
|
|
398
|
+
const c = ch.codePointAt(0);
|
|
398
399
|
if (c === 65533 || c < 32 && c !== 9 && c !== 10 && c !== 13 || c === 127) binary++;
|
|
399
400
|
}
|
|
400
|
-
return binary /
|
|
401
|
+
return total2 === 0 ? 0 : binary / total2;
|
|
401
402
|
}
|
|
402
403
|
function tryBase64Decode(token) {
|
|
403
404
|
const bytes = Buffer.from(token.replace(/-/g, "+").replace(/_/g, "/"), "base64");
|
|
@@ -1053,7 +1054,7 @@ var meta = {
|
|
|
1053
1054
|
|
|
1054
1055
|
// packages/decoders/src/meta-capi.ts
|
|
1055
1056
|
var HASH_FIELDS = ["em", "ph", "fn", "ln", "ct", "zp", "country", "external_id"];
|
|
1056
|
-
var
|
|
1057
|
+
var META_CAPI_PARAM_NAMES = {
|
|
1057
1058
|
em: "hashedEmail",
|
|
1058
1059
|
ph: "hashedPhone",
|
|
1059
1060
|
fn: "user_data.first_name",
|
|
@@ -1062,6 +1063,9 @@ var PARAM_NAMES = {
|
|
|
1062
1063
|
zp: "user_data.postal_code",
|
|
1063
1064
|
country: "user_data.country"
|
|
1064
1065
|
};
|
|
1066
|
+
function metaCapiBaseParam(name) {
|
|
1067
|
+
return name.replace(/\.\d+$/, "");
|
|
1068
|
+
}
|
|
1065
1069
|
var PRESENCE_FIELDS = ["fbp", "fbc"];
|
|
1066
1070
|
var EVENTS_PATH = /^\/v\d+(?:\.\d+)?\/(\d+)\/events\/?$/;
|
|
1067
1071
|
function eventsPixel(req) {
|
|
@@ -1083,6 +1087,12 @@ function str(v) {
|
|
|
1083
1087
|
if (typeof first === "string") return first === "" ? void 0 : first;
|
|
1084
1088
|
return typeof first === "number" ? String(first) : void 0;
|
|
1085
1089
|
}
|
|
1090
|
+
function strs(v) {
|
|
1091
|
+
return (Array.isArray(v) ? v : [v]).flatMap((item) => {
|
|
1092
|
+
if (typeof item === "string") return item === "" ? [] : [item];
|
|
1093
|
+
return typeof item === "number" ? [String(item)] : [];
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1086
1096
|
function eventItems(body) {
|
|
1087
1097
|
if (!body) return void 0;
|
|
1088
1098
|
try {
|
|
@@ -1099,11 +1109,11 @@ function decodeItem(item, req, pixel, newHitId, complete) {
|
|
|
1099
1109
|
const hashes = {};
|
|
1100
1110
|
const params = { pixelId: pixel };
|
|
1101
1111
|
for (const field of HASH_FIELDS) {
|
|
1102
|
-
const
|
|
1103
|
-
if (
|
|
1112
|
+
const values = strs(userData2[field]);
|
|
1113
|
+
if (values.length === 0) continue;
|
|
1104
1114
|
hashes[field] = { present: true, matchesIdentity: null };
|
|
1105
|
-
const param =
|
|
1106
|
-
if (param) params[param] = value;
|
|
1115
|
+
const param = META_CAPI_PARAM_NAMES[field];
|
|
1116
|
+
if (param) values.forEach((value, i) => params[i === 0 ? param : `${param}.${i}`] = value);
|
|
1107
1117
|
}
|
|
1108
1118
|
if (Object.keys(hashes).length > 0) ids.hashes = hashes;
|
|
1109
1119
|
for (const field of PRESENCE_FIELDS) if (str(userData2[field])) ids[field] = true;
|
|
@@ -1777,9 +1787,9 @@ var ScenarioError = class extends Error {
|
|
|
1777
1787
|
this.issues = issues;
|
|
1778
1788
|
}
|
|
1779
1789
|
};
|
|
1780
|
-
var VENDOR_KEYS = /* @__PURE__ */ new Set(["vendor", "event", "page", "transport", "host", "outcome", "count", "before", "in", "after"]);
|
|
1790
|
+
var VENDOR_KEYS = /* @__PURE__ */ new Set(["vendor", "event", "page", "transport", "host", "outcome", "count", "before", "in", "after", "from"]);
|
|
1781
1791
|
var GROUP_KEYS = ["consent", "ids", "params", "identity", "body"];
|
|
1782
|
-
var COOKIE_RULE_KEYS = ["cookie", "before", "in", "after"];
|
|
1792
|
+
var COOKIE_RULE_KEYS = ["cookie", "before", "in", "after", "from"];
|
|
1783
1793
|
var BODY_KEYS = ["has", "only", "ignore"];
|
|
1784
1794
|
var MAX_FIELD_NAME = 64;
|
|
1785
1795
|
var CONSENT_VALUES = ["granted", "denied", "unknown"];
|
|
@@ -2247,6 +2257,10 @@ function parseScenario(text2, extraVendorKeys = []) {
|
|
|
2247
2257
|
if (typeof v !== "string" || !v) fail(p, "must be a step label");
|
|
2248
2258
|
else if (!stepLabels2.has(v)) fail(p, `"${v}" is not a step label, defined labels: ${[...stepLabels2].join(", ") || "none"}`);
|
|
2249
2259
|
else rule.after = v;
|
|
2260
|
+
} else if (k === "from") {
|
|
2261
|
+
if (typeof v !== "string" || !v) fail(p, "must be a step label");
|
|
2262
|
+
else if (!stepLabels2.has(v)) fail(p, `"${v}" is not a step label, defined labels: ${[...stepLabels2].join(", ") || "none"}`);
|
|
2263
|
+
else rule.from = v;
|
|
2250
2264
|
} else if (VENDOR_KEYS.has(k)) {
|
|
2251
2265
|
fail(p, "invalid");
|
|
2252
2266
|
} else {
|
|
@@ -2255,8 +2269,9 @@ function parseScenario(text2, extraVendorKeys = []) {
|
|
|
2255
2269
|
}
|
|
2256
2270
|
if (rule.cookie) {
|
|
2257
2271
|
const mixed = Object.keys(flat).filter((k) => !COOKIE_RULE_KEYS.includes(k));
|
|
2258
|
-
if (mixed.length) fail(path, `cookie cannot be combined with ${mixed.join(", ")}; it only takes before, in and
|
|
2272
|
+
if (mixed.length) fail(path, `cookie cannot be combined with ${mixed.join(", ")}; it only takes before, in, after and from`);
|
|
2259
2273
|
}
|
|
2274
|
+
if (rule.from && rule.after) fail(path, "use either from or after, not both");
|
|
2260
2275
|
if (rule.before && rule.inEpoch) fail(path, "use either before or in, not both");
|
|
2261
2276
|
if (rule.body?.has && rule.body.only) fail(path, "body.has and body.only cannot be in the same entry");
|
|
2262
2277
|
if (rule.body && rule.hashesMatch) fail(path, "identity.hashesMatch cannot be combined with body.has or body.only");
|
|
@@ -2430,7 +2445,17 @@ function evaluate(records, scenario, options = {}) {
|
|
|
2430
2445
|
builtInChecks(records, scenario, ctx, add2);
|
|
2431
2446
|
return results;
|
|
2432
2447
|
}
|
|
2433
|
-
var isScoped = (rule) => Boolean(rule.before || rule.inEpoch || rule.after || consentFields.some((f) => rule.filter.consent[f]));
|
|
2448
|
+
var isScoped = (rule) => Boolean(rule.before || rule.inEpoch || rule.after || rule.from || consentFields.some((f) => rule.filter.consent[f]));
|
|
2449
|
+
function ruleWindowStart(rule, ctx) {
|
|
2450
|
+
const label = rule.from ?? rule.after;
|
|
2451
|
+
if (!label) return void 0;
|
|
2452
|
+
const step = ctx.steps.find((s) => s.label === label);
|
|
2453
|
+
if (!step) {
|
|
2454
|
+
const known = ctx.steps.map((s) => s.label).join(", ") || "none";
|
|
2455
|
+
return { pass: false, evidence: [], message: `Expected a step labelled "${label}", but the run has steps: ${known}.` };
|
|
2456
|
+
}
|
|
2457
|
+
return rule.from ? { at: step.startedAt, text: `from ${label}` } : { at: step.endedAt ?? step.startedAt, text: `after ${label}` };
|
|
2458
|
+
}
|
|
2434
2459
|
function evaluateRule(rule, ctx) {
|
|
2435
2460
|
const outcome = evaluateRuleHits(rule, ctx);
|
|
2436
2461
|
if (rule.cookie || !isScoped(rule)) return outcome;
|
|
@@ -2484,19 +2509,16 @@ function evaluateRuleHits(rule, ctx) {
|
|
|
2484
2509
|
hits = hits.filter((h) => anywhere(h) || inEpoch(h, selector, ctx));
|
|
2485
2510
|
narrowed.push(`in epoch(${selector})`);
|
|
2486
2511
|
}
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
return { pass: false, evidence: [], message: `Expected a step labelled "${rule.after}", but the run has steps: ${known}.` };
|
|
2492
|
-
}
|
|
2493
|
-
const from = step.endedAt ?? step.startedAt;
|
|
2512
|
+
const windowStart = ruleWindowStart(rule, ctx);
|
|
2513
|
+
if (windowStart && "message" in windowStart) return windowStart;
|
|
2514
|
+
if (windowStart) {
|
|
2515
|
+
const { at: start, text: text2 } = windowStart;
|
|
2494
2516
|
hits = hits.filter((h) => {
|
|
2495
2517
|
if (anywhere(h)) return true;
|
|
2496
2518
|
const at = judgedAt(h, ctx.index);
|
|
2497
|
-
return at !== void 0 && at >=
|
|
2519
|
+
return at !== void 0 && at >= start;
|
|
2498
2520
|
});
|
|
2499
|
-
narrowed.push(
|
|
2521
|
+
narrowed.push(text2);
|
|
2500
2522
|
}
|
|
2501
2523
|
const where2 = narrowed.length ? ` ${narrowed.join(", ")}` : "";
|
|
2502
2524
|
const vacuous = rule.before ? vacuousBeforeConsent(rule, ctx) : void 0;
|
|
@@ -2598,16 +2620,9 @@ function evaluateCookieRule(rule, patterns, ctx) {
|
|
|
2598
2620
|
let sightings = cookieSightings(patterns.map((p) => globToRegExp(p)), ctx);
|
|
2599
2621
|
const total2 = sightings.length;
|
|
2600
2622
|
const narrowed = [];
|
|
2601
|
-
|
|
2602
|
-
if (
|
|
2603
|
-
|
|
2604
|
-
if (!step) {
|
|
2605
|
-
const known = ctx.steps.map((s) => s.label).join(", ") || "none";
|
|
2606
|
-
return { pass: false, evidence: [], message: `Expected a step labelled "${rule.after}", but the run has steps: ${known}.` };
|
|
2607
|
-
}
|
|
2608
|
-
from = step.endedAt ?? step.startedAt;
|
|
2609
|
-
}
|
|
2610
|
-
const timed = rule.before || rule.inEpoch || from !== void 0;
|
|
2623
|
+
const windowStart = ruleWindowStart(rule, ctx);
|
|
2624
|
+
if (windowStart && "message" in windowStart) return windowStart;
|
|
2625
|
+
const timed = rule.before || rule.inEpoch || windowStart !== void 0;
|
|
2611
2626
|
const unplaced = timed ? sightings.filter((s) => s.t === void 0) : [];
|
|
2612
2627
|
if (timed) sightings = sightings.filter((s) => s.t !== void 0);
|
|
2613
2628
|
const keep = (test) => {
|
|
@@ -2622,9 +2637,9 @@ function evaluateCookieRule(rule, patterns, ctx) {
|
|
|
2622
2637
|
keep((t) => inEpochAt(t, selector, ctx));
|
|
2623
2638
|
narrowed.push(`in epoch(${selector})`);
|
|
2624
2639
|
}
|
|
2625
|
-
if (
|
|
2626
|
-
keep((t) => t >=
|
|
2627
|
-
narrowed.push(
|
|
2640
|
+
if (windowStart) {
|
|
2641
|
+
keep((t) => t >= windowStart.at);
|
|
2642
|
+
narrowed.push(windowStart.text);
|
|
2628
2643
|
}
|
|
2629
2644
|
const where2 = narrowed.length ? ` ${narrowed.join(", ")}` : "";
|
|
2630
2645
|
const headerNames = new Set(sightings.filter((s) => s.source === "Set-Cookie").map((s) => s.name));
|
|
@@ -2774,7 +2789,7 @@ function matchesFilter(hit, f, ctx) {
|
|
|
2774
2789
|
if (want && effective[field] !== want) return false;
|
|
2775
2790
|
}
|
|
2776
2791
|
for (const [name, want] of Object.entries(f.ids)) {
|
|
2777
|
-
const have = idValue(hit, name);
|
|
2792
|
+
const have = idValue(hit, name, ctx);
|
|
2778
2793
|
const compared = name.endsWith(".matchesIdentity");
|
|
2779
2794
|
const present = compared ? have === true : have !== void 0 && have !== false;
|
|
2780
2795
|
const absent = compared ? have === false : !present;
|
|
@@ -2798,7 +2813,7 @@ function matchesFilter(hit, f, ctx) {
|
|
|
2798
2813
|
}
|
|
2799
2814
|
return true;
|
|
2800
2815
|
}
|
|
2801
|
-
function idValue(hit, name) {
|
|
2816
|
+
function idValue(hit, name, ctx) {
|
|
2802
2817
|
if (name === "hashes") return Object.values(hit.ids.hashes ?? {}).some((h) => h.present);
|
|
2803
2818
|
if (Object.hasOwn(hit.ids, name)) {
|
|
2804
2819
|
const flat = hit.ids[name];
|
|
@@ -2809,7 +2824,7 @@ function idValue(hit, name) {
|
|
|
2809
2824
|
const hash = hit.ids.hashes && Object.hasOwn(hit.ids.hashes, field) ? hit.ids.hashes[field] : void 0;
|
|
2810
2825
|
if (!hash) return void 0;
|
|
2811
2826
|
if (prop === void 0) return hash.present;
|
|
2812
|
-
return prop === "matchesIdentity" ? hash.matchesIdentity : void 0;
|
|
2827
|
+
return prop === "matchesIdentity" ? hash.matchesIdentity ?? capiMatchesIdentity(hit, field, ctx.identity) : void 0;
|
|
2813
2828
|
}
|
|
2814
2829
|
function hostForms(url) {
|
|
2815
2830
|
try {
|
|
@@ -2951,10 +2966,39 @@ function joinLabels(labels) {
|
|
|
2951
2966
|
return all.length > 1 ? `${all.slice(0, -1).join(", ")} and ${all.at(-1)}` : all[0] ?? "";
|
|
2952
2967
|
}
|
|
2953
2968
|
var PLAIN_ADDRESS_PARAMS = /* @__PURE__ */ new Set(["user_data.city", "user_data.postal_code", "user_data.country"]);
|
|
2969
|
+
var PLAIN_ADDRESS_VENDORS = /* @__PURE__ */ new Set(["sgtm"]);
|
|
2954
2970
|
var DIGEST_SHAPE = /^(?:[0-9a-f]{64}|[A-Za-z0-9+/_-]{43}=?)$/i;
|
|
2955
2971
|
function allForms(h) {
|
|
2956
2972
|
return [h.hex, h.base64, h.base64url];
|
|
2957
2973
|
}
|
|
2974
|
+
function identityParamName(vendor, name) {
|
|
2975
|
+
return vendor === "meta-capi" ? metaCapiBaseParam(name) : name;
|
|
2976
|
+
}
|
|
2977
|
+
function hashJudge(identity) {
|
|
2978
|
+
const emailHashes = new Set(allForms(hashEmail(identity.email)));
|
|
2979
|
+
const phone = hashPhone(identity.phone);
|
|
2980
|
+
const phoneHashes = /* @__PURE__ */ new Set([...allForms(phone), ...allForms(sha256(identity.phone.replace(/\D/g, "")))]);
|
|
2981
|
+
const plain = /* @__PURE__ */ new Set([identity.email.toLowerCase(), identity.phone.toLowerCase(), identity.phone.replace(/\D/g, "")]);
|
|
2982
|
+
const extra = identity.extra ?? [];
|
|
2983
|
+
return (vendor, rawName, value) => {
|
|
2984
|
+
const name = identityParamName(vendor, rawName);
|
|
2985
|
+
const field = FIELD_PARAMS[name]?.(identity);
|
|
2986
|
+
const accepted = field === void 0 ? [] : [field, ...extra];
|
|
2987
|
+
const known = EMAIL_PARAM.test(name) ? emailHashes : PHONE_PARAM.test(name) ? phoneHashes : field !== void 0 ? fieldHashes(...accepted) : void 0;
|
|
2988
|
+
if (!known || !value) return void 0;
|
|
2989
|
+
if (PLAIN_ADDRESS_PARAMS.has(name) && PLAIN_ADDRESS_VENDORS.has(vendor) && !DIGEST_SHAPE.test(value)) return "plain";
|
|
2990
|
+
if (known.has(value)) return "match";
|
|
2991
|
+
const typed = value.trim().toLowerCase();
|
|
2992
|
+
return plain.has(typed) || accepted.some((v) => v.trim().toLowerCase() === typed) ? "unhashed" : "wrong";
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
function capiMatchesIdentity(hit, field, identity) {
|
|
2996
|
+
const base2 = Object.hasOwn(META_CAPI_PARAM_NAMES, field) ? META_CAPI_PARAM_NAMES[field] : void 0;
|
|
2997
|
+
if (hit.vendor !== "meta-capi" || !identity || !base2) return null;
|
|
2998
|
+
const judge2 = hashJudge(identity);
|
|
2999
|
+
const verdicts2 = Object.entries(hit.params).filter(([name]) => metaCapiBaseParam(name) === base2).map(([name, value]) => judge2(hit.vendor, name, value)).filter((v) => v !== void 0);
|
|
3000
|
+
return verdicts2.length === 0 ? null : verdicts2.every((v) => v === "match");
|
|
3001
|
+
}
|
|
2958
3002
|
function checkHashes(hits, ctx) {
|
|
2959
3003
|
const identity = ctx.identity;
|
|
2960
3004
|
if (!identity) {
|
|
@@ -2965,11 +3009,7 @@ function checkHashes(hits, ctx) {
|
|
|
2965
3009
|
message: "no run identity was given, so the hashes could not be checked."
|
|
2966
3010
|
};
|
|
2967
3011
|
}
|
|
2968
|
-
const
|
|
2969
|
-
const phone = hashPhone(identity.phone);
|
|
2970
|
-
const phoneHashes = /* @__PURE__ */ new Set([...allForms(phone), ...allForms(sha256(identity.phone.replace(/\D/g, "")))]);
|
|
2971
|
-
const plain = /* @__PURE__ */ new Set([identity.email.toLowerCase(), identity.phone.toLowerCase(), identity.phone.replace(/\D/g, "")]);
|
|
2972
|
-
const extra = identity.extra ?? [];
|
|
3012
|
+
const judge2 = hashJudge(identity);
|
|
2973
3013
|
const withHash = [];
|
|
2974
3014
|
const wrong = [];
|
|
2975
3015
|
const unhashed = [];
|
|
@@ -2987,26 +3027,24 @@ function checkHashes(hits, ctx) {
|
|
|
2987
3027
|
for (const id of Object.keys(hit.ids)) if (id !== "hashedEmail" && id !== "hashedPhone") uncheckedFields.add(guardFieldName(id));
|
|
2988
3028
|
}
|
|
2989
3029
|
for (const [name, value] of Object.entries(hit.params)) {
|
|
2990
|
-
const
|
|
2991
|
-
|
|
2992
|
-
const
|
|
2993
|
-
if (
|
|
2994
|
-
|
|
2995
|
-
plainAddressFields.add(fieldLabel(name));
|
|
3030
|
+
const verdict = judge2(hit.vendor, name, value);
|
|
3031
|
+
if (!verdict) continue;
|
|
3032
|
+
const label = fieldLabel(identityParamName(hit.vendor, name));
|
|
3033
|
+
if (verdict === "plain") {
|
|
3034
|
+
plainAddressFields.add(label);
|
|
2996
3035
|
continue;
|
|
2997
3036
|
}
|
|
2998
3037
|
seen = true;
|
|
2999
|
-
if (
|
|
3000
|
-
matchedFields.add(
|
|
3038
|
+
if (verdict === "match") {
|
|
3039
|
+
matchedFields.add(label);
|
|
3001
3040
|
continue;
|
|
3002
3041
|
}
|
|
3003
3042
|
bad = true;
|
|
3004
|
-
|
|
3005
|
-
if (plain.has(typed) || accepted.some((v) => v.trim().toLowerCase() === typed)) {
|
|
3043
|
+
if (verdict === "unhashed") {
|
|
3006
3044
|
raw = true;
|
|
3007
|
-
unhashedFields.add(
|
|
3045
|
+
unhashedFields.add(label);
|
|
3008
3046
|
} else {
|
|
3009
|
-
wrongFields.add(
|
|
3047
|
+
wrongFields.add(label);
|
|
3010
3048
|
wrongParams.add(name);
|
|
3011
3049
|
}
|
|
3012
3050
|
}
|
|
@@ -3048,6 +3086,15 @@ function checkHashes(hits, ctx) {
|
|
|
3048
3086
|
}
|
|
3049
3087
|
return { pass: true, evidence: withHash, message: `Hashed values in ${withHash.length} hit(s) match the run identity.` };
|
|
3050
3088
|
}
|
|
3089
|
+
function pageWithoutQuery(page2) {
|
|
3090
|
+
if (!page2) return "";
|
|
3091
|
+
try {
|
|
3092
|
+
const url = new URL(page2);
|
|
3093
|
+
return `${url.host}${url.pathname}`;
|
|
3094
|
+
} catch {
|
|
3095
|
+
return page2.split(/[?#]/)[0];
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3051
3098
|
function flagHost(flag2, ctx) {
|
|
3052
3099
|
const urls = [ctx.requests.get(flag2.recordIds[0] ?? "")?.url, /\s(\S+)$/.exec(flag2.detail)?.[1]];
|
|
3053
3100
|
for (const url of urls) {
|
|
@@ -3096,7 +3143,7 @@ function builtInChecks(records, scenario, ctx, addResult) {
|
|
|
3096
3143
|
"sandboxPageUrl",
|
|
3097
3144
|
sandboxed.length === 0,
|
|
3098
3145
|
sandboxed.map((h) => h.id),
|
|
3099
|
-
sandboxed.length === 0 ? "Expected no hit to carry a sandbox URL as its page, found none." : `Expected no hit to carry a sandbox URL as its page, found ${sandboxed.length}: ${sandboxed[0].page}.`
|
|
3146
|
+
sandboxed.length === 0 ? "Expected no hit to carry a sandbox URL as its page, found none." : `Expected no hit to carry a sandbox URL as its page, found ${sandboxed.length}: ${pageWithoutQuery(sandboxed[0].page)}.`
|
|
3100
3147
|
);
|
|
3101
3148
|
for (const check of [deniedIdentifiersCheck, earlyIdentifiersCheck]) {
|
|
3102
3149
|
const passes = (c) => {
|
|
@@ -3400,7 +3447,7 @@ function leafTexts(text2) {
|
|
|
3400
3447
|
const path = name.split(".");
|
|
3401
3448
|
path[path.length - 1] = path[path.length - 1].replace(/\[\]/g, "");
|
|
3402
3449
|
const where2 = guardFieldName(name);
|
|
3403
|
-
if (path.length > 1) out.push({ text: path.slice(0, -1).join("."), where: where2, leaf: true });
|
|
3450
|
+
if (path.length > 1) out.push({ text: path.slice(0, -1).join("."), where: where2, leaf: true, name: true });
|
|
3404
3451
|
out.push({ text: `${path[path.length - 1]}=${value}`, where: where2, leaf: true });
|
|
3405
3452
|
}
|
|
3406
3453
|
}
|
|
@@ -3418,12 +3465,13 @@ function bodyTexts(headers, body) {
|
|
|
3418
3465
|
if (body === "" || headersSayBinary(headers)) return [];
|
|
3419
3466
|
const split = splitMultipart(body, headers);
|
|
3420
3467
|
if (split?.parts.length) {
|
|
3468
|
+
const wholeIsBinary = isBinaryText(body);
|
|
3421
3469
|
const named = split.parts.flatMap((part) => {
|
|
3422
3470
|
const name = multipartPartName(part);
|
|
3423
|
-
if (isBinaryBody(part.headers, part.body)) return [];
|
|
3471
|
+
if (wholeIsBinary && isBinaryBody(part.headers, part.body)) return [];
|
|
3424
3472
|
return name === void 0 ? leafTexts(part.body) : [{ text: `${name}=${part.body}`, where: guardFieldName(name), leaf: true }];
|
|
3425
3473
|
});
|
|
3426
|
-
return [{ text: withoutBinaryParts(split,
|
|
3474
|
+
return [{ text: withoutBinaryParts(split, wholeIsBinary), where: "the body" }, ...named];
|
|
3427
3475
|
}
|
|
3428
3476
|
const isJson = /^\s*[{[]/.test(body) && bodyEntries({ postData: body }).parsed;
|
|
3429
3477
|
if (!isJson && /[\r\n]/.test(body.trim())) {
|
|
@@ -3432,18 +3480,27 @@ function bodyTexts(headers, body) {
|
|
|
3432
3480
|
}
|
|
3433
3481
|
return isBinaryText(body) ? [] : [{ text: body, where: "the body" }, ...leafTexts(body)];
|
|
3434
3482
|
}
|
|
3435
|
-
function
|
|
3483
|
+
function isEdgeShift(a, b, bodies) {
|
|
3484
|
+
const [short, long] = a.length <= b.length ? [a, b] : [b, a];
|
|
3485
|
+
if (!long.includes(short)) return false;
|
|
3486
|
+
return bodies.every((raw) => {
|
|
3487
|
+
const text2 = raw.replace(/\[\]|%5B%5D/gi, "");
|
|
3488
|
+
const covered = [];
|
|
3489
|
+
for (let i = text2.indexOf(long); i >= 0; i = text2.indexOf(long, i + 1)) covered.push([i, i + long.length]);
|
|
3490
|
+
for (let i = text2.indexOf(short); i >= 0; i = text2.indexOf(short, i + 1)) {
|
|
3491
|
+
if (!covered.some(([from, to]) => i >= from && i + short.length <= to)) return false;
|
|
3492
|
+
}
|
|
3493
|
+
return true;
|
|
3494
|
+
});
|
|
3495
|
+
}
|
|
3496
|
+
function mergeEdgeReadings(found, bodies) {
|
|
3436
3497
|
const best = (f) => Math.min(...f.where.values());
|
|
3437
3498
|
const valueOf2 = (key, kind) => key.slice(kind.length + 1);
|
|
3438
3499
|
const fields2 = [...found].filter(([, f]) => best(f) < 2);
|
|
3439
3500
|
for (const [key, f] of [...found]) {
|
|
3440
|
-
if (best(f) < 2) continue;
|
|
3501
|
+
if (best(f) < 2 || [...f.where.keys()].some((w) => w !== "the body")) continue;
|
|
3441
3502
|
const value = valueOf2(key, f.kind);
|
|
3442
|
-
const twin = fields2.find(([k, other]) =>
|
|
3443
|
-
if (other.kind !== f.kind) return false;
|
|
3444
|
-
const v = valueOf2(k, other.kind);
|
|
3445
|
-
return v.includes(value) || value.includes(v);
|
|
3446
|
-
});
|
|
3503
|
+
const twin = fields2.find(([k, other]) => other.kind === f.kind && isEdgeShift(valueOf2(k, other.kind), value, bodies));
|
|
3447
3504
|
if (!twin) continue;
|
|
3448
3505
|
for (const [w, tier] of f.where) twin[1].where.set(w, Math.min(tier, twin[1].where.get(w) ?? tier));
|
|
3449
3506
|
found.delete(key);
|
|
@@ -3463,7 +3520,7 @@ function findForeignData(requests, hits, identity) {
|
|
|
3463
3520
|
const url = scannedUrl(request, persisted.url, hitRequests.has(request.id));
|
|
3464
3521
|
const texts = slot(request.id, request.stepId).texts;
|
|
3465
3522
|
for (const text2 of [url, ...pathSegments(url)]) texts.push({ text: text2, where: "the URL" });
|
|
3466
|
-
|
|
3523
|
+
for (const text2 of bodyTexts(request.headers, persisted.postData)) texts.push(text2);
|
|
3467
3524
|
}
|
|
3468
3525
|
for (const hit of hits) {
|
|
3469
3526
|
const entry = slot(hit.requestId, hit.stepId);
|
|
@@ -3476,9 +3533,10 @@ function findForeignData(requests, hits, identity) {
|
|
|
3476
3533
|
const out = [];
|
|
3477
3534
|
for (const [requestId, entry] of byRequest) {
|
|
3478
3535
|
const found = /* @__PURE__ */ new Map();
|
|
3479
|
-
for (const { text: text2, where: where2, leaf } of entry.texts) {
|
|
3536
|
+
for (const { text: text2, where: where2, leaf, name } of entry.texts) {
|
|
3480
3537
|
const tier = where2 === "the URL" || where2 === "the body" ? 2 : leaf ? 1 : 0;
|
|
3481
3538
|
for (const m of scan(text2, identity, { stableHashes })) {
|
|
3539
|
+
if (name && m.kind === "phone") continue;
|
|
3482
3540
|
const key = `${m.kind}:${m.value}`;
|
|
3483
3541
|
const seen = found.get(key) ?? { kind: m.kind, where: /* @__PURE__ */ new Map() };
|
|
3484
3542
|
seen.where.set(where2, Math.min(tier, seen.where.get(where2) ?? tier));
|
|
@@ -3486,7 +3544,10 @@ function findForeignData(requests, hits, identity) {
|
|
|
3486
3544
|
}
|
|
3487
3545
|
}
|
|
3488
3546
|
if (found.size === 0) continue;
|
|
3489
|
-
mergeEdgeReadings(
|
|
3547
|
+
mergeEdgeReadings(
|
|
3548
|
+
found,
|
|
3549
|
+
entry.texts.filter((t) => t.where === "the body" && !t.leaf).map((t) => t.text)
|
|
3550
|
+
);
|
|
3490
3551
|
const kinds = [...new Set([...found.values()].map((f) => f.kind))].join(", ");
|
|
3491
3552
|
const places = /* @__PURE__ */ new Set();
|
|
3492
3553
|
for (const { where: where2 } of found.values()) {
|
|
@@ -3679,7 +3740,11 @@ function groupHits(run, options) {
|
|
|
3679
3740
|
}
|
|
3680
3741
|
return groups;
|
|
3681
3742
|
}
|
|
3682
|
-
|
|
3743
|
+
function isValueSegment(segment) {
|
|
3744
|
+
if (looksLikeValueToken(segment) || looksLikeValueToken(segment.replaceAll("-", ""))) return true;
|
|
3745
|
+
if (segment.includes("@") || /%[0-9a-fA-F]{2}/.test(segment)) return true;
|
|
3746
|
+
return valueKinds(segment).size > 0;
|
|
3747
|
+
}
|
|
3683
3748
|
function pagePath(page2) {
|
|
3684
3749
|
if (page2 === null) return "";
|
|
3685
3750
|
let path;
|
|
@@ -3732,11 +3797,12 @@ function hostOf2(url) {
|
|
|
3732
3797
|
}
|
|
3733
3798
|
}
|
|
3734
3799
|
function allowedFlagIds(run) {
|
|
3800
|
+
const platform = run.flags.filter((f) => f.kind === "platformHost").map((f) => f.id);
|
|
3735
3801
|
const check = run.results.find((r) => r.expectation === "builtin: unknownDestination");
|
|
3736
|
-
if (!check) return
|
|
3802
|
+
if (!check) return new Set(platform);
|
|
3737
3803
|
const unknown = run.flags.filter((f) => f.kind === "unknownDestination").map((f) => f.id);
|
|
3738
3804
|
const blocked = new Set(check.pass ? [] : check.evidence);
|
|
3739
|
-
return new Set(unknown.filter((id) => !blocked.has(id)));
|
|
3805
|
+
return /* @__PURE__ */ new Set([...platform, ...unknown.filter((id) => !blocked.has(id))]);
|
|
3740
3806
|
}
|
|
3741
3807
|
function flagCounts(run) {
|
|
3742
3808
|
const requestHosts = new Map(run.requests.map((r) => [r.id, hostOf2(r.url)]));
|
|
@@ -4088,6 +4154,11 @@ var GA4_ALIASES = {
|
|
|
4088
4154
|
checkout_completed: "purchase",
|
|
4089
4155
|
search_submitted: "search"
|
|
4090
4156
|
};
|
|
4157
|
+
function sameFrame(a, b) {
|
|
4158
|
+
if (!b) return false;
|
|
4159
|
+
if (a.id !== null && b.id !== null) return a.id === b.id;
|
|
4160
|
+
return a.url !== null && a.url === b.url;
|
|
4161
|
+
}
|
|
4091
4162
|
function unloadGapAdvice(networkMode) {
|
|
4092
4163
|
return networkMode === "live" ? "which is not captured without --net-log" : "which stub mode cannot capture. Add the name to options.unloadGapIgnore if the hit is not needed, or check it in a live run with --network live --net-log";
|
|
4093
4164
|
}
|
|
@@ -4110,7 +4181,7 @@ function buildUnloadGapFlags({ runId, networkMode, events, hits, navigations, ru
|
|
|
4110
4181
|
if (ga4Hits.length === 0 && hits.some(covered)) continue;
|
|
4111
4182
|
if (ga4Hits.some((h) => h.t >= event.t && h.t <= navigation + UNLOAD_GAP_SLACK_MS && h.event !== null && (h.event === name || h.event === expected || !ga4Name && GA4_EVENTS.has(h.event)))) continue;
|
|
4112
4183
|
const eventFrame = eventFrames?.get(event.id);
|
|
4113
|
-
if (eventFrame !== void 0 && ga4Hits.some((h) => h.t >= event.t && h.t <= navigation + UNLOAD_GAP_SLACK_MS && requestFrames?.get(h.requestId)
|
|
4184
|
+
if (eventFrame !== void 0 && ga4Hits.some((h) => h.t >= event.t && h.t <= navigation + UNLOAD_GAP_SLACK_MS && sameFrame(eventFrame, requestFrames?.get(h.requestId)))) continue;
|
|
4114
4185
|
const seconds = ((navigation - event.t) / 1e3).toFixed(1);
|
|
4115
4186
|
const unload = navigation === runEnd && !navigations.includes(navigation) ? "the run ended" : "the page navigated";
|
|
4116
4187
|
flags2.push(
|
|
@@ -5115,7 +5186,17 @@ function classifyForward(method, url) {
|
|
|
5115
5186
|
var USERNAME = "tagreeve";
|
|
5116
5187
|
var MAX_BODY_BYTES2 = 1024 * 1024;
|
|
5117
5188
|
var IDLE_TIMEOUT_MS = 3e4;
|
|
5118
|
-
var
|
|
5189
|
+
var UNSPECIFIED_ADDRESSES = /* @__PURE__ */ new Set(["0.0.0.0", "::", "::ffff:0.0.0.0"]);
|
|
5190
|
+
function isUnspecifiedHost(host) {
|
|
5191
|
+
const bare = host.replace(/^\[|\]$/g, "");
|
|
5192
|
+
if (bare === "") return true;
|
|
5193
|
+
try {
|
|
5194
|
+
const normalized = new URL(`http://${bare.includes(":") ? `[${bare}]` : bare}`).hostname.replace(/^\[|\]$/g, "");
|
|
5195
|
+
return UNSPECIFIED_ADDRESSES.has(normalized) || normalized === "::ffff:0:0";
|
|
5196
|
+
} catch {
|
|
5197
|
+
return false;
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5119
5200
|
function digest(value) {
|
|
5120
5201
|
return createHash2("sha256").update(value).digest();
|
|
5121
5202
|
}
|
|
@@ -5133,7 +5214,7 @@ function parseConnectTarget(authority) {
|
|
|
5133
5214
|
}
|
|
5134
5215
|
}
|
|
5135
5216
|
async function createRecordingProxy(options) {
|
|
5136
|
-
if (
|
|
5217
|
+
if (isUnspecifiedHost(options.host)) throw new Error("The proxy must not listen on a wildcard address.");
|
|
5137
5218
|
const credential = randomBytes3(24).toString("base64url");
|
|
5138
5219
|
const expected = digest(`Basic ${Buffer.from(`${USERNAME}:${credential}`).toString("base64")}`);
|
|
5139
5220
|
const idleMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
@@ -5284,6 +5365,10 @@ async function createRecordingProxy(options) {
|
|
|
5284
5365
|
});
|
|
5285
5366
|
});
|
|
5286
5367
|
const address = server.address();
|
|
5368
|
+
if (address && typeof address === "object" && isUnspecifiedHost(address.address)) {
|
|
5369
|
+
await new Promise((resolve3) => server.close(() => resolve3()));
|
|
5370
|
+
throw new Error("The proxy must not listen on a wildcard address.");
|
|
5371
|
+
}
|
|
5287
5372
|
const port = typeof address === "object" && address ? address.port : options.port;
|
|
5288
5373
|
return {
|
|
5289
5374
|
host: options.host,
|
|
@@ -5502,6 +5587,13 @@ function runDocker(args, options = {}) {
|
|
|
5502
5587
|
});
|
|
5503
5588
|
});
|
|
5504
5589
|
}
|
|
5590
|
+
var DOCKER_INSTALL_URL = "https://docs.docker.com/get-docker/";
|
|
5591
|
+
var DOCKER_NEEDED_MESSAGE = `Docker is needed for --server-container. Install it from ${DOCKER_INSTALL_URL}`;
|
|
5592
|
+
async function checkDockerPresent(env) {
|
|
5593
|
+
const version = await runDocker(["version", "--format", "{{.Server.Version}}"], { env, timeoutMs: 3e4 });
|
|
5594
|
+
const ok = !version.missing && version.code === 0;
|
|
5595
|
+
return { ok, serverVersion: ok ? version.stdout.trim() : "" };
|
|
5596
|
+
}
|
|
5505
5597
|
function imageTag(version) {
|
|
5506
5598
|
return `${IMAGE_REPOSITORY}:${version}`;
|
|
5507
5599
|
}
|
|
@@ -5515,12 +5607,13 @@ async function buildImage(options) {
|
|
|
5515
5607
|
const env = options.env ?? process.env;
|
|
5516
5608
|
const base2 = baseImage(env);
|
|
5517
5609
|
if ((options.arch ?? process.arch) !== "arm64") return { status: "not-needed", image: base2 };
|
|
5610
|
+
if (!(await checkDockerPresent(env)).ok) return { status: "dockerMissing", message: DOCKER_NEEDED_MESSAGE };
|
|
5518
5611
|
const tag = imageTag(options.version);
|
|
5519
5612
|
const dir = await mkdtemp(join4(options.tempRoot ?? tmpdir(), "tagreeve-image-"));
|
|
5520
5613
|
try {
|
|
5521
5614
|
await writeFile(join4(dir, "Dockerfile"), DOCKERFILE);
|
|
5522
5615
|
const built = await runDocker(["build", "--platform", "linux/arm64", "--build-arg", `GOOGLE_IMAGE=${base2}`, "--tag", tag, dir], { env });
|
|
5523
|
-
if (built.missing) return { status: "dockerMissing" };
|
|
5616
|
+
if (built.missing) return { status: "dockerMissing", message: DOCKER_NEEDED_MESSAGE };
|
|
5524
5617
|
if (built.code !== 0) return { status: "failed", message: built.stderr.trim().split("\n").slice(-10).join("\n") };
|
|
5525
5618
|
const inspected = await runDocker(["image", "inspect", "--format", "{{.Id}}", tag], { env });
|
|
5526
5619
|
return { status: "built", tag, imageId: inspected.code === 0 ? inspected.stdout.trim() : tag };
|
|
@@ -5557,9 +5650,9 @@ function loadContainerConfig(source, env = process.env) {
|
|
|
5557
5650
|
let raw;
|
|
5558
5651
|
if (source.kind === "file") {
|
|
5559
5652
|
try {
|
|
5560
|
-
const
|
|
5561
|
-
if (!
|
|
5562
|
-
if (process.platform !== "win32" && (
|
|
5653
|
+
const stat4 = statSync(source.path);
|
|
5654
|
+
if (!stat4.isFile()) throw new Error("not a file");
|
|
5655
|
+
if (process.platform !== "win32" && (stat4.mode & 63) !== 0) {
|
|
5563
5656
|
throw new ServerContainerError("configRejected", "The server container config file must be mode 0600. Run: chmod 600 <file>");
|
|
5564
5657
|
}
|
|
5565
5658
|
raw = readFileSync3(source.path, "utf8");
|
|
@@ -5611,9 +5704,9 @@ function resolveStandInCommand(env, serverHosts) {
|
|
|
5611
5704
|
if (!isAbsolute(value)) reject("it must be an absolute path");
|
|
5612
5705
|
let mode;
|
|
5613
5706
|
try {
|
|
5614
|
-
const
|
|
5615
|
-
if (!
|
|
5616
|
-
mode =
|
|
5707
|
+
const stat4 = statSync(value);
|
|
5708
|
+
if (!stat4.isFile()) reject("it must be a regular file");
|
|
5709
|
+
mode = stat4.mode;
|
|
5617
5710
|
} catch (error) {
|
|
5618
5711
|
if (error instanceof ServerContainerUsageError) throw error;
|
|
5619
5712
|
return reject("the file does not exist");
|
|
@@ -5711,16 +5804,13 @@ function followOutput(child, push) {
|
|
|
5711
5804
|
});
|
|
5712
5805
|
return { process: child, ended: () => ended };
|
|
5713
5806
|
}
|
|
5714
|
-
var DOCKER_INSTALL_URL = "https://docs.docker.com/get-docker/";
|
|
5715
5807
|
async function checkServerContainerHost(options) {
|
|
5716
5808
|
const env = options.env ?? process.env;
|
|
5717
|
-
const
|
|
5718
|
-
if (
|
|
5719
|
-
|
|
5720
|
-
}
|
|
5721
|
-
const major = Number(/^(\d+)\./.exec(version.stdout.trim())?.[1]);
|
|
5809
|
+
const docker = await checkDockerPresent(env);
|
|
5810
|
+
if (!docker.ok) throw new ServerContainerError("dockerMissing", DOCKER_NEEDED_MESSAGE);
|
|
5811
|
+
const major = Number(/^(\d+)\./.exec(docker.serverVersion)?.[1]);
|
|
5722
5812
|
if (Number.isInteger(major) && major < MIN_ENGINE_MAJOR) {
|
|
5723
|
-
throw new ServerContainerError("egressOpen", `Docker Engine ${
|
|
5813
|
+
throw new ServerContainerError("egressOpen", `Docker Engine ${docker.serverVersion} forwards DNS from internal networks (CVE-2024-29018). Upgrade Docker to ${MIN_ENGINE_MAJOR} or newer.`);
|
|
5724
5814
|
}
|
|
5725
5815
|
if ((await runDocker(["image", "inspect", "--format", "{{.Id}}", options.image], { env })).code !== 0) {
|
|
5726
5816
|
throw new ServerContainerError("imageMissing", `The image ${options.image} is not available. Run: tagreeve server-container build`);
|
|
@@ -6526,6 +6616,11 @@ var Recorder = class _Recorder {
|
|
|
6526
6616
|
dataLayerEvents = [];
|
|
6527
6617
|
mainFrameEventIds = /* @__PURE__ */ new Set();
|
|
6528
6618
|
eventFrames = /* @__PURE__ */ new Map();
|
|
6619
|
+
frameNumbers = /* @__PURE__ */ new WeakMap();
|
|
6620
|
+
frameNavigations = /* @__PURE__ */ new WeakMap();
|
|
6621
|
+
frameCount = 0;
|
|
6622
|
+
navigationSeen = /* @__PURE__ */ new WeakSet();
|
|
6623
|
+
requestFrameIds = /* @__PURE__ */ new Map();
|
|
6529
6624
|
collectorReports = [];
|
|
6530
6625
|
pending = /* @__PURE__ */ new Set();
|
|
6531
6626
|
steps = [];
|
|
@@ -6544,7 +6639,6 @@ var Recorder = class _Recorder {
|
|
|
6544
6639
|
navigationWindows = new NavigationWindows();
|
|
6545
6640
|
session;
|
|
6546
6641
|
sessionStopped;
|
|
6547
|
-
containerClient;
|
|
6548
6642
|
removeSignalHandlers;
|
|
6549
6643
|
/** Why the container did not start. Set by `launch`; `recordScenario` ends the run when it is. */
|
|
6550
6644
|
containerFailure;
|
|
@@ -6639,12 +6733,12 @@ var Recorder = class _Recorder {
|
|
|
6639
6733
|
if (!event) return;
|
|
6640
6734
|
this.dataLayerEvents.push({ ...event, stepId: this.currentStepId });
|
|
6641
6735
|
if (source.frame === source.page.mainFrame()) this.mainFrameEventIds.add(event.id);
|
|
6642
|
-
else this.eventFrames.set(event.id, source.frame.url());
|
|
6736
|
+
else this.eventFrames.set(event.id, { id: this.frameDocumentId(source.frame), url: source.frame.url() });
|
|
6643
6737
|
});
|
|
6644
6738
|
await context.addInitScript(dataLayerInitScript);
|
|
6645
6739
|
this.consent = await installConsent(context, this.options.autoconsent);
|
|
6646
6740
|
if (this.options.networkMode !== "live") {
|
|
6647
|
-
await context.exposeBinding(UNLOAD_BINDING, (
|
|
6741
|
+
await context.exposeBinding(UNLOAD_BINDING, (source, payload) => this.recordUnloadSend(payload, this.frameDocumentId(source.frame)));
|
|
6648
6742
|
await context.addInitScript(unloadInitScript);
|
|
6649
6743
|
}
|
|
6650
6744
|
if (this.options.handoffOverlay) {
|
|
@@ -6676,7 +6770,7 @@ var Recorder = class _Recorder {
|
|
|
6676
6770
|
signal: abort.signal,
|
|
6677
6771
|
currentStepId: () => this.currentStepId,
|
|
6678
6772
|
onCapture: (request, response) => {
|
|
6679
|
-
this.extraRequests.push(this.redactForHandoff(request, request.t));
|
|
6773
|
+
this.extraRequests.push(this.redactForHandoff(request, request.t, QUIET_MS));
|
|
6680
6774
|
this.responses.push(response);
|
|
6681
6775
|
}
|
|
6682
6776
|
});
|
|
@@ -6703,7 +6797,6 @@ var Recorder = class _Recorder {
|
|
|
6703
6797
|
this.removeSignalHandlers?.();
|
|
6704
6798
|
this.removeSignalHandlers = void 0;
|
|
6705
6799
|
this.sessionStopped ??= (async () => {
|
|
6706
|
-
await this.containerClient?.then((client) => client.dispose()).catch(() => void 0);
|
|
6707
6800
|
await this.session?.stop();
|
|
6708
6801
|
})();
|
|
6709
6802
|
return this.sessionStopped;
|
|
@@ -6735,10 +6828,36 @@ var Recorder = class _Recorder {
|
|
|
6735
6828
|
this.pending.add(promise);
|
|
6736
6829
|
void promise.finally(() => this.pending.delete(promise));
|
|
6737
6830
|
}
|
|
6831
|
+
/** A frame document is the frame plus how many navigation requests the frame has started. Held in memory only. */
|
|
6832
|
+
frameDocumentId(frame) {
|
|
6833
|
+
let number = this.frameNumbers.get(frame);
|
|
6834
|
+
if (number === void 0) {
|
|
6835
|
+
number = this.frameCount++;
|
|
6836
|
+
this.frameNumbers.set(frame, number);
|
|
6837
|
+
}
|
|
6838
|
+
return `${number}.${this.frameNavigations.get(frame) ?? 0}`;
|
|
6839
|
+
}
|
|
6840
|
+
countNavigation(request) {
|
|
6841
|
+
if (this.navigationSeen.has(request) || !request.isNavigationRequest()) return;
|
|
6842
|
+
this.navigationSeen.add(request);
|
|
6843
|
+
try {
|
|
6844
|
+
const frame = request.frame();
|
|
6845
|
+
this.frameNavigations.set(frame, (this.frameNavigations.get(frame) ?? 0) + 1);
|
|
6846
|
+
} catch {
|
|
6847
|
+
}
|
|
6848
|
+
}
|
|
6849
|
+
requestFrameId(request) {
|
|
6850
|
+
try {
|
|
6851
|
+
return this.frameDocumentId(request.frame());
|
|
6852
|
+
} catch {
|
|
6853
|
+
return null;
|
|
6854
|
+
}
|
|
6855
|
+
}
|
|
6738
6856
|
/** Created on first sight, from either the request event or the route handler, whichever comes first. */
|
|
6739
6857
|
recordFor(request) {
|
|
6740
6858
|
const existing = this.requests.get(request);
|
|
6741
6859
|
if (existing) return existing;
|
|
6860
|
+
this.countNavigation(request);
|
|
6742
6861
|
const url = request.url();
|
|
6743
6862
|
if (!/^https?:/.test(url) || url.startsWith(COLLECTOR_ORIGIN) || url.startsWith(SELFTEST_ORIGIN)) return void 0;
|
|
6744
6863
|
const body = request.postData();
|
|
@@ -6759,6 +6878,8 @@ var Recorder = class _Recorder {
|
|
|
6759
6878
|
};
|
|
6760
6879
|
record = this.redactForHandoff(record);
|
|
6761
6880
|
this.requests.set(request, record);
|
|
6881
|
+
const frameId = this.requestFrameId(request);
|
|
6882
|
+
if (frameId !== null) this.requestFrameIds.set(record.id, frameId);
|
|
6762
6883
|
if (request.isNavigationRequest() && isTopLevelFrameRequest(request)) {
|
|
6763
6884
|
this.navigationWindows.start(request, record.t);
|
|
6764
6885
|
this.navigations.push(record.t);
|
|
@@ -6766,8 +6887,8 @@ var Recorder = class _Recorder {
|
|
|
6766
6887
|
return record;
|
|
6767
6888
|
}
|
|
6768
6889
|
/** A person is typing during a handoff, so only requests that decode as tracking hits keep their body and query. */
|
|
6769
|
-
redactForHandoff(record, at = Date.now()) {
|
|
6770
|
-
if (!this.duringHandoff(at)) return record;
|
|
6890
|
+
redactForHandoff(record, at = Date.now(), graceMs = 0) {
|
|
6891
|
+
if (!this.duringHandoff(at, graceMs)) return record;
|
|
6771
6892
|
if (isCollectionEndpoint(record, this.trackers) || isKnownVendorCollection(record) || decodeRequest(record, void 0, this.trackers).length > 0) return record;
|
|
6772
6893
|
return {
|
|
6773
6894
|
...record,
|
|
@@ -6778,8 +6899,8 @@ var Recorder = class _Recorder {
|
|
|
6778
6899
|
redacted: "handoff"
|
|
6779
6900
|
};
|
|
6780
6901
|
}
|
|
6781
|
-
duringHandoff(at) {
|
|
6782
|
-
return this.handoffWindows.some((w) => at >= w.from && (w.to === null || at <= w.to));
|
|
6902
|
+
duringHandoff(at, graceMs) {
|
|
6903
|
+
return this.handoffWindows.some((w) => at >= w.from && (w.to === null || at <= w.to + graceMs));
|
|
6783
6904
|
}
|
|
6784
6905
|
/** Requests sent while a handoff is active, including unload sends queued then and replayed later, are stored without their typed values. */
|
|
6785
6906
|
setHandoff(active) {
|
|
@@ -6793,7 +6914,7 @@ var Recorder = class _Recorder {
|
|
|
6793
6914
|
holdRedaction() {
|
|
6794
6915
|
this.handoffWindows.push({ from: Date.now(), to: null, hold: true });
|
|
6795
6916
|
}
|
|
6796
|
-
recordUnloadSend(payload) {
|
|
6917
|
+
recordUnloadSend(payload, frameId) {
|
|
6797
6918
|
if (this.closed || this.unloadKeys.has(payload.key)) return;
|
|
6798
6919
|
this.unloadKeys.add(payload.key);
|
|
6799
6920
|
let record = {
|
|
@@ -6812,6 +6933,7 @@ var Recorder = class _Recorder {
|
|
|
6812
6933
|
outcome: "stubbed"
|
|
6813
6934
|
};
|
|
6814
6935
|
record = this.redactForHandoff(record, payload.queuedAt);
|
|
6936
|
+
this.requestFrameIds.set(record.id, frameId);
|
|
6815
6937
|
this.routed.add(record.id);
|
|
6816
6938
|
this.extraRequests.push(record);
|
|
6817
6939
|
this.responses.push({ type: "response", id: newId("response"), requestId: record.id, status: 204, setCookieNames: [] });
|
|
@@ -6873,14 +6995,13 @@ var Recorder = class _Recorder {
|
|
|
6873
6995
|
async routeToContainer(route, record, origin) {
|
|
6874
6996
|
const original = route.request();
|
|
6875
6997
|
const live = new URL(original.url());
|
|
6876
|
-
const { host: _host, ...
|
|
6998
|
+
const { host: _host, ...headers } = await original.allHeaders();
|
|
6877
6999
|
void _host;
|
|
6878
|
-
const headers = { cookie: "", ...sent };
|
|
6879
7000
|
record.outcome = "stubbed";
|
|
6880
7001
|
this.stubRecorded.add(record.id);
|
|
7002
|
+
let client;
|
|
6881
7003
|
try {
|
|
6882
|
-
|
|
6883
|
-
const client = await this.containerClient;
|
|
7004
|
+
client = await playwrightRequest.newContext();
|
|
6884
7005
|
const response = await client.fetch(`${origin}${live.pathname}${live.search}`, {
|
|
6885
7006
|
method: original.method(),
|
|
6886
7007
|
headers,
|
|
@@ -6893,6 +7014,8 @@ var Recorder = class _Recorder {
|
|
|
6893
7014
|
record.outcome = "failed";
|
|
6894
7015
|
record.failure = abortCode(error);
|
|
6895
7016
|
await route.abort(abortCode(error));
|
|
7017
|
+
} finally {
|
|
7018
|
+
await client?.dispose().catch(() => void 0);
|
|
6896
7019
|
}
|
|
6897
7020
|
}
|
|
6898
7021
|
isStubbedCollection(record) {
|
|
@@ -7229,7 +7352,7 @@ var Recorder = class _Recorder {
|
|
|
7229
7352
|
});
|
|
7230
7353
|
if (!this.netLogPath) {
|
|
7231
7354
|
const embedded = this.dataLayerEvents.filter((e) => !this.mainFrameEventIds.has(e.id));
|
|
7232
|
-
flags2.push(...buildUnloadGapFlags({ runId: this.runId, networkMode: this.options.networkMode, events: embedded, hits, navigations: this.navigations, runEnd: closeStartedAt, eventFrames: this.eventFrames, requestFrames: new Map(requests.map((r) => [r.id, r.frameUrl])), ignore: this.options.unloadGapIgnore }));
|
|
7355
|
+
flags2.push(...buildUnloadGapFlags({ runId: this.runId, networkMode: this.options.networkMode, events: embedded, hits, navigations: this.navigations, runEnd: closeStartedAt, eventFrames: this.eventFrames, requestFrames: new Map(requests.map((r) => [r.id, { id: this.requestFrameIds.get(r.id) ?? null, url: r.frameUrl }])), ignore: this.options.unloadGapIgnore }));
|
|
7233
7356
|
} else if (!netLog) {
|
|
7234
7357
|
flags2.push({ type: "flag", id: newId("flag"), runId: this.runId, kind: "netLogUnreadable", recordIds: [], detail: "The net log could not be read, so requests sent while a frame unloads may be missing." });
|
|
7235
7358
|
}
|
|
@@ -7441,12 +7564,14 @@ async function timeoutMessage(page2, firstLine, requested) {
|
|
|
7441
7564
|
|
|
7442
7565
|
// packages/recorder/src/payment.ts
|
|
7443
7566
|
var SHOPIFY_CARD_HOST = "checkout.pci.shopifyinc.com";
|
|
7567
|
+
var documentPath = (name) => new RegExp(`/${name}-(ltr|rtl)\\.html$`);
|
|
7444
7568
|
var shopifyFields = [
|
|
7445
|
-
{ kind: "number", frame: 'iframe[title*="Card number" i]', input: "input" },
|
|
7446
|
-
{ kind: "expiry", frame: 'iframe[title*="Expiration" i]', input: "input" },
|
|
7447
|
-
{ kind: "cvc", frame: 'iframe[title*="Security code" i]', input: "input" },
|
|
7448
|
-
{ kind: "name", frame: 'iframe[title*="Name on card" i]', input: "input" }
|
|
7569
|
+
{ kind: "number", frame: 'iframe[title*="Card number" i]', input: 'input[autocomplete="cc-number"], input[name="number"]', path: documentPath("number") },
|
|
7570
|
+
{ kind: "expiry", frame: 'iframe[title*="Expiration" i]', input: 'input[autocomplete="cc-exp"], input[name="expiry"]', path: documentPath("expiry") },
|
|
7571
|
+
{ kind: "cvc", frame: 'iframe[title*="Security code" i]', input: 'input[autocomplete="cc-csc"], input[name="verification_value"]', path: documentPath("verification_value") },
|
|
7572
|
+
{ kind: "name", frame: 'iframe[title*="Name on card" i]', input: 'input[autocomplete="cc-name"], input[name="name"]', path: documentPath("name") }
|
|
7449
7573
|
];
|
|
7574
|
+
var fixturePath = (legacy, shopify) => new RegExp(`^/card-frame(-${legacy}|-extra-input)?$|/${shopify}-(ltr|rtl)\\.html$`);
|
|
7450
7575
|
var RUNTIME = {
|
|
7451
7576
|
"shopify-bogus": { marker: "text=Bogus Gateway", cardHost: SHOPIFY_CARD_HOST, fields: shopifyFields },
|
|
7452
7577
|
"shopify-test": { marker: "text=/test mode/i", cardHost: SHOPIFY_CARD_HOST, fields: shopifyFields },
|
|
@@ -7454,9 +7579,9 @@ var RUNTIME = {
|
|
|
7454
7579
|
marker: "#pw-test-mode",
|
|
7455
7580
|
cardHost: "127.0.0.1",
|
|
7456
7581
|
fields: [
|
|
7457
|
-
{ kind: "number", frame: "#card-frame, #card-frame-number", input: "
|
|
7458
|
-
{ kind: "expiry", frame: "#card-frame, #card-frame-exp", input: "
|
|
7459
|
-
{ kind: "cvc", frame: "#card-frame, #card-frame-csc", input: "
|
|
7582
|
+
{ kind: "number", frame: "#card-frame, #card-frame-number", input: 'input[autocomplete="cc-number"], input[name="number"]', path: fixturePath("number", "number") },
|
|
7583
|
+
{ kind: "expiry", frame: "#card-frame, #card-frame-exp", input: 'input[autocomplete="cc-exp"], input[name="expiry"]', path: fixturePath("exp", "expiry") },
|
|
7584
|
+
{ kind: "cvc", frame: "#card-frame, #card-frame-csc", input: 'input[autocomplete="cc-csc"], input[name="verification_value"]', path: fixturePath("csc", "verification_value") }
|
|
7460
7585
|
]
|
|
7461
7586
|
}
|
|
7462
7587
|
};
|
|
@@ -7479,21 +7604,34 @@ function hostOf3(url) {
|
|
|
7479
7604
|
return "";
|
|
7480
7605
|
}
|
|
7481
7606
|
}
|
|
7607
|
+
function pathOf2(url) {
|
|
7608
|
+
try {
|
|
7609
|
+
return new URL(url).pathname;
|
|
7610
|
+
} catch {
|
|
7611
|
+
return "";
|
|
7612
|
+
}
|
|
7613
|
+
}
|
|
7482
7614
|
async function cardFrameServed(page2, field, cardHost, deadline) {
|
|
7483
7615
|
let reason = "not found";
|
|
7484
7616
|
for (; ; ) {
|
|
7485
7617
|
try {
|
|
7486
7618
|
let hidden = false;
|
|
7487
7619
|
let elsewhere = false;
|
|
7620
|
+
let otherPath;
|
|
7488
7621
|
for (const element of await page2.locator(field.frame).elementHandles()) {
|
|
7489
7622
|
const frame = await element.contentFrame();
|
|
7490
7623
|
if (!frame) continue;
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
if (
|
|
7494
|
-
|
|
7624
|
+
if (hostOf3(frame.url()) !== cardHost) {
|
|
7625
|
+
elsewhere = true;
|
|
7626
|
+
} else if (!field.path.test(pathOf2(frame.url()))) {
|
|
7627
|
+
otherPath = pathOf2(frame.url());
|
|
7628
|
+
} else if (await element.isVisible()) {
|
|
7629
|
+
return { element, frame };
|
|
7630
|
+
} else {
|
|
7631
|
+
hidden = true;
|
|
7632
|
+
}
|
|
7495
7633
|
}
|
|
7496
|
-
reason = hidden ? "not visible" : elsewhere ? "served from another host" : "not found";
|
|
7634
|
+
reason = hidden ? "not visible" : otherPath !== void 0 ? `served from another path: ${otherPath}` : elsewhere ? "served from another host" : "not found";
|
|
7497
7635
|
} catch {
|
|
7498
7636
|
return reason;
|
|
7499
7637
|
}
|
|
@@ -7555,26 +7693,45 @@ async function runPayment(page2, recorder, value, identity, testPayment, record,
|
|
|
7555
7693
|
if (index === 0) record.payment = { provider: provider.id, mode: "test", testMode: declared ? "declared" : "marker" };
|
|
7556
7694
|
}
|
|
7557
7695
|
}
|
|
7558
|
-
async function frameStillServed(element, cardHost) {
|
|
7696
|
+
async function frameStillServed(element, cardHost, field) {
|
|
7559
7697
|
const frame = await element.contentFrame();
|
|
7560
|
-
if (!frame || hostOf3(frame.url()) !== cardHost
|
|
7698
|
+
if (!frame || hostOf3(frame.url()) !== cardHost || !field.path.test(pathOf2(frame.url()))) {
|
|
7699
|
+
throw new OwnReason("the card frame is gone or not served from the card host");
|
|
7700
|
+
}
|
|
7561
7701
|
return frame;
|
|
7562
7702
|
}
|
|
7703
|
+
var FILL_TRY_MS = 500;
|
|
7563
7704
|
async function fillVerified(element, field, cardHost, value, timeout) {
|
|
7564
7705
|
const deadline = Date.now() + timeout;
|
|
7565
7706
|
for (; ; ) {
|
|
7566
|
-
const frame = await frameStillServed(element, cardHost);
|
|
7707
|
+
const frame = await frameStillServed(element, cardHost, field);
|
|
7567
7708
|
const inputs = frame.locator(field.input).filter({ visible: true });
|
|
7568
7709
|
const count = await inputs.count();
|
|
7569
7710
|
if (count === 1) {
|
|
7570
|
-
await frameStillServed(element, cardHost);
|
|
7571
|
-
|
|
7572
|
-
|
|
7711
|
+
await frameStillServed(element, cardHost, field);
|
|
7712
|
+
try {
|
|
7713
|
+
await inputs.fill(value, { timeout: Math.max(1, Math.min(FILL_TRY_MS, deadline - Date.now())) });
|
|
7714
|
+
return;
|
|
7715
|
+
} catch (error) {
|
|
7716
|
+
if (!(error instanceof Error && error.name === "TimeoutError") || Date.now() >= deadline) throw error;
|
|
7717
|
+
continue;
|
|
7718
|
+
}
|
|
7573
7719
|
}
|
|
7574
|
-
if (Date.now() >= deadline) throw new OwnReason(
|
|
7720
|
+
if (Date.now() >= deadline) throw new OwnReason(await countReason(frame, count));
|
|
7575
7721
|
await new Promise((resolve3) => setTimeout(resolve3, 100));
|
|
7576
7722
|
}
|
|
7577
7723
|
}
|
|
7724
|
+
async function countReason(frame, count) {
|
|
7725
|
+
const attribute = (v) => (v ?? "").replace(/\s+/g, " ").slice(0, 40);
|
|
7726
|
+
let inputs = " none visible";
|
|
7727
|
+
try {
|
|
7728
|
+
const seen = await frame.locator("input").filter({ visible: true }).evaluateAll((all) => all.map((e) => ({ name: e.getAttribute("name"), autocomplete: e.getAttribute("autocomplete"), type: e.getAttribute("type") })));
|
|
7729
|
+
if (seen.length > 0) inputs = seen.map((i) => ` [name=${attribute(i.name)} autocomplete=${attribute(i.autocomplete)} type=${attribute(i.type)}]`).join("");
|
|
7730
|
+
} catch {
|
|
7731
|
+
inputs = " inputs not readable";
|
|
7732
|
+
}
|
|
7733
|
+
return `${count} visible inputs match in ${pathOf2(frame.url())}:${inputs}`;
|
|
7734
|
+
}
|
|
7578
7735
|
function typedValues(provider, card, identity) {
|
|
7579
7736
|
const values = [card, provider.expiry, provider.cvc, identity.firstName, identity.lastName, `${identity.firstName} ${identity.lastName}`];
|
|
7580
7737
|
return values.filter((v) => v.length > 0).sort((a, b) => b.length - a.length);
|
|
@@ -8082,6 +8239,66 @@ Exit codes: 0 pass, 1 failed expectations, 2 usage or run error.
|
|
|
8082
8239
|
|
|
8083
8240
|
Scenario format: https://github.com/alfhen/tagreeve/blob/main/docs/design.md#11-expectations
|
|
8084
8241
|
`;
|
|
8242
|
+
var SUITE_USAGE = `Usage: tagreeve suite <dir> (--site <url> | --stores <stores.json>) [options]
|
|
8243
|
+
|
|
8244
|
+
Runs every scenario in <dir> and writes one record per run plus a suite.json.
|
|
8245
|
+
|
|
8246
|
+
Options:
|
|
8247
|
+
${USAGE.slice(USAGE.indexOf(" --site <url> The site to test. Give"), USAGE.indexOf("\nOptions for run:")).trimEnd()}
|
|
8248
|
+
-h, --help Show this help
|
|
8249
|
+
`;
|
|
8250
|
+
var DIFF_USAGE = `Usage: tagreeve diff <a.jsonl> <b.jsonl> [options]
|
|
8251
|
+
|
|
8252
|
+
Compares the hits of two run records. It exits 0 whether or not they differ.
|
|
8253
|
+
|
|
8254
|
+
Options:
|
|
8255
|
+
--by-page Add the page path to each key
|
|
8256
|
+
--all-flags Also show flag count changes for hosts allowed by allowUnknownDestination (hidden by default)
|
|
8257
|
+
--json Print the full diff result as JSON
|
|
8258
|
+
-h, --help Show this help
|
|
8259
|
+
`;
|
|
8260
|
+
var BASELINE_USAGE = `Usage: tagreeve baseline save <run.jsonl> <baseline.json> [options]
|
|
8261
|
+
|
|
8262
|
+
Saves the hit tuples of a run as a baseline file. Pass the file to "tagreeve run --baseline".
|
|
8263
|
+
|
|
8264
|
+
Options:
|
|
8265
|
+
--by-page Add the page path to each key
|
|
8266
|
+
-h, --help Show this help
|
|
8267
|
+
`;
|
|
8268
|
+
var REPORT_USAGE = `Usage: tagreeve report <run.jsonl | suite-dir> --html <out.html>
|
|
8269
|
+
|
|
8270
|
+
Writes an HTML report for a run record or a suite directory.
|
|
8271
|
+
|
|
8272
|
+
Options:
|
|
8273
|
+
--html <file> The report file to write (required)
|
|
8274
|
+
-h, --help Show this help
|
|
8275
|
+
`;
|
|
8276
|
+
var INSTALL_BROWSER_USAGE = `Usage: tagreeve install-browser
|
|
8277
|
+
|
|
8278
|
+
Installs the Chromium that Tagreeve drives. It takes no options.
|
|
8279
|
+
|
|
8280
|
+
Options:
|
|
8281
|
+
-h, --help Show this help
|
|
8282
|
+
`;
|
|
8283
|
+
var SERVER_CONTAINER_USAGE = `Usage: tagreeve server-container build
|
|
8284
|
+
|
|
8285
|
+
Builds the image for the server container feature on arm64 (Apple silicon) from Google's image. It needs Docker, pulls large images and never pushes. On amd64 it prints the image to use.
|
|
8286
|
+
|
|
8287
|
+
Options:
|
|
8288
|
+
-h, --help Show this help
|
|
8289
|
+
`;
|
|
8290
|
+
var HELP_TEXT = {
|
|
8291
|
+
run: RUN_USAGE,
|
|
8292
|
+
suite: SUITE_USAGE,
|
|
8293
|
+
diff: DIFF_USAGE,
|
|
8294
|
+
baseline: BASELINE_USAGE,
|
|
8295
|
+
report: REPORT_USAGE,
|
|
8296
|
+
"install-browser": INSTALL_BROWSER_USAGE,
|
|
8297
|
+
"server-container": SERVER_CONTAINER_USAGE
|
|
8298
|
+
};
|
|
8299
|
+
function helpText(topic) {
|
|
8300
|
+
return topic ? HELP_TEXT[topic] : USAGE;
|
|
8301
|
+
}
|
|
8085
8302
|
var NET_LOG_NEEDS_LIVE = "--net-log needs --network live. In stub mode it would let the requests a frame sends while it unloads leave the machine.";
|
|
8086
8303
|
function parseVariants(entries) {
|
|
8087
8304
|
const variants2 = [];
|
|
@@ -8124,13 +8341,29 @@ var OPTIONS = {
|
|
|
8124
8341
|
version: { type: "boolean" },
|
|
8125
8342
|
help: { type: "boolean", short: "h" }
|
|
8126
8343
|
};
|
|
8344
|
+
function commandOf(argv) {
|
|
8345
|
+
const { tokens } = parseArgs({ args: argv, allowPositionals: true, strict: false, options: OPTIONS, tokens: true });
|
|
8346
|
+
const isCommand = (word) => COMMANDS.includes(word);
|
|
8347
|
+
let skip = false;
|
|
8348
|
+
let skipped;
|
|
8349
|
+
for (const token of tokens) {
|
|
8350
|
+
if (token.kind === "option") {
|
|
8351
|
+
skip = !(token.name in OPTIONS) && token.value === void 0;
|
|
8352
|
+
} else if (token.kind === "positional") {
|
|
8353
|
+
if (!skip) return isCommand(token.value) ? token.value : skipped;
|
|
8354
|
+
if (skipped === void 0 && isCommand(token.value)) skipped = token.value;
|
|
8355
|
+
skip = false;
|
|
8356
|
+
}
|
|
8357
|
+
}
|
|
8358
|
+
return skipped;
|
|
8359
|
+
}
|
|
8127
8360
|
function parseCli(argv) {
|
|
8128
8361
|
try {
|
|
8129
8362
|
return parseCommand(argv);
|
|
8130
8363
|
} catch (error) {
|
|
8131
8364
|
if (error instanceof UsageError && error.command === void 0) {
|
|
8132
|
-
const
|
|
8133
|
-
if (
|
|
8365
|
+
const command = commandOf(argv);
|
|
8366
|
+
if (command !== void 0) error.command = command;
|
|
8134
8367
|
}
|
|
8135
8368
|
throw error;
|
|
8136
8369
|
}
|
|
@@ -8144,12 +8377,16 @@ function parseCommand(argv) {
|
|
|
8144
8377
|
options: OPTIONS
|
|
8145
8378
|
});
|
|
8146
8379
|
} catch (error) {
|
|
8380
|
+
const unknown = error instanceof Error && /^Unknown option '(-[^']*)'/.exec(error.message);
|
|
8381
|
+
if (unknown) throw new UsageError(`Unknown option ${unknown[1]}.`);
|
|
8147
8382
|
throw new UsageError(error instanceof Error ? error.message : String(error));
|
|
8148
8383
|
}
|
|
8149
8384
|
const { values, positionals } = parsed;
|
|
8150
8385
|
if (values.version) return { command: "version" };
|
|
8151
8386
|
const [command, ...rest] = positionals;
|
|
8152
|
-
if (values.help && command
|
|
8387
|
+
if (values.help && command !== void 0 && COMMANDS.includes(command)) {
|
|
8388
|
+
return { command: "help", topic: command };
|
|
8389
|
+
}
|
|
8153
8390
|
if (values.help || command === void 0) return { command: "help" };
|
|
8154
8391
|
if (command === "install-browser") {
|
|
8155
8392
|
if (rest.length) throw new UsageError("install-browser takes no arguments");
|
|
@@ -8384,7 +8621,7 @@ async function baselineCommand(args, io) {
|
|
|
8384
8621
|
}
|
|
8385
8622
|
|
|
8386
8623
|
// packages/cli/src/diff.ts
|
|
8387
|
-
function
|
|
8624
|
+
function pathOf3(page2) {
|
|
8388
8625
|
try {
|
|
8389
8626
|
return new URL(page2).pathname;
|
|
8390
8627
|
} catch {
|
|
@@ -8392,13 +8629,13 @@ function pathOf2(page2) {
|
|
|
8392
8629
|
}
|
|
8393
8630
|
}
|
|
8394
8631
|
function where(key, step, rawPage) {
|
|
8395
|
-
const raw = rawPage && key.page &&
|
|
8632
|
+
const raw = rawPage && key.page && pathOf3(rawPage) !== key.page ? `, recorded as ${rawPage}` : "";
|
|
8396
8633
|
const parts = [step && `step "${step}"`, key.page && `page ${key.page}${raw}`].filter(Boolean);
|
|
8397
8634
|
return parts.length ? ` (${parts.join(", ")})` : "";
|
|
8398
8635
|
}
|
|
8399
8636
|
function recordedPages(c) {
|
|
8400
8637
|
if (!c.key.page || c.a.page === null && c.b.page === null) return "";
|
|
8401
|
-
const differs = [c.a.page, c.b.page].some((p) => p !== null &&
|
|
8638
|
+
const differs = [c.a.page, c.b.page].some((p) => p !== null && pathOf3(p) !== c.key.page);
|
|
8402
8639
|
return differs ? `, recorded as ${c.a.page ?? "(none)"} -> ${c.b.page ?? "(none)"}` : "";
|
|
8403
8640
|
}
|
|
8404
8641
|
function add(tree, key, line) {
|
|
@@ -8444,7 +8681,7 @@ function formatDiff(result, a, b, options = {}) {
|
|
|
8444
8681
|
out.push("", "Flags");
|
|
8445
8682
|
for (const f of shownFlags) out.push(` ${flagChangeLabel(f)}`);
|
|
8446
8683
|
}
|
|
8447
|
-
if (hiddenFlags) out.push("", `${hiddenFlags} flag count change${hiddenFlags === 1 ? "" : "s"} for hosts allowed by allowUnknownDestination not shown (use --all-flags)`);
|
|
8684
|
+
if (hiddenFlags) out.push("", `${hiddenFlags} flag count change${hiddenFlags === 1 ? "" : "s"} for hosts allowed by allowUnknownDestination or platform hosts not shown (use --all-flags)`);
|
|
8448
8685
|
return `${out.join("\n")}
|
|
8449
8686
|
`;
|
|
8450
8687
|
}
|
|
@@ -8481,7 +8718,7 @@ function installBrowser() {
|
|
|
8481
8718
|
}
|
|
8482
8719
|
|
|
8483
8720
|
// packages/cli/src/report/index.ts
|
|
8484
|
-
import { mkdir as mkdir3, stat as
|
|
8721
|
+
import { mkdir as mkdir3, stat as stat3, writeFile as writeFile5 } from "node:fs/promises";
|
|
8485
8722
|
import { dirname as dirname4, join as join11, resolve as resolve2 } from "node:path";
|
|
8486
8723
|
|
|
8487
8724
|
// packages/cli/src/report/model.ts
|
|
@@ -8498,7 +8735,7 @@ var WORST_FIRST = ["leak", "unchecked", "mixed", "early", "full", "ping"];
|
|
|
8498
8735
|
var CONSENT_FIELDS = ["analytics", "ads", "adUserData", "adPersonalization"];
|
|
8499
8736
|
var MAX_EVIDENCE = 5;
|
|
8500
8737
|
var MAX_VALUE = 80;
|
|
8501
|
-
var SHOWN_VALUE_KEYS = /* @__PURE__ */ new Set(["vendor", "event", "in", "before", "after", "host", "count", "outcome", "transport", "cookie"]);
|
|
8738
|
+
var SHOWN_VALUE_KEYS = /* @__PURE__ */ new Set(["vendor", "event", "in", "before", "after", "from", "host", "count", "outcome", "transport", "cookie"]);
|
|
8502
8739
|
var MIXED_HIT = "some signals denied";
|
|
8503
8740
|
function flatten2(entry) {
|
|
8504
8741
|
const flat = {};
|
|
@@ -8772,7 +9009,7 @@ function rowLabel(row) {
|
|
|
8772
9009
|
|
|
8773
9010
|
// packages/cli/src/report/verdict.ts
|
|
8774
9011
|
function emptyFindings() {
|
|
8775
|
-
return { hits: /* @__PURE__ */ new Map(), identifiers: /* @__PURE__ */ new Map(), failed: 0, warned: 0, failedChecks: /* @__PURE__ */ new Map(), warnedChecks: /* @__PURE__ */ new Map(), unchecked: 0, unlinkedServerHits: 0, probableServerHits: 0 };
|
|
9012
|
+
return { hits: /* @__PURE__ */ new Map(), identifiers: /* @__PURE__ */ new Map(), namedChecks: /* @__PURE__ */ new Set(), failed: 0, warned: 0, failedChecks: /* @__PURE__ */ new Map(), warnedChecks: /* @__PURE__ */ new Map(), unchecked: 0, unlinkedServerHits: 0, probableServerHits: 0 };
|
|
8776
9013
|
}
|
|
8777
9014
|
function addFindings(into, model) {
|
|
8778
9015
|
into.unlinkedServerHits += model.serverContainer?.unlinked ?? 0;
|
|
@@ -8781,6 +9018,8 @@ function addFindings(into, model) {
|
|
|
8781
9018
|
row.segments.forEach((segment, i) => {
|
|
8782
9019
|
if (segment.mark !== "leak") return;
|
|
8783
9020
|
const target = segment.label === IDENTIFIER_LEAK || segment.label === IDENTIFIER_EARLY ? into.identifiers : into.hits;
|
|
9021
|
+
if (segment.label === IDENTIFIER_LEAK) into.namedChecks.add("deniedIdentifiers");
|
|
9022
|
+
if (segment.label === IDENTIFIER_EARLY) into.namedChecks.add("earlyIdentifiers");
|
|
8784
9023
|
const label = model.columns[i].label;
|
|
8785
9024
|
const vendors = target.get(label) ?? /* @__PURE__ */ new Set();
|
|
8786
9025
|
vendors.add(row.vendor);
|
|
@@ -8813,8 +9052,7 @@ function findingsSentence(f, inRuns = false) {
|
|
|
8813
9052
|
const parts = [];
|
|
8814
9053
|
for (const [label, vendors] of [...f.hits].sort(([a], [b]) => a.localeCompare(b))) parts.push(`${list(vendors)} ${vendors.size === 1 ? "sends" : "send"} hits in the ${label} state`);
|
|
8815
9054
|
for (const [label, vendors] of [...f.identifiers].sort(([a], [b]) => a.localeCompare(b))) parts.push(`identifiers go out to ${list(vendors)} in the ${label} state`);
|
|
8816
|
-
const
|
|
8817
|
-
const shown2 = (checks) => new Map([...checks].filter(([name]) => !(named && (name === "deniedIdentifiers" || name === "earlyIdentifiers"))));
|
|
9055
|
+
const shown2 = (checks) => new Map([...checks].filter(([name]) => !f.namedChecks.has(name)));
|
|
8818
9056
|
if (parts.length === 0 && f.unchecked === 0) parts.push("no leaks");
|
|
8819
9057
|
if (f.failed > 0) parts.push(`${plural(f.failed, "rule")} failed`);
|
|
8820
9058
|
parts.push(...checkParts(shown2(f.failedChecks), "failed", inRuns));
|
|
@@ -9017,7 +9255,7 @@ import { mkdir as mkdir2, readdir, readFile as readFile6, writeFile as writeFile
|
|
|
9017
9255
|
import { basename as basename2, extname, join as join9 } from "node:path";
|
|
9018
9256
|
|
|
9019
9257
|
// packages/cli/src/stores.ts
|
|
9020
|
-
import { readFile as readFile3 } from "node:fs/promises";
|
|
9258
|
+
import { readFile as readFile3, stat } from "node:fs/promises";
|
|
9021
9259
|
import { dirname as dirname3, resolve } from "node:path";
|
|
9022
9260
|
var STORE_NAME = /^[a-z0-9][a-z0-9_-]*$/;
|
|
9023
9261
|
var MAX_STORES = 50;
|
|
@@ -9049,7 +9287,7 @@ async function readStores(path) {
|
|
|
9049
9287
|
throw new StoresError(`${path}: stores must be a list of 1 to ${MAX_STORES} stores.`);
|
|
9050
9288
|
}
|
|
9051
9289
|
const names = /* @__PURE__ */ new Set();
|
|
9052
|
-
|
|
9290
|
+
const stores = list2.map((entry, index) => {
|
|
9053
9291
|
const fail = (reason) => {
|
|
9054
9292
|
throw new StoresError(`${path}: store ${index} ${reason}.`);
|
|
9055
9293
|
};
|
|
@@ -9084,10 +9322,16 @@ async function readStores(path) {
|
|
|
9084
9322
|
...autoconsentRules !== void 0 && { autoconsentRules: resolve(dirname3(path), autoconsentRules) }
|
|
9085
9323
|
};
|
|
9086
9324
|
});
|
|
9325
|
+
for (const [index, store] of stores.entries()) {
|
|
9326
|
+
if (store.autoconsentRules === void 0) continue;
|
|
9327
|
+
const isFile = await stat(store.autoconsentRules).then((s) => s.isFile(), () => false);
|
|
9328
|
+
if (!isFile) throw new StoresError(`${path}: store ${index} has autoconsentRules that are not a readable file.`);
|
|
9329
|
+
}
|
|
9330
|
+
return stores;
|
|
9087
9331
|
}
|
|
9088
9332
|
|
|
9089
9333
|
// packages/cli/src/test-payment-hosts.ts
|
|
9090
|
-
import { readFile as readFile4, stat } from "node:fs/promises";
|
|
9334
|
+
import { readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
9091
9335
|
import { homedir } from "node:os";
|
|
9092
9336
|
import { isAbsolute as isAbsolute2, join as join7 } from "node:path";
|
|
9093
9337
|
var FILE_NAME = "test-payment-hosts.json";
|
|
@@ -9121,7 +9365,7 @@ function parseEntry3(path, entry, index, loopbackHosted) {
|
|
|
9121
9365
|
async function readTestPaymentHosts(path, loopbackHosted = loopbackIsHostedForTests()) {
|
|
9122
9366
|
let mode;
|
|
9123
9367
|
try {
|
|
9124
|
-
mode = (await
|
|
9368
|
+
mode = (await stat2(path)).mode;
|
|
9125
9369
|
} catch (error) {
|
|
9126
9370
|
if (error.code === "ENOENT") throw new Error(`${path} does not exist. Create it with a JSON array of the hosts that may run test payments.`);
|
|
9127
9371
|
throw new Error(`Cannot read ${path}.`);
|
|
@@ -9220,7 +9464,7 @@ function buildSummary(records, results, path) {
|
|
|
9220
9464
|
ok: results.every(passesGate),
|
|
9221
9465
|
hits: countHits(records.hits),
|
|
9222
9466
|
epochs: records.consentEpochs.map((e) => ({ label: e.label, state: stateName(e.state), startT: e.startT, endT: e.endT })),
|
|
9223
|
-
flags: records.flags.map((f) => ({ kind: f.kind, detail: f.detail })),
|
|
9467
|
+
flags: records.flags.map((f) => ({ kind: f.kind, detail: redactFlagDetail(f.detail) })),
|
|
9224
9468
|
...testPayment && { testPayment },
|
|
9225
9469
|
...records.run.testServerContainer && { testServerContainer: true },
|
|
9226
9470
|
...serverContainer && { serverContainer },
|
|
@@ -9253,7 +9497,7 @@ function formatFlags(flags2) {
|
|
|
9253
9497
|
if (f.kind === "platformHost" && platformOf(f)) continue;
|
|
9254
9498
|
const target = groupTarget(f);
|
|
9255
9499
|
if (!target) {
|
|
9256
|
-
lines.push(` ${f.kind}: ${f.detail}`);
|
|
9500
|
+
lines.push(` ${f.kind}: ${redactFlagDetail(f.detail)}`);
|
|
9257
9501
|
continue;
|
|
9258
9502
|
}
|
|
9259
9503
|
const { label, url } = target;
|
|
@@ -9272,6 +9516,26 @@ function formatFlags(flags2) {
|
|
|
9272
9516
|
lines.push(...platformHostLines(flags2));
|
|
9273
9517
|
return lines;
|
|
9274
9518
|
}
|
|
9519
|
+
var URL_TOKEN = /[a-z][a-z0-9+.-]*:\/\/\S+/gi;
|
|
9520
|
+
var URL_PARTS = /^([a-z][a-z0-9+.-]*:\/\/)([^/?#]*)([^?#]*)(?:\?([^#]*))?(?:#.*)?$/i;
|
|
9521
|
+
function queryName(pair) {
|
|
9522
|
+
const raw = pair.split("=")[0];
|
|
9523
|
+
try {
|
|
9524
|
+
return guardFieldName(decodeURIComponent(raw));
|
|
9525
|
+
} catch {
|
|
9526
|
+
return guardFieldName(raw);
|
|
9527
|
+
}
|
|
9528
|
+
}
|
|
9529
|
+
function redactUrl(token) {
|
|
9530
|
+
const parts = URL_PARTS.exec(token);
|
|
9531
|
+
if (!parts) return token.split(/[?#]/)[0];
|
|
9532
|
+
const [, scheme, authority, path, query] = parts;
|
|
9533
|
+
const names = new Set((query ?? "").split("&").filter(Boolean).map(queryName));
|
|
9534
|
+
return `${scheme}${authority.slice(authority.lastIndexOf("@") + 1)}${path}${names.size > 0 ? `?${[...names].join("&")}` : ""}`;
|
|
9535
|
+
}
|
|
9536
|
+
function redactFlagDetail(detail) {
|
|
9537
|
+
return detail.replace(URL_TOKEN, redactUrl);
|
|
9538
|
+
}
|
|
9275
9539
|
function groupTarget(flag2) {
|
|
9276
9540
|
if (GROUPED_KINDS.has(flag2.kind)) {
|
|
9277
9541
|
const url = parseUrl2(/\s(\S+)$/.exec(flag2.detail)?.[1]);
|
|
@@ -9905,6 +10169,11 @@ async function suiteCommand(args, io, deps = { run: executeRun }) {
|
|
|
9905
10169
|
const paymentKey = (scenario, store) => JSON.stringify([scenario, store?.name]);
|
|
9906
10170
|
const testPayments = /* @__PURE__ */ new Map();
|
|
9907
10171
|
if (args.withTestPayment && args.allowTestPayment !== void 0) {
|
|
10172
|
+
if (stores.length && scenarios.some((x) => x.payment) && !targets.some((t) => normalizeHost(new URL(t.site).hostname) === allowedHost)) {
|
|
10173
|
+
io.stderr(`--allow-test-payment ${allowedHost}: no store in the stores file has that host.
|
|
10174
|
+
`);
|
|
10175
|
+
return 2;
|
|
10176
|
+
}
|
|
9908
10177
|
for (const s of scenarios.filter((x) => x.payment)) {
|
|
9909
10178
|
for (const { store, site } of targets) {
|
|
9910
10179
|
if (store && normalizeHost(new URL(site).hostname) !== allowedHost) continue;
|
|
@@ -10217,7 +10486,7 @@ async function load2(path) {
|
|
|
10217
10486
|
}
|
|
10218
10487
|
async function isSameFile(a, b) {
|
|
10219
10488
|
if (resolve2(a) === resolve2(b)) return true;
|
|
10220
|
-
const [sa, sb] = await Promise.all([
|
|
10489
|
+
const [sa, sb] = await Promise.all([stat3(a).catch(() => void 0), stat3(b).catch(() => void 0)]);
|
|
10221
10490
|
return sa !== void 0 && sb !== void 0 && sa.dev === sb.dev && sa.ino === sb.ino;
|
|
10222
10491
|
}
|
|
10223
10492
|
async function refuseOverwrite(html, inputs) {
|
|
@@ -10231,7 +10500,7 @@ async function write(args, html, io) {
|
|
|
10231
10500
|
return 0;
|
|
10232
10501
|
}
|
|
10233
10502
|
async function reportCommand(args, io) {
|
|
10234
|
-
if ((await
|
|
10503
|
+
if ((await stat3(args.input).catch(() => void 0))?.isDirectory()) {
|
|
10235
10504
|
const suiteDir = await resolveSuiteDir(args.input, io.stderr);
|
|
10236
10505
|
const { manifest, records: records2 } = await loadSuite(suiteDir);
|
|
10237
10506
|
const recordFiles = manifest.cells.flatMap((c) => typeof c.record === "string" ? [join11(suiteDir, c.record)] : []);
|
|
@@ -10264,7 +10533,8 @@ Image ID: ${result.imageId}
|
|
|
10264
10533
|
`);
|
|
10265
10534
|
return 0;
|
|
10266
10535
|
case "dockerMissing":
|
|
10267
|
-
io.stderr(
|
|
10536
|
+
io.stderr(`${result.message}
|
|
10537
|
+
`);
|
|
10268
10538
|
return 2;
|
|
10269
10539
|
case "failed":
|
|
10270
10540
|
io.stderr(`The image build failed.
|
|
@@ -10282,7 +10552,7 @@ async function main(argv, io = processIo) {
|
|
|
10282
10552
|
`);
|
|
10283
10553
|
return 0;
|
|
10284
10554
|
case "help":
|
|
10285
|
-
io.stdout(command.topic
|
|
10555
|
+
io.stdout(helpText(command.topic));
|
|
10286
10556
|
return 0;
|
|
10287
10557
|
case "install-browser":
|
|
10288
10558
|
return await installBrowser() === 0 ? 0 : 2;
|