防火墙测试框架

一个智能、自主的测试框架,用于PAN-OS 11.2下一代防火墙,使用LangGraph编排和MCP工具服务器。

  • by pravo-collab
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 pravo-collab/Agentic_NGFW_Validator

使用说明

代理式下一代防火墙(NGFW)验证器

一个基于LangGraph编排和MCP工具服务器的、针对PAN-OS 11.2下一代防火墙的智能自主测试框架。

架构概述

这个框架实现了 一键式测试流水线 该系统协调了五个专门的代理集群:

  1. 测试编写与摘要生成 - 制定测试计划并分析结果
  2. 云部署 - 通过Terraform管理基础设施
  3. 配置组合并应用 - 管理PAN-OS配置生命周期
  4. 事件重播 - 重播威胁场景(可选)
  5. PCAP 调试器 - 深度数据包分析与故障排除

关键特性

  • ✅ 自动生成测试用例 来自发行说明和Jira
  • ✅ 多云支持 (GCP, Azure, OCI) 翻译成中文是:(谷歌云平台,微软Azure,Oracle云基础设施)
  • ✅ 安全的配置管理 带有快照/回滚功能
  • ✅ 基于PCAP的调试 进行根本原因分析
  • ✅ 增强型RAG(Retrieval-Augmented Generation,检索增强生成) 决策制定
  • ✅ 事件回放 用于威胁验证

快速入门

先决条件

# Python 3.11+
python --version

# Install dependencies
pip install -r requirements.txt

# Set up environment
cp .env.example .env
# Edit .env with your credentials

运行您的第一个测试

# Initialize RAG indices
python scripts/init_rag.py

# Run NAT test suite on GCP
python main.py --features nat --cloud gcp --region us-central1

# Run with PCAP debugging
python main.py --features nat,dlp --cloud gcp --pcap-debug

# Run with incident replay
python main.py --features malware --cloud gcp --with-replay

项目结构

.
├── agents/                    # Agent cluster implementations
│   ├── test_authoring/       # Release Reader, Test Planner, Case Generator
│   ├── cloud_deployment/     # Topology Planner, TF Deployer, Traffic Runner
│   ├── config_management/    # Config Composer, Applier, Cleanup
│   ├── incident_replay/      # Intel Ingest, Replay Builder/Runner
│   └── pcap_debugger/        # PCAP Ingest, Analyzer, Root Cause
├── mcp_servers/              # MCP tool servers (side-effect boundary)
│   ├── tf_runner/           # Terraform operations
│   ├── panos_api/           # PAN-OS API wrapper
│   ├── traffic_orchestrator/ # Traffic generation & capture
│   ├── pcap_analyzer/       # Packet analysis tools
│   ├── cloud_inventory/     # Cloud resource management
│   ├── repo_io/             # Artifact storage
│   ├── docs_loader/         # RAG document ingestion
│   ├── secrets_vault/       # Credential management
│   └── config_diff/         # Semantic config comparison
├── orchestrator/             # LangGraph workflow engine
│   ├── graph.py             # Main orchestration graph
│   ├── state.py             # State contracts
│   └── nodes.py             # Graph nodes
├── rag/                      # RAG indices and loaders
│   ├── product_index/       # PAN-OS 11.2 docs
│   ├── test_patterns_index/ # Test patterns & recipes
│   ├── infra_index/         # Cloud/TF modules
│   ├── threat_index/        # CVEs, ATT&CK, replays
│   └── results_index/       # Historical results
├── database/                 # Result storage
│   ├── models.py            # SQLAlchemy models
│   └── migrations/          # Alembic migrations
├── tests/                    # Generated pytest suites
│   ├── fixtures/            # Common fixtures
│   └── generated/           # Auto-generated tests
├── artifacts/                # Test outputs
│   ├── reports/             # Markdown reports
│   ├── pcaps/               # Captured packets
│   └── configs/             # Applied configurations
├── templates/                # Config & test templates
│   ├── terraform/           # TF modules per cloud
│   ├── panos_configs/       # Feature config snippets
│   └── test_cases/          # Test case templates
├── main.py                   # CLI entry point
├── requirements.txt          # Python dependencies
└── .env.example             # Environment template

工作流程

TestPlan → Topology Plan → Deploy Infra → 
  ↓
For each feature:
  → Compose Config → Apply Config → Run Tests → 
  → (Optional: PCAP Debug) → Collect Results
  ↓
→ Store Results → Cleanup → Destroy Infra

国家合同

  • TestPlan.yaml 翻译为中文是:“测试计划.yaml”。 - 测试目标、方法、覆盖率
  • TopologyPlan.yaml 翻译为中文是:“拓扑计划.yaml” - 云资源、网络、预算
  • ConfigSpec.json - PAN-OS 配置意图
  • 已部署输出文件.json - 基础设施输出(IPs,区域)
  • FlowTimeline.json 翻译为中文是:“流程时间线.json” - 数据包流分析
  • PCAPDiagnosis.json 翻译为中文是:“PCAP诊断文件.json” 或者 “PCAP诊断报告.json”(具体翻译可能根据上下文有所调整,但基本意思是指一个用于PCAP(可能是指某种技术、系统或设备的缩写)诊断的JSON格式文件)。 - 根本原因及修复方法

数据库模式

  • 跑步(或运行,根据上下文可具体翻译) - 管道执行记录
  • 案件;情况;例子(根据上下文,"cases" 可以翻译为不同的词汇,这里提供了几种可能的翻译) - 单个测试用例的结果
  • 捕捉(或捕获) - PCAP文件元数据
  • 诊断结果 - PCAP分析结果

安全与治理

  • 🔒(锁形符号,常用于表示安全、保密或锁定状态) 秘密隔离 - 凭证从不在提示中出现
  • 🔄 翻译为中文是:🔄(这个符号本身没有直接对应的中文翻译,它通常表示“循环”、“重复”或“刷新”的意思,在中文语境中可能直接保留原样或根据上下文解释为相应的含义。) 快照/回滚 - 安全的配置更改
  • 💰(钱的表情符号,无具体文字含义) 预算之门 - 部署前的成本控制
  • 🔐 PCAP 安全性 - 静止时加密,删除敏感载荷

发展

添加新功能测试

  1. 更新 TestPlan.yaml 具有特性目标
  2. 在(某处)创建配置模板 templates/panos_configs/
  3. 添加 pytest 测试用例到 tests/generated/
  4. 运行带有(以下参数或配置的)管道 --features your_feature

添加新的云服务提供商

  1. 在(某处)创建TF模块 templates/terraform/
  2. 更新 TopologyPlanner 带有提供者规则
  3. 添加特定提供商的配额 cloud_inventory

贡献;做出贡献

看 CONTRIBUTING.md 翻译为中文是:“贡献指南.md” 或 “如何贡献.md”。这里,“CONTRIBUTING”通常指的是关于如何向某个项目或组织做出贡献的指南或说明,而“.md”是Markdown文件的扩展名,表示这是一个使用Markdown格式编写的文件 作为发展指南。

许可证

MIT 许可证 - 请参阅 许可证 详情如下。