cuonztech-privacy-chaos-gate 0.3.6 → 0.3.7

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 CHANGED
@@ -140,6 +140,15 @@ Version (User-Agent und Client-Hints ohne «Headless»), damit die Seite ihren B
140
140
  Besucher. `report.json` nennt die verwendete Kennung unter `browserUserAgent`. Bot-Schutz wird nicht umgangen
141
141
  (`navigator.webdriver` bleibt gesetzt); er führt wie oben beschrieben zu «nicht prüfbar».
142
142
 
143
+ **Besucherprofil und Land.** Seiten zeigen je nach Herkunft des Besuchers andere Banner. Gemessen an Schweizer Seiten
144
+ (November 2026) entscheidet dabei die IP-Adresse, nicht Sprache oder Zeitzone des Browsers. CPCG trennt deshalb:
145
+ `--visitor ch|eu` setzt Sprache und Zeitzone fest (Standard `ch`; vorher galten die des Rechners, auf einem GitHub-Runner
146
+ meist Englisch/USA), damit Läufe vergleichbar sind. Einen Besucher aus einem anderen Land simuliert erst `--proxy` mit
147
+ einem Ausgang dort. Mit `--visitor eu` oder `--proxy` misst CPCG das Land der eigenen IP über
148
+ `https://www.cloudflare.com/cdn-cgi/trace` (ein Abruf, nur in diesen Fällen) und schreibt es in den Report (`visitor`);
149
+ passt es nicht zum Profil, steht eine Warnung dabei. Der Proxy kommt nie aus einer `.env`: ein Proxy könnte
150
+ Tracker-Requests verschlucken und so das Gate beeinflussen. Die Erreichbarkeitsprüfung vor dem Scan läuft ohne Proxy.
151
+
143
152
  **Fortschritt und Zeitlimit.** Während des Scans zeigt die Konsole je Szenario eine Zeile («[3/17] fast-click (nach
144
153
  52 s)»). Jedes Szenario und jede Vor- und Schlussprüfung hat eine Obergrenze: je Szenario seine Navigationen mal
145
154
  `--timeout-ms` (mindestens 120 s, Unterseiten zuzüglich ihres Zeitbudgets), je Vorprüfung drei Navigationsfristen
@@ -183,6 +192,8 @@ cpcg --url https://staging.example.com \
183
192
  | `--settings-selector <css>` | Eigener Selektor des Einstellungen-Buttons |
184
193
  | `--banner-frame <teilstring>` | Teil der URL des iframes, in dem der Banner liegt (CMP im Frame); findet der Scan keinen solchen Frame, warnt er |
185
194
  | `--banner-wait <sekunden>` | Wartefenster auf einen spät erscheinenden Banner, 1 bis 60 (Standard 8; Umgebung `CPCG_BANNER_WAIT`). Mit Angabe wird das Fenster ausgeschöpft, ebenso bei `--accept-selector`/`--reject-selector`; die Schlussprüfung wartet zusätzlich eine Nachfrist |
195
+ | `--visitor <profil>` | Besucherprofil: `ch` (Sprache de-CH, Zeitzone Zürich, Standard) oder `eu` (de-DE, Berlin); feste Sprache und Zeitzone statt der des Rechners (Umgebung `CPCG_VISITOR`). Das Land der IP ändert nur `--proxy` (siehe «Besucherprofil und Land») |
196
+ | `--proxy <url>` | Proxy für alle Browser-Zugriffe, z. B. ein Ausgang in der EU: `http(s)://[user:pass@]host:port` oder `socks5://host:port` (Umgebung `CPCG_PROXY`, nie aus `.env`). Report und Konsole nennen den Proxy ohne Zugangsdaten und das gemessene IP-Land |
186
197
  | `--max-subpages <n>` | Obergrenze der Unterseiten-Stichprobe (Szenario `subpage-spa`), 1 bis 40 (Standard 12; Umgebung `CPCG_MAX_SUBPAGES`); das Zeitbudget wächst moderat mit (45 s bis 12, 90 s bis 24, sonst 120 s) |
187
198
  | `--sitemap` | Sitemap-Tiefenlauf: `subpage-spa` prüft Unterseiten aus `robots.txt`/`sitemap.xml` (auch Index und gzip) zusammen mit den Links der Startseite, reihum nach Pfadbereich, bis `--deep-budget` verbraucht ist; `--max-subpages` gilt dann nicht (Umgebung `CPCG_SITEMAP`) |
188
199
  | `--deep-budget <s>` | Zeitbudget des Tiefenlaufs für die Unterseiten, 30 bis 3600 s (Standard 300; Umgebung `CPCG_DEEP_BUDGET`) |
@@ -310,6 +321,8 @@ ohne sie werden sie mit Hinweis übersprungen.
310
321
  | `ignore` | leer | Befunde ausnehmen (Tracker-Name oder Host-Muster, eine Angabe je Zeile oder kommagetrennt) |
311
322
  | `accept-selector`, `reject-selector`, `settings-selector` | leer | Eigene CSS-Selektoren der Banner-Buttons (eine Angabe je Zeile) |
312
323
  | `banner-frame` | leer | Teil der URL des iframes mit dem Banner |
324
+ | `visitor` | leer (CLI: ch) | Besucherprofil `ch` oder `eu` (Sprache und Zeitzone) |
325
+ | `proxy` | leer | Proxy für alle Browser-Zugriffe (aus Secrets, wenn mit Zugangsdaten); wird als `CPCG_PROXY` übergeben, nie in der Kommandozeile |
313
326
  | `max-subpages` | leer (CLI: 12) | Höchstzahl verlinkter Unterseiten, die auf Tracker geprüft werden (max. 40; mehr dauert länger) |
314
327
  | `sitemap` | `false` | Sitemap-Tiefenlauf (siehe `--sitemap`) |
315
328
  | `deep-budget` | leer (CLI: 300) | Zeitbudget des Tiefenlaufs in Sekunden (30 bis 3600) |
@@ -397,7 +410,7 @@ einem Rechtsraum nicht blockiert, steht als Hinweis mit Begründung im Report. `
397
410
  |---|---|---|---|
398
411
  | Tracker vor der Einwilligung (`pre-consent-tracking`), auch ohne gespeicherte Entscheidung nach gelöschtem Speicher (`tracking-without-consent`) | blockiert (funktionale Drittanbieter und cookielose Reichweitenmessung: Hinweis) | Hinweis | Hinweis |
399
412
  | Tracker nach Ablehnen, auch nach beschädigter gespeicherter Ablehnung oder verlorenem Klick-Rennen mit registrierter Ablehnung (`tracking-after-deny`) | blockiert | blockiert | Hinweis |
400
- | Keine Ablehnen-Möglichkeit (`no-reject-option`) | blockiert | blockiert | Hinweis |
413
+ | Keine Ablehnen-Möglichkeit (`no-reject-option`): weder auf der ersten Ebene noch in den (geöffneten) Einstellungen; ein Schliessen-Kreuz zählt nur dann nicht als Ablehnen, wenn nach Schliessen und Neuladen weiter Tracker laden (gemessen in einem frischen Browser) | blockiert | blockiert | Hinweis |
401
414
  | Banner ohne Auswahl (`no-consent-choice`): nur Hinweistext, Infolink und Schliessen-Kreuz, weder Akzeptieren noch Ablehnen, und Tracking vor der Entscheidung | blockiert | blockiert | Hinweis |
402
415
  | Werbe-Tracker trotz Global Privacy Control (`gpc-ignored`) | Hinweis | US-CA: blockiert (nur Werbung); CH: Hinweis | Hinweis |
403
416
  | Nach Ablehnen meldet der IAB-TCF-String Zustimmung zu Zwecken (`tcf-consent-mismatch`) | blockiert | blockiert | Hinweis |
package/action.yml CHANGED
@@ -65,6 +65,14 @@ inputs:
65
65
  description: "Part of the URL of the iframe that contains the consent banner (CMP inside a frame)"
66
66
  required: false
67
67
  default: ""
68
+ visitor:
69
+ description: "Visitor profile: ch (de-CH, Europe/Zurich, default) or eu (de-DE, Europe/Berlin). Fixes browser language and time zone; the country of the IP is only changed by proxy"
70
+ required: false
71
+ default: ""
72
+ proxy:
73
+ description: "Proxy for all browser requests, e.g. an exit in the EU (http(s)://[user:pass@]host:port or socks5://host:port) — from secrets if it contains credentials. Passed via the CPCG_PROXY environment variable, never on the command line. The measured IP country is in the report"
74
+ required: false
75
+ default: ""
68
76
  max-subpages:
69
77
  description: "Maximum number of linked subpages checked for trackers (default 12, max 40; larger values take longer)"
70
78
  required: false
@@ -188,7 +196,7 @@ runs:
188
196
  shell: bash
189
197
  env:
190
198
  ACTION_PATH: ${{ github.action_path }}
191
- CPCG_PINNED_VERSION: "0.3.6" # = package.json version; bei jedem Release mit anheben (tests/action-pin.test.ts prüft das)
199
+ CPCG_PINNED_VERSION: "0.3.7" # = package.json version; bei jedem Release mit anheben (tests/action-pin.test.ts prüft das)
192
200
  run: |
193
201
  set -euo pipefail
194
202
 
@@ -223,6 +231,7 @@ runs:
223
231
  CPCG_LLM_MODEL: ${{ inputs.llm-model }}
224
232
  CPCG_LICENSE: ${{ inputs.license }}
225
233
  CPCG_TARGET_HEADERS: ${{ inputs.target-headers }}
234
+ CPCG_PROXY: ${{ inputs.proxy }}
226
235
  GITHUB_TOKEN: ${{ inputs.github-token }}
227
236
  IN_STAGING_URL: ${{ inputs.staging-url }}
228
237
  IN_LLM_REMEDIATION: ${{ inputs.llm-remediation }}
@@ -237,6 +246,7 @@ runs:
237
246
  IN_SETTINGS_SELECTOR: ${{ inputs.settings-selector }}
238
247
  IN_BANNER_FRAME: ${{ inputs.banner-frame }}
239
248
  IN_MAX_SUBPAGES: ${{ inputs.max-subpages }}
249
+ IN_VISITOR: ${{ inputs.visitor }}
240
250
  IN_BANNER_WAIT: ${{ inputs.banner-wait }}
241
251
  IN_SITEMAP: ${{ inputs.sitemap }}
242
252
  IN_DEEP_BUDGET: ${{ inputs.deep-budget }}
@@ -321,6 +331,7 @@ runs:
321
331
  opt_lines settings-selector "$IN_SETTINGS_SELECTOR"
322
332
  opt_lines banner-frame "$IN_BANNER_FRAME"
323
333
  opt_lines max-subpages "$IN_MAX_SUBPAGES"
334
+ opt_lines visitor "${IN_VISITOR:-}"
324
335
  opt_lines banner-wait "$IN_BANNER_WAIT"
325
336
  opt_bool sitemap "${IN_SITEMAP:-false}"
326
337
  opt_lines deep-budget "${IN_DEEP_BUDGET:-}"
@@ -132,6 +132,15 @@ var LeakReportSchema = z.object({
132
132
  browserVersion: z.string().optional(),
133
133
  /** User-Agent, mit dem sich die Scan-Kontexte gemeldet haben (Chrome-Kennzeichen ohne «Headless»). */
134
134
  browserUserAgent: z.string().optional(),
135
+ /** Besucherprofil des Laufs: Sprache, Zeitzone, Proxy (ohne Zugangsdaten) und gemessenes IP-Land. */
136
+ visitor: z.object({
137
+ profile: z.enum(["ch", "eu"]),
138
+ locale: z.string(),
139
+ timezoneId: z.string(),
140
+ proxy: z.string().optional(),
141
+ ipCountry: z.string().optional(),
142
+ ipCountryMatches: z.boolean().optional()
143
+ }).optional(),
135
144
  /** `--har`: in diesem Lauf geschriebene HAR-Dateien, relativ zum Report-Ordner (eigener Unterordner je Lauf). */
136
145
  harFiles: z.array(z.string()).optional(),
137
146
  /** Herkunft des Laufs: Version, Scan-Konfiguration ohne Geheimnisse und deren SHA-256 (`provenance.ts`). */
@@ -328,6 +337,13 @@ var GateConfigSchema = z.object({
328
337
  * bisherige Verhalten (8 s, bei Seiten ohne Banner-Hinweis früher beendet); mit Angabe wird das Fenster ausgeschöpft.
329
338
  */
330
339
  bannerWaitSeconds: z.number().min(1).max(60).optional(),
340
+ /**
341
+ * Besucherprofil (`--visitor`): feste Sprache und Zeitzone des Browsers (ch: de-CH/Zürich, eu: de-DE/Berlin), damit
342
+ * der Lauf nicht von der Maschine abhängt. Das Land der IP bestimmt nur `proxy`.
343
+ */
344
+ visitor: z.enum(["ch", "eu"]).default("ch"),
345
+ /** Proxy für alle Browser-Zugriffe (`--proxy`, Env `CPCG_PROXY`), z. B. ein Ausgang in der EU. Enthält ggf. Zugangsdaten: nie ausgeben. */
346
+ proxy: z.string().optional(),
331
347
  /** Hinweise zur Eingabe (z. B. leerer Selektor), die der Scanner in `scannerWarnings` übernimmt. */
332
348
  configWarnings: z.array(z.string()).optional(),
333
349
  /** Scanner-Overrides für eigene Banner (CSS-Selektoren bzw. Teilstring der Banner-Frame-URL). */
@@ -1464,6 +1480,91 @@ async function fetchWithTargetHeaders(url, init, headers, origins, fetchImpl = f
1464
1480
  }
1465
1481
  }
1466
1482
 
1483
+ // src/core/scanner/visitor.ts
1484
+ var EU_COUNTRIES = [
1485
+ "AT",
1486
+ "BE",
1487
+ "BG",
1488
+ "CY",
1489
+ "CZ",
1490
+ "DE",
1491
+ "DK",
1492
+ "EE",
1493
+ "ES",
1494
+ "FI",
1495
+ "FR",
1496
+ "GR",
1497
+ "HR",
1498
+ "HU",
1499
+ "IE",
1500
+ "IT",
1501
+ "LT",
1502
+ "LU",
1503
+ "LV",
1504
+ "MT",
1505
+ "NL",
1506
+ "PL",
1507
+ "PT",
1508
+ "RO",
1509
+ "SE",
1510
+ "SI",
1511
+ "SK"
1512
+ ];
1513
+ var VISITOR_PROFILES = {
1514
+ ch: { name: "ch", label: "Schweiz", locale: "de-CH", timezoneId: "Europe/Zurich", countries: ["CH", "LI"] },
1515
+ eu: { name: "eu", label: "EU", locale: "de-DE", timezoneId: "Europe/Berlin", countries: EU_COUNTRIES }
1516
+ };
1517
+ var VISITOR_NAMES = Object.keys(VISITOR_PROFILES);
1518
+ function isVisitorName(v) {
1519
+ return VISITOR_NAMES.includes(v);
1520
+ }
1521
+ var PROXY_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "socks5:"]);
1522
+ function parseProxy(raw) {
1523
+ let u;
1524
+ try {
1525
+ u = new URL(raw.trim());
1526
+ } catch {
1527
+ return { ok: false, reason: "keine g\xFCltige URL (erwartet z. B. http://host:3128)" };
1528
+ }
1529
+ if (!PROXY_SCHEMES.has(u.protocol)) return { ok: false, reason: `Schema \xAB${u.protocol.replace(/:$/, "")}\xBB nicht unterst\xFCtzt (http, https, socks5)` };
1530
+ if (!u.hostname) return { ok: false, reason: "Host fehlt" };
1531
+ if (u.pathname && u.pathname !== "/") return { ok: false, reason: "Pfad nicht erlaubt (nur Schema, Host und Port)" };
1532
+ if (u.protocol === "socks5:" && (u.username || u.password)) {
1533
+ return { ok: false, reason: "SOCKS5 mit Zugangsdaten wird vom Browser nicht unterst\xFCtzt (http/https-Proxy verwenden)" };
1534
+ }
1535
+ const server = `${u.protocol}//${u.host}`;
1536
+ let username;
1537
+ let password;
1538
+ try {
1539
+ username = u.username ? decodeURIComponent(u.username) : void 0;
1540
+ password = u.password ? decodeURIComponent(u.password) : void 0;
1541
+ } catch {
1542
+ return { ok: false, reason: "Zugangsdaten falsch kodiert (Sonderzeichen als %XX angeben)" };
1543
+ }
1544
+ return { ok: true, proxy: { server, ...username ? { username } : {}, ...password ? { password } : {} } };
1545
+ }
1546
+ function redactProxy(raw) {
1547
+ const p = parseProxy(raw);
1548
+ return p.ok ? p.proxy.server : "(ung\xFCltig)";
1549
+ }
1550
+ var IP_COUNTRY_URL = "https://www.cloudflare.com/cdn-cgi/trace";
1551
+ function parseTraceCountry(text) {
1552
+ const m = /^loc=([A-Z][A-Z0-9])\s*$/m.exec(text);
1553
+ return m && m[1] !== "XX" ? m[1] : void 0;
1554
+ }
1555
+ var TOR_COUNTRY = "T1";
1556
+ function countryLabel(country) {
1557
+ return country === TOR_COUNTRY ? "T1 (Tor-Netz, kein Land ausgewiesen)" : country;
1558
+ }
1559
+ function ipCountryMatches(profile, country) {
1560
+ return country ? profile.countries.includes(country) : void 0;
1561
+ }
1562
+ function visitorLine(v) {
1563
+ const p = VISITOR_PROFILES[v.profile];
1564
+ const ip = v.ipCountry ? `IP-Land ${countryLabel(v.ipCountry)}${v.ipCountryMatches === false && v.ipCountry !== TOR_COUNTRY ? " (passt nicht zum Profil)" : ""}` : "IP-Land nicht gemessen";
1565
+ return `${p.label} (${v.locale}, ${v.timezoneId})${v.proxy ? `, \xFCber Proxy ${v.proxy}` : ""}, ${ip}`;
1566
+ }
1567
+
1467
1568
  // src/config/index.ts
1468
1569
  var ENV_FILE_ALLOWED = /* @__PURE__ */ new Set([
1469
1570
  "OPENAI_API_KEY",
@@ -1609,6 +1710,17 @@ function resolveGateConfig(cliOptions) {
1609
1710
  deepBudgetSeconds = 300;
1610
1711
  }
1611
1712
  }
1713
+ const rawVisitor = String(present(cliOptions.visitor) ? cliOptions.visitor : present(env.CPCG_VISITOR) ? env.CPCG_VISITOR : "ch").trim().toLowerCase() || "ch";
1714
+ let visitor = "ch";
1715
+ if (isVisitorName(rawVisitor)) visitor = rawVisitor;
1716
+ else problems.push(`--visitor: ung\xFCltiger Wert "${rawVisitor}" (erwartet: ${VISITOR_NAMES.join(", ")})`);
1717
+ const rawProxy = present(cliOptions.proxy) ? String(cliOptions.proxy) : env.CPCG_PROXY;
1718
+ let proxy;
1719
+ if (present(rawProxy) && String(rawProxy).trim()) {
1720
+ const parsedProxy = parseProxy(String(rawProxy));
1721
+ if (parsedProxy.ok) proxy = String(rawProxy).trim();
1722
+ else problems.push(`--proxy: ${parsedProxy.reason}`);
1723
+ }
1612
1724
  const headerLines = present(cliOptions.targetHeader) && (!Array.isArray(cliOptions.targetHeader) || cliOptions.targetHeader.length > 0) ? Array.isArray(cliOptions.targetHeader) ? cliOptions.targetHeader : [cliOptions.targetHeader] : (env.CPCG_TARGET_HEADERS ?? "").split(/\r?\n/);
1613
1725
  const parsedHeaders = parseTargetHeaders(headerLines);
1614
1726
  problems.push(...parsedHeaders.problems);
@@ -1707,6 +1819,8 @@ function resolveGateConfig(cliOptions) {
1707
1819
  verifyWaitSeconds,
1708
1820
  targetHeaders,
1709
1821
  bannerWaitSeconds,
1822
+ visitor,
1823
+ ...proxy ? { proxy } : {},
1710
1824
  ...configWarnings.length > 0 ? { configWarnings } : {}
1711
1825
  };
1712
1826
  const parsed = GateConfigSchema.safeParse(merged);
@@ -2999,6 +3113,41 @@ function classifyLabel(raw, consentContext = false) {
2999
3113
  if (SETTINGS_LABEL.test(t)) return { role: "settings", score: 60 };
3000
3114
  return null;
3001
3115
  }
3116
+ var BANNER_MARK_SOURCE = "cookie|consent|(?:^|[^a-z])cmp(?:[^a-z]|$)|gdpr|dsgvo|onetrust|cookiebot|cybot|usercentrics|didomi|borlabs|klaro|iubenda|sp[-_]message|cookielaw|cc[-_]?(?:window|banner)|privacy[-_]?(?:banner|notice|popup|dialog|bar)|datenschutz[-_]?(?:banner|hinweis|leiste)";
3117
+ var BANNER_TOKENS = [
3118
+ "cookie",
3119
+ "consent",
3120
+ "cmp",
3121
+ "onetrust",
3122
+ "privacy",
3123
+ "didomi",
3124
+ "usercentrics",
3125
+ "iubenda",
3126
+ "gdpr",
3127
+ "dsgvo",
3128
+ "borlabs",
3129
+ "klaro",
3130
+ "cookiebot",
3131
+ "cybot",
3132
+ "cookielaw",
3133
+ "cc-window",
3134
+ "cc-banner",
3135
+ "sp_message",
3136
+ "sp-message",
3137
+ "datenschutz"
3138
+ ];
3139
+ var BANNER_MARKED_SELECTOR = "[role=dialog],[role=alertdialog],[aria-modal=true],dialog," + BANNER_TOKENS.flatMap((t) => [`[id*=${t} i]`, `[class*=${t} i]`]).join(",");
3140
+ var CLOSE_GLYPHS = "\xD7\u2715\u2716\u2717\u2718\u274C\u2A2F\u2573xX";
3141
+ var CLOSE_LABEL_SOURCE = `^(?:[${CLOSE_GLYPHS}]|.*\\b(?:close|schlie(?:ss|\xDF)en|ausblenden|fermer|chiudi|dismiss)\\b.*)$`;
3142
+ var AGREE_LABEL_SOURCE = "einverstanden|akzept|zustimm|accept|agree|allow|erlaub|verstanden|got it|\\bok\\b|okay|einstellung|setting|anpass|verwalt|customi|ablehn|reject|decline|refus|notwendig|necessary|speicher|\\bsave\\b";
3143
+ var CLOSE_CLASS_SELECTOR = "[class*=close i],[id*=close i],[aria-label*=close i],[aria-label*=schlie i],[title*=close i],[title*=schlie i],[class*=dismiss i]";
3144
+ var CLOSE_LABEL_RE = new RegExp(CLOSE_LABEL_SOURCE, "i");
3145
+ var AGREE_LABEL_RE = new RegExp(AGREE_LABEL_SOURCE, "i");
3146
+ function isCloseLabel(label) {
3147
+ const l = label.replace(/\uFE0F/g, "").replace(/\s+/g, " ").trim();
3148
+ if (!l || AGREE_LABEL_RE.test(l)) return false;
3149
+ return CLOSE_LABEL_RE.test(l);
3150
+ }
3002
3151
  var INFO_LINK = word(
3003
3152
  [
3004
3153
  "datenschutz\\p{L}*",
@@ -3029,6 +3178,7 @@ var INFO_LINK = word(
3029
3178
  ].join("|")
3030
3179
  );
3031
3180
  function classifyControl(label, consentContext = true) {
3181
+ if (isCloseLabel(label)) return "close";
3032
3182
  const m = classifyLabel(label, consentContext);
3033
3183
  if (m) return m.role;
3034
3184
  return INFO_LINK.test(normalizeLabel(label)) ? "info" : "unknown";
@@ -3162,10 +3312,16 @@ var BANNER_CONTAINER = "[role=dialog], [role=alertdialog], [aria-modal=true], di
3162
3312
  async function inSameBanner(anchor, other) {
3163
3313
  if (anchor.frame !== other.frame) return false;
3164
3314
  if (anchor.frame.parentFrame()) return true;
3165
- const a = anchor.handle;
3166
3315
  const b = await targetLocator(other).elementHandle({ timeout: 1e3 }).catch(() => null);
3167
- if (!a || !b) return false;
3168
- const same = await a.evaluate(
3316
+ if (!b) return false;
3317
+ const same = await sameBannerHandles(anchor.handle, b);
3318
+ await b.dispose().catch(() => {
3319
+ });
3320
+ return same;
3321
+ }
3322
+ async function sameBannerHandles(a, b) {
3323
+ if (!a) return false;
3324
+ return a.evaluate(
3169
3325
  (el, [otherEl, selector]) => {
3170
3326
  let root = el.closest(selector);
3171
3327
  while (root && root !== document.body && root !== document.documentElement) {
@@ -3176,9 +3332,6 @@ async function inSameBanner(anchor, other) {
3176
3332
  },
3177
3333
  [b, BANNER_CONTAINER]
3178
3334
  ).catch(() => false);
3179
- await b.dispose().catch(() => {
3180
- });
3181
- return same;
3182
3335
  }
3183
3336
  var TOGGLE_SELECTOR = "input[type=checkbox], [role=switch], [role=checkbox]";
3184
3337
  var CATEGORY_WORDS = /statisti|analyti|analys|marketing|werbung|werbe|advertis|targeting|personali|performance|leistung|funktional|functional|komfort|präferenz|preference|tracking|social|soziale|measurement|messung|mesure|publicit|pubblicit|statistich|profil|audience|reichweite|vendor|anbieter|partner|zweck|purpose|finalit|cookies?/i;
@@ -3312,7 +3465,18 @@ var scanButtons = (arg) => {
3312
3465
  chosen.el.setAttribute("data-cpcg-pick", arg.role || "x");
3313
3466
  return true;
3314
3467
  }
3468
+ const up = (start) => {
3469
+ const out = [];
3470
+ let n = start;
3471
+ for (let d = 0; d < 60 && n; d++) {
3472
+ out.push(n);
3473
+ n = n.parentElement ?? (n.getRootNode().host ?? null);
3474
+ }
3475
+ return out;
3476
+ };
3477
+ const anchorBoxes = arg.near ? up(arg.near).filter((e) => e !== document.body && e !== document.documentElement && e.matches(BOX)) : [];
3315
3478
  return visible.map((v, i) => {
3479
+ const near = anchorBoxes.length > 0 && up(v.el).some((e) => anchorBoxes.includes(e));
3316
3480
  let node = v.el;
3317
3481
  let box = null;
3318
3482
  let hit = false;
@@ -3331,26 +3495,144 @@ var scanButtons = (arg) => {
3331
3495
  }
3332
3496
  hit = CTX.test((container.textContent || "").slice(0, 3e3));
3333
3497
  }
3334
- return { i, text: v.text, ctx: hit };
3498
+ return { i, text: v.text, ctx: hit, near };
3335
3499
  });
3336
3500
  };
3337
- async function pickSemantic(frame, role) {
3338
- const list = await boundedFrameQuery(frame, frame.evaluate(scanButtons, { mode: "list" })).catch(() => null);
3339
- if (!list?.length) return null;
3340
- let best = null;
3501
+ async function semanticCandidates(frame, role, near) {
3502
+ let list;
3503
+ try {
3504
+ list = await boundedFrameQuery(frame, frame.evaluate(scanButtons, { mode: "list", near: near ?? null }));
3505
+ } catch (err) {
3506
+ if (err instanceof FrameQueryTimeout) return null;
3507
+ return [];
3508
+ }
3509
+ if (!list?.length) return [];
3510
+ const scored = [];
3341
3511
  for (const c of list) {
3342
3512
  const m = classifyLabel(c.text, c.ctx);
3343
3513
  if (m?.role !== role) continue;
3344
- const score = m.score + (c.ctx ? 10 : 0);
3345
- if (!best || score > best.score) best = { c, score };
3514
+ scored.push({ c, score: m.score + (c.ctx ? 10 : 0) });
3346
3515
  }
3347
- if (!best) return null;
3516
+ return scored.sort((a, b) => Number(!!b.c.near) - Number(!!a.c.near) || b.score - a.score).map((x) => x.c);
3517
+ }
3518
+ async function pickCandidate(frame, role, c) {
3348
3519
  const picked = await boundedFrameQuery(
3349
3520
  frame,
3350
- frame.evaluate(scanButtons, { mode: "pick", index: best.c.i, text: best.c.text, role })
3521
+ frame.evaluate(scanButtons, { mode: "pick", index: c.i, text: c.text, role })
3351
3522
  ).catch(() => false);
3352
3523
  if (!picked) return null;
3353
- return { frame, selector: `[data-cpcg-pick="${role}"]`, via: `${SEMANTIC_PREFIX}${role}`, label: best.c.text };
3524
+ return { frame, selector: `[data-cpcg-pick="${role}"]`, via: `${SEMANTIC_PREFIX}${role}`, label: c.text };
3525
+ }
3526
+ async function pickSemantic(frame, role) {
3527
+ const [best] = await semanticCandidates(frame, role) ?? [];
3528
+ return best ? pickCandidate(frame, role, best) : null;
3529
+ }
3530
+ var pickCounter = 0;
3531
+ var SAME_BANNER_CANDIDATES = 8;
3532
+ async function findInSameBanner(page, selectors, anchor, _opts = {}) {
3533
+ const skipped = [];
3534
+ const frame = anchor.frame;
3535
+ if (frame.isDetached()) return { target: null, skipped };
3536
+ const inIframe = !!frame.parentFrame();
3537
+ for (const selector of selectors) {
3538
+ if (isSemantic(selector)) {
3539
+ const role = selector.slice(SEMANTIC_PREFIX.length);
3540
+ const candidates = await semanticCandidates(frame, role, anchor.handle);
3541
+ if (candidates === null) return { target: null, skipped };
3542
+ for (const c of candidates.slice(0, SAME_BANNER_CANDIDATES)) {
3543
+ const t = await pickCandidate(frame, role, c);
3544
+ if (!t) continue;
3545
+ if (await inSameBanner(anchor, t)) return { target: t, skipped };
3546
+ skipped.push(c.text);
3547
+ }
3548
+ continue;
3549
+ }
3550
+ let handles;
3551
+ try {
3552
+ handles = await boundedFrameQuery(frame, frame.locator(selector).filter({ visible: true }).elementHandles());
3553
+ } catch (err) {
3554
+ if (err instanceof FrameQueryTimeout) return { target: null, skipped };
3555
+ continue;
3556
+ }
3557
+ try {
3558
+ for (const h of handles.slice(0, SAME_BANNER_CANDIDATES)) {
3559
+ const label = await boundedFrameQuery(
3560
+ frame,
3561
+ h.evaluate((node) => {
3562
+ const el = node;
3563
+ return (el.innerText || el.getAttribute("aria-label") || "").replace(/\s+/g, " ").trim().slice(0, 60);
3564
+ })
3565
+ ).catch(() => null);
3566
+ if (label === null) continue;
3567
+ if (inIframe || await sameBannerHandles(anchor.handle, h)) {
3568
+ const id = `pick-${++pickCounter}`;
3569
+ const marked = await boundedFrameQuery(
3570
+ frame,
3571
+ h.evaluate((node, mark) => {
3572
+ node.setAttribute("data-cpcg-pick", mark);
3573
+ return true;
3574
+ }, id)
3575
+ ).catch(() => false);
3576
+ if (!marked) continue;
3577
+ return { target: { frame, selector: `[data-cpcg-pick="${id}"]`, via: selector, label: label || void 0 }, skipped };
3578
+ }
3579
+ skipped.push(label || selector);
3580
+ }
3581
+ } finally {
3582
+ await Promise.all(handles.map((x) => x.dispose().catch(() => void 0)));
3583
+ }
3584
+ }
3585
+ return { target: null, skipped };
3586
+ }
3587
+ async function findCloseNear(anchor) {
3588
+ const handle = await targetLocator(anchor).elementHandle({ timeout: 1500 }).catch(() => null);
3589
+ if (!handle) return null;
3590
+ const id = `close-${++pickCounter}`;
3591
+ const found = await boundedFrameQuery(
3592
+ anchor.frame,
3593
+ handle.evaluate(
3594
+ (el, a) => {
3595
+ const CLOSE = new RegExp(a.close, "i");
3596
+ const AGREE = new RegExp(a.agree, "i");
3597
+ const visible = (e) => {
3598
+ const r = e.getBoundingClientRect();
3599
+ const st = getComputedStyle(e);
3600
+ return r.width > 0 && r.height > 0 && st.visibility !== "hidden" && st.display !== "none";
3601
+ };
3602
+ const labelOf = (e) => (e.innerText || e.getAttribute("aria-label") || e.getAttribute("title") || "").replace(/️/g, "").replace(/\s+/g, " ").trim();
3603
+ let n = el;
3604
+ for (let d = 0; d < 60 && n; d++) {
3605
+ if (n !== document.body && n !== document.documentElement && n.matches(a.container)) {
3606
+ const roots = [n, ...n.shadowRoot ? [n.shadowRoot] : []];
3607
+ for (const root of roots) {
3608
+ for (const c of Array.from(root.querySelectorAll(`${a.cand}, ${a.closeSel}`))) {
3609
+ if (c === el || !visible(c)) continue;
3610
+ const label = labelOf(c);
3611
+ if (AGREE.test(label)) continue;
3612
+ if (CLOSE.test(label) || c.matches(a.closeSel)) {
3613
+ c.setAttribute("data-cpcg-pick", a.id);
3614
+ return true;
3615
+ }
3616
+ }
3617
+ }
3618
+ }
3619
+ n = n.parentElement ?? (n.getRootNode().host ?? null);
3620
+ }
3621
+ return false;
3622
+ },
3623
+ {
3624
+ container: BANNER_CONTAINER,
3625
+ cand: "button, a, [role=button], [tabindex]",
3626
+ closeSel: CLOSE_CLASS_SELECTOR,
3627
+ close: CLOSE_LABEL_SOURCE,
3628
+ agree: AGREE_LABEL_SOURCE,
3629
+ id
3630
+ }
3631
+ )
3632
+ ).catch(() => false);
3633
+ await handle.dispose().catch(() => {
3634
+ });
3635
+ return found ? { frame: anchor.frame, selector: `[data-cpcg-pick="${id}"]`, via: "close", label: "Schliessen" } : null;
3354
3636
  }
3355
3637
  async function findInFrame(frame, selectors) {
3356
3638
  const plain = selectors.filter((s) => !isSemantic(s));
@@ -3406,12 +3688,13 @@ async function findTarget(page, selectors, opts = {}) {
3406
3688
  }
3407
3689
  return null;
3408
3690
  }
3409
- var scanBannerHint = () => {
3410
- const MARK = /cookie|consent|(?:^|[^a-z])cmp(?:[^a-z]|$)|gdpr|dsgvo|onetrust|cookiebot|usercentrics|didomi|borlabs|klaro|iubenda|sp[-_]message|cookielaw|cc[-_]?(?:window|banner)|privacy[-_]?(?:banner|notice|popup|dialog|bar)|datenschutz[-_]?(?:banner|hinweis|leiste)/i;
3691
+ var scanBannerHint = (arg) => {
3692
+ const MARK = new RegExp(arg.mark, "i");
3693
+ const CROSS = new RegExp(`^[${arg.closeGlyphs}]$`);
3411
3694
  const WEAK = /cookie|consent|einwilligung|tracking|datenschutz|privacy|gdpr|dsgvo/i;
3412
3695
  const STRONG = /cookie|consent|einwilligung|tracking|\bcmp\b|gdpr|dsgvo/i;
3413
3696
  const CAND = "button, a, [role=button], input[type=button], input[type=submit], input[type=checkbox], [onclick], [tabindex], summary";
3414
- const CLOSE = "[class*=close i],[id*=close i],[aria-label*=close i],[aria-label*=schlie i],[title*=close i],[title*=schlie i],[class*=dismiss i]";
3697
+ const CLOSE = arg.closeSel;
3415
3698
  const SKIP = /^(HTML|HEAD|BODY|SCRIPT|STYLE|LINK|META|NOSCRIPT|A|BUTTON|INPUT|LABEL|SELECT|TEXTAREA|SVG|IMG|OPTION|TEMPLATE)$/;
3416
3699
  const visible = (el) => {
3417
3700
  const rect = el.getBoundingClientRect();
@@ -3444,7 +3727,7 @@ var scanBannerHint = () => {
3444
3727
  if (!(marked ? WEAK : STRONG).test(text)) continue;
3445
3728
  if (!modal && !el.querySelector(CAND)) {
3446
3729
  const pos = getComputedStyle(el).position;
3447
- const cross = !!el.querySelector(CLOSE) || Array.from(el.querySelectorAll("*")).some((c) => c.children.length === 0 && /^[×✕✖xX]$/.test((c.textContent || "").trim()));
3730
+ const cross = !!el.querySelector(CLOSE) || Array.from(el.querySelectorAll("*")).some((c) => c.children.length === 0 && CROSS.test((c.textContent || "").replace(/\uFE0F/g, "").trim()));
3448
3731
  if (!(marked && (pos === "fixed" || pos === "sticky" || cross))) continue;
3449
3732
  }
3450
3733
  return true;
@@ -3499,18 +3782,19 @@ async function detectBannerHints(page) {
3499
3782
  for (const frame of page.frames()) {
3500
3783
  if (frame.isDetached()) continue;
3501
3784
  if (frame.parentFrame() && CMP_FRAME.test(frame.url()) && await frameShown(frame)) return true;
3502
- if (await boundedFrameQuery(frame, frame.evaluate(scanBannerHint)).catch(() => false) && await frameShown(frame)) return true;
3785
+ if (await boundedFrameQuery(frame, frame.evaluate(scanBannerHint, { mark: BANNER_MARK_SOURCE, closeGlyphs: CLOSE_GLYPHS, closeSel: CLOSE_CLASS_SELECTOR })).catch(() => false) && await frameShown(frame)) return true;
3503
3786
  }
3504
3787
  return false;
3505
3788
  }
3506
3789
  var NO_CHOICE = { found: false, infoOnly: false, other: [], info: [], hasClose: false, text: "" };
3507
- var probeBannerChoice = () => {
3508
- const MARK = /cookie|consent|(?:^|[^a-z])cmp(?:[^a-z]|$)|gdpr|dsgvo|onetrust|cookiebot|usercentrics|didomi|borlabs|klaro|iubenda|sp[-_]message|cookielaw|cc[-_]?(?:window|banner)|privacy[-_]?(?:banner|notice|popup|dialog|bar)|datenschutz[-_]?(?:banner|hinweis|leiste)/i;
3790
+ var probeBannerChoice = (arg) => {
3791
+ const MARK = new RegExp(arg.mark, "i");
3509
3792
  const WEAK = /cookie|consent|einwilligung|tracking|datenschutz|privacy|gdpr|dsgvo/i;
3510
3793
  const STRONG = /cookie|consent|einwilligung|tracking|\bcmp\b|gdpr|dsgvo/i;
3511
3794
  const CAND = "button, a, [role=button], input, select, textarea, [onclick], summary, label";
3512
- const CLOSE_SEL = "[class*=close i],[id*=close i],[aria-label*=close i],[aria-label*=schlie i],[title*=close i],[title*=schlie i],[class*=dismiss i]";
3513
- const CLOSE_LABEL = /^(×|✕|✖|x|close|schlie(?:ss|ß)en|fermer|chiudi|dismiss|banner schliessen)$/i;
3795
+ const CLOSE_SEL = arg.closeSel;
3796
+ const CLOSE_LABEL = new RegExp(arg.closeLabel, "i");
3797
+ const AGREE_LABEL = new RegExp(arg.agreeLabel, "i");
3514
3798
  const INFO_LABEL = /mehr (?:erfahren|informationen|infos)|weitere (?:informationen|infos)|datenschutz|cookie[- ]?(?:richtlinie|policy|erkl[aä]rung|hinweis|informationen)|privacy|learn more|more info|details|impressum|en savoir plus|maggiori informazioni|ulteriori informazioni/i;
3515
3799
  const SKIP = /^(HTML|HEAD|BODY|SCRIPT|STYLE|LINK|META|NOSCRIPT|A|BUTTON|INPUT|LABEL|SELECT|TEXTAREA|SVG|IMG|OPTION|TEMPLATE)$/;
3516
3800
  const visible = (el) => {
@@ -3520,7 +3804,7 @@ var probeBannerChoice = () => {
3520
3804
  return style.visibility !== "hidden" && style.display !== "none" && parseFloat(style.opacity || "1") >= 0.05;
3521
3805
  };
3522
3806
  const labelOf = (el) => (el.innerText || el.value || "").replace(/\s+/g, " ").trim() || (el.getAttribute("aria-label") || el.getAttribute("title") || "").trim();
3523
- const MARKED_SEL = "[role=dialog],[role=alertdialog],[aria-modal=true],dialog,[id*=cookie i],[class*=cookie i],[id*=consent i],[class*=consent i],[id*=cmp i],[class*=cmp i],[id*=onetrust i],[class*=onetrust i],[id*=privacy i],[class*=privacy i],[id*=didomi i],[id*=usercentrics i],[id*=iubenda i],[id*=gdpr i],[class*=gdpr i],[id*=dsgvo i],[class*=dsgvo i],[id*=borlabs i],[class*=borlabs i],[id*=klaro i],[class*=klaro i],[id*=cookiebot i],[id*=cybot i],[id*=cookielaw i],[class*=cookielaw i]";
3807
+ const MARKED_SEL = arg.markedSel;
3524
3808
  let container = null;
3525
3809
  for (const el of Array.from(document.querySelectorAll(MARKED_SEL))) {
3526
3810
  if (SKIP.test(el.tagName.toUpperCase())) continue;
@@ -3561,8 +3845,10 @@ var probeBannerChoice = () => {
3561
3845
  if (all.some((o) => o !== el && o.contains(el) && !(o.tagName === "LABEL"))) continue;
3562
3846
  seen.add(el);
3563
3847
  const label = labelOf(el);
3564
- const closeLike = el.matches(CLOSE_SEL) || CLOSE_LABEL.test(label);
3565
- if (closeLike && (label.length <= 24 || el.matches(CLOSE_SEL))) {
3848
+ const plainLabel = label.replace(/\uFE0F/g, "").trim();
3849
+ const agrees = AGREE_LABEL.test(plainLabel);
3850
+ const closeLike = !agrees && (CLOSE_LABEL.test(plainLabel) || el.matches(CLOSE_SEL));
3851
+ if (closeLike) {
3566
3852
  hasClose = true;
3567
3853
  continue;
3568
3854
  }
@@ -3578,7 +3864,13 @@ var probeBannerChoice = () => {
3578
3864
  async function describeBannerChoice(page) {
3579
3865
  for (const frame of page.frames()) {
3580
3866
  if (frame.isDetached() || frame.parentFrame()) continue;
3581
- const r = await boundedFrameQuery(frame, frame.evaluate(probeBannerChoice)).catch(() => void 0);
3867
+ const r = await boundedFrameQuery(frame, frame.evaluate(probeBannerChoice, {
3868
+ mark: BANNER_MARK_SOURCE,
3869
+ markedSel: BANNER_MARKED_SELECTOR,
3870
+ closeLabel: CLOSE_LABEL_SOURCE,
3871
+ agreeLabel: AGREE_LABEL_SOURCE,
3872
+ closeSel: CLOSE_CLASS_SELECTOR
3873
+ })).catch(() => void 0);
3582
3874
  if (r?.found) {
3583
3875
  return { found: true, infoOnly: r.other.length === 0, other: r.other, info: r.info, hasClose: r.hasClose, text: r.text };
3584
3876
  }
@@ -4120,6 +4412,10 @@ var ChaosScanner = class {
4120
4412
  frameQueryTimeouts = 0;
4121
4413
  /** User-Agent der Scan-Kontexte (für den Report). */
4122
4414
  userAgent;
4415
+ /** Besucherprofil des laufenden Scans (Sprache, Zeitzone) und was davon im Bericht steht. */
4416
+ visitorProfile = VISITOR_PROFILES.ch;
4417
+ visitorInfo;
4418
+ ipCountryUrl;
4123
4419
  /**
4124
4420
  * Abgebrochene Schritte, die auch nach dem Schliessen ihrer Kontexte nicht endeten. `scan()` kehrt erst zurück, wenn
4125
4421
  * sie nach dem Schliessen des Browsers ausgelaufen sind: sonst könnten sie in einen späteren Lauf derselben Instanz
@@ -4176,6 +4472,7 @@ var ChaosScanner = class {
4176
4472
  this.cnameResolver = options.cnameResolver;
4177
4473
  this.sitemapFetcher = options.sitemapFetcher;
4178
4474
  this.onProgress = options.onProgress;
4475
+ this.ipCountryUrl = options.ipCountryUrl ?? IP_COUNTRY_URL;
4179
4476
  this.overrides = {
4180
4477
  acceptSelectors: options.acceptSelectors,
4181
4478
  rejectSelectors: options.rejectSelectors,
@@ -4225,6 +4522,15 @@ var ChaosScanner = class {
4225
4522
  this.maxSubpages = config.maxSubpages ?? 12;
4226
4523
  this.bannerProbe = "none";
4227
4524
  this.frameQueryTimeouts = 0;
4525
+ this.visitorProfile = VISITOR_PROFILES[config.visitor ?? "ch"];
4526
+ this.visitorInfo = {
4527
+ profile: this.visitorProfile.name,
4528
+ locale: this.visitorProfile.locale,
4529
+ timezoneId: this.visitorProfile.timezoneId,
4530
+ ...config.proxy ? { proxy: redactProxy(config.proxy) } : {}
4531
+ };
4532
+ const proxySetting = config.proxy ? parseProxy(config.proxy) : void 0;
4533
+ if (proxySetting && !proxySetting.ok) throw new Error(`--proxy: ${proxySetting.reason}`);
4228
4534
  this.bannerIssue = void 0;
4229
4535
  this.botProtection = void 0;
4230
4536
  this.challengeUnsolved = false;
@@ -4288,6 +4594,7 @@ var ChaosScanner = class {
4288
4594
  }
4289
4595
  browser = await launchScanBrowser({
4290
4596
  headless: config.headless,
4597
+ ...proxySetting?.ok ? { proxy: proxySetting.proxy } : {},
4291
4598
  // Mit Freigabe-Headern liefert der Scanner Dokumente der eigenen Origin selbst aus (route.fetch/fulfill). Chrome
4292
4599
  // kennt dann deren Netzadresse nicht und blockiert Anfragen ins lokale/private Netz (Local Network Access), die
4293
4600
  // die Seite sonst normal laden würde (Staging im internen Netz). Nur in diesem Fall abgeschaltet.
@@ -4300,6 +4607,9 @@ var ChaosScanner = class {
4300
4607
  this.browserVersion = `chromium ${browser.version()}`;
4301
4608
  this.userAgent = browserUserAgent(browser.version());
4302
4609
  const scanBrowser = browser;
4610
+ if (config.visitor === "eu" || config.proxy) {
4611
+ await this.boundedStep("Messung IP-Land", preStepDeadlineMs(config), () => this.measureIpCountry(scanBrowser, config));
4612
+ }
4303
4613
  await this.boundedStep("Pr\xFCfung der eigenen Selektoren", preStepDeadlineMs(config), () => this.checkOverrideSelectors(scanBrowser));
4304
4614
  await this.boundedStep(
4305
4615
  "Vorpr\xFCfung Google Consent Mode",
@@ -4741,8 +5051,8 @@ var ChaosScanner = class {
4741
5051
  });
4742
5052
  }
4743
5053
  await this.drainAbandoned();
4744
- if (this.targetHeaders && this.harFiles.length) {
4745
- const names = Object.keys(this.targetHeaders);
5054
+ if (this.harFiles.length) {
5055
+ const names = [...Object.keys(this.targetHeaders ?? {}), "proxy-authorization"];
4746
5056
  for (const file of this.harFiles) await redactHarHeaders(file, names);
4747
5057
  }
4748
5058
  }
@@ -4760,6 +5070,7 @@ var ChaosScanner = class {
4760
5070
  scannedAt: (/* @__PURE__ */ new Date()).toISOString(),
4761
5071
  ...this.browserVersion ? { browserVersion: this.browserVersion } : {},
4762
5072
  ...this.userAgent ? { browserUserAgent: this.userAgent } : {},
5073
+ ...this.visitorInfo ? { visitor: this.visitorInfo } : {},
4763
5074
  ...this.harFiles.length ? {
4764
5075
  harFiles: this.harFiles.map(
4765
5076
  (f) => path3.relative(path3.dirname(path3.resolve(config.reportOutput)), f).split(path3.sep).join("/")
@@ -5005,12 +5316,45 @@ var ChaosScanner = class {
5005
5316
  `${this.frameQueryTimeouts} Abfrage(n) an Seiten-Frames blieben ohne Antwort (je ${FRAME_QUERY_MS / 1e3} s).` + (unknown ? " Ob die Seite einen Banner hat, ist damit nicht belegt (kein \xABkein Banner\xBB)." : "")
5006
5317
  );
5007
5318
  }
5008
- async newContext(browser, options = {}) {
5009
- const harPath = this.harDir ? path3.join(this.harDir, `context-${String(++this.harCount).padStart(3, "0")}.har`) : void 0;
5319
+ /**
5320
+ * Land der IP, über die der Browser ins Netz geht (über den Proxy, falls gesetzt). Passt es nicht zum Profil, sieht
5321
+ * die Seite einen Besucher aus diesem Land, nicht aus dem Profil: deutliche Warnung, das Ergebnis bleibt gültig.
5322
+ */
5323
+ async measureIpCountry(browser, config) {
5324
+ const context = await this.newContext(browser, {}, { har: false });
5325
+ let country;
5326
+ try {
5327
+ const page = await context.newPage();
5328
+ const res = await page.goto(this.ipCountryUrl, { waitUntil: "domcontentloaded", timeout: Math.min(config.timeoutMs, 15e3) });
5329
+ country = parseTraceCountry(await res?.text().catch(() => "") ?? "");
5330
+ } catch {
5331
+ country = void 0;
5332
+ } finally {
5333
+ await context.close().catch(() => {
5334
+ });
5335
+ }
5336
+ const matches = ipCountryMatches(this.visitorProfile, country);
5337
+ this.visitorInfo = { ...this.visitorInfo, ...country ? { ipCountry: country, ipCountryMatches: matches } : {} };
5338
+ const label = this.visitorProfile.label;
5339
+ if (!country) {
5340
+ this.warnings.push(`Besucherprofil ${label}: Land der IP nicht ermittelbar; ob die Seite einen Besucher aus ${label} sah, ist nicht belegt.`);
5341
+ } else if (country === TOR_COUNTRY) {
5342
+ this.warnings.push(
5343
+ `Besucherprofil ${label}: der Ausgang ist das Tor-Netz (Cloudflare weist \xABT1\xBB statt eines Landes aus). Seiten sehen je nach Geo-Dienst das Land des Tor-Ausgangs oder \xABTor\xBB; viele sperren Tor (Bot-Schutz). F\xFCr belastbare L\xE4nder-Vergleiche einen Proxy mit festem Land nutzen.`
5344
+ );
5345
+ } else if (matches === false) {
5346
+ this.warnings.push(
5347
+ `Besucherprofil ${label}, aber IP-Land ${country}: Seiten, die nach IP-Adresse entscheiden, zeigen den Banner f\xFCr ${country}. Sprache und Zeitzone sind ${label}; f\xFCr echte Besucher aus ${label} --proxy mit Ausgang dort setzen.`
5348
+ );
5349
+ }
5350
+ }
5351
+ async newContext(browser, options = {}, opts = {}) {
5352
+ const harPath = this.harDir && opts.har !== false ? path3.join(this.harDir, `context-${String(++this.harCount).padStart(3, "0")}.har`) : void 0;
5010
5353
  if (harPath) this.harFiles.push(harPath);
5011
5354
  const har = harPath ? { recordHar: { path: harPath, content: "omit" } } : {};
5012
5355
  const userAgent = options.userAgent ?? this.userAgent ?? browserUserAgent(browser.version());
5013
- const context = await browser.newContext({ serviceWorkers: "block", ...har, ...userAgent ? { userAgent } : {}, ...options });
5356
+ const visitor = { locale: this.visitorProfile.locale, timezoneId: this.visitorProfile.timezoneId };
5357
+ const context = await browser.newContext({ serviceWorkers: "block", ...har, ...visitor, ...userAgent ? { userAgent } : {}, ...options });
5014
5358
  this.liveContexts.add(context);
5015
5359
  context.once("close", () => this.liveContexts.delete(context));
5016
5360
  onFrameQueryTimeout(context, () => {
@@ -5547,6 +5891,34 @@ var ChaosScanner = class {
5547
5891
  await probeContext.close().catch(() => {
5548
5892
  });
5549
5893
  }
5894
+ },
5895
+ probeClose: async () => {
5896
+ const probeContext = await this.newContext(browser);
5897
+ try {
5898
+ const probePage = await probeContext.newPage();
5899
+ watchScope(probePage, scope);
5900
+ await this.gotoTarget(probePage, _config, scope, "domcontentloaded", { probe: true });
5901
+ const acc = await findTarget(probePage, this.session.accept, { frameHint: this.session.frameHint });
5902
+ const close = acc ? await findCloseNear(acc) : null;
5903
+ if (!close) return { clicked: false, tracked: 0 };
5904
+ const clicked = await targetLocator(close).click({ timeout: 2e3 }).then(() => true, () => false);
5905
+ if (!clicked) return { clicked: false, tracked: 0 };
5906
+ scope.noteScannerClick();
5907
+ await probePage.waitForTimeout(1200);
5908
+ let tracked = 0;
5909
+ probeContext.on("request", (req) => {
5910
+ const t = identifyTracker(req.url());
5911
+ if (t && this.trackerVerdict(t) === "violation") tracked++;
5912
+ });
5913
+ await this.gotoTarget(probePage, _config, scope, "domcontentloaded", { probe: true });
5914
+ await probePage.waitForTimeout(2500);
5915
+ return { clicked: true, tracked };
5916
+ } catch {
5917
+ return { clicked: false, tracked: 0 };
5918
+ } finally {
5919
+ await probeContext.close().catch(() => {
5920
+ });
5921
+ }
5550
5922
  }
5551
5923
  };
5552
5924
  let outcome = false;
@@ -5756,14 +6128,8 @@ var ChaosScanner = class {
5756
6128
  async rejectViaSettings(page, session, scope, accept, hooks) {
5757
6129
  const frameHint = session.frameHint;
5758
6130
  const acceptHandle = await targetLocator(accept).elementHandle({ timeout: 1500 }).catch(() => null);
5759
- const settingsHit = await findInFrame(accept.frame, session.settings).catch(() => null) ?? await findTarget(page, session.settings, { frameHint });
5760
- let settings = settingsHit && await inSameBanner({ frame: accept.frame, handle: acceptHandle }, settingsHit) ? settingsHit : null;
5761
- if (settingsHit && !settings) {
5762
- hooks.log(`settings-outside-banner:${settingsHit.label ?? settingsHit.via}`);
5763
- const vendorOnly = session.settings.filter((s) => !s.startsWith("@semantic:"));
5764
- const vendorHit = await findTarget(page, vendorOnly, { frameHint });
5765
- settings = vendorHit && await inSameBanner({ frame: accept.frame, handle: acceptHandle }, vendorHit) ? vendorHit : null;
5766
- }
6131
+ const { target: settings, skipped } = await findInSameBanner(page, session.settings, { frame: accept.frame, handle: acceptHandle }, { frameHint });
6132
+ for (const label of skipped.slice(0, 3)) hooks.log(`settings-outside-banner:${label}`);
5767
6133
  await acceptHandle?.dispose().catch(() => {
5768
6134
  });
5769
6135
  if (!settings) return { outcome: "no-settings" };
@@ -5915,6 +6281,25 @@ var ChaosScanner = class {
5915
6281
  ctx.reason("Ablehnen \xFCber die Einstellungen (\xABAuswahl speichern\xBB) gelang nicht \u2014 daher kein Befund");
5916
6282
  return "unknown";
5917
6283
  }
6284
+ const closes = others.filter((o) => o.kind === "close");
6285
+ let closeNote = "";
6286
+ if (closes.length > 0) {
6287
+ const closeLabel = closes[0].text;
6288
+ const probe = await ctx.probeClose();
6289
+ if (!probe.clicked) {
6290
+ ctx.reason(`Schliessen-Element (\xAB${closeLabel}\xBB) im Banner nicht bedienbar \u2014 ob es ablehnt, ist offen, daher kein Befund`);
6291
+ return "unknown";
6292
+ }
6293
+ if (probe.tracked === 0) {
6294
+ ctx.log("close-acts-as-reject");
6295
+ ctx.reason(
6296
+ `Das Schliessen-Element (\xAB${closeLabel}\xBB) wirkt wie Ablehnen: nach Schliessen und Neuladen kein Tracking (Testlauf in frischem Kontext) \u2014 daher kein Befund \xABkein Ablehnen\xBB`
6297
+ );
6298
+ return "unknown";
6299
+ }
6300
+ ctx.log(`close-not-reject(${probe.tracked})`);
6301
+ closeNote = ` Das Schliessen-Element (\xAB${closeLabel}\xBB) lehnt nicht ab: nach Schliessen und Neuladen ${probe.tracked} Tracker-Request(s) (Testlauf in frischem Kontext).`;
6302
+ }
5918
6303
  const before = nonAdvisory(captured).length;
5919
6304
  const afterAccept = before > 0 ? 0 : await ctx.probeAccept();
5920
6305
  if (before === 0 && afterAccept === 0) {
@@ -5929,12 +6314,12 @@ var ChaosScanner = class {
5929
6314
  trackerCategory: "unknown",
5930
6315
  requestUrl: config.targetUrl,
5931
6316
  method: "DOM",
5932
- description: `Kein gleichwertiges Ablehnen auf der ersten Ebene gefunden: Der Banner bietet \xAB${accept.label ?? accept.via}\xBB an, aber weder \xABAblehnen\xBB noch \xABNur notwendige\xBB (auch nicht in den Einstellungen); Tracking ist aktiv (${trackingText}). Messergebnis: im Banner l\xE4sst sich keine Ablehnung w\xE4hlen (relevant im Modell opt-out; im Modell opt-in fehlt die gleichwertige Wahl). Automatische Erkennung, technischer Befund, keine Rechtsbewertung.`
6317
+ description: `Kein Ablehnen im Banner gefunden: Der Banner bietet \xAB${accept.label ?? accept.via}\xBB an, aber kein \xABAblehnen\xBB oder \xABNur notwendige\xBB auf der ersten Ebene, ${secondLevelOpened ? "und auch die ge\xF6ffneten Einstellungen bieten keinen Ablehnen-Weg" : "und keine Einstellungen"}; Tracking ist aktiv (${trackingText}).${closeNote} Messergebnis: im Banner l\xE4sst sich keine Ablehnung w\xE4hlen (relevant im Modell opt-out; im Modell opt-in fehlt die gleichwertige Wahl). Automatische Erkennung, technischer Befund, keine Rechtsbewertung.`
5933
6318
  },
5934
6319
  "pre-consent"
5935
6320
  );
5936
6321
  ctx.note(
5937
- "Kein gleichwertiges Ablehnen auf der ersten Ebene gefunden, obwohl Tracking aktiv ist. Automatische Erkennung, technischer Befund, keine Rechtsbewertung."
6322
+ `Kein Ablehnen im Banner gefunden (weder auf der ersten Ebene noch ${secondLevelOpened ? "in den ge\xF6ffneten Einstellungen" : "\xFCber Einstellungen, der Banner bietet keine"}), obwohl Tracking aktiv ist. Automatische Erkennung, technischer Befund, keine Rechtsbewertung.`
5938
6323
  );
5939
6324
  ctx.log("finding:no-reject-option");
5940
6325
  return "violation";
@@ -9879,6 +10264,7 @@ function buildEvidenceMarkdown(report, title = "Evidence Report", options = {})
9879
10264
  ...options.client ? [`**Kunde:** ${escapeMarkdownText(options.client)} `] : [],
9880
10265
  `**Ziel:** \`${escapeCell(report.targetUrl)}\` `,
9881
10266
  `**Scan:** ${escapeMarkdownText(report.scannedAt)} `,
10267
+ ...report.visitor ? [`**Besucherprofil:** ${escapeMarkdownText(visitorLine(report.visitor))} `] : [],
9882
10268
  `**Technisches Gate:** ${facts.gateHeadline} \xB7 ${facts.findingsText} \xB7 ${facts.gateDisclaimer}`,
9883
10269
  `**Szenarien:** ${facts.checked} gepr\xFCft, ${facts.uncheckableTotal} nicht pr\xFCfbar`,
9884
10270
  `**Rechtsr\xE4ume:** ${jurisdictionModelLabel(profiles)}` + (facts.advisory > 0 ? ` \xB7 **Hinweise:** ${facts.advisory} (nicht blockierend, siehe \xABHinweise\xBB)` : ""),
@@ -10610,6 +10996,7 @@ ${demoBanner}
10610
10996
  ` : ""}<span>Ziel: <code>${esc2(report.targetUrl)}</code></span>
10611
10997
  <span>Scan: ${esc2(fmtTime(report.scannedAt))}</span>
10612
10998
  <span>Dauer: ${esc2(fmtDuration(report.durationMs))}</span>
10999
+ ${report.visitor ? `<span>Besucher: ${esc2(visitorLine(report.visitor))}</span>` : ""}
10613
11000
  </div>
10614
11001
  <div class="gate ${gateClass}">
10615
11002
  <span class="gtitle">${esc2(gateTitle)}</span>
@@ -11418,7 +11805,7 @@ import pc from "picocolors";
11418
11805
  import { createHash } from "crypto";
11419
11806
  import fs10 from "fs/promises";
11420
11807
  import path10 from "path";
11421
- var CPCG_VERSION = true ? "0.3.6" : "dev";
11808
+ var CPCG_VERSION = true ? "0.3.7" : "dev";
11422
11809
  function scanConfigOf(config) {
11423
11810
  return {
11424
11811
  targetUrl: config.targetUrl,
@@ -11437,6 +11824,9 @@ function scanConfigOf(config) {
11437
11824
  settingsSelectors: config.settingsSelectors ?? [],
11438
11825
  bannerFrame: config.bannerFrame ?? null,
11439
11826
  headless: config.headless,
11827
+ // Besucherprofil und Ausgang gehören zur Prüfung; der Proxy nur ohne Zugangsdaten (zwei Ausgänge = zwei Konfigurationen).
11828
+ visitor: config.visitor ?? "ch",
11829
+ proxy: config.proxy ? redactProxy(config.proxy) : null,
11440
11830
  // Nur die Namen der Freigabe-Header: die Werte sind Geheimnisse.
11441
11831
  targetHeaders: Object.keys(config.targetHeaders ?? {}).sort()
11442
11832
  };
@@ -11882,6 +12272,10 @@ var PrivacyChaosGate = class {
11882
12272
  if (config.strict) row("Strict", "true (Hinweise blockieren ebenfalls)");
11883
12273
  if (config.ignore.length > 0) row("Ignore", config.ignore.join(", "));
11884
12274
  row("Jurisdiction", config.jurisdiction);
12275
+ {
12276
+ const v = VISITOR_PROFILES[config.visitor ?? "ch"];
12277
+ row("Visitor", `${v.label} (${v.locale}, ${v.timezoneId})${config.proxy ? `, \xFCber Proxy ${redactProxy(config.proxy)}` : ", ohne Proxy (IP dieses Rechners)"}`);
12278
+ }
11885
12279
  if (config.targetHeaders) row("Target Headers", `${targetHeaderNames(config.targetHeaders).join(", ")} (Werte verborgen, nur an die Ziel-Origin)`);
11886
12280
  row("Report Output", config.reportOutput);
11887
12281
  console.log("");
package/dist/cli.js CHANGED
@@ -11,12 +11,12 @@ import {
11
11
  resolveEntitlement,
12
12
  resolveGateConfig,
13
13
  resolveJurisdictions
14
- } from "./chunk-PDBLZE7N.js";
14
+ } from "./chunk-RXTWCLK5.js";
15
15
 
16
16
  // src/cli.ts
17
17
  import { Command, CommanderError } from "commander";
18
18
  import pc from "picocolors";
19
- var VERSION = true ? "0.3.6" : "dev";
19
+ var VERSION = true ? "0.3.7" : "dev";
20
20
  for (const stream of [process.stdout, process.stderr]) {
21
21
  stream.on("error", (err) => {
22
22
  if (err.code !== "EPIPE") throw err;
@@ -49,7 +49,7 @@ Lizenz:
49
49
  `;
50
50
  var collect = (value, previous) => [...previous, value];
51
51
  var program = new Command();
52
- program.name("cpcg").description("Cuonztech Privacy Chaos Gate - CI/CD Shift-Left Consent Scanner & Auto-Remediation").version(VERSION).option("-u, --url <url>", "Staging- oder localhost-URL (http/https) \u2014 Pflicht").option("-k, --api-key <key>", "LLM-API-Key; wirkt nur mit --llm-remediation (Env-Fallback nur passend zum Provider)").option("--allow-custom-banner-fix [boolean]", "Auto-Fix darf auch bei eigenem Banner (kein erkanntes CMP) Skripte \xE4ndern. Standard aus: dann nur Anleitung (default: false)").option("--llm-remediation [boolean]", "Opt-in: Quellcode darf zur Patch-Erzeugung an den LLM-Anbieter gesendet werden (default: false)").option("-p, --llm-provider <provider>", "LLM-Provider: openai | anthropic | gemini (umgesetzt ist derzeit nur openai; sonst greift die Regel-Engine) (default: openai)").option("-m, --llm-model <model>", "LLM-Modell (default: gpt-4o)").option("--auto-fix [boolean]", "Code-Patches erzeugen und im Quellverzeichnis anwenden (default: true nur mit ausdr\xFCcklichem --source-dir, sonst false)").option("--fail-on-leak [boolean]", "Build blockieren (Exit 1), wenn Leaks bleiben (default: true)").option("--fail-on-uncheckable [boolean]", "Exit 4, wenn Kernszenarien nicht pr\xFCfbar sind; bei false Exit 0, das Ergebnis bleibt als unvollst\xE4ndig markiert (default: true)").option("-r, --report-output <path>", "Pfad des JSON-Reports (default: reports/privacy-chaos-report.json)").option("-s, --source-dir <dir>", "Quellcode-Verzeichnis f\xFCr Auto-Fix; ausdr\xFCcklich angeben, um Auto-Fix zu aktivieren").option("--git-commit [boolean]", "Fixes automatisch in den Git-Branch committen \u2014 Lizenz erforderlich (default: false)").option("--create-pr [boolean]", "Fix-Branch anlegen und GitHub-PR \xF6ffnen; hat Vorrang vor --git-commit \u2014 Lizenz erforderlich (default: false)").option("--github-token <token>", "GitHub-Token f\xFCr PR-Erstellung (besser: Env GITHUB_TOKEN)").option("--base-branch <branch>", "PR-Basisbranch (default: Default-Branch des Remotes)").option("--branch-prefix <prefix>", "Branch-Pr\xE4fix f\xFCr Fix-PRs (default: fix/cpcg-privacy)").option("--headless [boolean]", "Browser headless starten (default: true)").option("--timeout-ms <ms>", "Timeout je Szenario-Navigation und f\xFCr den Erreichbarkeits-Check in ms, positive ganze Zahl (default: 30000)").option("--strict [boolean]", "Hinweise (rein funktionale Drittanbieter wie Google Fonts) blockieren das Gate ebenfalls (default: false)").option("--ignore <liste>", "Befunde ignorieren: Tracker-Name oder Host-Muster, kommagetrennt oder mehrfach (z. B. fonts.googleapis.com,*.hotjar.com); im Report als \xABignoriert\xBB ausgewiesen; `*`/`**` und nackte TLDs (com, ch) werden immer abgelehnt (zum Abschalten der Blockierung --fail-on-leak false), ganze Zonen (*.com) ohne --allow-broad-ignore", collect, []).option("--allow-broad-ignore [boolean]", "Ganze Zonen als --ignore-Muster (*.com, *.co.uk, .ch) bewusst zulassen; sie werden in Konsole und Report als Warnung ausgewiesen; `*` und nackte TLDs bleiben abgelehnt (default: false)").option("--accept-selector <css>", "Eigener CSS-Selektor des Akzeptieren-Buttons (mehrfach oder kommagetrennt)", collect, []).option("--reject-selector <css>", "Eigener CSS-Selektor des Ablehnen-Buttons (mehrfach oder kommagetrennt)", collect, []).option("--settings-selector <css>", "Eigener CSS-Selektor des Einstellungen-Buttons (mehrfach oder kommagetrennt)", collect, []).option("--banner-frame <teilstring>", "Teilstring der URL des Banner-iframes (CMP im Frame)").option("--max-subpages <n>", "Obergrenze der Unterseiten-Stichprobe (Szenario subpage-spa), ganze Zahl 1\u201340 (default: 12; Env CPCG_MAX_SUBPAGES). Bleibt die Stichprobe unvollst\xE4ndig, weist das Gate das aus (Exit-Code unver\xE4ndert)").option("--sitemap [boolean]", "Sitemap-Tiefenlauf: Unterseiten aus robots.txt/sitemap.xml und den Links der Startseite pr\xFCfen, bis --deep-budget verbraucht ist (statt --max-subpages; Env CPCG_SITEMAP)").option("--deep-budget <sekunden>", "Zeitbudget des Sitemap-Tiefenlaufs f\xFCr die Unterseiten, 30\u20133600 (default: 300; Env CPCG_DEEP_BUDGET)").option("--deep-state <pfad>", "Zustandsdatei des Tiefenlaufs: der n\xE4chste Lauf setzt bei den noch nicht gepr\xFCften Unterseiten fort (Env CPCG_DEEP_STATE)").option("--baseline <pfad>", "Report (JSON) eines fr\xFCheren Laufs: der Bericht nennt neue, weggefallene und gleich gebliebene Befunde (Env CPCG_BASELINE)").option("--har [boolean]", "HAR-Mitschnitt je Browser-Kontext ohne Inhalte nach evidence/har neben dem Report (Env CPCG_HAR); enth\xE4lt Adressen und Header der Zielseite").option("--verify-url <url>", "Geschlossener Kreis: hat die Ziel-URL Befunde, zus\xE4tzlich diese URL pr\xFCfen (z. B. Vorschau des Fix-PRs); nur ein sauberer, vollst\xE4ndiger Scan dort heisst \xABFix verifiziert\xBB (Env CPCG_VERIFY_URL)").option("--verify-wait <sekunden>", "So lange auf die Erreichbarkeit der Verify-URL warten, 0\u20131800 (default: 0; Env CPCG_VERIFY_WAIT)").option("--target-header <name: wert>", "Freigabe-Header nur f\xFCr die gepr\xFCfte Website (mehrfach), z. B. f\xFCr eine WAF-Ausnahme oder Vercel \xABx-vercel-protection-bypass: \u2026\xBB; geht nie an Drittanbieter, Werte erscheinen in keinem Report. Im CI besser \xFCber Env CPCG_TARGET_HEADERS (eine Zeile je Header)", collect, []).option("--banner-wait <sekunden>", "Wartefenster auf einen (sp\xE4t erscheinenden) Banner in Sekunden, 1\u201360 (default: 8, bei Seiten ohne Banner-Hinweis fr\xFCher beendet; mit Angabe wird das Fenster ausgesch\xF6pft, auch bei --accept-selector/--reject-selector; Env CPCG_BANNER_WAIT)").option("--license <token>", "Cuonztech CPCG Lizenzcode CPCG-\u2026 oder Kunden-Key CPCG-K-\u2026 (oder Env CPCG_LICENSE) \u2014 nach Online-Kauf per E-Mail").option(
52
+ program.name("cpcg").description("Cuonztech Privacy Chaos Gate - CI/CD Shift-Left Consent Scanner & Auto-Remediation").version(VERSION).option("-u, --url <url>", "Staging- oder localhost-URL (http/https) \u2014 Pflicht").option("-k, --api-key <key>", "LLM-API-Key; wirkt nur mit --llm-remediation (Env-Fallback nur passend zum Provider)").option("--allow-custom-banner-fix [boolean]", "Auto-Fix darf auch bei eigenem Banner (kein erkanntes CMP) Skripte \xE4ndern. Standard aus: dann nur Anleitung (default: false)").option("--llm-remediation [boolean]", "Opt-in: Quellcode darf zur Patch-Erzeugung an den LLM-Anbieter gesendet werden (default: false)").option("-p, --llm-provider <provider>", "LLM-Provider: openai | anthropic | gemini (umgesetzt ist derzeit nur openai; sonst greift die Regel-Engine) (default: openai)").option("-m, --llm-model <model>", "LLM-Modell (default: gpt-4o)").option("--auto-fix [boolean]", "Code-Patches erzeugen und im Quellverzeichnis anwenden (default: true nur mit ausdr\xFCcklichem --source-dir, sonst false)").option("--fail-on-leak [boolean]", "Build blockieren (Exit 1), wenn Leaks bleiben (default: true)").option("--fail-on-uncheckable [boolean]", "Exit 4, wenn Kernszenarien nicht pr\xFCfbar sind; bei false Exit 0, das Ergebnis bleibt als unvollst\xE4ndig markiert (default: true)").option("-r, --report-output <path>", "Pfad des JSON-Reports (default: reports/privacy-chaos-report.json)").option("-s, --source-dir <dir>", "Quellcode-Verzeichnis f\xFCr Auto-Fix; ausdr\xFCcklich angeben, um Auto-Fix zu aktivieren").option("--git-commit [boolean]", "Fixes automatisch in den Git-Branch committen \u2014 Lizenz erforderlich (default: false)").option("--create-pr [boolean]", "Fix-Branch anlegen und GitHub-PR \xF6ffnen; hat Vorrang vor --git-commit \u2014 Lizenz erforderlich (default: false)").option("--github-token <token>", "GitHub-Token f\xFCr PR-Erstellung (besser: Env GITHUB_TOKEN)").option("--base-branch <branch>", "PR-Basisbranch (default: Default-Branch des Remotes)").option("--branch-prefix <prefix>", "Branch-Pr\xE4fix f\xFCr Fix-PRs (default: fix/cpcg-privacy)").option("--headless [boolean]", "Browser headless starten (default: true)").option("--visitor <profil>", "Besucherprofil: ch (de-CH, Zeitzone Z\xFCrich) oder eu (de-DE, Berlin); feste Sprache/Zeitzone statt der des Rechners (default: ch; Env CPCG_VISITOR). Das Land der IP \xE4ndert nur --proxy").option("--proxy <url>", "Proxy f\xFCr alle Browser-Zugriffe, z. B. ein Ausgang in der EU: http(s)://[user:pass@]host:port oder socks5://host:port (Env CPCG_PROXY, nie aus .env). Das gemessene IP-Land steht im Report").option("--timeout-ms <ms>", "Timeout je Szenario-Navigation und f\xFCr den Erreichbarkeits-Check in ms, positive ganze Zahl (default: 30000)").option("--strict [boolean]", "Hinweise (rein funktionale Drittanbieter wie Google Fonts) blockieren das Gate ebenfalls (default: false)").option("--ignore <liste>", "Befunde ignorieren: Tracker-Name oder Host-Muster, kommagetrennt oder mehrfach (z. B. fonts.googleapis.com,*.hotjar.com); im Report als \xABignoriert\xBB ausgewiesen; `*`/`**` und nackte TLDs (com, ch) werden immer abgelehnt (zum Abschalten der Blockierung --fail-on-leak false), ganze Zonen (*.com) ohne --allow-broad-ignore", collect, []).option("--allow-broad-ignore [boolean]", "Ganze Zonen als --ignore-Muster (*.com, *.co.uk, .ch) bewusst zulassen; sie werden in Konsole und Report als Warnung ausgewiesen; `*` und nackte TLDs bleiben abgelehnt (default: false)").option("--accept-selector <css>", "Eigener CSS-Selektor des Akzeptieren-Buttons (mehrfach oder kommagetrennt)", collect, []).option("--reject-selector <css>", "Eigener CSS-Selektor des Ablehnen-Buttons (mehrfach oder kommagetrennt)", collect, []).option("--settings-selector <css>", "Eigener CSS-Selektor des Einstellungen-Buttons (mehrfach oder kommagetrennt)", collect, []).option("--banner-frame <teilstring>", "Teilstring der URL des Banner-iframes (CMP im Frame)").option("--max-subpages <n>", "Obergrenze der Unterseiten-Stichprobe (Szenario subpage-spa), ganze Zahl 1\u201340 (default: 12; Env CPCG_MAX_SUBPAGES). Bleibt die Stichprobe unvollst\xE4ndig, weist das Gate das aus (Exit-Code unver\xE4ndert)").option("--sitemap [boolean]", "Sitemap-Tiefenlauf: Unterseiten aus robots.txt/sitemap.xml und den Links der Startseite pr\xFCfen, bis --deep-budget verbraucht ist (statt --max-subpages; Env CPCG_SITEMAP)").option("--deep-budget <sekunden>", "Zeitbudget des Sitemap-Tiefenlaufs f\xFCr die Unterseiten, 30\u20133600 (default: 300; Env CPCG_DEEP_BUDGET)").option("--deep-state <pfad>", "Zustandsdatei des Tiefenlaufs: der n\xE4chste Lauf setzt bei den noch nicht gepr\xFCften Unterseiten fort (Env CPCG_DEEP_STATE)").option("--baseline <pfad>", "Report (JSON) eines fr\xFCheren Laufs: der Bericht nennt neue, weggefallene und gleich gebliebene Befunde (Env CPCG_BASELINE)").option("--har [boolean]", "HAR-Mitschnitt je Browser-Kontext ohne Inhalte nach evidence/har neben dem Report (Env CPCG_HAR); enth\xE4lt Adressen und Header der Zielseite").option("--verify-url <url>", "Geschlossener Kreis: hat die Ziel-URL Befunde, zus\xE4tzlich diese URL pr\xFCfen (z. B. Vorschau des Fix-PRs); nur ein sauberer, vollst\xE4ndiger Scan dort heisst \xABFix verifiziert\xBB (Env CPCG_VERIFY_URL)").option("--verify-wait <sekunden>", "So lange auf die Erreichbarkeit der Verify-URL warten, 0\u20131800 (default: 0; Env CPCG_VERIFY_WAIT)").option("--target-header <name: wert>", "Freigabe-Header nur f\xFCr die gepr\xFCfte Website (mehrfach), z. B. f\xFCr eine WAF-Ausnahme oder Vercel \xABx-vercel-protection-bypass: \u2026\xBB; geht nie an Drittanbieter, Werte erscheinen in keinem Report. Im CI besser \xFCber Env CPCG_TARGET_HEADERS (eine Zeile je Header)", collect, []).option("--banner-wait <sekunden>", "Wartefenster auf einen (sp\xE4t erscheinenden) Banner in Sekunden, 1\u201360 (default: 8, bei Seiten ohne Banner-Hinweis fr\xFCher beendet; mit Angabe wird das Fenster ausgesch\xF6pft, auch bei --accept-selector/--reject-selector; Env CPCG_BANNER_WAIT)").option("--license <token>", "Cuonztech CPCG Lizenzcode CPCG-\u2026 oder Kunden-Key CPCG-K-\u2026 (oder Env CPCG_LICENSE) \u2014 nach Online-Kauf per E-Mail").option(
53
53
  "--jurisdiction <code>",
54
54
  "Rechtsr\xE4ume, komma-getrennt: CH | EU | UK | US-CA | BR | ROW (default: CH,EU). Der strengste Befund je Rechtsraum gewinnt; der Report f\xFChrt alle auf."
55
55
  ).option("--report-pdf [boolean]", "Deluxe-PDF (Deckblatt + Evidence) nach dem Scan erzeugen \u2014 Lizenz erforderlich").option("--client <name>", "Kundenname f\xFCr Kundenreport und PDF-Deckblatt \u2014 Lizenz erforderlich (PDF-default: Host der Ziel-URL)").option("--demo [boolean]", "Demo-Lauf \u2014 Report wird als synthetische Testdaten gekennzeichnet").addHelpText("after", EXIT_CODES_HELP).allowExcessArguments(false).showHelpAfterError("(cpcg --help zeigt alle Optionen)").exitOverride().action(async (options) => {
package/dist/index.d.ts CHANGED
@@ -812,6 +812,29 @@ declare const LeakReportSchema: z.ZodObject<{
812
812
  browserVersion: z.ZodOptional<z.ZodString>;
813
813
  /** User-Agent, mit dem sich die Scan-Kontexte gemeldet haben (Chrome-Kennzeichen ohne «Headless»). */
814
814
  browserUserAgent: z.ZodOptional<z.ZodString>;
815
+ /** Besucherprofil des Laufs: Sprache, Zeitzone, Proxy (ohne Zugangsdaten) und gemessenes IP-Land. */
816
+ visitor: z.ZodOptional<z.ZodObject<{
817
+ profile: z.ZodEnum<["ch", "eu"]>;
818
+ locale: z.ZodString;
819
+ timezoneId: z.ZodString;
820
+ proxy: z.ZodOptional<z.ZodString>;
821
+ ipCountry: z.ZodOptional<z.ZodString>;
822
+ ipCountryMatches: z.ZodOptional<z.ZodBoolean>;
823
+ }, "strip", z.ZodTypeAny, {
824
+ profile: "ch" | "eu";
825
+ locale: string;
826
+ timezoneId: string;
827
+ proxy?: string | undefined;
828
+ ipCountry?: string | undefined;
829
+ ipCountryMatches?: boolean | undefined;
830
+ }, {
831
+ profile: "ch" | "eu";
832
+ locale: string;
833
+ timezoneId: string;
834
+ proxy?: string | undefined;
835
+ ipCountry?: string | undefined;
836
+ ipCountryMatches?: boolean | undefined;
837
+ }>>;
815
838
  /** `--har`: in diesem Lauf geschriebene HAR-Dateien, relativ zum Report-Ordner (eigener Unterordner je Lauf). */
816
839
  harFiles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
817
840
  /** Herkunft des Laufs: Version, Scan-Konfiguration ohne Geheimnisse und deren SHA-256 (`provenance.ts`). */
@@ -1135,6 +1158,14 @@ declare const LeakReportSchema: z.ZodObject<{
1135
1158
  passedScenarios: ("happy-path-denied" | "happy-path-accepted" | "fast-click" | "state-manipulation" | "network-drop" | "consent-revoked" | "category-selective" | "consent-persistence" | "banner-ignored" | "subpage-spa" | "cmp-failure" | "embed-leaks" | "consent-mode-v2" | "duplicate-events" | "mobile-usability" | "gpc-signal")[];
1136
1159
  failedScenarios: ("happy-path-denied" | "happy-path-accepted" | "fast-click" | "state-manipulation" | "network-drop" | "consent-revoked" | "category-selective" | "consent-persistence" | "banner-ignored" | "subpage-spa" | "cmp-failure" | "embed-leaks" | "consent-mode-v2" | "duplicate-events" | "mobile-usability" | "gpc-signal")[];
1137
1160
  summary: string;
1161
+ visitor?: {
1162
+ profile: "ch" | "eu";
1163
+ locale: string;
1164
+ timezoneId: string;
1165
+ proxy?: string | undefined;
1166
+ ipCountry?: string | undefined;
1167
+ ipCountryMatches?: boolean | undefined;
1168
+ } | undefined;
1138
1169
  evidence?: {
1139
1170
  targetUrl: string;
1140
1171
  status: "passed" | "suspicious" | "not-checkable" | "not-applicable";
@@ -1307,6 +1338,14 @@ declare const LeakReportSchema: z.ZodObject<{
1307
1338
  passedScenarios: ("happy-path-denied" | "happy-path-accepted" | "fast-click" | "state-manipulation" | "network-drop" | "consent-revoked" | "category-selective" | "consent-persistence" | "banner-ignored" | "subpage-spa" | "cmp-failure" | "embed-leaks" | "consent-mode-v2" | "duplicate-events" | "mobile-usability" | "gpc-signal")[];
1308
1339
  failedScenarios: ("happy-path-denied" | "happy-path-accepted" | "fast-click" | "state-manipulation" | "network-drop" | "consent-revoked" | "category-selective" | "consent-persistence" | "banner-ignored" | "subpage-spa" | "cmp-failure" | "embed-leaks" | "consent-mode-v2" | "duplicate-events" | "mobile-usability" | "gpc-signal")[];
1309
1340
  summary: string;
1341
+ visitor?: {
1342
+ profile: "ch" | "eu";
1343
+ locale: string;
1344
+ timezoneId: string;
1345
+ proxy?: string | undefined;
1346
+ ipCountry?: string | undefined;
1347
+ ipCountryMatches?: boolean | undefined;
1348
+ } | undefined;
1310
1349
  evidence?: {
1311
1350
  targetUrl: string;
1312
1351
  status: "passed" | "suspicious" | "not-checkable" | "not-applicable";
@@ -1933,6 +1972,13 @@ declare const GateConfigSchema: z.ZodObject<{
1933
1972
  * bisherige Verhalten (8 s, bei Seiten ohne Banner-Hinweis früher beendet); mit Angabe wird das Fenster ausgeschöpft.
1934
1973
  */
1935
1974
  bannerWaitSeconds: z.ZodOptional<z.ZodNumber>;
1975
+ /**
1976
+ * Besucherprofil (`--visitor`): feste Sprache und Zeitzone des Browsers (ch: de-CH/Zürich, eu: de-DE/Berlin), damit
1977
+ * der Lauf nicht von der Maschine abhängt. Das Land der IP bestimmt nur `proxy`.
1978
+ */
1979
+ visitor: z.ZodDefault<z.ZodEnum<["ch", "eu"]>>;
1980
+ /** Proxy für alle Browser-Zugriffe (`--proxy`, Env `CPCG_PROXY`), z. B. ein Ausgang in der EU. Enthält ggf. Zugangsdaten: nie ausgeben. */
1981
+ proxy: z.ZodOptional<z.ZodString>;
1936
1982
  /** Hinweise zur Eingabe (z. B. leerer Selektor), die der Scanner in `scannerWarnings` übernimmt. */
1937
1983
  configWarnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1938
1984
  /** Scanner-Overrides für eigene Banner (CSS-Selektoren bzw. Teilstring der Banner-Frame-URL). */
@@ -1988,6 +2034,7 @@ declare const GateConfigSchema: z.ZodObject<{
1988
2034
  deepBudgetSeconds: number;
1989
2035
  verifyWaitSeconds: number;
1990
2036
  har: boolean;
2037
+ visitor: "ch" | "eu";
1991
2038
  apiKey?: string | undefined;
1992
2039
  githubToken?: string | undefined;
1993
2040
  baseBranch?: string | undefined;
@@ -2002,6 +2049,7 @@ declare const GateConfigSchema: z.ZodObject<{
2002
2049
  recheckPaths?: string[] | undefined;
2003
2050
  extraFirstPartyHosts?: string[] | undefined;
2004
2051
  bannerWaitSeconds?: number | undefined;
2052
+ proxy?: string | undefined;
2005
2053
  configWarnings?: string[] | undefined;
2006
2054
  acceptSelectors?: string[] | undefined;
2007
2055
  rejectSelectors?: string[] | undefined;
@@ -2051,6 +2099,8 @@ declare const GateConfigSchema: z.ZodObject<{
2051
2099
  extraFirstPartyHosts?: string[] | undefined;
2052
2100
  har?: boolean | undefined;
2053
2101
  bannerWaitSeconds?: number | undefined;
2102
+ visitor?: "ch" | "eu" | undefined;
2103
+ proxy?: string | undefined;
2054
2104
  configWarnings?: string[] | undefined;
2055
2105
  acceptSelectors?: string[] | undefined;
2056
2106
  rejectSelectors?: string[] | undefined;
@@ -2245,6 +2295,10 @@ interface CliRawOptions {
2245
2295
  deepBudget?: string | number;
2246
2296
  /** Zustandsdatei der Wiederaufnahme */
2247
2297
  deepState?: string;
2298
+ /** Besucherprofil (ch, eu) */
2299
+ visitor?: string;
2300
+ /** Proxy-URL für alle Browser-Zugriffe (kann Zugangsdaten enthalten) */
2301
+ proxy?: string;
2248
2302
  /** Vorlauf-Report für den Vergleich */
2249
2303
  baseline?: string;
2250
2304
  /** HAR-Mitschnitt */
@@ -2313,6 +2367,8 @@ interface ChaosScannerOptions extends ScannerOverrides {
2313
2367
  sitemapFetcher?: SitemapFetcher;
2314
2368
  /** Fortschritt: wird beim Start jedes Szenarios (und der Schlussprüfung) gerufen; die CLI zeigt daraus eine Zeile. */
2315
2369
  onProgress?: (event: ScanProgress) => void;
2370
+ /** Adresse für die Messung des IP-Lands (Standard `IP_COUNTRY_URL`); Tests geben einen lokalen Dienst mit. */
2371
+ ipCountryUrl?: string;
2316
2372
  }
2317
2373
  /** Fortschritt des Scans: gestartetes Szenario, laufende Nummer, Gesamtzahl, Zeit seit Scanbeginn. */
2318
2374
  interface ScanProgress {
@@ -2334,6 +2390,10 @@ declare class ChaosScanner implements ChaosScannerInterface {
2334
2390
  private frameQueryTimeouts;
2335
2391
  /** User-Agent der Scan-Kontexte (für den Report). */
2336
2392
  private userAgent?;
2393
+ /** Besucherprofil des laufenden Scans (Sprache, Zeitzone) und was davon im Bericht steht. */
2394
+ private visitorProfile;
2395
+ private visitorInfo?;
2396
+ private readonly ipCountryUrl;
2337
2397
  /**
2338
2398
  * Abgebrochene Schritte, die auch nach dem Schliessen ihrer Kontexte nicht endeten. `scan()` kehrt erst zurück, wenn
2339
2399
  * sie nach dem Schliessen des Browsers ausgelaufen sind: sonst könnten sie in einen späteren Lauf derselben Instanz
@@ -2437,6 +2497,11 @@ declare class ChaosScanner implements ChaosScannerInterface {
2437
2497
  private markTimeLimit;
2438
2498
  /** Frame-Abfragen ohne Antwort: Warnung; ohne gesehenen Banner ist «kein Banner» damit nicht belegt. */
2439
2499
  private noteFrameQueryTimeouts;
2500
+ /**
2501
+ * Land der IP, über die der Browser ins Netz geht (über den Proxy, falls gesetzt). Passt es nicht zum Profil, sieht
2502
+ * die Seite einen Besucher aus diesem Land, nicht aus dem Profil: deutliche Warnung, das Ergebnis bleibt gültig.
2503
+ */
2504
+ private measureIpCountry;
2440
2505
  private newContext;
2441
2506
  /**
2442
2507
  * Steht ein Banner-Bedienelement schon im Dokument, wenn kein Skript der Seite läuft? Dann ist das Banner eingebettet
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ import {
57
57
  uncheckableReasons,
58
58
  uncheckableReasonsForReport,
59
59
  waitForVerifyUrl
60
- } from "./chunk-PDBLZE7N.js";
60
+ } from "./chunk-RXTWCLK5.js";
61
61
 
62
62
  // src/index.ts
63
63
  async function runGate(optionsOrConfig) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cuonztech-privacy-chaos-gate",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "CuonzTech Privacy Chaos Gate — CI/CD Consent-Scanner, Chaos-Szenarien und Auto-Fix-PR",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",