On This Page
Key terms: Data Fiduciary — entity determining purpose and means of processing (GDPR equivalent: Data Controller). Privacy by Design — the principle of embedding privacy protections into system architecture from the outset rather than retrofitting them. Section 8(4) — DPDPA obligation requiring Data Fiduciaries to implement "appropriate technical and organisational measures to ensure effective observance of the provisions of this Act." Technical and Organisational Measures (TOMs) — the enumerated minimum security controls in Rule 6(1)(a)-(g). PII Scanner — a tool that statically analyses code or data for patterns matching personal data (names, emails, phone numbers, Aadhaar numbers). Significant Data Fiduciary (SDF) — a Data Fiduciary notified by the Central Government under Section 10(1) as carrying higher-risk processing, subject to additional obligations including Rule 13(3) algorithmic due diligence.
Introduction
Many personal data breaches start as code: a logged email address, an unencrypted column, a leaked key. The CI/CD pipeline is the cheapest place to catch them, and this guide turns Section 8(4), Section 8(5) with Rule 6(1), Section 6(1) and Section 8(7) into three gates.
Most DPDPA compliance guidance stops at policies and consent forms. That is a problem, because personal data breaches do not originate in policy documents -- they originate in code. A hardcoded API key in a microservice, an unencrypted PII field logged to stdout, a test fixture populated with production data -- these are the engineering failures behind the breaches that Section 2(u) of the DPDPA defines.
If you want the obligations first and the pipeline second, the DPDPA checklist lists each one with the section or Rule behind it.
If you are serious about DPDPA privacy by design, you need compliance checks that run where your code lives: in the CI/CD pipeline. This article translates specific DPDPA obligations and DPDP Rules 2025 requirements into automated pipeline gates that your engineering team can implement this quarter.
We will cover four areas: the legal obligations that demand automation, the framework controls that map to pipeline tooling, concrete GitHub Actions and GitLab CI configurations, and the privacy-aware deployment gates that prevent non-compliant code from reaching production.
This is not a theoretical exercise. Every configuration shown here is production-grade and maps to a specific section of the Act or Rules.
What Does Section 8(4) Require in Your CI/CD Pipeline?
Section 8(4) requires appropriate technical and organisational measures to ensure effective observance of the Act and the Rules. It does not mention pipelines; an automated gate that blocks non-compliant changes is one such measure, and it leaves evidence on every change.
Section 8(4): The Closest Thing to a Privacy by Design Duty
"A Data Fiduciary shall implement appropriate technical and organisational measures to ensure effective observance of the provisions of this Act and the rules made thereunder." -- Section 8(4), DPDPA 2023
This is not a suggestion. The Act requires "appropriate technical and organisational measures" -- not just a security policy PDF filed in a shared drive. A CI/CD pipeline with automated compliance gates is precisely the kind of technical measure Section 8(4) contemplates: a system that enforces the provisions of the Act at every code change.
A DPDPA compliance assessment tells you which of these gates your obligations actually need before you build them.
Section 8(5) and Rule 6(1): Reasonable Security Safeguards, Specified
Section 8(5) requires Data Fiduciaries to take "reasonable security safeguards to prevent personal data breach." The DPDP Rules 2025, Rule 6(1), specify what "reasonable" means in practice:
"A Data Fiduciary shall protect personal data in its possession or under its control, including in respect of any processing undertaken by it or on its behalf by a Data Processor, by taking reasonable security safeguards to prevent personal data breach, which shall include, at the minimum,— (a) appropriate data security measures, such as securing of personal data through encryption, obfuscation, masking or the use of virtual tokens mapped to that personal data; (b) appropriate measures to control access to the computer resources used by such Data Fiduciary or such a Data Processor, wherever applicable; (c) visibility on the accessing of such personal data, through appropriate logs, monitoring and review, for enabling detection of unauthorised access, its investigation and remediation to prevent recurrence; (d) reasonable measures for continued processing in the event of confidentiality, integrity or availability of such personal data being compromised as a result of destruction or loss of access to personal data or otherwise, such as by way of data-backups; (e) for enabling the detection of unauthorised access, its investigation, remediation to prevent recurrence and continued processing in the event of such a compromise, retain such logs and personal data for a period of one year, unless compliance with any law for the time being in force requires otherwise; (f) appropriate provision in the contract entered into between such Data Fiduciary and such a Data Processor, wherever applicable, for taking reasonable security safeguards; and (g) appropriate technical and organisational measures to ensure effective observance of security safeguards." -- Rule 6(1), DPDP Rules 2025 (in force from 13 May 2027)
Every one of these requirements can be verified programmatically in a pipeline. Encryption configuration, access control policies, logging setup, backup configuration, retention settings, and processor contract enforcement -- all of these have infrastructure-as-code representations that a CI job can validate.
Section 6(1): Data Minimisation
"The consent given by the Data Principal shall be free, specific, informed, unconditional and unambiguous with a clear affirmative action, and shall signify an agreement to the processing of her personal data for the specified purpose and be limited to such personal data as is necessary for such specified purpose." -- Section 6(1), DPDPA 2023
The phrase "limited to such personal data as is necessary" establishes a statutory data minimisation principle. In code, this means: do not collect fields you do not need, do not log PII unnecessarily, and do not pass personal data to services that have no business processing it. Custom SAST rules can catch violations of this principle at the pull request stage.
Section 8(7): Erasure Capability as a Technical Requirement
Section 8(7) obligates Data Fiduciaries to erase personal data upon consent withdrawal or purpose completion. For large e-commerce, online gaming and social media platforms, Rule 8(1) and the Third Schedule add a fixed erasure deadline: three years after the Data Principal last approached the platform or exercised her rights, with a 48-hour warning under Rule 8(2). This is not a future compliance item -- it is a data architecture requirement that your schema and API design must support from the start. A pipeline check can verify that database migration files include the soft-delete or hard-delete mechanisms required for erasure workflows.
Rule 13(3): Algorithmic Software Verification (SDFs)
For Significant Data Fiduciaries, Rule 13(3) requires due diligence to verify that "algorithmic software adopted by it for hosting, display, uploading, modification, publishing, transmission, storage, updating or sharing of personal data processed by it are not likely to pose a risk to the rights of Data Principals." The rule does not name any tooling, but ML model scanning in the deployment pipeline is one practical way to evidence this due diligence.
The Engineering Translation: Framework Controls for Pipeline Automation
Each obligation maps to a framework control and a pipeline tool: Rule 6(1)(a) to encryption checks on infrastructure code, Section 6(1)'s limit to necessary data to SAST rules on collected fields, and Section 8(7) to an erasure-capability check before deploy.
| DPDPA Obligation | Section/Rule | Framework Control | CI/CD Implementation |
|---|---|---|---|
| Appropriate technical measures | S.8(4) | ISO A.8.25 (Secure development lifecycle) | Pipeline-enforced quality gates |
| Encryption at rest and in transit | Rule 6(1)(a) | ISO A.8.24 (Use of cryptography), NIST PR.DS-01 | IaC policy checks (terraform validate, OPA) |
| Access control measures | Rule 6(1)(b) | ISO A.8.3 (Information access restriction), SOC 2 CC6.3 | IAM policy validation, least-privilege checks |
| Logging and monitoring | Rule 6(1)(c) | ISO A.8.15 (Logging), NIST DE.CM-01 | Config validation for log shipping |
| Data backup measures | Rule 6(1)(d) | ISO A.8.13 (Information backup) | Backup config validation in IaC |
| Log retention (1 year minimum) | Rule 6(1)(e), Rule 8(3) | ISO A.8.15 (Logging) | Retention policy as code |
| Data minimisation | S.6(1) | NIST Privacy CT.DP-P1 | Custom SAST rules for over-collection |
| Erasure capability | S.8(7) | ISO A.8.10 (Information deletion) | Schema migration checks |
| Breach detection readiness | S.8(6), Rule 7 | ISO A.5.24 (Incident management), SOC 2 CC7.3 | Alerting config validation |
| Secure coding | S.8(5) | ISO A.8.28 (Secure coding), SOC 2 CC6.1 | SAST, dependency scanning, secrets detection |
| Algorithmic risk (SDF only) | Rule 13(3) | NIST GV.PO-P1 | ML model fairness scanning |
Threat Model: STRIDE and LINDDUN in the Pipeline Context
Two privacy-relevant threats are particularly suited to CI/CD detection:
- STRIDE -- Information Disclosure: SAST rules catch hardcoded PII, credentials, and personal data in log statements before they reach production. This directly prevents the "accidental disclosure" component of a "personal data breach" under Section 2(u).
- LINDDUN -- Linkability and Identifiability: Data flow analysis in the pipeline can detect when personal data from separate processing purposes is being correlated without authorisation, or when test data contains real identifiable information.
Implementation Guide: Privacy-Aware CI/CD Pipeline
Three gates, in order: SAST and secrets scanning on every pull request, policy checks on infrastructure code before it is applied, and a privacy gate before production. A failure at any gate blocks the merge or the release.
What Does DPDPA Require for Your CI/CD Pipeline?
The three-gate architecture below maps to the Rule 6(1) enumeration of minimum security safeguards. Each gate is independently blockable — a failure at Gate 1 prevents progression to Gate 2, and so on. Here is the ordered sequence for setting up the complete pipeline:
- Configure pre-commit hooks with the PII detection patterns (see Gate 1 below) — catches violations before they enter the CI system at all.
- Add the Gate 1 SAST workflow file (
.github/workflows/dpdpa-privacy-checks.yml) and the custom Semgrep rules (.semgrep/dpdpa-rules.yml) to your repository. - Add the Gate 2 OPA policy files (
policies/dpdpa/encryption.rego,policies/dpdpa/retention.rego) and wire the IaC validation job as a dependency of both Gate 1 jobs (needs: [sast-privacy-scan, secrets-scan]). - Add the erasure check (
check_erasure_support.py) and the PII fields config (config/pii-fields.yaml). Purpose-binding and retention checks depend on your API spec and data model, so write those for your own codebase. - Add the Gate 3 deployment job (
privacy-deployment-gate) gated onneeds: iac-policy-checkandif: github.ref == 'refs/heads/main'. - Run all three gates in audit mode on the existing codebase first — generate a baseline violation report, triage by severity, and clear the backlog before switching to blocking mode.
Architecture Overview
The pipeline architecture adds three privacy-specific gate types to your existing DevSecOps flow:
flowchart LR
A[Developer Push] --> B[Pre-Commit Hooks]
B --> C[CI Pipeline Triggered]
C --> D{Gate 1:<br/>SAST + Secrets}
D -->|Pass| E{Gate 2:<br/>IaC Policy Check}
D -->|Fail| F[Block Merge<br/>+ Report Finding]
E -->|Pass| G{Gate 3:<br/>Privacy Deployment Gate}
E -->|Fail| F
G -->|Pass| H[Deploy to Staging]
G -->|Fail| F
H --> I[Post-Deploy Validation]
I --> J[Production Deploy]
style D fill:#f9d6d6,stroke:#d44
style E fill:#fef3cd,stroke:#d4a
style G fill:#d4edda,stroke:#28a745
Alt Text: Flowchart showing a CI/CD pipeline with three privacy-specific gates -- SAST and secrets scanning (red), infrastructure-as-code policy checks (yellow), and privacy deployment gates (green) -- each capable of blocking a merge on failure.
Gate 1: SAST and Secrets Scanning for Personal Data Exposure
This gate catches the most common source of DPDPA-relevant vulnerabilities: personal data leaking through code patterns.
What it checks (mapped to DPDPA obligations):
| Check | DPDPA Obligation | Example Violation |
|---|---|---|
| PII in log statements | S.8(5), Rule 6(1)(a) (masking) | logger.info(f"User email: {user.email}") |
| Hardcoded personal data | S.8(5) | test_aadhaar = "1234-5678-9012" |
| Secrets in source | S.8(5), Rule 6(1)(b) | DB_PASSWORD = "prod_secret_123" |
| Over-collection patterns | S.6(1) | API endpoint requesting fields beyond stated purpose |
| Unencrypted PII storage | Rule 6(1)(a) | Personal data stored in plaintext columns |
GitHub Actions configuration:
# .github/workflows/dpdpa-privacy-checks.yml
# Third-party actions are pinned to a commit SHA; the comment gives the tag.
name: DPDPA Privacy Compliance Checks
on:
pull_request:
branches: [main, develop]
push:
branches: [main]
permissions:
contents: read
jobs:
sast-privacy-scan:
name: "Gate 1: SAST + PII Detection"
runs-on: ubuntu-latest
container:
# semgrep/semgrep-action is archived; Semgrep's recommended setup runs its image directly.
image: semgrep/semgrep:1.140.0
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Run Semgrep with DPDPA custom rules
run: >-
semgrep scan --error
--config p/secrets
--config p/owasp-top-ten
--config .semgrep/dpdpa-rules.yml
src/
- name: Detect PII in log statements
shell: bash
run: |
# Custom grep-based check for common PII logging patterns
# Flags: aadhaar, PAN, email, phone in log/print statements
VIOLATIONS=$(grep -rn \
-e 'log.*\(.*aadhaar\|aadhar\|pan_number\|email.*@\)' \
-e 'print.*\(.*aadhaar\|aadhar\|pan_number\)' \
-e 'logger\.\(info\|debug\|warn\).*\(.*email\|phone\|mobile\)' \
--include="*.py" --include="*.js" --include="*.ts" \
--include="*.java" --include="*.go" \
src/ || true)
if [ -n "$VIOLATIONS" ]; then
echo "::error::DPDPA Gate 1 FAILED: PII detected in log statements"
echo "$VIOLATIONS"
echo "Violation: Section 8(5) - reasonable security safeguards"
echo "Rule 6(1)(a): secure personal data by masking or obfuscation; keep it out of logs"
exit 1
fi
- name: Scan for hardcoded test data with real PII patterns
shell: bash
run: |
# Check for Aadhaar number patterns (XXXX XXXX XXXX or XXXX-XXXX-XXXX)
# Check for PAN patterns (AAAAA0000A)
# [[:space:]] is the POSIX class; "\s" inside [...] would only match a backslash or "s".
AADHAAR_HITS=$(grep -rnE \
'\b[0-9]{4}[[:space:]-][0-9]{4}[[:space:]-][0-9]{4}\b' \
--include="*.py" --include="*.js" --include="*.ts" \
--include="*.json" --include="*.yaml" --include="*.yml" \
src/ tests/ fixtures/ 2>/dev/null || true)
PAN_HITS=$(grep -rnE \
'\b[A-Z]{5}[0-9]{4}[A-Z]\b' \
--include="*.py" --include="*.js" --include="*.ts" \
--include="*.json" --include="*.yaml" --include="*.yml" \
src/ tests/ fixtures/ 2>/dev/null || true)
if [ -n "$AADHAAR_HITS" ] || [ -n "$PAN_HITS" ]; then
echo "::warning::Potential real PII in test fixtures."
echo "$AADHAAR_HITS"
echo "$PAN_HITS"
echo "DPDPA Section 6(1): data must be limited to what is necessary."
echo "Use synthetic/anonymised test data instead."
fi
secrets-scan:
name: "Gate 1: Verified secrets"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Run TruffleHog for secrets
uses: trufflesecurity/trufflehog@31ce31ee1abbcc7dc8eee5764c17121c3044c8b2 # v3.99.7
with:
extra_args: --only-verifiedThe tested version of this code, with its test suite, is in the ci-cd folder of our open-source DPDPA Engineering Kit on GitHub.
Equivalent GitLab CI configuration:
# .gitlab-ci.yml (privacy gates section)
stages:
- privacy-scan
- iac-validate
- deploy-gate
- deploy
dpdpa-sast-scan:
stage: privacy-scan
image: semgrep/semgrep:1.140.0
script:
# --gitlab-sast writes GitLab's SAST report schema; plain --json output is
# not accepted by artifacts:reports:sast.
- semgrep scan --config p/secrets --config p/owasp-top-ten
--config .semgrep/dpdpa-rules.yml
--error --gitlab-sast --output gl-sast-report.json src/
- |
# PII in log statements check (same patterns as the GitHub workflow;
# the \( ... \) groups keep each alternation inside its log call)
VIOLATIONS=$(grep -rn \
-e 'log.*\(.*aadhaar\|aadhar\|pan_number\|email.*@\)' \
-e 'print.*\(.*aadhaar\|aadhar\|pan_number\)' \
-e 'logger\.\(info\|debug\|warn\).*\(.*email\|phone\|mobile\)' \
--include="*.py" --include="*.js" --include="*.ts" \
--include="*.java" --include="*.go" \
src/ || true)
if [ -n "$VIOLATIONS" ]; then
echo "DPDPA Gate 1 FAILED: PII in log statements"
echo "$VIOLATIONS"
echo "Ref: Section 8(5), Rule 6(1)(a)"
exit 1
fi
artifacts:
when: always
reports:
sast: gl-sast-report.json
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "main"'Custom Semgrep rules for DPDPA-specific patterns:
# .semgrep/dpdpa-rules.yml
rules:
- id: dpdpa-pii-in-logs
message: >
Logging personal data undermines the DPDPA Section 8(5) safeguards
duty; Rule 6(1)(a) lists masking and obfuscation. PII must not appear in application logs.
Use a structured logger with PII field redaction.
severity: ERROR
languages: [python]
patterns:
- pattern-either:
- pattern: logging.$LEVEL(..., $EXPR, ...)
- pattern: logger.$LEVEL(..., $EXPR, ...)
- metavariable-regex:
metavariable: $EXPR
regex: .*(email|phone|aadhaar|pan_number|mobile|address).*
- id: dpdpa-unencrypted-pii-storage
message: >
Storing personal data without encryption, masking or
tokenisation falls short of Rule 6(1)(a). Use field-level encryption or ensure
the storage backend has encryption at rest enabled.
severity: WARNING
languages: [python]
# Django declares fields in the class body (`email = models.CharField(...)`),
# and metavariable-regex has to sit under `patterns`.
patterns:
- pattern-inside: |
class $MODEL(...):
...
- pattern: $FIELD = models.CharField(...)
- metavariable-regex:
metavariable: $FIELD
regex: ^(aadhaar|aadhaar_number|pan|pan_number|email|phone|mobile|address|dob|date_of_birth)$
- id: dpdpa-excessive-data-collection
message: >
API endpoint collects more fields than may be necessary
for the stated purpose. Review against DPDPA Section 6(1)
data minimisation requirement.
severity: WARNING
languages: [python]
# Meta.fields belongs to ModelSerializer; a plain Serializer has no Meta.
pattern: |
class $SERIALIZER(serializers.ModelSerializer):
...
class Meta:
...
fields = '__all__'Gate 2: Infrastructure-as-Code Policy Validation
This gate validates that your infrastructure configuration meets the technical requirements specified in Rule 6(1).
# .github/workflows/dpdpa-privacy-checks.yml (continued)
iac-policy-check:
name: "Gate 2: IaC DPDPA Policy Validation"
runs-on: ubuntu-latest
needs: [sast-privacy-scan, secrets-scan]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1
with:
terraform_wrapper: false
- name: Install OPA
uses: open-policy-agent/setup-opa@b2b258e089860efaadaaf71bf6e3aecb4a3eeff1 # v2.4.0
with:
version: 1.10.1
- name: Plan Terraform
working-directory: infrastructure
run: |
# The plan needs read-only cloud credentials (e.g. OIDC) configured for this job.
terraform init -backend=false -input=false
terraform plan -input=false -out=tfplan.binary
terraform show -json tfplan.binary > ../tfplan.json
- name: Check encryption at rest and log retention (Rules 6(1)(a), 6(1)(e), 8(3))
run: |
# `opa eval --fail-defined` exits non-zero when the query returns any result,
# so each deny message becomes a failed gate.
opa eval --data policies/dpdpa/ --input tfplan.json --format pretty \
'msgs := [m | m := data.dpdpa[_].deny[_]]'
if ! opa eval --data policies/dpdpa/ --input tfplan.json --fail-defined \
'data.dpdpa[_].deny[_]' > /dev/null; then
echo "::error::DPDPA Gate 2 FAILED: see the deny messages above"
exit 1
fiExample OPA policy for DPDPA encryption requirements:
# policies/dpdpa/encryption.rego
# Rule 6(1)(a) lists encryption among the reasonable security safeguards for
# personal data. Used as a CI/CD gate on `terraform show -json` plan output.
#
# Rego v1 syntax (OPA 1.0+).
package dpdpa.encryption
# S3 default encryption must use KMS (SSE-S3 is on by default for every new
# bucket since January 2023, so "no encryption" no longer happens; the useful
# check is which keys are used).
deny contains msg if {
resource := input.resource_changes[_]
resource.type == "aws_s3_bucket_server_side_encryption_configuration"
rule := resource.change.after.rule[_]
algo := rule.apply_server_side_encryption_by_default[_].sse_algorithm
not algo in {"aws:kms", "aws:kms:dsse"}
msg := sprintf(
"S3 default encryption must use aws:kms, found %s. Rule 6(1)(a) lists encryption as a safeguard; KMS keys give the access control and audit trail behind it. [%s]",
[algo, resource.address],
)
}
# RDS instances must have storage encryption on
deny contains msg if {
resource := input.resource_changes[_]
resource.type == "aws_db_instance"
not is_true(resource.change.after, "storage_encrypted")
msg := sprintf(
"RDS instance '%s' has storage_encrypted off. Rule 6(1)(a) lists encryption as a safeguard. [%s]",
[resource.change.after.identifier, resource.address],
)
}
# RDS instances should use a customer-managed KMS key
deny contains msg if {
resource := input.resource_changes[_]
resource.type == "aws_db_instance"
resource.change.after.storage_encrypted == true
not has_value(resource.change.after, "kms_key_id")
not known_after_apply(resource, "kms_key_id")
msg := sprintf(
"RDS instance '%s' uses the AWS-managed key. Policy: use a customer-managed KMS key so you control rotation, access and deletion (DPDPA does not name a key type). [%s]",
[resource.change.after.identifier, resource.address],
)
}
# EBS volumes must be encrypted
deny contains msg if {
resource := input.resource_changes[_]
resource.type == "aws_ebs_volume"
not is_true(resource.change.after, "encrypted")
msg := sprintf(
"EBS volume %s is unencrypted. Rule 6(1)(a). [%s]",
[object.get(object.get(resource.change.after, "tags", {}), "Name", "(untagged)"), resource.address],
)
}
# ElastiCache must encrypt at rest and in transit
deny contains msg if {
resource := input.resource_changes[_]
resource.type == "aws_elasticache_replication_group"
not is_true(resource.change.after, "at_rest_encryption_enabled")
msg := sprintf(
"ElastiCache '%s' lacks at-rest encryption. Rule 6(1)(a). [%s]",
[resource.change.after.replication_group_id, resource.address],
)
}
deny contains msg if {
resource := input.resource_changes[_]
resource.type == "aws_elasticache_replication_group"
not is_true(resource.change.after, "transit_encryption_enabled")
msg := sprintf(
"ElastiCache '%s' lacks in-transit encryption. Rule 6(1)(a). [%s]",
[resource.change.after.replication_group_id, resource.address],
)
}
# Plan JSON writes unset attributes as null, which Rego's `not` does not treat as false
has_value(obj, attr) if {
not object.get(obj, attr, null) in {null, ""}
}
# A value Terraform will only know after apply (e.g. a key ARN created in the same plan)
known_after_apply(resource, attr) if {
resource.change.after_unknown[attr] == true
}
is_true(obj, attr) if {
object.get(obj, attr, false) == true
}The log-retention policy that the same Gate 2 query picks up:
# policies/dpdpa/retention.rego
# Rules 6(1)(e) and 8(3) keep logs of personal data processing for at least one year.
# Gate 2 of the privacy-by-design pipeline runs this on `terraform show -json` plan output.
package dpdpa.retention
min_days := 365
# CloudWatch log groups must keep logs for a year. retention_in_days = 0 (or unset) means "never expire".
deny contains msg if {
resource := input.resource_changes[_]
resource.type == "aws_cloudwatch_log_group"
days := object.get(resource.change.after, "retention_in_days", 0)
days != null
days > 0
days < min_days
msg := sprintf(
"Log group %s keeps logs for %d days; Rules 6(1)(e) and 8(3) need at least %d. [%s]",
[object.get(resource.change.after, "name", "(unnamed)"), days, min_days, resource.address],
)
}Gate 3: Privacy Deployment Gate
The final gate runs before production deployment and performs higher-level checks that require application context.
# .github/workflows/dpdpa-privacy-checks.yml (continued)
privacy-deployment-gate:
name: "Gate 3: Privacy Deployment Validation"
runs-on: ubuntu-latest
needs: iac-policy-check
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"
- name: Verify erasure capability exists (Section 8(7))
run: |
pip install pyyaml==6.0.2
# Check that all models storing personal data have
# a corresponding erasure/anonymisation method
python scripts/check_erasure_support.py \
--models-dir src/models/ \
--pii-fields-config config/pii-fields.yaml
# Exit code 1 if any PII model lacks erasure support
# Gate 3 can also check purpose bindings against your API spec, check
# retention settings and generate a compliance report. Those scripts
# depend on your codebase, so they are not shown; add them here once
# you have written them.Supporting Script: PII Erasure Capability Check
#!/usr/bin/env python3
"""
check_erasure_support.py
Validates that every model containing PII fields has a corresponding
erasure method, satisfying DPDPA Section 8(7) erasure obligations.
Usage: python check_erasure_support.py \
--models-dir src/models/ \
--pii-fields-config config/pii-fields.yaml
"""
import argparse
import ast
import sys
from pathlib import Path
import yaml
def load_pii_fields(config_path: str) -> set:
"""Load the set of field names classified as PII."""
with open(config_path) as f:
config = yaml.safe_load(f)
return set(config.get("pii_field_names", []))
def check_model_file(file_path: Path, pii_fields: set) -> list:
"""Parse a Python model file and check for erasure support."""
violations = []
source = file_path.read_text()
tree = ast.parse(source, filename=str(file_path))
for node in ast.walk(tree):
if not isinstance(node, ast.ClassDef):
continue
# Find fields that match PII field names
model_pii_fields = []
has_erasure_method = False
for item in node.body:
# Check for PII field assignments
# `email = models.CharField()` (Django) and annotated fields such as
# `email: str` (dataclasses, Pydantic) or `email: Mapped[str] = ...` (SQLAlchemy 2.0)
targets = item.targets if isinstance(item, ast.Assign) else (
[item.target] if isinstance(item, ast.AnnAssign) else []
)
for target in targets:
if isinstance(target, ast.Name):
if target.id in pii_fields:
model_pii_fields.append(target.id)
# Check for erasure/anonymise method
if isinstance(item, (ast.FunctionDef, ast.AsyncFunctionDef)):
if item.name in ("erase", "anonymise", "anonymize",
"delete_personal_data", "gdpr_erase",
"dpdpa_erase"):
has_erasure_method = True
if model_pii_fields and not has_erasure_method:
violations.append({
"file": str(file_path),
"model": node.name,
"pii_fields": model_pii_fields,
"violation": (
f"Model '{node.name}' contains PII fields "
f"{model_pii_fields} but has no erasure method. "
f"DPDPA Section 8(7) requires erasure capability."
),
})
return violations
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--models-dir", required=True)
parser.add_argument("--pii-fields-config", required=True)
args = parser.parse_args()
pii_fields = load_pii_fields(args.pii_fields_config)
models_dir = Path(args.models_dir)
all_violations = []
for py_file in models_dir.rglob("*.py"):
violations = check_model_file(py_file, pii_fields)
all_violations.extend(violations)
if all_violations:
print(f"DPDPA GATE 3 FAILED: {len(all_violations)} model(s) "
f"lack erasure support")
for v in all_violations:
print(f" - {v['violation']}")
sys.exit(1)
else:
print("DPDPA Gate 3 PASSED: All PII models have erasure methods")
sys.exit(0)
if __name__ == "__main__":
main()PII Fields Configuration
# config/pii-fields.yaml
# Fields classified as personal data under DPDPA Section 2(t)
# "personal data means any data about an individual who is
# identifiable by or in relation to such data"
pii_field_names:
# Direct identifiers
- aadhaar
- aadhaar_number
- pan
- pan_number
- passport_number
- voter_id
# Contact information
- email
- email_address
- phone
- phone_number
- mobile
- mobile_number
- address
- postal_code
- pincode
# Biometric, health and financial (DPDPA has no separate 'sensitive' category)
- date_of_birth
- dob
- gender
- biometric_data
- health_data
- financial_data
# Behavioural (relevant for Section 9 -- children)
- location_data
- browsing_history
- device_fingerprint
- ip_address
Pipeline Integration: End-to-End Flow
The three gates sit inside your existing deployment flow, and each writes an audit entry. Keeping those entries for a year matches the one-year log minimums in Rule 6(1)(e) and Rule 8(3).
sequenceDiagram
participant Dev as Developer
participant PR as Pull Request
participant G1 as Gate 1: SAST
participant G2 as Gate 2: IaC
participant G3 as Gate 3: Deploy
participant Prod as Production
participant Audit as Audit Trail
Dev->>PR: Push code changes
PR->>G1: Trigger SAST + secrets scan
G1->>G1: Semgrep custom rules (PII in logs)
G1->>G1: TruffleHog (secrets detection)
G1->>G1: PII pattern matching (Aadhaar, PAN)
alt Gate 1 fails
G1->>PR: Block merge + report violations
G1->>Audit: Log finding (S.8(5) non-compliance)
else Gate 1 passes
G1->>G2: Trigger IaC policy check
end
G2->>G2: OPA/Rego: encryption at rest check
G2->>G2: OPA/Rego: log retention >= 365 days
G2->>G2: OPA/Rego: IAM least-privilege check
alt Gate 2 fails
G2->>PR: Block merge + report violations
G2->>Audit: Log finding (Rule 6(1) non-compliance)
else Gate 2 passes
G2->>G3: Trigger deployment gate
end
G3->>G3: Erasure capability check (S.8(7))
G3->>G3: Purpose binding validation (S.6(1))
G3->>G3: Retention config check (Rule 8(1))
alt Gate 3 fails
G3->>PR: Block deploy + report violations
else Gate 3 passes
G3->>Prod: Deploy to production
G3->>Audit: Generate compliance report
end
Audit->>Audit: Retain reports with logs for >= 1 year (Rules 6(1)(e), 8(3))
Alt Text: Sequence diagram showing the end-to-end flow of a DPDPA privacy-aware CI/CD pipeline with three gates -- SAST scanning, infrastructure-as-code policy validation, and deployment-time privacy checks -- each generating audit trail entries retained for one year per Rule 8(3).
GitHub Actions DPDPA Gates (YAML)
FAQ: DPDPA Privacy by Design in CI/CD
Does DPDPA require privacy by design?
Not by that name. Section 8(4) requires Data Fiduciaries to implement "appropriate technical and organisational measures to ensure effective observance of the provisions of this Act and the rules made thereunder." The Act never uses the phrase "privacy by design", but building those measures into your systems from the start, for example as CI/CD gates, is a practical way to meet Section 8(4).
What CI/CD gates are required for DPDPA compliance?
The DPDPA does not prescribe specific pipeline tooling, but Rule 6(1) enumerates what "reasonable security safeguards" must achieve: encryption of personal data (Rule 6(1)(a)), access control (Rule 6(1)(b)), logging and monitoring (Rule 6(1)(c)), backup and availability (Rule 6(1)(d)), and one-year retention of logs and personal data (Rule 6(1)(e)). The three-gate architecture in this guide — SAST, IaC policy validation, and deployment checks — maps directly to this enumeration.
How do you detect PII in code at commit time?
The most effective approach combines three layers: (1) pre-commit hooks using grep patterns for Aadhaar (XXXX-XXXX-XXXX format), PAN (AAAAA0000A format), and common field names; (2) Semgrep custom rules that do semantic analysis — detecting PII in log calls even when the field name is an indirect variable reference; and (3) TruffleHog for credential and secrets detection. The PII fields config (config/pii-fields.yaml) shown in this guide defines the canonical list of field names classified as personal data under DPDPA Section 2(t).
What is Section 8(4) of DPDPA?
Section 8(4) is the closest the DPDPA comes to a privacy by design duty. It states: "A Data Fiduciary shall implement appropriate technical and organisational measures to ensure effective observance of the provisions of this Act and the rules made thereunder." Read with Rule 6(1)'s minimum security safeguards, it calls for technical controls, not only policies. A breach of Section 8(4) falls under item 7 of the Schedule (any other provision), with a penalty of up to fifty crore rupees.
How does DPDPA privacy-by-design compare to GDPR Article 25?
| Dimension | DPDPA Section 8(4) | GDPR Article 25 |
|---|---|---|
| Explicit "privacy by design" language | No — uses "appropriate technical and organisational measures" | Yes — explicitly names "data protection by design and by default" |
| Scope | All Data Fiduciaries | All Data Controllers |
| Default protections mandate | Implied via S.8(5) and Rule 6(1) | Explicit: "only personal data which are necessary for each specific purpose" by default |
| Certification mechanism | Not yet specified | Article 25(3) allows approved certification mechanisms |
| Enforcement anchor | S.8(4) + Schedule penalties | Article 83(4): up to €10M or 2% global turnover |
| Children's data | Section 9 (under-18; verifiable parental consent per Rule 10, with class- and purpose-based exemptions in Rule 12 and the Fourth Schedule) | Article 8 (varies by member state, typically 13-16) |
Myth: Privacy-by-design compliance requires a separate review gate that slows down deployments.
This is a common misconception. The three gates in this guide run in parallel with — or are integrated directly into — your existing CI jobs. Gate 1 (SAST) typically adds 2-4 minutes to a pull request check that already runs SAST. Gate 2 (IaC) runs alongside terraform plan validation. Gate 3 (deployment checks) runs in the same job sequence as your existing pre-production smoke tests. The automation cost is front-loaded: writing the rules and scripts. After that, the pipeline enforces privacy by design faster than any manual review process.
Common Pitfalls
The commonest mistake is treating a pipeline gate as the whole of Section 8(4). It catches problems early, but you still need runtime monitoring, incident playbooks, training and governance.
Q: Is a CI/CD privacy gate sufficient to satisfy Section 8(4)'s "appropriate technical and organisational measures"?
No single control satisfies Section 8(4) in isolation. A CI/CD pipeline with privacy gates is one layer of a defense-in-depth approach. You also need runtime controls (WAF, DLP, monitoring), organisational measures (training, incident response playbooks), and governance (DPIAs, audit schedules). The pipeline catches issues at the earliest and cheapest point in the development lifecycle -- but it is not a substitute for the rest of the stack.
Q: How do we handle false positives from PII detection rules?
Use a suppression mechanism with audit trail requirements. Every suppression should require: (1) a justification comment in code referencing the DPDPA section that makes it acceptable, (2) approval from a designated reviewer, and (3) periodic review of all suppressions. Never silently suppress findings -- that defeats the purpose of the gate and creates audit risk.
Q: Should the pipeline block merges or just warn?
For Gate 1 (secrets and hardcoded PII): block. These are clear violations with no legitimate justification. For Gate 2 (IaC policy): block for encryption and access control, warn for configuration best practices. For Gate 3 (deployment checks): block for missing erasure capability on PII models, warn for purpose binding gaps that may need product team input.
Q: What about existing code that predates these checks?
Run the gates in audit mode first. Generate a baseline report of all existing violations, prioritise them by severity (secrets and unencrypted PII first), and work through the backlog. Switch to blocking mode once the backlog is cleared. This is exactly how you would approach any SAST rollout -- the DPDPA context does not change the adoption pattern.
Q: How does this apply to Data Processors?
Under Section 8(1), the Data Fiduciary is responsible for compliance "in respect of any processing undertaken by it or on its behalf by a Data Processor." If you are a SaaS company acting as a Data Processor, Rule 6(1)(f) requires your Data Fiduciary client to make "appropriate provision in the contract" with you for taking reasonable security safeguards. These pipeline checks give those clients auditable evidence that you meet the safeguards the contract requires.
Q: What is the penalty exposure for not implementing technical measures?
The Schedule to the DPDPA specifies that breach of Section 8(5) (reasonable security safeguards) may attract a penalty extending to two hundred and fifty crore rupees (approximately USD 26 million at about ₹95/USD, October 2026). Breach of "any other provision" (which would include Section 8(4)) may extend to fifty crore rupees. These are maximum amounts; the Board considers factors including the nature of the breach, mitigation actions taken, and proportionality (Section 33(2)). The existence of automated pipeline controls is direct evidence of mitigation action under Section 33(2)(e).
Next Steps
Ready to embed DPDPA compliance into your deployment pipeline? StateCheck Security builds custom privacy-aware CI/CD gates tailored to your tech stack, data architecture, and DPDPA obligation profile. We do not just hand you YAML files -- we work with your engineering team to implement, tune, and maintain the gates as your codebase and the regulatory landscape evolve.
Request a DPDPA Compliance Audit
Related Articles
- The DPDPA to ISO 27001 Mapping Guide: Leveraging Annex A for Privacy Compliance -- Maps the DPDPA obligations referenced in this article to ISO 27001:2022 Annex A controls. Use it to understand which framework controls your pipeline gates are enforcing.
- SOC 2 Privacy Criteria vs. DPDPA: Bridging the Gap for Indian SaaS Companies -- If your SaaS company already holds SOC 2, this companion piece shows which Trust Services Criteria overlap with the DPDPA obligations automated by these pipeline gates.
- Threat Modeling for DPDPA: Adapting LINDDUN and STRIDE for Privacy -- Deep dive into the STRIDE and LINDDUN threat categories referenced in the framework mapping table above.
- The DPDPA Breach Notification: Automating SIEM Alerts to Legal Workflows -- What happens when your pipeline gates miss something and a breach occurs. The incident response automation companion to this prevention-focused article.
Primary sources
- The Digital Personal Data Protection Act, 2023 Act No. 22 of 2023, Gazette of India, 11 August 2023 (PDF, Ministry of Electronics and Information Technology)
- The Digital Personal Data Protection Rules, 2025 G.S.R. 846(E), Gazette of India, 13 November 2025 (PDF, Gazette of India)
This article is general information, not legal advice.