Runner: Analyse-Skript und Datenschutz-Zusatzseite einsetzen

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-01 10:02:52 +00:00
1 parent add7fa4add
commit 7de9f1aaa3
6 files changed
+309

No files matched your search

+20
View File
@@ -4,6 +4,8 @@ const RE_REPO = /^[\w.-]+\/[\w.-]+$/;
const RE_SHA = /^[0-9a-f]{7,40}$/;
const RE_BRANCH = /^[\w./-]{1,100}$/;
const RE_ENV = /^[A-Z_][A-Z0-9_]*$/;
const RE_SITE_KEY = /^[a-z0-9]{16,40}$/;
const RE_COLOR = /^#[0-9a-f]{6}$/;
const MODES = ['auto', 'build', 'dev'];
export const isValidRunId = (s) => typeof s === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s);
@@ -45,9 +47,27 @@ export function validateJob(body) {
env[n] = v;
}
}
let analytics;
if (body.analytics !== undefined) {
const a = body.analytics;
if (!a || typeof a !== 'object' || Array.isArray(a)) return { ok: false, error: 'Ungültige Analyse-Angaben' };
if (typeof a.siteKey !== 'string' || !RE_SITE_KEY.test(a.siteKey)) return { ok: false, error: 'Ungültiger Analyse-Schlüssel' };
if (typeof a.color !== 'string' || !RE_COLOR.test(a.color)) return { ok: false, error: 'Ungültige Analyse-Farbe' };
const pr = a.privacy;
if (!pr || typeof pr !== 'object' || Array.isArray(pr)) return { ok: false, error: 'Ungültige Analyse-Datenschutzangaben' };
const privacy = {};
for (const [k, max] of [['company', 200], ['address', 300], ['email', 200]]) {
const v = pr[k];
// eslint-disable-next-line no-control-regex
if (typeof v !== 'string' || !v.trim() || v.length > max || /[\x00-\x1f\x7f]/.test(v)) return { ok: false, error: `Ungültige Analyse-Datenschutzangabe: ${k}` };
privacy[k] = v;
}
analytics = { siteKey: a.siteKey, color: a.color, privacy };
}
// Whitelist: keine ungeprüften Client-Felder im Job
const job = { sub, repo, sha, branch, mode, env };
if (index !== undefined) job.index = index;
if (displayName !== undefined) job.displayName = displayName;
if (analytics !== undefined) job.analytics = analytics;
return { ok: true, job };
}