-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathdata-protection.yaml
More file actions
186 lines (162 loc) · 5.86 KB
/
data-protection.yaml
File metadata and controls
186 lines (162 loc) · 5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Data Protection Policy Template
# Prevents data leakage and ensures PII handling compliance
kernel:
version: "1.0"
mode: strict
template: data-protection
description: |
Policy for protecting sensitive data and preventing data leakage.
Suitable for applications handling PII, financial data, or health information.
signals:
enabled:
- SIGSTOP # Pause for human review
- SIGKILL # Terminate on critical violation
policies:
# ============================================
# PII Detection and Protection
# ============================================
- name: pii_detection
description: Detect and block exposure of personally identifiable information
severity: critical
scope: output # Check agent outputs
deny:
- patterns:
# Social Security Numbers (US)
- '\b\d{3}-\d{2}-\d{4}\b'
- '\b\d{9}\b' # SSN without dashes
# Credit Card Numbers
- '\b(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})\b'
# Email addresses (in sensitive contexts)
- '(?i)(email|e-mail)\s*[:=]\s*["\']?[\w.+-]+@[\w-]+\.[\w.-]+["\']?'
# Phone numbers
- '\b\d{3}[-.]?\d{3}[-.]?\d{4}\b'
# Passport numbers
- '(?i)passport\s*[:=]?\s*[A-Z0-9]{6,9}'
# Driver's license
- '(?i)driver.*license\s*[:=]?\s*[A-Z0-9]{5,15}'
action: SIGKILL
message: "PII detected in output - data must be masked or removed"
# ============================================
# Financial Data Protection
# ============================================
- name: financial_data_protection
description: Protect financial information
severity: critical
deny:
- patterns:
# Bank account numbers
- '(?i)(account|acct)\s*(?:number|#|no)?\s*[:=]?\s*\d{8,17}'
# Routing numbers
- '(?i)routing\s*(?:number|#)?\s*[:=]?\s*\d{9}'
# CVV/CVC
- '(?i)(cvv|cvc|cv2)\s*[:=]?\s*\d{3,4}'
action: SIGKILL
message: "Financial data exposure blocked"
# ============================================
# Health Data Protection (HIPAA)
# ============================================
- name: health_data_protection
description: Protect health-related information (HIPAA compliance)
severity: critical
deny:
- patterns:
# Medical Record Numbers
- '(?i)(mrn|medical\s*record)\s*[:=]?\s*[A-Z0-9]{6,12}'
# Health Insurance IDs
- '(?i)(insurance|member)\s*id\s*[:=]?\s*[A-Z0-9]{8,15}'
# Diagnosis codes
- '(?i)diagnosis\s*[:=]?\s*[A-Z]\d{2}\.\d{1,2}'
action: SIGKILL
message: "Protected health information (PHI) detected"
# ============================================
# Logging Safety
# ============================================
- name: safe_logging
description: Prevent sensitive data in logs
severity: high
deny:
- patterns:
# Logging passwords
- '(?i)log.*password'
- '(?i)console\.log.*password'
- '(?i)print.*password'
- '(?i)logger\..*password'
# Logging tokens/keys
- '(?i)log.*(?:token|api[_-]?key|secret)'
- '(?i)console\.log.*(?:token|api[_-]?key)'
action: SIGSTOP
message: "Sensitive data should not be logged"
# ============================================
# Data Retention
# ============================================
- name: data_retention_warnings
description: Warn about potential data retention issues
severity: medium
deny:
- patterns:
# Storing data without expiry
- '(?i)cache\.set\s*\([^)]*\)\s*[^,]*$' # Cache without TTL
- '(?i)localStorage\.setItem'
- '(?i)sessionStorage\.setItem'
action: SIGSTOP
message: "Consider data retention policies - add TTL or expiration"
# ============================================
# Data Export Controls
# ============================================
- name: data_export_controls
description: Monitor data export operations
severity: high
deny:
- patterns:
# Bulk data exports
- '(?i)SELECT\s+\*\s+FROM\s+\w+\s*;' # SELECT * without WHERE
- '(?i)pg_dump'
- '(?i)mysqldump'
- '(?i)mongodump'
action: SIGSTOP
message: "Bulk data export detected - ensure authorization"
# ============================================
# Encryption Requirements
# ============================================
- name: encryption_requirements
description: Ensure sensitive data is encrypted
severity: high
deny:
- patterns:
# Storing sensitive data in plain text
- '(?i)(password|secret|key)\s*=\s*["\'][^"\']+["\']'
# Weak hashing
- '(?i)md5\s*\('
- '(?i)sha1\s*\('
action: SIGSTOP
message: "Use strong encryption (AES-256, SHA-256+) for sensitive data"
# ============================================
# Third-Party Data Sharing
# ============================================
- name: third_party_sharing
description: Monitor data sharing with third parties
severity: medium
deny:
- patterns:
# External API calls with user data
- '(?i)(fetch|axios|requests)\s*\.\s*(get|post)\s*\([^)]*user'
action: SIGSTOP
message: "Review third-party data sharing for compliance"
audit:
enabled: true
log_path: "./logs/data-protection-audit.log"
include:
- all_violations
- pii_detections
- data_exports
retention_days: 365 # Longer retention for compliance
compliance:
frameworks:
- GDPR
- CCPA
- HIPAA
data_classification:
public: []
internal: ["email", "name"]
confidential: ["ssn", "credit_card", "health_data"]
restricted: ["password", "encryption_key"]