Pankajajagdish/azure-cloud-security-auditor
GitHub: Pankajajagdish/azure-cloud-security-auditor
纯 Azure 云安全态势扫描器,用于检测订阅级别下存储、密钥库、网络安全组等核心资源的配置合规性与风险暴露。
Stars: 0 | Forks: 0
# Azure 云安全审计工具
[](https://www.python.org/downloads/)
[](https://azure.microsoft.com/)
[]()
[](LICENSE)
**纯粹的 Azure 云安全态势扫描器** — 不包含 Kubernetes,也不包含 AKS。审计你的 Azure 订阅在 **Defender for Cloud**、**Azure Policy**、**Storage**、**Key Vault** 和 **Network Security Groups** 中的常见配置错误。
专为管理 Azure 生产环境的 **云安全工程师**、**DevSecOps** 和 **云工程师** 打造。
## 检查内容
| 领域 | 检查项 |
|------|--------|
| **Defender for Cloud** | 安全得分百分比 |
| **Azure Policy** | 不合规资源数量 |
| **Storage Accounts** | 仅限 HTTPS 强制执行、加密 |
| **Key Vault** | 软删除、清除保护 |
| **NSGs** | 敏感端口(22, 3389, 445, 数据库端口)的面向 Internet 规则 |
## 功能特点
- 单条命令实现订阅范围内的安全审计
- 带有修复步骤的 **高 / 中** 严重级别发现
- 输出 **JSON** 格式,适用于 SIEM、Log Analytics 或 CI/CD pipeline
- 提供 `--fail-on-high` 退出状态码,用于 Azure DevOps / GitHub Actions 的拦截控制
- 使用 **DefaultAzureCredential**(CLI、托管标识、服务主体)
## 快速开始
```
git clone https://github.com/Pankajajagdish/azure-cloud-security-auditor.git
cd azure-cloud-security-auditor
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
az login
az account set --subscription ""
python azure_security_auditor.py --subscription-id ""
python azure_security_auditor.py --subscription-id "" --format json --fail-on-high
```
## 输出示例
```
=================================================================
AZURE CLOUD SECURITY AUDIT REPORT
=================================================================
Subscription : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Defender Score: 72.5% (target: >80%)
Policy Non-Compliant Resources: 14
Findings : 3 HIGH | 2 MEDIUM
-----------------------------------------------------------------
[HIGH ] Storage Security — prodstorage001
Issue : HTTPS-only traffic not enforced
Fix : Set supportsHttpsTrafficOnly=true on storage account
[HIGH ] Network Security — nsg-app/ssh-rule
Issue : Inbound rule exposes sensitive port 22 to internet
Fix : Restrict source to known IP ranges or use Private Endpoint
=================================================================
```
## CI/CD 拦截示例
```
# Azure DevOps / GitHub Actions
- name: Azure security audit gate
run: |
pip install -r requirements.txt
python azure_security_auditor.py \
--subscription-id ${{ secrets.AZURE_SUBSCRIPTION_ID }} \
--format json \
--fail-on-high
```
## 所需权限
| 角色 | 范围 |
|------|-------|
| `Security Reader` | Subscription |
| `Reader` | Subscription |
| `Policy Insights Data Reader` | Subscription(可选) |
## 作者
**Pankaja Jagdish Kulkarni** — 云 / DevSecOps 工程师
[GitHub](https://github.com/Pankajajagdish) · [LinkedIn](https://linkedin.com/in/pankaja-jagdish-kulkarni)
## 许可证
MIT — 详情请见 [LICENSE](LICENSE)。
标签:Azure, DevSecOps, Python, 上游代理, 云安全态势管理, 前端应用, 无后门, 逆向工具