privacy-review-rails
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCheck Privacy — Review Changed Files
检查隐私合规性——审核已修改文件
Prerequisite
前提条件
Dependency path: !
test -d "${CLAUDE_SKILL_DIR}/../privacy-by-design-rails" && echo "${CLAUDE_SKILL_DIR}/../privacy-by-design-rails" || echo "NOT_FOUND"If the dependency path above is , stop and tell the user:
NOT_FOUNDThis skill depends on privacy-by-design-rails, which is not installed. Install it with:(addnpx skills add codeminer42/skills --skill privacy-by-design-railsfor global installation)-g
Do not proceed until the dependency is installed.
依赖路径:!
test -d "${CLAUDE_SKILL_DIR}/../privacy-by-design-rails" && echo "${CLAUDE_SKILL_DIR}/../privacy-by-design-rails" || echo "NOT_FOUND"如果上述依赖路径显示为,请停止操作并告知用户:
NOT_FOUND此技能依赖privacy-by-design-rails,但该依赖未安装。 请使用以下命令安装:(添加npx skills add codeminer42/skills --skill privacy-by-design-rails参数进行全局安装)-g
在依赖安装完成前,请勿继续后续操作。
Step 1: Scan Changed Files + Related Files
步骤1:扫描已修改文件及关联文件
If is not found when running the command below, ask the user how to run Ruby in their environment instead of trying to resolve it yourself.
rubyRun the scanner in mode. This scans the changed files AND automatically pulls in related files (e.g., a changed migration pulls in its model and ; a changed mailer template pulls in its mailer class):
--changed-onlyfilter_parameter_logging.rbbash
ruby ${CLAUDE_SKILL_DIR}/../privacy-by-design-rails/scripts/scanner.rb --changed-onlyParse the JSON output. It includes:
- — files the developer actually modified
changed_files - — files pulled in for context (not changed, but affected by the changes)
related_files - — scanner findings across both changed and related files
findings - — privacy checklist status
checklist
If is empty, tell the user there are no privacy-relevant changes and stop.
changed_files如果运行以下命令时未找到,请询问用户在其环境中如何运行Ruby,不要自行尝试解决。
ruby以模式运行扫描器。该模式会扫描已修改的文件,并自动关联相关文件(例如,修改的迁移文件会关联对应的模型文件和;修改的邮件模板会关联对应的邮件类):
--changed-onlyfilter_parameter_logging.rbbash
ruby ${CLAUDE_SKILL_DIR}/../privacy-by-design-rails/scripts/scanner.rb --changed-only解析JSON格式的输出结果,其中包含:
- —— 开发者实际修改的文件
changed_files - —— 为提供上下文而关联的文件(未被修改,但受变更影响)
related_files - —— 扫描器在已修改文件和关联文件中发现的问题
findings - —— 隐私合规检查清单的完成状态
checklist
如果为空,请告知用户当前没有与隐私相关的修改,并停止操作。
changed_filesStep 2: Deep-Dive on Changed Files
步骤2:深入审核已修改文件
The scanner catches mechanical violations. Now verify the findings and check for things the scanner can't detect. For each changed file, apply the relevant checks from and the rules in :
${CLAUDE_SKILL_DIR}/../privacy-by-design-rails/references/pii-definition.md${CLAUDE_SKILL_DIR}/../privacy-by-design-rails/rules/扫描器可检测出机械性违规情况。现在需要验证扫描结果,并检查扫描器无法检测到的问题。针对每个已修改文件,参考中的相关检查项,以及中的规则:
${CLAUDE_SKILL_DIR}/../privacy-by-design-rails/references/pii-definition.md${CLAUDE_SKILL_DIR}/../privacy-by-design-rails/rules/For changed models:
针对已修改的模型文件:
- PII classification: Read the model and its schema columns. Apply the Mandatory Classification Rules (Rules 1-4) from to classify every column. Don't just rely on the scanner's pattern matching — check for domain-specific fields with non-standard names.
references/pii-definition.md - Encryption: Does every PII column have ?
encrypts - filter_attributes: Does the model declare listing all its PII fields?
self.filter_attributes - ransackable_attributes: If the model defines , are sensitive fields (encrypted_password, reset_password_token) or PII fields exposed?
ransackable_attributes
- PII分类:阅读模型及其架构列,应用中的强制分类规则(规则1-4)对每一列进行分类。不要仅依赖扫描器的模式匹配——需检查具有非标准名称的特定领域字段。
references/pii-definition.md - 加密:所有PII列是否都配置了?
encrypts - filter_attributes:模型是否声明了并列出所有PII字段?
self.filter_attributes - ransackable_attributes:如果模型定义了,是否暴露了敏感字段(如encrypted_password、reset_password_token)或PII字段?
ransackable_attributes
For changed migrations:
针对已修改的迁移文件:
- Read the corresponding model (from ) to check if
related_filesdeclarations exist for new PII columns.encrypts - Check if (from
config/initializers/filter_parameter_logging.rb) includes the new PII field names.related_files
- 查看对应的模型文件(来自),检查新添加的PII列是否已声明
related_files。encrypts - 检查(来自
config/initializers/filter_parameter_logging.rb)是否包含新添加的PII字段名称。related_files
For changed mailers/templates:
针对已修改的邮件类/模板:
- Check addresses for PII (user emails as sender).
from: - Check subject lines for PII (names, emails visible in inbox previews).
- Check template bodies: distinguish emails sent to OTHER users (violation) vs emails sent to the data subject themselves (acceptable — note with justification).
- 检查地址是否包含PII(如使用用户邮箱作为发件人)。
from: - 检查邮件主题是否包含PII(如姓名、邮箱会在收件箱预览中显示)。
- 检查邮件模板内容:区分发送给其他用户的邮件(属于违规)和发送给数据主体本人的邮件(合规——需注明理由)。
For changed jobs/workers:
针对已修改的任务/工作器:
- Does the base class () set
ApplicationJob?self.log_arguments = false - Do parameters pass PII data instead of record IDs?
perform
- 基类()是否设置了
ApplicationJob?self.log_arguments = false - 参数是否传递了PII数据而非记录ID?
perform
For changed controllers:
针对已修改的控制器:
- Is assigned a full ActiveRecord object instead of just an ID?
session[...] - Do responses include PII that shouldn't be exposed?
render json:
- 是否存储了完整的ActiveRecord对象而非仅ID?
session[...] - 响应是否包含不应暴露的PII?
render json:
For changed initializers:
针对已修改的初始化文件:
- If it configures an error reporter (Rollbar, Sentry, Bugsnag): are configured? Is
scrub_fieldsenabled? Areanonymize_user_ipsettings restricted to ID only?person_*_method
- 如果配置了错误报告工具(如Rollbar、Sentry、Bugsnag):是否配置了?是否启用了
scrub_fields?anonymize_user_ip设置是否仅限制为ID?person_*_method
For changed services:
针对已修改的服务文件:
- Does the service send data to an external API? If so, does the payload include PII?
- 该服务是否向外部API发送数据?如果是,请求 payload 是否包含PII?
Step 3: Report
步骤3:生成报告
Group verified violations by severity (CRITICAL > HIGH > MEDIUM). For each violation:
- Location:
file:line - What's wrong: clear description
- Correct pattern: code example from the relevant rule in
${CLAUDE_SKILL_DIR}/../privacy-by-design-rails/rules/ - Changed vs related: note whether the violation is in a changed file (developer should fix) or a related file (pre-existing issue exposed by the change)
For scanner findings you verified as false positives, briefly explain why you dismissed them.
If no violations, tell the user their changes look privacy-compliant.
按照严重程度(CRITICAL > HIGH > MEDIUM)对已验证的违规情况进行分组。每个违规项需包含:
- 位置:
文件路径:行号 - 问题描述:清晰说明违规内容
- 正确示例:参考中对应规则的代码示例
${CLAUDE_SKILL_DIR}/../privacy-by-design-rails/rules/ - 文件类型:注明违规情况出现在已修改文件中(开发者需修复)还是关联文件中(变更暴露的既有问题)
对于已验证为误报的扫描结果,简要说明驳回理由。
如果未发现违规情况,请告知用户其修改符合隐私合规要求。
Step 4: Offer to Fix
步骤4:提供修复建议
Ask the user if they want fixes applied. Apply unambiguous fixes directly; ask about ambiguous ones (e.g., deterministic vs non-deterministic encryption, whether a field is genuinely PII).
询问用户是否需要应用修复方案。对于明确的违规项直接修复;对于模糊不清的情况(如确定性加密与非确定性加密的选择、字段是否属于PII),需先与用户确认。