diff --git a/backend-compliance/compliance/services/tcf_vendor_authority.py b/backend-compliance/compliance/services/tcf_vendor_authority.py index 7618425d..e1fd71ec 100644 --- a/backend-compliance/compliance/services/tcf_vendor_authority.py +++ b/backend-compliance/compliance/services/tcf_vendor_authority.py @@ -91,28 +91,38 @@ async def fetch_and_ingest_tcf_vendors(db: Session) -> dict: leg_purposes = v.get("legIntPurposes") or [] all_purposes = list(set(purposes) | set(leg_purposes)) category = _category_for_purposes(all_purposes) + privacy_url = (v.get("policyUrl") or "").strip()[:500] or None # Cookie-Names die der Vendor laut TCF setzt sind nicht in der # GVL — wir kennzeichnen nur den Vendor-Eintrag mit ID + Purposes. - # Vendor wird mit synthetic cookie_name='_tcf_marker' - # gespeichert; Library-Lookup nutzt vendor_name-Match. marker = f"_tcf_v{vid}" try: db.execute(sa_text( """ INSERT INTO compliance.cookie_library - (cookie_name, actual_category, vendor_name, source) - VALUES (:n, :cat, :v, 'iab_tcf_v2') + (cookie_name, domain_pattern, vendor_name, + vendor_privacy_url, actual_category, + purpose_en, source_name, source_url, confidence) + VALUES (:n, :dp, :v, :pu, :cat, :purp, 'iab_tcf_v2', + 'https://vendor-list.consensu.org/v3/vendor-list.json', + 0.99) ON CONFLICT (cookie_name) DO UPDATE - SET actual_category = EXCLUDED.actual_category, - vendor_name = EXCLUDED.vendor_name + SET actual_category = EXCLUDED.actual_category, + vendor_name = EXCLUDED.vendor_name, + vendor_privacy_url = EXCLUDED.vendor_privacy_url, + purpose_en = EXCLUDED.purpose_en, + source_name = EXCLUDED.source_name, + confidence = EXCLUDED.confidence """ - ), {"n": marker, "cat": category, - "v": f"[TCF-{vid}] {name}"}) + ), {"n": marker, "dp": "*", + "v": f"[TCF-{vid}] {name}", + "pu": privacy_url, "cat": category, + "purp": f"IAB TCF v2 Purposes: {sorted(all_purposes)}"}) inserted += 1 except Exception as e: logger.warning("TCF vendor %s insert failed: %s", vid, e) skipped += 1 + db.rollback() # neue Transaktion fuer naechsten Insert db.commit() return {"n_vendors_in_gvl": len(vendors), "inserted": inserted, "skipped": skipped}