Source type enum enforced
Why it matters
Unvalidated free-text source type fields let any string enter your database — 'scraped', 'Scraped', 'SCRAPER', and '' all become distinct values. Downstream deduplication queries, compliance lookups, and per-source quality analytics break silently when the field is inconsistent. CWE-20 (Improper Input Validation) and ISO 27001:2022 A.8.9 both require that data integrity controls are in place at the input boundary. Without a constrained enum, you cannot reliably segment contacts by acquisition method or demonstrate to a regulator that you know where each record came from.
Severity rationale
High because an unconstrained source_type field silently corrupts every downstream provenance query and compliance report that groups or filters by source.
Remediation
Add a constrained enum at the database level via a Prisma enum type or a SQL CHECK constraint. A free-text column with no constraint is not acceptable even if application code currently writes consistent values — future ingestion paths or admin tools may not.
// schema.prisma
enum SourceType {
SCRAPER
API
PURCHASED
FORM
REFERRAL
}
model Contact {
id String @id @default(cuid())
source_type SourceType
}
-- Migration for existing tables
ALTER TABLE contacts
ADD COLUMN source_type TEXT NOT NULL
CHECK (source_type IN ('scraper', 'api', 'purchased', 'form', 'referral'));
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Data Sourcing & Provenance Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-20 — Improper Input Validation
- iso-27001:2022 · A.8.9 — Configuration management
Taxons
History
- 2026-04-18·v1.0.0·Initial import from data-sourcing-provenance·automated