返回更新列表
新发布Aug 12, 2026

cfripper v1.21.1

用于分析 CloudFormation 模板并检查其安全合规性的库和 CLI 工具。

分享

cfripper 标识

CFRipper

构建状态 PyPI 版本 homebrew 版本 许可证

CFRipper 是一个用于 AWS CloudFormation 模板的库和 CLI 安全分析器。您可以使用 CFRipper 来防止将不安全的 AWS 资源部署到您的云环境中。您可以通过添加新的自定义插件来编写自己的合规性检查。

文档及更多详情请访问 https://cfripper.readthedocs.io/

CLI 用法

常规执行

$ cfripper /tmp/root.yaml /tmp/root_bypass.json --format txt
Analysing /tmp/root.yaml...
Not adding CrossAccountTrustRule failure in rootRole because no AWS Account ID was found in the config.
Valid: False
Issues found:
 - FullWildcardPrincipalRule: rootRole should not allow full wildcard '*', or wildcard in account ID like 'arn:aws:iam::*:12345' at '*'
 - IAMRolesOverprivilegedRule: Role 'rootRole' contains an insecure permission '*' in policy 'root'
Analysing /tmp/root_bypass.json...
Valid: True

使用 "resolve" 标志

$ cfripper /tmp/root.yaml /tmp/root_bypass.json --format txt --resolve
Analysing /tmp/root.yaml...
Not adding CrossAccountTrustRule failure in rootRole because no AWS Account ID was found in the config.
Valid: False
Issues found:
 - FullWildcardPrincipalRule: rootRole should not allow full wildcard '*', or wildcard in account ID like 'arn:aws:iam::*:12345' at '*'
 - IAMRolesOverprivilegedRule: Role 'rootRole' contains an insecure permission '*' in policy 'root'
Analysing /tmp/root_bypass.json...
Not adding CrossAccountTrustRule failure in rootRole because no AWS Account ID was found in the config.
Valid: False
Issues found:
 - IAMRolesOverprivilegedRule: Role 'rootRole' contains an insecure permission '*' in policy 'root'
Monitored issues found:
 - PartialWildcardPrincipalRule: rootRole contains an unknown principal: 123456789012
 - PartialWildcardPrincipalRule: rootRole should not allow wildcard, account-wide or root in resource-id like 'arn:aws:iam::12345:root' at 'arn:aws:iam::123456789012:root'

使用 json 格式和输出文件夹参数

$ cfripper /tmp/root.yaml /tmp/root_bypass.json --format json --resolve --output-folder /tmp
Analysing /tmp/root.yaml...
Not adding CrossAccountTrustRule failure in rootRole because no AWS Account ID was found in the config.
Result saved in /tmp/root.yaml.cfripper.results.json
Analysing /tmp/root_bypass.json...
Not adding CrossAccountTrustRule failure in rootRole because no AWS Account ID was found in the config.
Result saved in /tmp/root_bypass.json.cfripper.results.json

使用规则配置文件

$ cfripper tests/test_templates/config/security_group_firehose_ips.json --rules-config-file cfripper/config/rule_configs/example_rules_config_for_cli.py
Analysing tests/test_templates/config/security_group_firehose_ips.json...
Valid: True

使用规则过滤器文件

$ cfripper tests/test_templates/config/security_group_firehose_ips.json --rules-filters-folder cfripper/config/rule_configs/
example_rules_config_for_cli.py loaded
Analysing tests/test_templates/config/security_group_firehose_ips.json...
Valid: True

退出代码

"""
分析通过参数传入的 AWS CloudFormation 模板。
退出代码:
  - 0 = 所有模板有效且成功扫描
  - 1 = 扫描至少一个模板时出错/出现问题
  - 2 = 至少一个模板不符合 CFRipper 要求(模板已成功扫描)
  - 3 = 扫描模板时出现未知/未处理的异常
"""

开发

前提条件

本项目使用 uv 进行依赖管理。按以下方式安装:

# macOS
brew install uv

# Linux/macOS
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

设置

# 安装开发依赖
make install-dev

# 运行测试(lint + 单元测试)
make test

# 运行 linter
make lint

# 格式化代码
make format

# 更改依赖后更新锁定文件
make lock

分类