cuonztech-privacy-chaos-gate 0.3.3 → 0.3.5

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,333 +1,333 @@
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
- max-subpages:
69
- description: "Maximum number of linked subpages checked for trackers (default 12, max 40; larger values take longer)"
70
- required: false
71
- default: ""
72
- sitemap:
73
- description: "Deep run: check subpages from robots.txt/sitemap.xml and homepage links until deep-budget is used up (true/false)"
74
- required: false
75
- default: "false"
76
- deep-budget:
77
- description: "Time budget of the sitemap deep run for subpages in seconds (30-3600, default 300)"
78
- required: false
79
- default: ""
80
- deep-state:
81
- description: "State file of the deep run; the next run continues with unchecked subpages (persist it with actions/cache)"
82
- required: false
83
- default: ""
84
- baseline-report:
85
- 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)"
86
- required: false
87
- default: ""
88
- har:
89
- description: "Record a HAR file per browser context without bodies into evidence/har next to the report (true/false)"
90
- required: false
91
- default: "false"
92
- verify-url:
93
- 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'"
94
- required: false
95
- default: ""
96
- verify-wait:
97
- description: "Seconds to wait until verify-url is reachable (0-1800, default 0)"
98
- required: false
99
- default: ""
100
- target-headers:
101
- 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."
102
- required: false
103
- default: ""
104
- banner-wait:
105
- description: "Seconds to wait for a late consent banner (1-60; default as in the CLI)"
106
- required: false
107
- default: ""
108
- report-output:
109
- description: "File path where the JSON LeakReport will be written"
110
- required: false
111
- default: "reports/privacy-chaos-report.json"
112
- target-source-dir:
113
- description: "Root directory of the application source code to inspect and patch"
114
- required: false
115
- default: "."
116
- git-commit:
117
- description: "Commit generated privacy fixes into the checked-out branch (requires auto-fix and a valid license; skipped without one)"
118
- required: false
119
- default: "false"
120
- create-pr:
121
- 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)"
122
- required: false
123
- default: "false"
124
- github-token:
125
- description: "GitHub token for create-pr (contents: write and pull-requests: write). Passed via the GITHUB_TOKEN environment variable, never on the command line."
126
- required: false
127
- default: ""
128
- license:
129
- description: "CuonzTech CPCG license (CPCG-… or customer key CPCG-K-…) — from secrets, after online purchase. Not needed for scan and console gate; required for customer report/PDF, git-commit and create-pr. Passed via the CPCG_LICENSE environment variable."
130
- required: false
131
- default: ""
132
- report-pdf:
133
- description: "Create the deluxe PDF (cover page + evidence) after the scan. Requires a valid license; skipped without one."
134
- required: false
135
- default: "false"
136
- client-name:
137
- description: "Client name for the customer report and the PDF cover page. Requires a valid license."
138
- required: false
139
- default: ""
140
- jurisdiction:
141
- description: "Jurisdictions whose rules decide what blocks the gate, comma-separated: CH | EU | UK | US-CA | BR | ROW (strictest wins; default CH,EU as in the CLI)"
142
- required: false
143
- default: "CH,EU"
144
-
145
- outputs:
146
- leaks-found:
147
- description: "'true' if leaks were detected during chaos tests"
148
- value: ${{ steps.cpcg-run.outputs.leaks_found }}
149
- leaks-count:
150
- description: "Number of tracker leaks detected"
151
- value: ${{ steps.cpcg-run.outputs.leaks_count }}
152
- patch-applied:
153
- description: "'true' if an auto-remediation patch was successfully applied"
154
- value: ${{ steps.cpcg-run.outputs.patch_applied }}
155
- report-path:
156
- description: "Absolute or relative path to the generated JSON report"
157
- value: ${{ steps.cpcg-run.outputs.report_path }}
158
- gate_state:
159
- 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."
160
- value: ${{ steps.cpcg-run.outputs.gate_state }}
161
- incomplete:
162
- description: "'true' if core scenarios could not be checked conclusively"
163
- value: ${{ steps.cpcg-run.outputs.incomplete }}
164
- uncheckable_count:
165
- description: "Number of scenarios that could not be checked"
166
- value: ${{ steps.cpcg-run.outputs.uncheckable_count }}
167
- leak_requests:
168
- description: "Number of blocking tracker requests/cookies (before consent, after reject/revoke and the other blocking phases)"
169
- value: ${{ steps.cpcg-run.outputs.leak_requests }}
170
- verified:
171
- 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"
172
- value: ${{ steps.cpcg-run.outputs.verified }}
173
- exit_code:
174
- description: "Exit code of the CLI (0 ok, 1 leaks, 2 license invalid or revoked, 3 error, 4 incomplete)"
175
- value: ${{ steps.cpcg-run.outputs.exit_code }}
176
-
177
- runs:
178
- using: "composite"
179
- steps:
180
- - name: Setup Node.js
181
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
182
- with:
183
- node-version: "24"
184
-
185
- # Installationsschritt: bewusst ohne Secrets (Lizenz, Token, API-Key) in der Umgebung. Nur hier läuft npm.
186
- - name: Install Privacy Chaos Gate
187
- id: cpcg-install
188
- shell: bash
189
- env:
190
- ACTION_PATH: ${{ github.action_path }}
191
- CPCG_PINNED_VERSION: "0.3.3" # = package.json version; bei jedem Release mit anheben (tests/action-pin.test.ts prüft das)
192
- run: |
193
- set -euo pipefail
194
-
195
- CLI_PATH="$ACTION_PATH/dist/cli.js"
196
- if [ -f "$CLI_PATH" ]; then
197
- # Eigener Build im Action-Pfad (Repo-CI): Abhängigkeiten und Browser bringt der Workflow mit.
198
- echo "cli=$CLI_PATH" >> "$GITHUB_OUTPUT"
199
- exit 0
200
- fi
201
-
202
- # Veröffentlichtes Paket in der gepinnten Version. Lifecycle-Skripte der Abhängigkeiten laufen nicht
203
- # (--ignore-scripts); der Playwright-Browser wird unten ausdrücklich installiert.
204
- TOOL_DIR="$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/cpcg-XXXXXX")"
205
- npm install --prefix "$TOOL_DIR" --ignore-scripts --no-audit --no-fund --loglevel=error "cuonztech-privacy-chaos-gate@${CPCG_PINNED_VERSION}"
206
- PW_CLI="$TOOL_DIR/node_modules/playwright/cli.js"
207
- if [ -f "$PW_CLI" ]; then
208
- node "$PW_CLI" install --with-deps chromium
209
- else
210
- npx --yes playwright install --with-deps chromium
211
- fi
212
- echo "cli=$TOOL_DIR/node_modules/cuonztech-privacy-chaos-gate/dist/cli.js" >> "$GITHUB_OUTPUT"
213
-
214
- - name: Run Privacy Chaos Gate
215
- id: cpcg-run
216
- shell: bash
217
- # Alle Inputs gelangen nur über env in das Skript (keine ${{ }}-Interpolation im run-Block:
218
- # sonst könnten Input-Werte als Shell-Code ausgeführt werden). Die Lizenz steht nie in der Kommandozeile.
219
- env:
220
- CPCG_CLI: ${{ steps.cpcg-install.outputs.cli }}
221
- CPCG_LLM_API_KEY: ${{ inputs.api-key }}
222
- CPCG_LLM_PROVIDER: ${{ inputs.llm-provider }}
223
- CPCG_LLM_MODEL: ${{ inputs.llm-model }}
224
- CPCG_LICENSE: ${{ inputs.license }}
225
- CPCG_TARGET_HEADERS: ${{ inputs.target-headers }}
226
- GITHUB_TOKEN: ${{ inputs.github-token }}
227
- IN_STAGING_URL: ${{ inputs.staging-url }}
228
- IN_LLM_REMEDIATION: ${{ inputs.llm-remediation }}
229
- IN_ALLOW_CUSTOM_BANNER_FIX: ${{ inputs.allow-custom-banner-fix }}
230
- IN_AUTO_FIX: ${{ inputs.auto-fix }}
231
- IN_FAIL_ON_LEAK: ${{ inputs.fail-on-leak }}
232
- IN_FAIL_ON_UNCHECKABLE: ${{ inputs.fail-on-uncheckable }}
233
- IN_STRICT: ${{ inputs.strict }}
234
- IN_IGNORE: ${{ inputs.ignore }}
235
- IN_ACCEPT_SELECTOR: ${{ inputs.accept-selector }}
236
- IN_REJECT_SELECTOR: ${{ inputs.reject-selector }}
237
- IN_SETTINGS_SELECTOR: ${{ inputs.settings-selector }}
238
- IN_BANNER_FRAME: ${{ inputs.banner-frame }}
239
- IN_MAX_SUBPAGES: ${{ inputs.max-subpages }}
240
- IN_BANNER_WAIT: ${{ inputs.banner-wait }}
241
- IN_SITEMAP: ${{ inputs.sitemap }}
242
- IN_DEEP_BUDGET: ${{ inputs.deep-budget }}
243
- IN_DEEP_STATE: ${{ inputs.deep-state }}
244
- IN_BASELINE: ${{ inputs.baseline-report }}
245
- IN_HAR: ${{ inputs.har }}
246
- IN_VERIFY_URL: ${{ inputs.verify-url }}
247
- IN_VERIFY_WAIT: ${{ inputs.verify-wait }}
248
- IN_REPORT_OUTPUT: ${{ inputs.report-output }}
249
- IN_SOURCE_DIR: ${{ inputs.target-source-dir }}
250
- IN_GIT_COMMIT: ${{ inputs.git-commit }}
251
- IN_CREATE_PR: ${{ inputs.create-pr }}
252
- IN_REPORT_PDF: ${{ inputs.report-pdf }}
253
- IN_CLIENT: ${{ inputs.client-name }}
254
- IN_JURISDICTION: ${{ inputs.jurisdiction }}
255
- run: |
256
- set -euo pipefail
257
-
258
- # Freigabe-Header-Werte im Log maskieren (auch wenn sie nicht aus secrets stammen).
259
- while IFS= read -r line; do
260
- value="${line#*:}"
261
- value="${value#"${value%%[![:space:]]*}"}"
262
- if [ -n "$value" ] && [ "$value" != "$line" ]; then echo "::add-mask::$value"; fi
263
- done <<< "${CPCG_TARGET_HEADERS:-}"
264
-
265
- RUNNER=(node "$CPCG_CLI")
266
-
267
- # Optionen immer als --name=wert: ein Wert, der mit "-" beginnt, wird so nie als eigene Option gelesen.
268
- ARGS=(
269
- "--url=$IN_STAGING_URL"
270
- "--auto-fix=$IN_AUTO_FIX"
271
- "--fail-on-leak=$IN_FAIL_ON_LEAK"
272
- "--report-output=$IN_REPORT_OUTPUT"
273
- "--source-dir=$IN_SOURCE_DIR"
274
- "--git-commit=$IN_GIT_COMMIT"
275
- "--create-pr=$IN_CREATE_PR"
276
- "--report-pdf=$IN_REPORT_PDF"
277
- "--jurisdiction=$IN_JURISDICTION"
278
- )
279
- if [ -n "$IN_CLIENT" ]; then
280
- ARGS+=("--client=$IN_CLIENT")
281
- fi
282
-
283
- # Neuere Optionen nur weitergeben, wenn die installierte CLI sie kennt (ältere Versionen würden sonst mit
284
- # "unknown option" abbrechen). Kennt sie eine gewünschte Option nicht, wird das gemeldet, nicht still übergangen.
285
- HELP="$("${RUNNER[@]}" --help 2>&1 || true)"
286
- supports() { printf '%s\n' "$HELP" | grep -q -- "$1"; }
287
- warn_unsupported() {
288
- echo "::warning title=CPCG::Die installierte CLI kennt --$1 nicht; der Input wird ignoriert. Paket- und Action-Version angleichen."
289
- }
290
- # Boolesche Option: übergeben, wenn bekannt; unbekannt und angefordert ("true") → Warnung.
291
- opt_bool() {
292
- if supports "--$1"; then
293
- ARGS+=("--$1=$2")
294
- elif [ "$2" = "true" ]; then
295
- warn_unsupported "$1"
296
- fi
297
- return 0
298
- }
299
- # Wert-Option (mehrzeilig erlaubt: je nichtleere Zeile eine Option): nur wenn gesetzt.
300
- opt_lines() {
301
- local flag="$1" value="$2" line
302
- [ -n "${value//[[:space:]]/}" ] || return 0
303
- if ! supports "--$flag"; then
304
- warn_unsupported "$flag"
305
- return 0
306
- fi
307
- while IFS= read -r line; do
308
- line="${line#"${line%%[![:space:]]*}"}"
309
- line="${line%"${line##*[![:space:]]}"}"
310
- if [ -n "$line" ]; then ARGS+=("--$flag=$line"); fi
311
- done <<< "$value"
312
- return 0
313
- }
314
- opt_bool fail-on-uncheckable "$IN_FAIL_ON_UNCHECKABLE"
315
- opt_bool llm-remediation "$IN_LLM_REMEDIATION"
316
- opt_bool allow-custom-banner-fix "$IN_ALLOW_CUSTOM_BANNER_FIX"
317
- opt_bool strict "$IN_STRICT"
318
- opt_lines ignore "$IN_IGNORE"
319
- opt_lines accept-selector "$IN_ACCEPT_SELECTOR"
320
- opt_lines reject-selector "$IN_REJECT_SELECTOR"
321
- opt_lines settings-selector "$IN_SETTINGS_SELECTOR"
322
- opt_lines banner-frame "$IN_BANNER_FRAME"
323
- opt_lines max-subpages "$IN_MAX_SUBPAGES"
324
- opt_lines banner-wait "$IN_BANNER_WAIT"
325
- opt_bool sitemap "${IN_SITEMAP:-false}"
326
- opt_lines deep-budget "${IN_DEEP_BUDGET:-}"
327
- opt_lines deep-state "${IN_DEEP_STATE:-}"
328
- opt_lines baseline "${IN_BASELINE:-}"
329
- opt_bool har "${IN_HAR:-false}"
330
- opt_lines verify-url "${IN_VERIFY_URL:-}"
331
- opt_lines verify-wait "${IN_VERIFY_WAIT:-}"
332
-
333
- "${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
+ max-subpages:
69
+ description: "Maximum number of linked subpages checked for trackers (default 12, max 40; larger values take longer)"
70
+ required: false
71
+ default: ""
72
+ sitemap:
73
+ description: "Deep run: check subpages from robots.txt/sitemap.xml and homepage links until deep-budget is used up (true/false)"
74
+ required: false
75
+ default: "false"
76
+ deep-budget:
77
+ description: "Time budget of the sitemap deep run for subpages in seconds (30-3600, default 300)"
78
+ required: false
79
+ default: ""
80
+ deep-state:
81
+ description: "State file of the deep run; the next run continues with unchecked subpages (persist it with actions/cache)"
82
+ required: false
83
+ default: ""
84
+ baseline-report:
85
+ 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)"
86
+ required: false
87
+ default: ""
88
+ har:
89
+ description: "Record a HAR file per browser context without bodies into evidence/har next to the report (true/false)"
90
+ required: false
91
+ default: "false"
92
+ verify-url:
93
+ 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'"
94
+ required: false
95
+ default: ""
96
+ verify-wait:
97
+ description: "Seconds to wait until verify-url is reachable (0-1800, default 0)"
98
+ required: false
99
+ default: ""
100
+ target-headers:
101
+ 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."
102
+ required: false
103
+ default: ""
104
+ banner-wait:
105
+ description: "Seconds to wait for a late consent banner (1-60; default as in the CLI)"
106
+ required: false
107
+ default: ""
108
+ report-output:
109
+ description: "File path where the JSON LeakReport will be written"
110
+ required: false
111
+ default: "reports/privacy-chaos-report.json"
112
+ target-source-dir:
113
+ description: "Root directory of the application source code to inspect and patch"
114
+ required: false
115
+ default: "."
116
+ git-commit:
117
+ description: "Commit generated privacy fixes into the checked-out branch (requires auto-fix and a valid license; skipped without one)"
118
+ required: false
119
+ default: "false"
120
+ create-pr:
121
+ 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)"
122
+ required: false
123
+ default: "false"
124
+ github-token:
125
+ description: "GitHub token for create-pr (contents: write and pull-requests: write). Passed via the GITHUB_TOKEN environment variable, never on the command line."
126
+ required: false
127
+ default: ""
128
+ license:
129
+ 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."
130
+ required: false
131
+ default: ""
132
+ report-pdf:
133
+ description: "Create the deluxe PDF (cover page + evidence) after the scan. Requires a valid license; skipped without one."
134
+ required: false
135
+ default: "false"
136
+ client-name:
137
+ description: "Client name for the customer report and the PDF cover page. Requires a valid license."
138
+ required: false
139
+ default: ""
140
+ jurisdiction:
141
+ description: "Jurisdictions whose rules decide what blocks the gate, comma-separated: CH | EU | UK | US-CA | BR | ROW (strictest wins; default CH,EU as in the CLI)"
142
+ required: false
143
+ default: "CH,EU"
144
+
145
+ outputs:
146
+ leaks-found:
147
+ description: "'true' if leaks were detected during chaos tests"
148
+ value: ${{ steps.cpcg-run.outputs.leaks_found }}
149
+ leaks-count:
150
+ description: "Number of tracker leaks detected"
151
+ value: ${{ steps.cpcg-run.outputs.leaks_count }}
152
+ patch-applied:
153
+ description: "'true' if an auto-remediation patch was successfully applied"
154
+ value: ${{ steps.cpcg-run.outputs.patch_applied }}
155
+ report-path:
156
+ description: "Absolute or relative path to the generated JSON report"
157
+ value: ${{ steps.cpcg-run.outputs.report_path }}
158
+ gate_state:
159
+ 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."
160
+ value: ${{ steps.cpcg-run.outputs.gate_state }}
161
+ incomplete:
162
+ description: "'true' if core scenarios could not be checked conclusively"
163
+ value: ${{ steps.cpcg-run.outputs.incomplete }}
164
+ uncheckable_count:
165
+ description: "Number of scenarios that could not be checked"
166
+ value: ${{ steps.cpcg-run.outputs.uncheckable_count }}
167
+ leak_requests:
168
+ description: "Number of blocking tracker requests/cookies (before consent, after reject/revoke and the other blocking phases)"
169
+ value: ${{ steps.cpcg-run.outputs.leak_requests }}
170
+ verified:
171
+ 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"
172
+ value: ${{ steps.cpcg-run.outputs.verified }}
173
+ exit_code:
174
+ 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)"
175
+ value: ${{ steps.cpcg-run.outputs.exit_code }}
176
+
177
+ runs:
178
+ using: "composite"
179
+ steps:
180
+ - name: Setup Node.js
181
+ uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
182
+ with:
183
+ node-version: "24"
184
+
185
+ # Installationsschritt: bewusst ohne Secrets (Lizenz, Token, API-Key) in der Umgebung. Nur hier läuft npm.
186
+ - name: Install Privacy Chaos Gate
187
+ id: cpcg-install
188
+ shell: bash
189
+ env:
190
+ ACTION_PATH: ${{ github.action_path }}
191
+ CPCG_PINNED_VERSION: "0.3.5" # = package.json version; bei jedem Release mit anheben (tests/action-pin.test.ts prüft das)
192
+ run: |
193
+ set -euo pipefail
194
+
195
+ CLI_PATH="$ACTION_PATH/dist/cli.js"
196
+ if [ -f "$CLI_PATH" ]; then
197
+ # Eigener Build im Action-Pfad (Repo-CI): Abhängigkeiten und Browser bringt der Workflow mit.
198
+ echo "cli=$CLI_PATH" >> "$GITHUB_OUTPUT"
199
+ exit 0
200
+ fi
201
+
202
+ # Veröffentlichtes Paket in der gepinnten Version. Lifecycle-Skripte der Abhängigkeiten laufen nicht
203
+ # (--ignore-scripts); der Playwright-Browser wird unten ausdrücklich installiert.
204
+ TOOL_DIR="$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/cpcg-XXXXXX")"
205
+ npm install --prefix "$TOOL_DIR" --ignore-scripts --no-audit --no-fund --loglevel=error "cuonztech-privacy-chaos-gate@${CPCG_PINNED_VERSION}"
206
+ PW_CLI="$TOOL_DIR/node_modules/playwright/cli.js"
207
+ if [ -f "$PW_CLI" ]; then
208
+ node "$PW_CLI" install --with-deps chromium
209
+ else
210
+ npx --yes playwright install --with-deps chromium
211
+ fi
212
+ echo "cli=$TOOL_DIR/node_modules/cuonztech-privacy-chaos-gate/dist/cli.js" >> "$GITHUB_OUTPUT"
213
+
214
+ - name: Run Privacy Chaos Gate
215
+ id: cpcg-run
216
+ shell: bash
217
+ # Alle Inputs gelangen nur über env in das Skript (keine ${{ }}-Interpolation im run-Block:
218
+ # sonst könnten Input-Werte als Shell-Code ausgeführt werden). Die Lizenz steht nie in der Kommandozeile.
219
+ env:
220
+ CPCG_CLI: ${{ steps.cpcg-install.outputs.cli }}
221
+ CPCG_LLM_API_KEY: ${{ inputs.api-key }}
222
+ CPCG_LLM_PROVIDER: ${{ inputs.llm-provider }}
223
+ CPCG_LLM_MODEL: ${{ inputs.llm-model }}
224
+ CPCG_LICENSE: ${{ inputs.license }}
225
+ CPCG_TARGET_HEADERS: ${{ inputs.target-headers }}
226
+ GITHUB_TOKEN: ${{ inputs.github-token }}
227
+ IN_STAGING_URL: ${{ inputs.staging-url }}
228
+ IN_LLM_REMEDIATION: ${{ inputs.llm-remediation }}
229
+ IN_ALLOW_CUSTOM_BANNER_FIX: ${{ inputs.allow-custom-banner-fix }}
230
+ IN_AUTO_FIX: ${{ inputs.auto-fix }}
231
+ IN_FAIL_ON_LEAK: ${{ inputs.fail-on-leak }}
232
+ IN_FAIL_ON_UNCHECKABLE: ${{ inputs.fail-on-uncheckable }}
233
+ IN_STRICT: ${{ inputs.strict }}
234
+ IN_IGNORE: ${{ inputs.ignore }}
235
+ IN_ACCEPT_SELECTOR: ${{ inputs.accept-selector }}
236
+ IN_REJECT_SELECTOR: ${{ inputs.reject-selector }}
237
+ IN_SETTINGS_SELECTOR: ${{ inputs.settings-selector }}
238
+ IN_BANNER_FRAME: ${{ inputs.banner-frame }}
239
+ IN_MAX_SUBPAGES: ${{ inputs.max-subpages }}
240
+ IN_BANNER_WAIT: ${{ inputs.banner-wait }}
241
+ IN_SITEMAP: ${{ inputs.sitemap }}
242
+ IN_DEEP_BUDGET: ${{ inputs.deep-budget }}
243
+ IN_DEEP_STATE: ${{ inputs.deep-state }}
244
+ IN_BASELINE: ${{ inputs.baseline-report }}
245
+ IN_HAR: ${{ inputs.har }}
246
+ IN_VERIFY_URL: ${{ inputs.verify-url }}
247
+ IN_VERIFY_WAIT: ${{ inputs.verify-wait }}
248
+ IN_REPORT_OUTPUT: ${{ inputs.report-output }}
249
+ IN_SOURCE_DIR: ${{ inputs.target-source-dir }}
250
+ IN_GIT_COMMIT: ${{ inputs.git-commit }}
251
+ IN_CREATE_PR: ${{ inputs.create-pr }}
252
+ IN_REPORT_PDF: ${{ inputs.report-pdf }}
253
+ IN_CLIENT: ${{ inputs.client-name }}
254
+ IN_JURISDICTION: ${{ inputs.jurisdiction }}
255
+ run: |
256
+ set -euo pipefail
257
+
258
+ # Freigabe-Header-Werte im Log maskieren (auch wenn sie nicht aus secrets stammen).
259
+ while IFS= read -r line; do
260
+ value="${line#*:}"
261
+ value="${value#"${value%%[![:space:]]*}"}"
262
+ if [ -n "$value" ] && [ "$value" != "$line" ]; then echo "::add-mask::$value"; fi
263
+ done <<< "${CPCG_TARGET_HEADERS:-}"
264
+
265
+ RUNNER=(node "$CPCG_CLI")
266
+
267
+ # Optionen immer als --name=wert: ein Wert, der mit "-" beginnt, wird so nie als eigene Option gelesen.
268
+ ARGS=(
269
+ "--url=$IN_STAGING_URL"
270
+ "--auto-fix=$IN_AUTO_FIX"
271
+ "--fail-on-leak=$IN_FAIL_ON_LEAK"
272
+ "--report-output=$IN_REPORT_OUTPUT"
273
+ "--source-dir=$IN_SOURCE_DIR"
274
+ "--git-commit=$IN_GIT_COMMIT"
275
+ "--create-pr=$IN_CREATE_PR"
276
+ "--report-pdf=$IN_REPORT_PDF"
277
+ "--jurisdiction=$IN_JURISDICTION"
278
+ )
279
+ if [ -n "$IN_CLIENT" ]; then
280
+ ARGS+=("--client=$IN_CLIENT")
281
+ fi
282
+
283
+ # Neuere Optionen nur weitergeben, wenn die installierte CLI sie kennt (ältere Versionen würden sonst mit
284
+ # "unknown option" abbrechen). Kennt sie eine gewünschte Option nicht, wird das gemeldet, nicht still übergangen.
285
+ HELP="$("${RUNNER[@]}" --help 2>&1 || true)"
286
+ supports() { printf '%s\n' "$HELP" | grep -q -- "$1"; }
287
+ warn_unsupported() {
288
+ echo "::warning title=CPCG::Die installierte CLI kennt --$1 nicht; der Input wird ignoriert. Paket- und Action-Version angleichen."
289
+ }
290
+ # Boolesche Option: übergeben, wenn bekannt; unbekannt und angefordert ("true") → Warnung.
291
+ opt_bool() {
292
+ if supports "--$1"; then
293
+ ARGS+=("--$1=$2")
294
+ elif [ "$2" = "true" ]; then
295
+ warn_unsupported "$1"
296
+ fi
297
+ return 0
298
+ }
299
+ # Wert-Option (mehrzeilig erlaubt: je nichtleere Zeile eine Option): nur wenn gesetzt.
300
+ opt_lines() {
301
+ local flag="$1" value="$2" line
302
+ [ -n "${value//[[:space:]]/}" ] || return 0
303
+ if ! supports "--$flag"; then
304
+ warn_unsupported "$flag"
305
+ return 0
306
+ fi
307
+ while IFS= read -r line; do
308
+ line="${line#"${line%%[![:space:]]*}"}"
309
+ line="${line%"${line##*[![:space:]]}"}"
310
+ if [ -n "$line" ]; then ARGS+=("--$flag=$line"); fi
311
+ done <<< "$value"
312
+ return 0
313
+ }
314
+ opt_bool fail-on-uncheckable "$IN_FAIL_ON_UNCHECKABLE"
315
+ opt_bool llm-remediation "$IN_LLM_REMEDIATION"
316
+ opt_bool allow-custom-banner-fix "$IN_ALLOW_CUSTOM_BANNER_FIX"
317
+ opt_bool strict "$IN_STRICT"
318
+ opt_lines ignore "$IN_IGNORE"
319
+ opt_lines accept-selector "$IN_ACCEPT_SELECTOR"
320
+ opt_lines reject-selector "$IN_REJECT_SELECTOR"
321
+ opt_lines settings-selector "$IN_SETTINGS_SELECTOR"
322
+ opt_lines banner-frame "$IN_BANNER_FRAME"
323
+ opt_lines max-subpages "$IN_MAX_SUBPAGES"
324
+ opt_lines banner-wait "$IN_BANNER_WAIT"
325
+ opt_bool sitemap "${IN_SITEMAP:-false}"
326
+ opt_lines deep-budget "${IN_DEEP_BUDGET:-}"
327
+ opt_lines deep-state "${IN_DEEP_STATE:-}"
328
+ opt_lines baseline "${IN_BASELINE:-}"
329
+ opt_bool har "${IN_HAR:-false}"
330
+ opt_lines verify-url "${IN_VERIFY_URL:-}"
331
+ opt_lines verify-wait "${IN_VERIFY_WAIT:-}"
332
+
333
+ "${RUNNER[@]}" "${ARGS[@]}"