implementing-aws-macie-for-data-classification

实施 Amazon Macie,利用机器学习和模式匹配自动发现、分类并保护 S3 存储桶中的敏感数据,包括 PII、金融数据和凭据检测。

9 stars

Best use case

implementing-aws-macie-for-data-classification is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

实施 Amazon Macie,利用机器学习和模式匹配自动发现、分类并保护 S3 存储桶中的敏感数据,包括 PII、金融数据和凭据检测。

Teams using implementing-aws-macie-for-data-classification should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/implementing-aws-macie-for-data-classification/SKILL.md --create-dirs "https://raw.githubusercontent.com/killvxk/cybersecurity-skills-zh/main/skills/implementing-aws-macie-for-data-classification/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/implementing-aws-macie-for-data-classification/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How implementing-aws-macie-for-data-classification Compares

Feature / Agentimplementing-aws-macie-for-data-classificationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

实施 Amazon Macie,利用机器学习和模式匹配自动发现、分类并保护 S3 存储桶中的敏感数据,包括 PII、金融数据和凭据检测。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 实施 AWS Macie 进行数据分类

## 概述

Amazon Macie(亚马逊 Macie)是一项全托管的数据安全与隐私服务,使用机器学习(Machine Learning)和模式匹配(Pattern Matching)来发现和保护 Amazon S3 中的敏感数据。Macie 每天自动评估您的 S3 存储桶清单,识别包含 PII(个人身份信息)、金融信息、凭据及其他敏感数据类型的对象。它提供两种发现方式:用于广泛可见性的自动化敏感数据发现,以及用于深度分析的定向发现任务。

## 前置条件

- 拥有含待分类数据的 S3 存储桶的 AWS 账户
- 具备 Macie 服务配置所需的 IAM 权限
- 已配置 AWS Organizations(用于多账户部署)
- S3 存储桶位于受支持的区域

## 启用 Macie

### 通过 AWS CLI

```bash
# 在当前账户/区域启用 Macie
aws macie2 enable-macie

# 验证 Macie 已启用
aws macie2 get-macie-session

# 启用自动化敏感数据发现
aws macie2 update-automated-discovery-configuration \
  --status ENABLED
```

### 通过 Terraform

```hcl
resource "aws_macie2_account" "main" {}

resource "aws_macie2_classification_export_configuration" "main" {
  depends_on = [aws_macie2_account.main]

  s3_destination {
    bucket_name = aws_s3_bucket.macie_results.id
    key_prefix  = "macie-findings/"
    kms_key_arn = aws_kms_key.macie.arn
  }
}
```

## 配置发现任务

### 为特定存储桶创建分类任务

```bash
aws macie2 create-classification-job \
  --job-type ONE_TIME \
  --name "pii-scan-production-buckets" \
  --s3-job-definition '{
    "bucketDefinitions": [{
      "accountId": "123456789012",
      "buckets": [
        "production-data-bucket",
        "customer-records-bucket"
      ]
    }]
  }' \
  --managed-data-identifier-selector ALL
```

### 创建定期计划任务

```bash
aws macie2 create-classification-job \
  --job-type SCHEDULED \
  --name "weekly-sensitive-data-scan" \
  --schedule-frequency-details '{
    "weekly": {
      "dayOfWeek": "MONDAY"
    }
  }' \
  --s3-job-definition '{
    "bucketDefinitions": [{
      "accountId": "123456789012",
      "buckets": ["all-data-bucket"]
    }],
    "scoping": {
      "includes": {
        "and": [{
          "simpleScopeTerm": {
            "comparator": "STARTS_WITH",
            "key": "OBJECT_KEY",
            "values": ["uploads/", "documents/"]
          }
        }]
      }
    }
  }'
```

## 自定义数据标识符

### 为内部 ID 创建自定义标识符

```bash
aws macie2 create-custom-data-identifier \
  --name "internal-employee-id" \
  --description "匹配内部员工 ID 格式 EMP-XXXXXX" \
  --regex "EMP-[0-9]{6}" \
  --severity-levels '[
    {"occurrencesThreshold": 1, "severity": "LOW"},
    {"occurrencesThreshold": 10, "severity": "MEDIUM"},
    {"occurrencesThreshold": 50, "severity": "HIGH"}
  ]'
```

### 为项目代码创建标识符

```bash
aws macie2 create-custom-data-identifier \
  --name "project-code-identifier" \
  --description "匹配格式为 PRJ-XXXX-XX 的项目代码" \
  --regex "PRJ-[A-Z]{4}-[0-9]{2}" \
  --keywords '["project", "code", "initiative"]' \
  --maximum-match-distance 50
```

## 允许列表

### 创建允许列表以抑制误报

```bash
aws macie2 create-allow-list \
  --name "test-data-exclusions" \
  --description "排除已知测试数据模式" \
  --criteria '{
    "regex": "TEST-[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}"
  }'
```

## 托管数据标识符

Macie 提供 300 余种托管数据标识符,涵盖以下类别:

| 类别 | 示例 |
|------|------|
| **PII** | 社会安全号码、护照号码、驾驶证、出生日期、姓名、地址 |
| **金融** | 信用卡号、银行账号、SWIFT 代码 |
| **凭据** | AWS 密钥、API 密钥、SSH 私钥、OAuth 令牌 |
| **医疗** | HIPAA 标识符、医疗保险理赔号 |
| **法务** | 税务识别号、国家身份证号 |

## 发现结果管理

### 列出发现结果

```bash
# 获取敏感数据发现结果
aws macie2 list-findings \
  --finding-criteria '{
    "criterion": {
      "severity.description": {
        "eq": ["High"]
      },
      "category": {
        "eq": ["CLASSIFICATION"]
      }
    }
  }' \
  --sort-criteria '{"attributeName": "updatedAt", "orderBy": "DESC"}' \
  --max-results 25
```

### 获取发现结果详情

```bash
aws macie2 get-findings \
  --finding-ids '["finding-id-1", "finding-id-2"]'
```

### 将发现结果导出至 Security Hub

```bash
# Macie 自动将发现结果发布到 Security Hub
# 验证集成状态:
aws macie2 get-macie-session --query 'findingPublishingFrequency'
```

## EventBridge 集成与自动响应

```json
{
  "source": ["aws.macie"],
  "detail-type": ["Macie Finding"],
  "detail": {
    "severity": {
      "description": ["High", "Critical"]
    }
  }
}
```

### 用于自动修复的 Lambda 函数

```python
import boto3
import json

s3 = boto3.client('s3')
sns = boto3.client('sns')

def lambda_handler(event, context):
    finding = event['detail']
    severity = finding['severity']['description']
    bucket = finding['resourcesAffected']['s3Bucket']['name']
    key = finding['resourcesAffected']['s3Object']['key']
    sensitive_types = [d['type'] for d in finding.get('classificationDetails', {}).get('result', {}).get('sensitiveData', [])]

    if severity in ['High', 'Critical']:
        # 为对象打标签以供审查
        s3.put_object_tagging(
            Bucket=bucket,
            Key=key,
            Tagging={
                'TagSet': [
                    {'Key': 'macie-finding', 'Value': severity},
                    {'Key': 'sensitive-data', 'Value': ','.join(sensitive_types)},
                    {'Key': 'requires-review', 'Value': 'true'}
                ]
            }
        )

        # 通知安全团队
        sns.publish(
            TopicArn='arn:aws:sns:us-east-1:123456789012:security-alerts',
            Subject=f'Macie {severity} 发现结果: {bucket}/{key}',
            Message=json.dumps({
                'bucket': bucket,
                'key': key,
                'severity': severity,
                'sensitive_data_types': sensitive_types,
                'finding_id': finding['id']
            }, indent=2)
        )

    return {'statusCode': 200}
```

## 多账户部署

### 指定 Macie 管理员账户

```bash
# 从管理账户执行
aws macie2 enable-organization-admin-account \
  --admin-account-id 111111111111
```

### 添加成员账户

```bash
# 从管理员账户执行
aws macie2 create-member \
  --account '{"accountId": "222222222222", "email": "security@example.com"}'
```

## 监控 Macie 运营状态

### 使用量统计

```bash
aws macie2 get-usage-statistics \
  --filter-by '[{"comparator": "GT", "key": "accountId", "values": []}]' \
  --sort-by '{"key": "accountId", "orderBy": "ASC"}'
```

### 分类任务状态

```bash
aws macie2 list-classification-jobs \
  --filter-criteria '{"includes": [{"comparator": "EQ", "key": "jobStatus", "values": ["RUNNING"]}]}'
```

## 参考资料

- AWS Macie 文档: https://docs.aws.amazon.com/macie/
- AWS Macie 定价
- Macie 分析支持的文件类型
- 使用 Macie 实现 GDPR 和 CCPA 合规

Related Skills

testing-for-sensitive-data-exposure

9
from killvxk/cybersecurity-skills-zh

在安全评估中识别敏感数据暴露漏洞,包括 API 密钥泄露、响应中的 PII、不安全存储以及未受保护的数据传输。

performing-sqlite-database-forensics

9
from killvxk/cybersecurity-skills-zh

对 SQLite 数据库执行取证分析,从空闲列表(Freelist)和 WAL 文件中恢复已删除记录,解码编码时间戳,并从浏览器历史、即时通讯应用和移动设备数据库中提取证据。

implementing-zero-trust-with-hashicorp-boundary

9
from killvxk/cybersecurity-skills-zh

使用 HashiCorp Boundary 实现具备动态凭据代理、会话录制和 Vault 集成的身份感知零信任基础设施访问管理。

implementing-zero-trust-with-beyondcorp

9
from killvxk/cybersecurity-skills-zh

使用身份感知代理(IAP,Identity-Aware Proxy)、上下文感知访问策略、设备信任验证和 Access Context Manager,部署 Google BeyondCorp Enterprise 零信任访问控制,对 GCP 资源和内部应用强制执行基于身份和安全态势的访问。

implementing-zero-trust-network-access

9
from killvxk/cybersecurity-skills-zh

通过配置身份感知代理、微分段、基于条件访问策略的持续验证,以及在 AWS、Azure 和 GCP 环境中以 BeyondCorp 风格的架构替代传统 VPN 访问,在云环境中实施零信任网络访问(ZTNA)。

implementing-zero-trust-network-access-with-zscaler

9
from killvxk/cybersecurity-skills-zh

使用 Zscaler 实施零信任网络访问(Zero Trust Network Access,ZTNA),通过 Zscaler Private Access(ZPA)配置应用分段、访问策略和连接器,替代传统 VPN 架构

implementing-zero-trust-in-cloud

9
from killvxk/cybersecurity-skills-zh

本技能指导组织按照 NIST SP 800-207 和 Google BeyondCorp 原则在云环境中实施零信任(Zero Trust)架构,涵盖以身份为中心的访问控制、微分段(Micro-Segmentation)、持续验证、设备信任评估,以及部署身份感知代理(Identity-Aware Proxy)以消除 AWS、Azure 和 GCP 环境中的隐式网络信任。

implementing-zero-trust-for-saas-applications

9
from killvxk/cybersecurity-skills-zh

使用 CASB、SSPM、条件访问策略、OAuth 应用治理和会话控制,为 SaaS 应用实施零信任访问控制, 对云托管服务强制执行身份验证、设备合规性检查和数据保护。

implementing-zero-trust-dns-with-nextdns

9
from killvxk/cybersecurity-skills-zh

将 NextDNS 实施为零信任 DNS 过滤层,提供加密解析、威胁情报阻断、隐私保护,以及跨所有端点的组织策略执行。

implementing-zero-standing-privilege-with-cyberark

9
from killvxk/cybersecurity-skills-zh

部署 CyberArk Secure Cloud Access,通过基于时间、权限和审批控制的即时访问,在混合云和多云环境中消除常设权限。

implementing-zero-knowledge-proof-for-authentication

9
from killvxk/cybersecurity-skills-zh

零知识证明(ZKP)允许证明者在不泄露秘密本身的情况下证明对某个秘密(如密码或私钥)的了解。本技能实现 Schnorr 身份识别协议和使用离散对数问题的简化 ZKPP,使服务器永远不需要获取用户密码即可完成认证。

implementing-web-application-logging-with-modsecurity

9
from killvxk/cybersecurity-skills-zh

配置带有 OWASP 核心规则集(CRS)的 ModSecurity WAF,实现 Web 应用程序日志记录, 调整规则以减少误报,分析审计日志进行攻击检测,并为应用程序特定威胁实现自定义 SecRules。 分析师配置 SecRuleEngine、SecAuditEngine 和 CRS 偏执级别,以在安全覆盖范围和运营稳定性之间取得平衡。 适用于涉及 WAF 配置、ModSecurity 规则调整、Web 应用审计日志或 CRS 部署的场景。