cuonztech-privacy-chaos-gate 0.3.11 → 0.3.12

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/action.yml CHANGED
@@ -1,344 +1,344 @@
1
- name: "Cuonztech Privacy Chaos Gate"
2
- description: "CI gate that stress-tests cookie consent banners, judges findings per jurisdiction and proposes fixes (PR for OneTrust/Cookiebot)"
3
- author: "Cuonztech"
4
- branding:
5
- icon: "shield"
6
- color: "purple"
7
-
8
- inputs:
9
- staging-url:
10
- description: "The URL of the staging or localhost web environment to stress-test"
11
- required: true
12
- api-key:
13
- description: "API key for the optional LLM patch generation. Only OpenAI is implemented (llm-provider openai); other providers fall back to the built-in rules. Has no effect without llm-remediation: true. Passed via the CPCG_LLM_API_KEY environment variable."
14
- required: false
15
- default: ""
16
- llm-remediation:
17
- description: "Opt-in: allow the source code to be sent to the LLM provider (OpenAI only) to generate patches (needs api-key). Off by default; only passed on if the installed CLI supports it."
18
- required: false
19
- default: "false"
20
- allow-custom-banner-fix:
21
- description: "Opt-in: the auto-fix may change scripts even when the site uses its own banner (no supported CMP). Off by default: then only manual steps are reported. Only passed on if the installed CLI supports it."
22
- required: false
23
- default: "false"
24
- llm-provider:
25
- description: "LLM provider for auto-remediation. Only 'openai' is implemented; 'anthropic' and 'gemini' fall back to the built-in rules."
26
- required: false
27
- default: "openai"
28
- llm-model:
29
- description: "Model to use for auto-remediation"
30
- required: false
31
- default: "gpt-4o"
32
- auto-fix:
33
- description: "Generate and apply code patches on the runner when tracker leaks are detected. Off by default: a gate should not silently change files; combine with create-pr to receive the fix as a pull request."
34
- required: false
35
- default: "false"
36
- fail-on-leak:
37
- description: "Block the build (exit code 1) if unpatched critical leaks remain"
38
- required: false
39
- default: "true"
40
- fail-on-uncheckable:
41
- description: "Block the build (exit code 4) if core scenarios could not be checked conclusively (e.g. consent banner not found). Only passed on if the installed CLI supports it; otherwise a warning is printed."
42
- required: false
43
- default: "true"
44
- strict:
45
- description: "Hints (purely functional third parties such as Google Fonts) also block the gate. Off by default: they are reported as hints, not as blockers. Only passed on if the installed CLI supports it."
46
- required: false
47
- default: "false"
48
- ignore:
49
- description: "Findings to ignore: tracker name or host pattern, one per line or comma-separated (e.g. fonts.googleapis.com or *.hotjar.com). Ignored findings are listed as ignored in the report."
50
- required: false
51
- default: ""
52
- accept-selector:
53
- description: "Own CSS selector of the accept button, one per line (when the built-in CMP detection does not find it)"
54
- required: false
55
- default: ""
56
- reject-selector:
57
- description: "Own CSS selector of the reject button, one per line"
58
- required: false
59
- default: ""
60
- settings-selector:
61
- description: "Own CSS selector of the settings button, one per line"
62
- required: false
63
- default: ""
64
- banner-frame:
65
- description: "Part of the URL of the iframe that contains the consent banner (CMP inside a frame)"
66
- required: false
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: ""
76
- max-subpages:
77
- description: "Maximum number of linked subpages checked for trackers (default 12, max 40; larger values take longer)"
78
- required: false
79
- default: ""
80
- sitemap:
81
- description: "Deep run: check subpages from robots.txt/sitemap.xml and homepage links until deep-budget is used up (true/false)"
82
- required: false
83
- default: "false"
84
- deep-budget:
85
- description: "Time budget of the sitemap deep run for subpages in seconds (30-3600, default 300)"
86
- required: false
87
- default: ""
88
- deep-state:
89
- description: "State file of the deep run; the next run continues with unchecked subpages (persist it with actions/cache)"
90
- required: false
91
- default: ""
92
- baseline-report:
93
- description: "Report JSON of an earlier run; the report lists new, resolved and unchanged findings (restore it e.g. with actions/cache or download-artifact)"
94
- required: false
95
- default: ""
96
- har:
97
- description: "Record a HAR file per browser context without bodies into evidence/har next to the report (true/false)"
98
- required: false
99
- default: "false"
100
- verify-url:
101
- description: "Closed loop: if the target URL has findings, also scan this URL (e.g. the preview deployment of the fix PR); only a clean, complete scan there counts as 'fix verified'"
102
- required: false
103
- default: ""
104
- verify-wait:
105
- description: "Seconds to wait until verify-url is reachable (0-1800, default 0)"
106
- required: false
107
- default: ""
108
- target-headers:
109
- description: "Allowlist headers for your own site only, one 'Name: value' per line (e.g. WAF bypass or 'x-vercel-protection-bypass: ...'). Pass from secrets; sent only to the target/verify origin, never to third parties, never printed. Passed via the CPCG_TARGET_HEADERS environment variable."
110
- required: false
111
- default: ""
112
- banner-wait:
113
- description: "Seconds to wait for a late consent banner (1-60; default as in the CLI)"
114
- required: false
115
- default: ""
116
- report-output:
117
- description: "File path where the JSON LeakReport will be written"
118
- required: false
119
- default: "reports/privacy-chaos-report.json"
120
- target-source-dir:
121
- description: "Root directory of the application source code to inspect and patch"
122
- required: false
123
- default: "."
124
- git-commit:
125
- description: "Commit generated privacy fixes into the checked-out branch (requires auto-fix and a valid license; skipped without one)"
126
- required: false
127
- default: "false"
128
- create-pr:
129
- description: "Create a fix branch and open a GitHub Pull Request with the generated fix (requires auto-fix, github-token and a valid license; takes precedence over git-commit)"
130
- required: false
131
- default: "false"
132
- github-token:
133
- description: "GitHub token for create-pr (contents: write and pull-requests: write). Passed via the GITHUB_TOKEN environment variable, never on the command line."
134
- required: false
135
- default: ""
136
- license:
137
- description: "CuonzTech CPCG license (CPCG-… or customer key CPCG-K-…) — from secrets, after online purchase. Without a valid license the scan and gate still run with a real exit code, but the output is limited to numbers (no tracker names, reports, PDF, auto-fix, commit or PR). Passed via the CPCG_LICENSE environment variable."
138
- required: false
139
- default: ""
140
- report-pdf:
141
- description: "Create the customer report PDF (summary, tailored fix guide, technical evidence) after the scan. Requires a valid license; skipped without one."
142
- required: false
143
- default: "false"
144
- client-name:
145
- description: "Client name for the customer report and the PDF cover page. Requires a valid license."
146
- required: false
147
- default: ""
148
- jurisdiction:
149
- description: "Jurisdictions whose rules decide what blocks the gate, comma-separated: CH | CH-SENSIBEL | EU | UK | US-CA | BR | ROW (strictest wins; default CH,EU as in the CLI; CH-SENSIBEL = opt-in profile for sites with health, religion, politics or children data, only when chosen)"
150
- required: false
151
- default: "CH,EU"
152
-
153
- outputs:
154
- leaks-found:
155
- description: "'true' if leaks were detected during chaos tests"
156
- value: ${{ steps.cpcg-run.outputs.leaks_found }}
157
- leaks-count:
158
- description: "Number of tracker leaks detected"
159
- value: ${{ steps.cpcg-run.outputs.leaks_count }}
160
- patch-applied:
161
- description: "'true' if an auto-remediation patch was successfully applied"
162
- value: ${{ steps.cpcg-run.outputs.patch_applied }}
163
- report-path:
164
- description: "Absolute or relative path to the generated JSON report"
165
- value: ${{ steps.cpcg-run.outputs.report_path }}
166
- gate_state:
167
- description: "Gate result as written by the CLI: clean, remediated (fix verified by re-scan), fix-proposed, blocked, inconclusive. Empty if the installed CLI predates this output."
168
- value: ${{ steps.cpcg-run.outputs.gate_state }}
169
- incomplete:
170
- description: "'true' if core scenarios could not be checked conclusively"
171
- value: ${{ steps.cpcg-run.outputs.incomplete }}
172
- uncheckable_count:
173
- description: "Number of scenarios that could not be checked"
174
- value: ${{ steps.cpcg-run.outputs.uncheckable_count }}
175
- leak_requests:
176
- description: "Number of blocking tracker requests/cookies (before consent, after reject/revoke and the other blocking phases)"
177
- value: ${{ steps.cpcg-run.outputs.leak_requests }}
178
- verified:
179
- description: "true if a re-scan (verify-url or target URL after a local fix) was clean and complete, false if not, empty if no re-scan ran"
180
- value: ${{ steps.cpcg-run.outputs.verified }}
181
- exit_code:
182
- description: "Exit code of the CLI (0 ok, 1 leaks, 3 error, 4 incomplete; 2 is not used, an invalid license limits the output instead)"
183
- value: ${{ steps.cpcg-run.outputs.exit_code }}
184
-
185
- runs:
186
- using: "composite"
187
- steps:
188
- - name: Setup Node.js
189
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
190
- with:
191
- node-version: "24"
192
-
193
- # Installationsschritt: bewusst ohne Secrets (Lizenz, Token, API-Key) in der Umgebung. Nur hier läuft npm.
194
- - name: Install Privacy Chaos Gate
195
- id: cpcg-install
196
- shell: bash
197
- env:
198
- ACTION_PATH: ${{ github.action_path }}
199
- CPCG_PINNED_VERSION: "0.3.11" # = package.json version; bei jedem Release mit anheben (tests/action-pin.test.ts prüft das)
200
- run: |
201
- set -euo pipefail
202
-
203
- CLI_PATH="$ACTION_PATH/dist/cli.js"
204
- if [ -f "$CLI_PATH" ]; then
205
- # Eigener Build im Action-Pfad (Repo-CI): Abhängigkeiten und Browser bringt der Workflow mit.
206
- echo "cli=$CLI_PATH" >> "$GITHUB_OUTPUT"
207
- exit 0
208
- fi
209
-
210
- # Veröffentlichtes Paket in der gepinnten Version. Lifecycle-Skripte der Abhängigkeiten laufen nicht
211
- # (--ignore-scripts); der Playwright-Browser wird unten ausdrücklich installiert.
212
- TOOL_DIR="$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/cpcg-XXXXXX")"
213
- npm install --prefix "$TOOL_DIR" --ignore-scripts --no-audit --no-fund --loglevel=error "cuonztech-privacy-chaos-gate@${CPCG_PINNED_VERSION}"
214
- PW_CLI="$TOOL_DIR/node_modules/playwright/cli.js"
215
- if [ -f "$PW_CLI" ]; then
216
- node "$PW_CLI" install --with-deps chromium
217
- else
218
- npx --yes playwright install --with-deps chromium
219
- fi
220
- echo "cli=$TOOL_DIR/node_modules/cuonztech-privacy-chaos-gate/dist/cli.js" >> "$GITHUB_OUTPUT"
221
-
222
- - name: Run Privacy Chaos Gate
223
- id: cpcg-run
224
- shell: bash
225
- # Alle Inputs gelangen nur über env in das Skript (keine ${{ }}-Interpolation im run-Block:
226
- # sonst könnten Input-Werte als Shell-Code ausgeführt werden). Die Lizenz steht nie in der Kommandozeile.
227
- env:
228
- CPCG_CLI: ${{ steps.cpcg-install.outputs.cli }}
229
- CPCG_LLM_API_KEY: ${{ inputs.api-key }}
230
- CPCG_LLM_PROVIDER: ${{ inputs.llm-provider }}
231
- CPCG_LLM_MODEL: ${{ inputs.llm-model }}
232
- CPCG_LICENSE: ${{ inputs.license }}
233
- CPCG_TARGET_HEADERS: ${{ inputs.target-headers }}
234
- CPCG_PROXY: ${{ inputs.proxy }}
235
- GITHUB_TOKEN: ${{ inputs.github-token }}
236
- IN_STAGING_URL: ${{ inputs.staging-url }}
237
- IN_LLM_REMEDIATION: ${{ inputs.llm-remediation }}
238
- IN_ALLOW_CUSTOM_BANNER_FIX: ${{ inputs.allow-custom-banner-fix }}
239
- IN_AUTO_FIX: ${{ inputs.auto-fix }}
240
- IN_FAIL_ON_LEAK: ${{ inputs.fail-on-leak }}
241
- IN_FAIL_ON_UNCHECKABLE: ${{ inputs.fail-on-uncheckable }}
242
- IN_STRICT: ${{ inputs.strict }}
243
- IN_IGNORE: ${{ inputs.ignore }}
244
- IN_ACCEPT_SELECTOR: ${{ inputs.accept-selector }}
245
- IN_REJECT_SELECTOR: ${{ inputs.reject-selector }}
246
- IN_SETTINGS_SELECTOR: ${{ inputs.settings-selector }}
247
- IN_BANNER_FRAME: ${{ inputs.banner-frame }}
248
- IN_MAX_SUBPAGES: ${{ inputs.max-subpages }}
249
- IN_VISITOR: ${{ inputs.visitor }}
250
- IN_BANNER_WAIT: ${{ inputs.banner-wait }}
251
- IN_SITEMAP: ${{ inputs.sitemap }}
252
- IN_DEEP_BUDGET: ${{ inputs.deep-budget }}
253
- IN_DEEP_STATE: ${{ inputs.deep-state }}
254
- IN_BASELINE: ${{ inputs.baseline-report }}
255
- IN_HAR: ${{ inputs.har }}
256
- IN_VERIFY_URL: ${{ inputs.verify-url }}
257
- IN_VERIFY_WAIT: ${{ inputs.verify-wait }}
258
- IN_REPORT_OUTPUT: ${{ inputs.report-output }}
259
- IN_SOURCE_DIR: ${{ inputs.target-source-dir }}
260
- IN_GIT_COMMIT: ${{ inputs.git-commit }}
261
- IN_CREATE_PR: ${{ inputs.create-pr }}
262
- IN_REPORT_PDF: ${{ inputs.report-pdf }}
263
- IN_CLIENT: ${{ inputs.client-name }}
264
- IN_JURISDICTION: ${{ inputs.jurisdiction }}
265
- run: |
266
- set -euo pipefail
267
-
268
- # Freigabe-Header-Werte im Log maskieren (auch wenn sie nicht aus secrets stammen).
269
- while IFS= read -r line; do
270
- value="${line#*:}"
271
- value="${value#"${value%%[![:space:]]*}"}"
272
- if [ -n "$value" ] && [ "$value" != "$line" ]; then echo "::add-mask::$value"; fi
273
- done <<< "${CPCG_TARGET_HEADERS:-}"
274
-
275
- RUNNER=(node "$CPCG_CLI")
276
-
277
- # Optionen immer als --name=wert: ein Wert, der mit "-" beginnt, wird so nie als eigene Option gelesen.
278
- ARGS=(
279
- "--url=$IN_STAGING_URL"
280
- "--auto-fix=$IN_AUTO_FIX"
281
- "--fail-on-leak=$IN_FAIL_ON_LEAK"
282
- "--report-output=$IN_REPORT_OUTPUT"
283
- "--source-dir=$IN_SOURCE_DIR"
284
- "--git-commit=$IN_GIT_COMMIT"
285
- "--create-pr=$IN_CREATE_PR"
286
- "--report-pdf=$IN_REPORT_PDF"
287
- "--jurisdiction=$IN_JURISDICTION"
288
- )
289
- if [ -n "$IN_CLIENT" ]; then
290
- ARGS+=("--client=$IN_CLIENT")
291
- fi
292
-
293
- # Neuere Optionen nur weitergeben, wenn die installierte CLI sie kennt (ältere Versionen würden sonst mit
294
- # "unknown option" abbrechen). Kennt sie eine gewünschte Option nicht, wird das gemeldet, nicht still übergangen.
295
- HELP="$("${RUNNER[@]}" --help 2>&1 || true)"
296
- supports() { printf '%s\n' "$HELP" | grep -q -- "$1"; }
297
- warn_unsupported() {
298
- echo "::warning title=CPCG::Die installierte CLI kennt --$1 nicht; der Input wird ignoriert. Paket- und Action-Version angleichen."
299
- }
300
- # Boolesche Option: übergeben, wenn bekannt; unbekannt und angefordert ("true") → Warnung.
301
- opt_bool() {
302
- if supports "--$1"; then
303
- ARGS+=("--$1=$2")
304
- elif [ "$2" = "true" ]; then
305
- warn_unsupported "$1"
306
- fi
307
- return 0
308
- }
309
- # Wert-Option (mehrzeilig erlaubt: je nichtleere Zeile eine Option): nur wenn gesetzt.
310
- opt_lines() {
311
- local flag="$1" value="$2" line
312
- [ -n "${value//[[:space:]]/}" ] || return 0
313
- if ! supports "--$flag"; then
314
- warn_unsupported "$flag"
315
- return 0
316
- fi
317
- while IFS= read -r line; do
318
- line="${line#"${line%%[![:space:]]*}"}"
319
- line="${line%"${line##*[![:space:]]}"}"
320
- if [ -n "$line" ]; then ARGS+=("--$flag=$line"); fi
321
- done <<< "$value"
322
- return 0
323
- }
324
- opt_bool fail-on-uncheckable "$IN_FAIL_ON_UNCHECKABLE"
325
- opt_bool llm-remediation "$IN_LLM_REMEDIATION"
326
- opt_bool allow-custom-banner-fix "$IN_ALLOW_CUSTOM_BANNER_FIX"
327
- opt_bool strict "$IN_STRICT"
328
- opt_lines ignore "$IN_IGNORE"
329
- opt_lines accept-selector "$IN_ACCEPT_SELECTOR"
330
- opt_lines reject-selector "$IN_REJECT_SELECTOR"
331
- opt_lines settings-selector "$IN_SETTINGS_SELECTOR"
332
- opt_lines banner-frame "$IN_BANNER_FRAME"
333
- opt_lines max-subpages "$IN_MAX_SUBPAGES"
334
- opt_lines visitor "${IN_VISITOR:-}"
335
- opt_lines banner-wait "$IN_BANNER_WAIT"
336
- opt_bool sitemap "${IN_SITEMAP:-false}"
337
- opt_lines deep-budget "${IN_DEEP_BUDGET:-}"
338
- opt_lines deep-state "${IN_DEEP_STATE:-}"
339
- opt_lines baseline "${IN_BASELINE:-}"
340
- opt_bool har "${IN_HAR:-false}"
341
- opt_lines verify-url "${IN_VERIFY_URL:-}"
342
- opt_lines verify-wait "${IN_VERIFY_WAIT:-}"
343
-
344
- "${RUNNER[@]}" "${ARGS[@]}"
1
+ name: "Cuonztech Privacy Chaos Gate"
2
+ description: "CI gate that stress-tests cookie consent banners, judges findings per jurisdiction and proposes fixes (PR for OneTrust/Cookiebot)"
3
+ author: "Cuonztech"
4
+ branding:
5
+ icon: "shield"
6
+ color: "purple"
7
+
8
+ inputs:
9
+ staging-url:
10
+ description: "The URL of the staging or localhost web environment to stress-test"
11
+ required: true
12
+ api-key:
13
+ description: "API key for the optional LLM patch generation. Only OpenAI is implemented (llm-provider openai); other providers fall back to the built-in rules. Has no effect without llm-remediation: true. Passed via the CPCG_LLM_API_KEY environment variable."
14
+ required: false
15
+ default: ""
16
+ llm-remediation:
17
+ description: "Opt-in: allow the source code to be sent to the LLM provider (OpenAI only) to generate patches (needs api-key). Off by default; only passed on if the installed CLI supports it."
18
+ required: false
19
+ default: "false"
20
+ allow-custom-banner-fix:
21
+ description: "Opt-in: the auto-fix may change scripts even when the site uses its own banner (no supported CMP). Off by default: then only manual steps are reported. Only passed on if the installed CLI supports it."
22
+ required: false
23
+ default: "false"
24
+ llm-provider:
25
+ description: "LLM provider for auto-remediation. Only 'openai' is implemented; 'anthropic' and 'gemini' fall back to the built-in rules."
26
+ required: false
27
+ default: "openai"
28
+ llm-model:
29
+ description: "Model to use for auto-remediation"
30
+ required: false
31
+ default: "gpt-4o"
32
+ auto-fix:
33
+ description: "Generate and apply code patches on the runner when tracker leaks are detected. Off by default: a gate should not silently change files; combine with create-pr to receive the fix as a pull request."
34
+ required: false
35
+ default: "false"
36
+ fail-on-leak:
37
+ description: "Block the build (exit code 1) if unpatched critical leaks remain"
38
+ required: false
39
+ default: "true"
40
+ fail-on-uncheckable:
41
+ description: "Block the build (exit code 4) if core scenarios could not be checked conclusively (e.g. consent banner not found). Only passed on if the installed CLI supports it; otherwise a warning is printed."
42
+ required: false
43
+ default: "true"
44
+ strict:
45
+ description: "Hints (purely functional third parties such as Google Fonts) also block the gate. Off by default: they are reported as hints, not as blockers. Only passed on if the installed CLI supports it."
46
+ required: false
47
+ default: "false"
48
+ ignore:
49
+ description: "Findings to ignore: tracker name or host pattern, one per line or comma-separated (e.g. fonts.googleapis.com or *.hotjar.com). Ignored findings are listed as ignored in the report."
50
+ required: false
51
+ default: ""
52
+ accept-selector:
53
+ description: "Own CSS selector of the accept button, one per line (when the built-in CMP detection does not find it)"
54
+ required: false
55
+ default: ""
56
+ reject-selector:
57
+ description: "Own CSS selector of the reject button, one per line"
58
+ required: false
59
+ default: ""
60
+ settings-selector:
61
+ description: "Own CSS selector of the settings button, one per line"
62
+ required: false
63
+ default: ""
64
+ banner-frame:
65
+ description: "Part of the URL of the iframe that contains the consent banner (CMP inside a frame)"
66
+ required: false
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: ""
76
+ max-subpages:
77
+ description: "Maximum number of linked subpages checked for trackers (default 12, max 40; larger values take longer)"
78
+ required: false
79
+ default: ""
80
+ sitemap:
81
+ description: "Deep run: check subpages from robots.txt/sitemap.xml and homepage links until deep-budget is used up (true/false)"
82
+ required: false
83
+ default: "false"
84
+ deep-budget:
85
+ description: "Time budget of the sitemap deep run for subpages in seconds (30-3600, default 300)"
86
+ required: false
87
+ default: ""
88
+ deep-state:
89
+ description: "State file of the deep run; the next run continues with unchecked subpages (persist it with actions/cache)"
90
+ required: false
91
+ default: ""
92
+ baseline-report:
93
+ description: "Report JSON of an earlier run; the report lists new, resolved and unchanged findings (restore it e.g. with actions/cache or download-artifact)"
94
+ required: false
95
+ default: ""
96
+ har:
97
+ description: "Record a HAR file per browser context without bodies into evidence/har next to the report (true/false)"
98
+ required: false
99
+ default: "false"
100
+ verify-url:
101
+ description: "Closed loop: if the target URL has findings, also scan this URL (e.g. the preview deployment of the fix PR); only a clean, complete scan there counts as 'fix verified'"
102
+ required: false
103
+ default: ""
104
+ verify-wait:
105
+ description: "Seconds to wait until verify-url is reachable (0-1800, default 0)"
106
+ required: false
107
+ default: ""
108
+ target-headers:
109
+ description: "Allowlist headers for your own site only, one 'Name: value' per line (e.g. WAF bypass or 'x-vercel-protection-bypass: ...'). Pass from secrets; sent only to the target/verify origin, never to third parties, never printed. Passed via the CPCG_TARGET_HEADERS environment variable."
110
+ required: false
111
+ default: ""
112
+ banner-wait:
113
+ description: "Seconds to wait for a late consent banner (1-60; default as in the CLI)"
114
+ required: false
115
+ default: ""
116
+ report-output:
117
+ description: "File path where the JSON LeakReport will be written"
118
+ required: false
119
+ default: "reports/privacy-chaos-report.json"
120
+ target-source-dir:
121
+ description: "Root directory of the application source code to inspect and patch"
122
+ required: false
123
+ default: "."
124
+ git-commit:
125
+ description: "Commit generated privacy fixes into the checked-out branch (requires auto-fix and a valid license; skipped without one)"
126
+ required: false
127
+ default: "false"
128
+ create-pr:
129
+ description: "Create a fix branch and open a GitHub Pull Request with the generated fix (requires auto-fix, github-token and a valid license; takes precedence over git-commit)"
130
+ required: false
131
+ default: "false"
132
+ github-token:
133
+ description: "GitHub token for create-pr (contents: write and pull-requests: write). Passed via the GITHUB_TOKEN environment variable, never on the command line."
134
+ required: false
135
+ default: ""
136
+ license:
137
+ description: "CuonzTech CPCG license (CPCG-… or customer key CPCG-K-…) — from secrets, after online purchase. Without a valid license the scan and gate still run with a real exit code, but the output is limited to numbers (no tracker names, reports, PDF, auto-fix, commit or PR). Passed via the CPCG_LICENSE environment variable."
138
+ required: false
139
+ default: ""
140
+ report-pdf:
141
+ description: "Create the customer report PDF (summary, tailored fix guide, technical evidence) after the scan. Requires a valid license; skipped without one."
142
+ required: false
143
+ default: "false"
144
+ client-name:
145
+ description: "Client name for the customer report and the PDF cover page. Requires a valid license."
146
+ required: false
147
+ default: ""
148
+ jurisdiction:
149
+ description: "Jurisdictions whose rules decide what blocks the gate, comma-separated: CH | CH-SENSIBEL | EU | UK | US-CA | BR | ROW (strictest wins; default CH,EU as in the CLI; CH-SENSIBEL = opt-in profile for sites with health, religion, politics or children data, only when chosen)"
150
+ required: false
151
+ default: "CH,EU"
152
+
153
+ outputs:
154
+ leaks-found:
155
+ description: "'true' if leaks were detected during chaos tests"
156
+ value: ${{ steps.cpcg-run.outputs.leaks_found }}
157
+ leaks-count:
158
+ description: "Number of tracker leaks detected"
159
+ value: ${{ steps.cpcg-run.outputs.leaks_count }}
160
+ patch-applied:
161
+ description: "'true' if an auto-remediation patch was successfully applied"
162
+ value: ${{ steps.cpcg-run.outputs.patch_applied }}
163
+ report-path:
164
+ description: "Absolute or relative path to the generated JSON report"
165
+ value: ${{ steps.cpcg-run.outputs.report_path }}
166
+ gate_state:
167
+ description: "Gate result as written by the CLI: clean, remediated (fix verified by re-scan), fix-proposed, blocked, inconclusive. Empty if the installed CLI predates this output."
168
+ value: ${{ steps.cpcg-run.outputs.gate_state }}
169
+ incomplete:
170
+ description: "'true' if core scenarios could not be checked conclusively"
171
+ value: ${{ steps.cpcg-run.outputs.incomplete }}
172
+ uncheckable_count:
173
+ description: "Number of scenarios that could not be checked"
174
+ value: ${{ steps.cpcg-run.outputs.uncheckable_count }}
175
+ leak_requests:
176
+ description: "Number of blocking tracker requests/cookies (before consent, after reject/revoke and the other blocking phases)"
177
+ value: ${{ steps.cpcg-run.outputs.leak_requests }}
178
+ verified:
179
+ description: "true if a re-scan (verify-url or target URL after a local fix) was clean and complete, false if not, empty if no re-scan ran"
180
+ value: ${{ steps.cpcg-run.outputs.verified }}
181
+ exit_code:
182
+ description: "Exit code of the CLI (0 ok, 1 leaks, 3 error, 4 incomplete; 2 is not used, an invalid license limits the output instead)"
183
+ value: ${{ steps.cpcg-run.outputs.exit_code }}
184
+
185
+ runs:
186
+ using: "composite"
187
+ steps:
188
+ - name: Setup Node.js
189
+ uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
190
+ with:
191
+ node-version: "24"
192
+
193
+ # Installationsschritt: bewusst ohne Secrets (Lizenz, Token, API-Key) in der Umgebung. Nur hier läuft npm.
194
+ - name: Install Privacy Chaos Gate
195
+ id: cpcg-install
196
+ shell: bash
197
+ env:
198
+ ACTION_PATH: ${{ github.action_path }}
199
+ CPCG_PINNED_VERSION: "0.3.12" # = package.json version; bei jedem Release mit anheben (tests/action-pin.test.ts prüft das)
200
+ run: |
201
+ set -euo pipefail
202
+
203
+ CLI_PATH="$ACTION_PATH/dist/cli.js"
204
+ if [ -f "$CLI_PATH" ]; then
205
+ # Eigener Build im Action-Pfad (Repo-CI): Abhängigkeiten und Browser bringt der Workflow mit.
206
+ echo "cli=$CLI_PATH" >> "$GITHUB_OUTPUT"
207
+ exit 0
208
+ fi
209
+
210
+ # Veröffentlichtes Paket in der gepinnten Version. Lifecycle-Skripte der Abhängigkeiten laufen nicht
211
+ # (--ignore-scripts); der Playwright-Browser wird unten ausdrücklich installiert.
212
+ TOOL_DIR="$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/cpcg-XXXXXX")"
213
+ npm install --prefix "$TOOL_DIR" --ignore-scripts --no-audit --no-fund --loglevel=error "cuonztech-privacy-chaos-gate@${CPCG_PINNED_VERSION}"
214
+ PW_CLI="$TOOL_DIR/node_modules/playwright/cli.js"
215
+ if [ -f "$PW_CLI" ]; then
216
+ node "$PW_CLI" install --with-deps chromium
217
+ else
218
+ npx --yes playwright install --with-deps chromium
219
+ fi
220
+ echo "cli=$TOOL_DIR/node_modules/cuonztech-privacy-chaos-gate/dist/cli.js" >> "$GITHUB_OUTPUT"
221
+
222
+ - name: Run Privacy Chaos Gate
223
+ id: cpcg-run
224
+ shell: bash
225
+ # Alle Inputs gelangen nur über env in das Skript (keine ${{ }}-Interpolation im run-Block:
226
+ # sonst könnten Input-Werte als Shell-Code ausgeführt werden). Die Lizenz steht nie in der Kommandozeile.
227
+ env:
228
+ CPCG_CLI: ${{ steps.cpcg-install.outputs.cli }}
229
+ CPCG_LLM_API_KEY: ${{ inputs.api-key }}
230
+ CPCG_LLM_PROVIDER: ${{ inputs.llm-provider }}
231
+ CPCG_LLM_MODEL: ${{ inputs.llm-model }}
232
+ CPCG_LICENSE: ${{ inputs.license }}
233
+ CPCG_TARGET_HEADERS: ${{ inputs.target-headers }}
234
+ CPCG_PROXY: ${{ inputs.proxy }}
235
+ GITHUB_TOKEN: ${{ inputs.github-token }}
236
+ IN_STAGING_URL: ${{ inputs.staging-url }}
237
+ IN_LLM_REMEDIATION: ${{ inputs.llm-remediation }}
238
+ IN_ALLOW_CUSTOM_BANNER_FIX: ${{ inputs.allow-custom-banner-fix }}
239
+ IN_AUTO_FIX: ${{ inputs.auto-fix }}
240
+ IN_FAIL_ON_LEAK: ${{ inputs.fail-on-leak }}
241
+ IN_FAIL_ON_UNCHECKABLE: ${{ inputs.fail-on-uncheckable }}
242
+ IN_STRICT: ${{ inputs.strict }}
243
+ IN_IGNORE: ${{ inputs.ignore }}
244
+ IN_ACCEPT_SELECTOR: ${{ inputs.accept-selector }}
245
+ IN_REJECT_SELECTOR: ${{ inputs.reject-selector }}
246
+ IN_SETTINGS_SELECTOR: ${{ inputs.settings-selector }}
247
+ IN_BANNER_FRAME: ${{ inputs.banner-frame }}
248
+ IN_MAX_SUBPAGES: ${{ inputs.max-subpages }}
249
+ IN_VISITOR: ${{ inputs.visitor }}
250
+ IN_BANNER_WAIT: ${{ inputs.banner-wait }}
251
+ IN_SITEMAP: ${{ inputs.sitemap }}
252
+ IN_DEEP_BUDGET: ${{ inputs.deep-budget }}
253
+ IN_DEEP_STATE: ${{ inputs.deep-state }}
254
+ IN_BASELINE: ${{ inputs.baseline-report }}
255
+ IN_HAR: ${{ inputs.har }}
256
+ IN_VERIFY_URL: ${{ inputs.verify-url }}
257
+ IN_VERIFY_WAIT: ${{ inputs.verify-wait }}
258
+ IN_REPORT_OUTPUT: ${{ inputs.report-output }}
259
+ IN_SOURCE_DIR: ${{ inputs.target-source-dir }}
260
+ IN_GIT_COMMIT: ${{ inputs.git-commit }}
261
+ IN_CREATE_PR: ${{ inputs.create-pr }}
262
+ IN_REPORT_PDF: ${{ inputs.report-pdf }}
263
+ IN_CLIENT: ${{ inputs.client-name }}
264
+ IN_JURISDICTION: ${{ inputs.jurisdiction }}
265
+ run: |
266
+ set -euo pipefail
267
+
268
+ # Freigabe-Header-Werte im Log maskieren (auch wenn sie nicht aus secrets stammen).
269
+ while IFS= read -r line; do
270
+ value="${line#*:}"
271
+ value="${value#"${value%%[![:space:]]*}"}"
272
+ if [ -n "$value" ] && [ "$value" != "$line" ]; then echo "::add-mask::$value"; fi
273
+ done <<< "${CPCG_TARGET_HEADERS:-}"
274
+
275
+ RUNNER=(node "$CPCG_CLI")
276
+
277
+ # Optionen immer als --name=wert: ein Wert, der mit "-" beginnt, wird so nie als eigene Option gelesen.
278
+ ARGS=(
279
+ "--url=$IN_STAGING_URL"
280
+ "--auto-fix=$IN_AUTO_FIX"
281
+ "--fail-on-leak=$IN_FAIL_ON_LEAK"
282
+ "--report-output=$IN_REPORT_OUTPUT"
283
+ "--source-dir=$IN_SOURCE_DIR"
284
+ "--git-commit=$IN_GIT_COMMIT"
285
+ "--create-pr=$IN_CREATE_PR"
286
+ "--report-pdf=$IN_REPORT_PDF"
287
+ "--jurisdiction=$IN_JURISDICTION"
288
+ )
289
+ if [ -n "$IN_CLIENT" ]; then
290
+ ARGS+=("--client=$IN_CLIENT")
291
+ fi
292
+
293
+ # Neuere Optionen nur weitergeben, wenn die installierte CLI sie kennt (ältere Versionen würden sonst mit
294
+ # "unknown option" abbrechen). Kennt sie eine gewünschte Option nicht, wird das gemeldet, nicht still übergangen.
295
+ HELP="$("${RUNNER[@]}" --help 2>&1 || true)"
296
+ supports() { printf '%s\n' "$HELP" | grep -q -- "$1"; }
297
+ warn_unsupported() {
298
+ echo "::warning title=CPCG::Die installierte CLI kennt --$1 nicht; der Input wird ignoriert. Paket- und Action-Version angleichen."
299
+ }
300
+ # Boolesche Option: übergeben, wenn bekannt; unbekannt und angefordert ("true") → Warnung.
301
+ opt_bool() {
302
+ if supports "--$1"; then
303
+ ARGS+=("--$1=$2")
304
+ elif [ "$2" = "true" ]; then
305
+ warn_unsupported "$1"
306
+ fi
307
+ return 0
308
+ }
309
+ # Wert-Option (mehrzeilig erlaubt: je nichtleere Zeile eine Option): nur wenn gesetzt.
310
+ opt_lines() {
311
+ local flag="$1" value="$2" line
312
+ [ -n "${value//[[:space:]]/}" ] || return 0
313
+ if ! supports "--$flag"; then
314
+ warn_unsupported "$flag"
315
+ return 0
316
+ fi
317
+ while IFS= read -r line; do
318
+ line="${line#"${line%%[![:space:]]*}"}"
319
+ line="${line%"${line##*[![:space:]]}"}"
320
+ if [ -n "$line" ]; then ARGS+=("--$flag=$line"); fi
321
+ done <<< "$value"
322
+ return 0
323
+ }
324
+ opt_bool fail-on-uncheckable "$IN_FAIL_ON_UNCHECKABLE"
325
+ opt_bool llm-remediation "$IN_LLM_REMEDIATION"
326
+ opt_bool allow-custom-banner-fix "$IN_ALLOW_CUSTOM_BANNER_FIX"
327
+ opt_bool strict "$IN_STRICT"
328
+ opt_lines ignore "$IN_IGNORE"
329
+ opt_lines accept-selector "$IN_ACCEPT_SELECTOR"
330
+ opt_lines reject-selector "$IN_REJECT_SELECTOR"
331
+ opt_lines settings-selector "$IN_SETTINGS_SELECTOR"
332
+ opt_lines banner-frame "$IN_BANNER_FRAME"
333
+ opt_lines max-subpages "$IN_MAX_SUBPAGES"
334
+ opt_lines visitor "${IN_VISITOR:-}"
335
+ opt_lines banner-wait "$IN_BANNER_WAIT"
336
+ opt_bool sitemap "${IN_SITEMAP:-false}"
337
+ opt_lines deep-budget "${IN_DEEP_BUDGET:-}"
338
+ opt_lines deep-state "${IN_DEEP_STATE:-}"
339
+ opt_lines baseline "${IN_BASELINE:-}"
340
+ opt_bool har "${IN_HAR:-false}"
341
+ opt_lines verify-url "${IN_VERIFY_URL:-}"
342
+ opt_lines verify-wait "${IN_VERIFY_WAIT:-}"
343
+
344
+ "${RUNNER[@]}" "${ARGS[@]}"