Skip to content

Security: SamAdebisi/Data_Platform_Scaffold

Security

docs/security.md

Security Controls

Tokenisation

  • security/tokenization.py offers deterministic HMAC-based tokenisation for PAN-like fields. Use different secrets per environment and rotate regularly.
  • security/pii/tokenize.py illustrates envelope encryption with AES-GCM for reversible tokenisation when needed.
  • Store the secrets (TOK_SECRET, data encryption keys) in a central KMS; environment variables are used only for local testing.

Envelope Encryption

  • security/kms.py demonstrates wrapping/unwrapping data encryption keys (DEKs) with a master secret via HKDF + AES-GCM.
  • security/kms/envelope.py shows RSA-based wrapping as an alternative for asymmetric contexts.
  • Replace inline master secrets with calls to AWS KMS, GCP KMS, or Azure Key Vault in production.

Row-Level Security Templates

  • SQL files under security/policies and security/rls provide sample RLS policies for BigQuery, Snowflake, and generic data warehouses.
  • Adapt the predicates (customer_region, role) to your organisational structure.

API Hardening

  • Require HTTPS termination in front of the ingestion API and rotate JWT secrets/public keys via a secret manager.
  • Implement rate limiting (via API gateway or FastAPI middleware) to guard against brute-force attempts.
  • Log authentication failures with contextual metadata for audit trails.

Compliance

  • PGP signing and SFTP delivery scripts enforce encryption-in-transit and at-rest for compliance exports.
  • Document key rotation schedules and maintain access control lists for operators interacting with export destinations.

Additional Recommendations

  • Enable static analysis (e.g., bandit, ruff) in CI to detect insecure patterns.
  • Use container scanning tools (Trivy, Grype) against the Docker images.
  • Implement secrets scanning (Gitleaks) to prevent accidental credential commits.

There aren't any published security advisories