Webhook icon
Schedule icon
WorkingDirectory icon
Clone icon
Commands icon
Docker icon
Switch icon
SlackIncomingWebhook icon
Fail icon
Log icon

SOPS GitOps Secret Decryption Drift and Integrity Verification Gate

Audit SOPS-encrypted GitOps manifests in Kestra to detect plaintext leaks, corrupted MAC signatures, and missing Age recipient keys before cluster sync.

Categories
Infrastructure

Prevents unencrypted secrets from leaking into version control and blocks corrupted SOPS manifests from breaking GitOps deployment controllers (Flux CD, Argo CD) by automating pre-deployment cryptographic validation, recipient key compliance, and MAC integrity verification.

How it works

  1. Trigger Reception (gitops_pr_webhook, nightly_secret_drift_schedule): Triggered immediately via authenticated webhook when pull requests or commits touch secret files, or runs on a nightly schedule to detect key rotation drift across all branches.
  2. Repository Clone (clone_gitops_repo): Clones the target GitOps repository at the specified branch or pull request commit SHA within an isolated io.kestra.plugin.core.flow.WorkingDirectory.
  3. SOPS Cryptographic Audit (audit_sops_manifests): Runs a containerized Python and sops CLI audit engine on Docker that scans manifests matching *secret*.yaml and *.enc.yaml, checks for missing SOPS envelopes, flags unencrypted leaf values, verifies that the expected Age recipient key is present, and executes cryptographic MAC validation.
  4. Policy Routing & Incident Escalation (route_audit_outcome): Evaluates the audit status via io.kestra.plugin.core.flow.Switch:
    • CRITICAL_PLAINTEXT_LEAK: Dispatches an urgent alert to Slack (alert_plaintext_leak_slack) and halts the pipeline via io.kestra.plugin.core.execution.Fail to prevent unencrypted credentials from reaching production.
    • CORRUPTED_MAC_OR_DECRYPT_FAILURE: Alerts the platform team with exact sops -e -i <file> remediation commands when merge conflict corruption invalidates sops.mac.
    • RECIPIENT_KEY_MISMATCH: Warns engineers that manifests need sops updatekeys rotation after an Age key update.
    • VERIFIED_CLEAN (Default): Logs an audit certification receipt (log_clean_audit) confirming all manifests are cryptographically sound.

What you get

  • Zero-Leakage GitOps Safeguard: Catches accidentally unencrypted passwords, API tokens, and connection strings before they merge into production branches.
  • Merge Conflict Corruption Defense: Detects broken sops.mac signatures caused by manual conflict resolution before they crash Flux or Argo CD controllers.
  • Key Rotation Verification: Ensures all manifests contain current Age recipient public keys after team access changes.
  • Automated CI/CD Gating: Fails fast with clear remediation instructions and notifies Slack incident channels.

Who it's for

  • Platform Engineers & SREs maintaining GitOps repositories with Flux CD, Argo CD, or Helm.
  • DevSecOps Teams enforcing zero-plaintext secrets compliance across microservice repositories.
  • Security Engineers needing an automated, continuous audit trail of encrypted secrets in version control.

Why orchestrate this with Kestra

  • Declarative Pre-Deployment Gate: Combines repository cloning, containerized CLI verification, policy branching, and Slack alerting into a single reproducible YAML workflow.
  • Multi-Trigger Governance: Supports dual webhook triggers for real-time pull request validation and recurring cron schedules for continuous drift detection.
  • Secret Masking & Security: Age private keys and webhook URLs are injected dynamically via {{ secret('NAME') }} and never persisted in workflow definitions or task logs.

Prerequisites

  • A running Kestra v2.0 instance with Docker task runner support (plugin-scripts-runner-docker).
  • Network access to clone the target GitOps repository.

Secrets

  • GITOPS_WEBHOOK_KEY: Secret authentication key used to validate incoming GitHub/GitLab webhook payloads (required).
  • SOPS_AGE_KEY: Age secret key (AGE-SECRET-KEY-1...) used to test in-memory decryption and MAC integrity (required for full decryption tests).
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL for alerting on policy breaches and verification failures (optional).

Quick start

  1. Configure GITOPS_WEBHOOK_KEY and SOPS_AGE_KEY in your Kestra namespace secrets.
  2. Import this blueprint into your Kestra instance under the company.gitops namespace.
  3. Click Execute with default inputs to clone the official SOPS project repository and audit its real *.enc.yaml test fixtures, verifying the VERIFIED_CLEAN certification path. These fixtures use PGP, not Age, so expected_age_recipient is left empty by default; set it once you point the flow at your own Age-encrypted repository.
  4. Set git_repository_url to your team's GitOps repository to audit live manifests.
  5. Activate gitops_pr_webhook in your repository's GitHub/GitLab webhook settings.

How to extend

  • Cloud KMS Integration: Extend the audit script to verify AWS KMS, GCP KMS, Azure Key Vault, or HashiCorp Vault key ARNs in sops.kms or sops.gcp_kms.
  • Automated Pull Request Comments: Add an io.kestra.plugin.github.issues.Create or comment task to post the generated audit Markdown table directly onto the GitHub pull request.
  • PagerDuty Escalation: Route CRITICAL_PLAINTEXT_LEAK cases to PagerDuty or Opsgenie for immediate incident response when high-risk production keys leak.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.