mcpField
D
data-privacy-compliance

data-privacy-compliance

github.com/davila7安全33.0k477 次安装1 天前更新
代码仓库

关于 data-privacy-compliance

data-privacy-compliance 为团队提供 GDPR、CCPA 和 HIPAA 等法规的隐私实践指导,涵盖数据主体请求、同意管理、影响评估、隐私设计和泄露响应。

主要功能

  1. 01GDPR、CCPA 和 HIPAA 指导
  2. 02数据主体权利流程
  3. 03同意管理模式
  4. 04DPIA 规划
  5. 05隐私设计实践
  6. 06数据泄露响应指导

适用场景

  1. 01建立隐私合规流程
  2. 02处理访问或删除请求
  3. 03设计同意与 Cookie 控制
  4. 04规划数据泄露响应

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/davila7/claude-code-templates --skill data-privacy-compliance

安装后在 Claude Code 中输入/data-privacy-compliance确认已加载。

详细介绍

数据隐私合规

为在 GDPR、CCPA、HIPAA 及其他全球数据保护法规下实施数据隐私合规提供全面指导。

何时使用本技能

在以下情况下使用本技能:

  • 实施 GDPR、CCPA 或 HIPAA 合规
  • 开展数据保护影响评估(DPIA)
  • 管理数据主体权利(访问、删除、可携带)
  • 实施同意管理系统
  • 起草隐私政策与通知
  • 处理数据泄露与事件响应
  • 设计隐私-by-design 系统
  • 开展隐私审计与评估

主要法规概览

GDPR(通用数据保护条例)

适用范围: 欧盟居民的数据,无论公司位于何处 关键要求:

  • 处理的合法依据(同意、合同、正当利益等)
  • 数据主体权利(访问、删除、可携带、反对)
  • 高风险处理的数据保护影响评估
  • 72 小时泄露通知要求
  • 处理活动记录
  • 隐私-by-design 和默认隐私保护

处罚: 最高 2000 万欧元或全球年收入的 4%

CCPA/CPRA(加州消费者隐私法案)

适用范围: 加州居民的数据 关键要求:

  • 知悉所收集数据的权利
  • 删除个人信息的权利
  • 选择退出出售/共享的权利
  • 更正不准确信息的权利
  • 限制使用敏感个人信息的权利

处罚: 每次故意违规最高 7,500 美元

HIPAA(健康保险流通与责任法案)

适用范围: 美国的受保护健康信息(PHI) 关键要求:

  • 隐私规则(患者权利与信息使用)
  • 安全规则(ePHI 的保障措施)
  • 泄露通知规则(60 天通知)
  • 商业伙伴协议(BAA)

处罚: 每类违规每年最高 150 万美元

数据主体权利实施

1. 访问权(GDPR 第 15 条 / CCPA § 1798.100)

请求处理器:

async function handleAccessRequest(userId, email) {
  // Verify identity
  const verified = await verifyIdentity(email);
  if (!verified) throw new Error('Identity verification failed');

  // Collect all personal data
  const userData = await collectUserData(userId);

  // Format for readability
  const report = {
    personalInfo: userData.profile,
    activityLogs: userData.activities,
    preferences: userData.settings,
    thirdPartySharing: userData.dataSharing,
    retentionPeriod: '2 years from last activity',
    dataProtectionOfficer: '[email protected]'
  };

  // Generate downloadable report
  const pdf = await generatePDFReport(report);

  // Log request for compliance
  await logAccessRequest(userId, 'completed');

  return pdf;
}

响应时限:

  • GDPR:1 个月(可延长至 3 个月)
  • CCPA:45 天(可延长至 90 天)
2. 删除权(GDPR 第 17 条 / CCPA § 1798.105)

删除处理器:

async function handleDeletionRequest(userId, email) {
  // Verify identity
  const verified = await verifyIdentity(email);
  if (!verified) throw new Error('Identity verification failed');

  // Check for legal obligations to retain
  const mustRetain = await checkRetentionRequirements(userId);
  if (mustRetain.required) {
    return {
      status: 'partial_deletion',
      retained: mustRetain.data,
      reason: mustRetain.legalBasis,
      retentionPeriod: mustRetain.period
    };
  }

  // Delete from all systems
  await Promise.all([
    deleteFromDatabase(userId),
    deleteFromBackups(userId), // Mark for deletion in next backup cycle
    deleteFromAnalytics(userId),
    deleteFromThirdPartyServices(userId),
    revokeAPIKeys(userId),
    anonymizeHistoricalRecords(userId)
  ]);

  // Confirm deletion
  await sendDeletionConfirmation(email);
  await logDeletionRequest(userId, 'completed');

  return { status: 'deleted', timestamp: new Date() };
}

例外情况(可拒绝删除):

  • 法律义务(税务记录、合同)
  • 公共利益/科学研究
  • 法律主张的抗辩
  • 行使言论自由
3. 数据可携带权(GDPR 第 20 条)

导出处理器:

async function handlePortabilityRequest(userId, format = 'json') {
  const userData = await collectUserData(userId);

  // Structure in machine-readable format
  const portableData = {
    exportDate: new Date().toISOString(),
    userId: userId,
    data: {
      profile: userData.profile,
      content: userData.userGeneratedContent,
      settings: userData.preferences,
      history: userData.activityHistory
    }
  };

  // Support multiple formats
  if (format === 'csv') {
    return convertToCSV(portableData);
  } else if (format === 'xml') {
    return convertToXML(portableData);
  }

  return portableData; // JSON by default
}

要求:

  • 结构化、常用、机器可读的格式
  • 能够直接传输给另一控制者
  • 仅适用于数据主体提供的数据
  • 仅适用于基于同意或合同的自动化处理
4. 反对权(GDPR 第 21 条)

反对处理器:

async function handleObjectionRequest(userId, processingType) {
  switch (processingType) {
    case 'direct_marketing':
      // Must stop immediately
      await disableMarketing(userId);
      await updateConsent(userId, 'marketing', false);
      break;

    case 'legitimate_interest':
      // Assess if we have compelling grounds
      const assessment = await assessLegitimateInterest(userId);
      if (!assessment.compelling) {
        await stopProcessing(userId, processingType);
      }
      return assessment;

    case 'profiling':
      await disableProfiling(userId);
      await updateConsent(userId, 'profiling', false);
      break;

    default:
      throw new Error('Invalid processing type');
  }

  await logObjectionRequest(userId, processingType, 'granted');
}

同意管理

同意要求(GDPR)

有效同意必须:

  1. 自由给出(无胁迫)
  2. 具体(针对每个目的)
  3. 知情(清晰的语言)
  4. 明确(清晰的肯定行动)
  5. 可撤回(撤回与给出同样容易)

同意实现:


<form>
  <h3>Privacy Preferences</h3>

  <label>
    <input type="checkbox" name="essential" checked disabled>
    <strong>Essential cookies (Required)</strong>
    <p>Necessary for website functionality</p>
  </label>

  <label>
    <input type="checkbox" name="analytics" value="analytics">
    <strong>Analytics cookies</strong>
    <p>Help us improve our website by collecting usage data</p>
  </label>

  <label>
    <input type="checkbox" name="marketing" value="marketing">
    <strong>Marketing cookies</strong>
    <p>Show you personalized ads based on your interests</p>
  </label>

  <button type="submit">Save Preferences</button>
  <a href="/privacy-policy">Learn More</a>
</form>

同意记录存储:

const consentRecord = {
  userId: 'user123',
  timestamp: new Date().toISOString(),
  consentVersion: '2.0',
  purposes: {
    essential: { granted: true, required: true },
    analytics: { granted: true, purpose: 'Website improvement' },
    marketing: { granted: false, purpose: 'Personalized advertising' }
  },
  ipAddress: '192.168.1.1', // For proof
  userAgent: 'Mozilla/5.0...', // For context
  method: 'explicit_opt_in' // or 'implicit', 'presumed'
};

await saveConsentRecord(consentRecord);
Cookie 横幅(符合 GDPR)
<div id="cookie-banner" role="dialog" aria-labelledby="cookie-title">
  <h2 id="cookie-title">Cookie Preferences</h2>
  <p>
    We use cookies to enhance your experience. Choose which cookies you
    allow us to use. You can change your preferences at any time.
  </p>

  <button onclick="acceptAll()">Accept All</button>
  <button onclick="rejectNonEssential()">Reject Non-Essential</button>
  <button onclick="showPreferences()">Manage Preferences</button>
</div>

<script>
// Must not load non-essential cookies until consent given
function acceptAll() {
  setConsent({ analytics: true, marketing: true });
  loadAnalyticsCookies();
  loadMarketingCookies();
  hideBanner();
}

function rejectNonEssential() {
  setConsent({ analytics: false, marketing: false });
  hideBanner();
}
</script>

隐私-by-design 原则

1. 数据最小化

原则: 仅收集指定目的所必需的数据

实现:

// ❌ Bad: Collecting unnecessary data
const userRegistration = {
  email: req.body.email,
  password: req.body.password,
  fullName: req.body.fullName,
  phoneNumber: req.body.phoneNumber, // Not needed
  dateOfBirth: req.body.dateOfBirth, // Not needed
  address: req.body.address, // Not needed
  socialSecurityNumber: req.body.ssn // Definitely not needed!
};

// ✅ Good: Only essential data
const userRegistration = {
  email: req.body.email,
  password: hashPassword(req.body.password),
  displayName: req.body.displayName // Optional
};
2. 目的限制

原则: 仅将数据用于指定的、明确的目的

实现:

// Document and enforce purpose
const dataProcessingPurpose = {
  email: [
    'account_authentication',
    'order_confirmations',
    'password_reset'
  ],
  phoneNumber: [
    'order_delivery_notifications'
    // NOT: 'marketing_calls' (requires separate consent)
  ],
  purchaseHistory: [
    'order_fulfillment',
    'customer_support'
    // NOT: 'targeted_advertising' (requires separate consent)
  ]
};

async function processData(data, purpose) {
  if (!isAllowedPurpose(data.type, purpose)) {
    throw new Error('Purpose not authorized for this data');
  }
  // Proceed with processing
}
3. 存储限制

原则: 仅在必要时保留数据

实现:

const retentionPolicy = {
  userAccounts: {
    active: 'indefinite',
    inactive: '2 years',
    deleted: '30 days grace period'
  },
  orderRecords: '7 years', // Legal requirement
  supportTickets: '3 years',
  analytics: '26 months',
  marketingData: '1 year or until consent withdrawn'
};

// Automated data deletion
async function enforceRetentionPolicy() {
  const now = new Date();

  // Delete inactive accounts
  await User.deleteMany({
    lastActive: { $lt: subYears(now, 2) },
    status: 'inactive'
  });

  // Anonymize old analytics
  await Analytics.updateMany(
    { createdAt: { $lt: subMonths(now, 26) } },
    { $unset: { userId: 1, ipAddress: 1 } }
  );

  // Delete expired marketing consent
  await MarketingConsent.deleteMany({
    $or: [
      { expiresAt: { $lt: now } },
      { withdrawnAt: { $lt: subDays(now, 30) } }
    ]
  });
}

// Schedule daily
cron.schedule('0 2 * * *', enforceRetentionPolicy);

数据保护影响评估(DPIA)

何时需要(GDPR 第 35 条):

  • 系统性和大规模画像
  • 大规模处理敏感数据
  • 对公共可访问区域的系统性监控
  • 具有高隐私风险的新技术

DPIA 模板:

# Data Protection Impact Assessment

## Processing Overview
- **Purpose**: [Describe the processing activity]
- **Data Types**: [Personal data categories]
- **Data Subjects**: [Who is affected]
- **Recipients**: [Who receives the data]

## Necessity Assessment
- [ ] Is processing necessary for the stated purpose?
- [ ] Could the purpose be achieved with less data?
- [ ] Is the retention period justified?

## Risk Assessment
| Risk | Likelihood | Severity | Mitigation |
|------|------------|----------|------------|
| Data breach | Medium | High | Encryption, access controls |
| Unauthorized access | Low | High | 2FA, audit logs |
| Purpose creep | Medium | Medium | Purpose documentation, training |

## Safeguards
- [ ] Encryption at rest and in transit
- [ ] Access controls and authentication
- [ ] Regular security audits
- [ ] Data minimization applied
- [ ] Retention policies enforced
- [ ] DPO consulted
- [ ] Data subject rights mechanism in place

## Conclusion
Processing is/is not acceptable with proposed safeguards.

Signed: [Data Protection Officer]
Date: [Assessment Date]

隐私政策要求

基本要素:

# Privacy Policy

## 1. Identity of Controller
Company Name, Address, Contact Information
Data Protection Officer: [email protected]

## 2. Data We Collect
- Account data: email, name
- Usage data: pages visited, features used
- Technical data: IP address, browser type

## 3. Legal Basis for Processing
- **Consent**: Marketing communications
- **Contract**: Order fulfillment
- **Legitimate Interest**: Fraud prevention
- **Legal Obligation**: Tax records

## 4. How We Use Your Data
- Provide services you requested
- Improve our products
- Send important updates
- [Be specific, avoid vague statements]

## 5. Data Sharing
- Payment processors (Stripe, PayPal)
- Shipping providers (FedEx, UPS)
- Analytics (Google Analytics)

We do NOT sell your personal data.

## 6. Your Rights
- Right to access your data
- Right to correct inaccuracies
- Right to delete your data
- Right to object to processing
- Right to data portability
- Right to withdraw consent

Contact: [email protected]

## 7. Data Retention
- Account data: Until account deletion + 30 days
- Order history: 7 years (legal requirement)
- Marketing data: 1 year or until opt-out

## 8. Security
We use industry-standard security measures including
encryption, secure servers, and regular security audits.

## 9. International Transfers
Data may be transferred to US servers. We use Standard
Contractual Clauses approved by the EU Commission.

## 10. Changes to Policy
Last updated: [Date]
We will notify you of material changes via email.

## 11. Contact
Questions? Contact our Data Protection Officer at [email protected]

事件响应

数据泄露响应计划

72 小时内(GDPR):

1. **Detect & Contain** (0-4 hours)
   - Identify scope of breach
   - Isolate affected systems
   - Prevent further data loss

2. **Assess** (4-24 hours)
   - Determine data types affected
   - Identify number of individuals
   - Assess risk to rights and freedoms
   - Document everything

3. **Notify Authority** (24-72 hours)
   - Report to supervisory authority
   - Include: nature, categories, approximate numbers,
     likely consequences, measures taken

4. **Notify Data Subjects** (ASAP if high risk)
   - Direct communication required
   - Describe breach in clear language
   - Provide recommendations for protection

数据泄露通知模板:

Subject: Important Security Notice

Dear [Name],

We are writing to inform you of a data security incident that may
have affected your personal information.

WHAT HAPPENED:
On [date], we discovered that [brief description].

WHAT INFORMATION WAS INVOLVED:
[List specific data types: name, email, etc.]
[List what was NOT involved]

WHAT WE ARE DOING:
- [Immediate actions taken]
- [Ongoing security enhancements]
- [Resources provided to affected individuals]

WHAT YOU CAN DO:
- Change your password immediately
- Monitor your accounts for suspicious activity
- [Specific recommendations]

FOR MORE INFORMATION:
Contact our dedicated hotline: [phone]
Email: [email protected]

We sincerely apologize for this incident and the inconvenience
it may cause.

Sincerely,
[Name, Title]

合规检查清单

GDPR 合规
  • 为所有处理活动记录合法依据
  • 发布并可访问隐私政策
  • 同意机制实现细粒度控制
  • 建立数据主体权利请求流程
  • 维护处理活动记录
  • 任命数据保护官(如需要)
  • 对高风险处理开展 DPIA
  • 制定数据泄露通知程序
  • 供应商合同包含数据处理协议
  • 实施国际数据传输保障措施
  • 完成员工数据保护培训
CCPA 合规
  • 在主页提供“Do Not Sell My Personal Information”链接
  • 隐私政策披露数据收集与出售情况
  • 建立可验证消费者请求的机制
  • 制定退出请求处理流程(48 小时内响应)
  • 发布关于请求与合规情况的年度报告
  • 更新服务提供商协议
  • 在收集时提供通知
HIPAA 合规
  • 完成风险评估
  • 记录安全政策与程序
  • 对员工进行 HIPAA 要求培训
  • 签署业务伙伴协议
  • 实施访问控制与审计追踪
  • 对 ePHI 进行加密
  • 建立数据泄露通知程序
  • 制定应急计划与灾难恢复

隐私合规是一个持续的过程,而不是一次性的检查清单。随着法规演变和你的数据处理发生变化,应定期审查并更新相关实践。

评论

支持 Markdown