📑 ???
????DPR ????????????
????????????????????GDPR, Regulation (EU) 2016/679??? 2018 ??5 ??25 ???????????DPR ??strong>???????????rticle 3?????????????????????????????????????????????????????????????????????????????GDPR ?????/p>
????????GDPR ??????????????????????????strong>????????ersonal Data, Art. 4(1)???
- ?????????????????/strong>??-582/14 Breyer ?????????
- ????????????????????/li>
- ?????/strong>???????????????????P???????????????
- ?????????????????rt. 9???????????????????????
?????? GDPR ????????????????strong>??????????????strong>???????????/p>
| ??? | ???/??? | ????????? |
|---|---|---|
| Art. 5(1)(a) | ??????????????????/td> | ?????????????????/td> |
| Art. 5(1)(c) | ??????????ata Minimisation??/td> | ????????????????????/td> |
| Art. 15 | ??????Right of Access??/td> | ???????????? |
| Art. 17 | ??????Right to Erasure??/td> | ??????????????/td> |
| Art. 20 | ???????????Data Portability??/td> | JMAP ???/IMAP ??? |
| Art. 25 | Privacy by Design / Default | ?????????????????/td> |
| Art. 33-34 | ???????????? | 72 ???????????????????/td> |
| Art. 35 | ??????????????PIA??/td> | ??????????????? |
| Art. 44-49 | ????????? | ???????????CC??IA |
????rivacy by Design ?????????
2.1 ??????
GDPR Art. 25 ????????????????????????????????????????????????????????strong>?????/strong>??strong>????????????????????????????????????????????????/p>
- ?????????????????????????????/li>
- ???????????????????????????????/li>
- ????????????????????????????????
- ???????/strong>??????????????????Positive-Sum??/li>
- ???????????/strong>????????????????????/li>
- ???????????/strong>??????????????????
- ?????????????????????
- ???????????/strong>????????????????????/li>
2.2 ???????????????Art. 5(1)(e) ????????/h3>
???????????????????????????????????/p>
# Dovecot ?????????????????doveadm purge ??plugin??# ??????????expire ???
# /etc/dovecot/conf.d/90-plugin.conf
plugin {
# ???????????30 ???Trash?? expire = Trash 30
# ????????? 14 ???Spam?? expire2 = Spam 14
# ???????????365 ???Sent?? expire3 = Sent 365
# ??????????730 ?????????????? expire4 = 730
}
# ????????? doveadm ?????????
cat > /usr/local/bin/expire-old-emails.sh << 'SH'
#!/bin/bash
# ???????????????????????Dovecot ?????MAIL_DIR="/var/mail"
RETENTION_DAYS=730
TRASH_RETENTION=30
SPAM_RETENTION=14
# ???????????? 30 ??????
find "$MAIL_DIR" -path "*/Trash/*" -name "*,*" -type f -mtime +$TRASH_RETENTION -exec rm {} \;
find "$MAIL_DIR" -path "*/Spam/*" -name "*,*" -type f -mtime +$SPAM_RETENTION -exec rm {} \;
# ?????????????????????
find "$MAIL_DIR" -path "*/INBOX/*" -name "*,*" -type f -mtime +$RETENTION_DAYS -exec rm {} \;
# ??????
doveadm force-resync -u '*' 2>/dev/null
SH
# ????????? doveadm expunge ?????????
cat > /usr/local/bin/dovecot-expunge.sh << 'SH'
#!/bin/bash
# ?????????????????Dovecot ??????????????DOMAIN="example.com"
LOG_FILE="/var/log/mail-expunge-$(date +%Y%m%d).log"
# ???????????30 ??doveadm expunge -A mailbox Trash savedbefore 30d 2>&1 >> "$LOG_FILE"
doveadm expunge -A mailbox Junk savedbefore 14d 2>&1 >> "$LOG_FILE"
# ??????????730 ????????
doveadm expunge -A mailbox Sent savedbefore 730d 2>&1 >> "$LOG_FILE"
SH
chmod 755 /usr/local/bin/dovecot-expunge.sh
# crontab ??????
echo "0 2 * * 0 /usr/local/bin/dovecot-expunge.sh" > /etc/cron.d/dovecot-expunge
2.3 ??????????????
Privacy by Design ?????????????????strong>??????????????????????????????????????????/p>
# rsyslog ????????????
# /etc/logrotate.d/mail
/var/log/mail.log
/var/log/dovecot*.log
{
rotate 12
weekly
compress
delaycompress
missingok
notifempty
postrotate
# GDPR ????????????????????IP ???
# ???????????????????IP ???
invoke-rc.d rsyslog rotate > /dev/null 2>&1 || true
endscript
}
# Postfix ???????? ?????????????# /etc/postfix/main.cf
# ??????????????????:
# debug_peer_level ???????????debug_peer_level = 2
# SMTP ?????????????????????????smtpd_command_filter = pcre:/etc/postfix/command_filter.pcre
??????????????????????RFC 8620 JMAP??/h2>
3.1 ?????????????????
GDPR Art. 20 ??????????????????????????????/strong>???????????????????????????????????strong>?????????????/strong>??????????????????????/p>
JMAP??SON Meta Application Protocol??FC 8620??? IETF ??????????????????????????????????????????????MAP ??? JSON ??????????????????????????/p>
????????JMAP ????????????????????????????? IMAP ?????????????????? GDPR Art. 17??ight to Erasure / "Right to be Forgotten"??????????????????????????????????????/p>
???????????/strong>??rt. 17(3)??? ???????????????????????? ??? 1??????????????? ??? 2?????????????????/strong> ??? 3??????????????/strong> ??? GDPR Art. 17(3)(e) ???????????????????????????????????????
3.2 RFC 8620 JMAP ???
????/th> IMAP (RFC 9051) JMAP (RFC 8620) ?????? ??????????? FETCH JSON????????/td> ???/??? ?????? JMAP keyword ?????? ?????/td> ????????/td> JMAP Contacts (RFC 8616) ??? ????????/td> JMAP Calendars (RFC 8621) ?????? ??????????/td> ?????????????????? ?????? UIDNEXT + MODSEQ @since ??? + state ??? 3.3 JMAP ????????????
# JMAP ????????? Cyrus JMAP ??Stalwart JMAP??# ???????????JMAP ??? API ??????????????
# 1. ???????????????????????MAP Session Resource??cat > /usr/local/bin/jmap-export-for-user.py << 'PYTHON'
#!/usr/bin/env python3
"""
JMAP ?????? ??GDPR Art. 20 ???
?????????????????????????????? JSON ???
"""
import json
import requests
import os
import sys
JMAP_ENDPOINT = "https://mail.example.com/jmap"
def get_jmap_session(username, password):
"""??? JMAP Session Resource"""
resp = requests.post(JMAP_ENDPOINT, json={
"using": ["urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:mail",
"urn:ietf:params:jmap:contacts"],
"username": username,
"password": password
})
if resp.status_code != 200:
print(f"JMAP ??????: {resp.status_code}")
sys.exit(1)
return resp.json()
def export_all_mailboxes(session, username):
"""??????????????"""
api_url = session['apiUrl']
mailbox_state = session['mailboxState']
# ?????????? mailbox_resp = requests.post(api_url, json={
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
"methodCalls": [
["Mailbox/get", {"accountId": username}, "0"],
["Email/get", {"accountId": username, "fetchAllBodyValues": True}, "1"]
]
})
result = mailbox_resp.json()
return result
def save_export(username, data):
"""????????? JSON ???"""
output_dir = f"/tmp/gdpr-export-{username}"
os.makedirs(output_dir, exist_ok=True)
with open(f"{output_dir}/mailbox_dump.json", 'w') as f:
json.dump(data, f, indent=2)
# ??JSON ????????mbox ?????????
with open(f"{output_dir}/export.mbox", 'w') as mbox:
for email in data.get('emailList', []):
if 'textBody' in email or 'htmlBody' in email:
mbox.write(f"From {email.get('from', {})}\n")
mbox.write(f"Date: {email.get('receivedAt', '')}\n")
mbox.write(f"Subject: {email.get('subject', '')}\n")
mbox.write(f"\n{email.get('textBody', email.get('htmlBody', ''))}\n\n")
print(f"??????: {output_dir}")
print(f"??????: {sum(os.path.getsize(f'{output_dir}/{f}') for f in os.listdir(output_dir))} bytes")
return output_dir
if __name__ == '__main__':
username = sys.argv[1] if len(sys.argv) > 1 else input("?????")
password = os.environ.get('JMAP_EXPORT_PASSWORD') or input("???:")
session = get_jmap_session(username, password)
data = export_all_mailboxes(session, username)
save_export(username, data)
PYTHON
chmod 755 /usr/local/bin/jmap-export-for-user.py3.4 IMAP/mbox ???????????????
# ??? imapsync ????????????????????????
cat > /usr/local/bin/gdpr-imap-export.sh << 'SH'
#!/bin/bash
# GDPR Art. 20 ????????????IMAP ?????mbox
# ??????: ./gdpr-imap-export.sh user@example.com /tmp/export
USER="$1"
OUTDIR="$2"
if [ -z "$USER" ] || [ -z "$OUTDIR" ]; then
echo "???: $0 ??????????ight to Erasure??/h2>
4.1 ???????????/h3>
4.2 ????????????
# ????????????????????????
cat > /usr/local/bin/gdpr-account-erasure.sh << 'SH'
#!/bin/bash
# GDPR Art. 17 ???????????????????
# ???????????
# 1. ????????????Art. 12(6)??# 2. ?????????????????rt. 17(3)??# 3. ?????30 ??"????? ???
USER="$1"
if [ -z "$USER" ]; then
echo "???: $0 # Postfix ?????????????????
cat > /usr/local/bin/gdpr-anonymize-logs.sh << 'SH'
#!/bin/bash
# ????????????????????????????# ????????????????????LOG_DIR="/var/log"
for logfile in "$LOG_DIR"/mail.log.*.gz "$LOG_DIR"/dovecot*.log.*.gz; do
[ -f "$logfile" ] || continue
TMP_FILE="${logfile}.tmp"
# ??[redacted] ??????????????????
zcat "$logfile" | \
sed -E 's/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/[redacted-email]/g' | \
sed -E 's/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[redacted-ip]/g' | \
gzip > "$TMP_FILE"
mv "$TMP_FILE" "$logfile"
done
echo "??????????? $(date)"
SH
# ?????????????????cat > /usr/local/bin/gdpr-backup-erasure-manager.sh << 'SH'
#!/bin/bash
# ??????????????????????????BACKUP_RETENTION_DAYS=90
DELETED_USERS_DB="/var/lib/gdpr/deleted_users.sqlite"
# ???????????????
# ??pg_dump / rsync ????????deleted_users ?????????
echo "?????????: $(date)"
echo "?????????: ${BACKUP_RETENTION_DAYS} ??
echo ""
echo "????? ?????????????????????????????..."
# ?????????????????????????????? borg prune??SH
????????????????
5.1 ??????
GDPR Art. 33-34 ?????/p>
- ?????/strong>????????????????????72 ????????????????rt. 33(1)??/li>
- ?????????????????
- ??????????????????????????????????/strong>???????????????????????rt. 34(1)??/li>
- ?????/strong>??????????????????????????strong>????????????Art. 33(2)??/li>
5.2 ????????????????????
# ???????????????????cat > /usr/local/bin/detect-mail-breach.sh << 'SH'
#!/bin/bash
# ???????????????????????
# ???????????
REPORT="/var/log/breach-monitor-$(date +%Y%m%d).log"
echo "=== ????????????? $(date) ===" >> "$REPORT"
# 1. ???????????????????# Dovecot ?????find ???????????? IMAP FETCH
grep "$(date +%H:%M)" /var/log/dovecot.log | \
grep -i "FETCH\|F" | \
awk '{print $NF}' | sort | uniq -c | sort -rn | \
while read count user; do
if [ "$count" -gt 100 ]; then
echo "[ALERT] ?????????: ${user}: ${count} ??FETCH" >> "$REPORT"
fi
done
# 2. ?????????????????????????grep "$(date +%H:%M)" /var/log/mail.log | \
grep "SASL LOGIN authentication failed" | \
awk '{for(i=1;i<=NF;i++) if($i ~ /^[0-9.]+$/) print $i}' | \
sort | uniq -c | sort -rn | \
while read count ip; do
if [ "$count" -gt 10 ]; then
echo "[ALERT] ??????: ${ip}: ${count} ????? >> "$REPORT"
fi
done
# 3. ???????SMTP ????????? spam bot??# ??? pflogsumm ???
pflogsumm -d today /var/log/mail.log 2>/dev/null | \
grep -A 20 "Top 50 SMTP senders" >> "$REPORT"
echo "=== ??? ===" >> "$REPORT"
SH
chmod 755 /usr/local/bin/detect-mail-breach.sh
5.3 72 ?????????
????????????????????????
| ??? | ??? | ?????/th> | ??? |
|---|---|---|---|
| 0-2 h | ????????????????????/td> | ?????? | ????????? |
| 2-4 h | ???????????????????????/td> | ?????? | ????????? |
| 4-12 h | ?????????????????????????? | DFIR ??? | ?????? |
| 12-24 h | ?????????????????????????? | DPO / ??? | ????????? |
| 24-48 h | ??????????????rt. 33??/td> | DPO | ????????? |
| 48-72 h | ??????????????????Art. 34??/td> | DPO + ??? | ??????/???????? |
| ??2 h | ???????????? | DPO | ?????????????????/td> |
5.4 ?????????
GDPR ???????????rt. 33(3) ??????????????/p>
Subject: Personal Data Breach Notification ??Article 33 GDPR
To: [Supervisory Authority Email]
Date: [YYYY-MM-DD]
1. ???????? - ???: [Organization Name]
- DPO ??????: [DPO email / phone]
2. ??????
- ??????: [Date and time UTC]
- ??????: [Date and time UTC]
- ??????: [SMTP credential theft / Mailbox unauthorized access / etc.]
- ??????: [Postfix SMTP / Dovecot IMAP / Webmail / Backup]
3. ???????????????
- ?????????: [Email content, metadata, attachments, passwords]
- ???????????rt. 9?? [Yes/No + description]
- ????????????????? [Number]
- ???????????????????? [Number]
4. ??????
- [List of potential consequences for data subjects]
5. ??????????????????
- [Mitigation measures taken]
- [Planned remediation steps]
6. ?????????????? - [Reasons for delayed notification]
---
DPO Signature
?????????????????DPIA??/h2>
6.1 DPIA ?????????Art. 35??/h3>
GDPR Art. 35 ??????????????????????????????????????????????????????????????????????????????????????????????????????????? DPIA ????????/p>
- ?????????????????????????????????/?????/li>
- ?????????????????/strong>?????????????????????
- ??????????????????????????/li>
6.2 ?????? DPIA ???
# DPIA ???????????cat > /usr/local/bin/dpia-mail-assessment.py << 'PYTH3'
#!/usr/bin/env python3
"""
?????? GDPR DPIA ??????
?????????????????"""
import json
dpia_questions = [
{
"id": "Q1",
"question": "???????????????????????????????????????????",
"weight": 3,
"critical": True
},
{
"id": "Q2",
"question": "????????????????????????/???/?????,
"weight": 2,
"critical": True
},
{
"id": "Q3",
"question": "?????????????????5000 ???",
"weight": 1,
"critical": False
},
{
"id": "Q4",
"question": "????????????????????????????????,
"weight": 3,
"critical": True
},
{
"id": "Q5",
"question": "???????????????/?????????????????????",
"weight": 2,
"critical": False
},
{
"id": "Q6",
"question": "??????????????????????????? firstname.lastname@domain???",
"weight": 1,
"critical": False
},
{
"id": "Q7",
"question": "??????????????????????????,
"weight": -1, # ?????????? "critical": False
},
{
"id": "Q8",
"question": "?????????????????????",
"weight": -1, # ???
"critical": False
}
]
def run_dpia_assessment():
print("=== GDPR DPIA ????????? ===")
print("????????????y/n??")
score = 0
critical_flags = []
for q in dpia_questions:
answer = input(f"{q['question']} (y/n): ").strip().lower()
if answer == 'y':
score += q['weight']
if q['critical']:
critical_flags.append(q['id'])
elif answer == 'n' and q['weight'] < 0:
score += q['weight'] * -1 # ??????????????????
print("\n=== ?????? ===")
print(f"??????: {score}")
if score >= 5:
print("???: ???????????????? DPIA??rt. 35??)
elif score >= 3:
print("???: ????????????? DPIA")
else:
print("???: ????????????DPIA ???????????)
if critical_flags:
print(f"\n???????? {', '.join(critical_flags)}")
print("\n?????????:")
print("1. ???????????? TLS + ????????)
print("2. ????????????????????)
print("3. ?????????????????")
print("4. ??????????????????")
print("5. ??? Pseudonymization ?????????????????")
if __name__ == '__main__':
run_dpia_assessment()
PYTH3
chmod 755 /usr/local/bin/dpia-mail-assessment.py
????????????????/h2>
7.1 ??????
????????????????????EEA ?????????????????????????????DPR Chapter V, Art. 44-49???
| ??? | ?????? | ?????? |
|---|---|---|
| ????????/td> | Art. 45 | ???????????????????????"????????????????? |
| ???????????CC??/td> | Art. 46(2)(c) + ?????? 2021/914 | ????????????????????????????/td> |
| ???????????????BCR??/td> | Art. 47 | ?????????????????/td> |
| ???????????? | Art. 49(1)(a) | ???????????????????/td> |
| ??????????????/td> | Art. 49(1)(b) | ???????????????????? |
7.2 ???????????IA??/h3>
??? EDPB (European Data Protection Board) ??Recommendations 01/2020?????? SCC ??????????????????????????????????ransfer Impact Assessment, TIA???
# TIA ?????? ??????????????????cat > /usr/local/bin/tia-mail-flow-audit.sh << 'SH'
#!/bin/bash
# ?????????????????# ?????????????????????
echo "=== ?????????????????==="
echo "???: $(date)"
echo ""
# 1. ????SMTP ???????????MX ???????????echo "--- ?????? SMTP ?????????????????---"
# ??? pflogsumm ?????????
pflogsumm -d today /var/log/mail.log 2>/dev/null | \
grep -E "to=<[^>]+>" | \
awk -F@ '{print $NF}' | sed 's/>//' | \
sort | uniq -c | sort -rn | head -20
echo ""
# 2. ?????????????
echo "--- ???????????---"
curl -s ifconfig.co/json 2>/dev/null || echo "??????"
echo ""
# 3. ??????????????????????????
echo "--- ?????????????---"
# ???????Postfix ??? content_filter ??smtp ???
postconf -n content_filter smtpd_proxy_filter smtp_host_lookup 2>/dev/null
echo ""
# 4. ????????????
echo "--- ??????????---"
echo "????EU SCC ??? v2021 ????????
echo "????DPA????????????????????
7.3 SCC ???????????/h3>
??????????????????DPA??????????????SCC ??????
# Entity-based SCC (Module 2: Controller-to-Processor, EU 2021/914)
# ?????????????????????????????????
# ?????????????
# [ ] Clause 7: ???????????" - ??? Docking Clause
# [ ] Clause 8: ?????????????????# [ ] Clause 9: ??????????????????????????????????# [ ] Clause 10: ?????????????????SLA?????Art. 15-22??# [ ] Clause 11: ??????????????edress??# [ ] Clause 12: ??????????????????
# [ ] Annex I A: ???????????????
# [ ] Annex I B: ??????????????????????????????????# [ ] Annex I C: ??????
# [ ] Annex II: ????????????????????????????????????
# ?????? (Schrems II ??:
# [ ] TIA ????????????????????? SCC ????????# [ ] ?????????????????/code>
???????/h3>
- Regulation (EU) 2016/679 ??General Data Protection Regulation (GDPR). Official Journal of the European Union, May 2016. Art. 17 (Right to Erasure), Art. 20 (Data Portability), Art. 25 (Privacy by Design), Art. 33-34 (Breach Notification).
- RFC 8620 ??The JSON Meta Application Protocol (JMAP). IETF, July 2019.
- RFC 8616 ??Email Mailstore: JSON Meta Application Protocol (JMAP) for Mail. IETF, July 2019.
- EDPB ??Guidelines 01/2021 on Examples regarding Data Breach Notification (Version 2.0, June 2022).
- EDPB ??Recommendations 01/2020 on Measures that Supplement Transfer Tools to Ensure Compliance with the EU Level of Protection of Personal Data (Version 2.0, June 2021 / Schrems II).
- EDPB ??Guidelines 4/2019 on Article 25 Data Protection by Design and by Default (Version 2.0, October 2020).
- European Commission Implementing Decision (EU) 2021/914 ??Standard Contractual Clauses for the Transfer of Personal Data to Third Countries. June 2021.
- Article 29 Working Party ??Guidelines on Data Protection Impact Assessment (DPIA) and Determining Whether Processing Is "Likely to Result in High Risk" (WP 248, Rev. 1, October 2017).
- CJEU ??Case C-582/14 (Breyer) [email address as personal data].
- M3AAWG ??Email and GDPR: Compliance Considerations for Messaging Providers (2025 Update).
引用本文
ztpop.net 知识库编辑. "本文标题" ztpop.net 知识库.
本站技术文章采用 CC-BY 4.0 许可,可自由引用,仅需标注来源 ztpop.net。
