VMware Policy
Unified audit logging, policy enforcement, and input sanitization -- the infrastructure layer for the entire VMware MCP skill family.
Infrastructure dependency: All 8 VMware skills depend on vmware-policy. It is auto-installed and provides the @vmware_tool decorator, sanitize(), and the shared audit database.
Family: vmware-aiops (VM lifecycle), vmware-monitor (read-only monitoring), vmware-storage (iSCSI/vSAN), vmware-vks (Tanzu Kubernetes), vmware-nsx (NSX networking), vmware-nsx-security (DFW/firewall), vmware-aria (metrics/alerts/capacity), vmware-avi (AVI/ALB/AKO).
| vmware-pilot (workflow orchestration)
What This Skill Does
| Category | Components | Count |
|---|
| Audit Logging | AuditEngine (SQLite WAL), log rotation, agent detection | 3 |
| Policy Engine |
deny rules, maintenance windows, change limits, hot-reload | 4 |
|
Sanitization |
sanitize() -- prompt injection defense, control char stripping | 1 |
|
Decorator |
@vmware_tool -- pre-check + execute + post-log + metadata | 1 |
|
CLI |
vmware-audit log,
vmware-audit export,
vmware-audit stats | 3 |
Quick Install
CODEBLOCK0
vmware-policy is automatically installed as a dependency of all VMware skills. Manual install is only needed for standalone audit querying.
When to Use This Skill
- - Query the unified audit trail across all VMware skills
- View denied operations and policy violations
- Check audit statistics (by skill, by status, by time range)
- Export audit logs as JSON for external analysis
- Configure deny rules, maintenance windows, or change limits
- Integrate the
@vmware_tool decorator into a new VMware skill
This skill is auto-loaded as a dependency -- you do not need to invoke it directly. It activates when:
- - Any VMware skill tool function is called (via
@vmware_tool decorator) - User asks about audit logs, denied operations, or policy rules
- User runs
vmware-audit CLI commands
Related Skills -- Skill Routing
| User Intent | Recommended Skill |
|---|
| VM lifecycle, deployment, guest ops | vmware-aiops (uv tool install vmware-aiops) |
| Read-only monitoring, zero risk |
vmware-monitor (
uv tool install vmware-monitor) |
| Storage: iSCSI, vSAN, datastores |
vmware-storage (
uv tool install vmware-storage) |
| Tanzu Kubernetes (vSphere 8.x+) |
vmware-vks (
uv tool install vmware-vks) |
| NSX networking: segments, gateways, NAT |
vmware-nsx (
uv tool install vmware-nsx-mgmt) |
| NSX security: DFW rules, security groups |
vmware-nsx-security (
uv tool install vmware-nsx-security) |
| Aria Ops: metrics, alerts, capacity |
vmware-aria (
uv tool install vmware-aria) |
| Load balancer, AVI, ALB, AKO, Ingress |
vmware-avi (
uv tool install vmware-avi) |
| Multi-step workflows with approval |
vmware-pilot |
| Audit log query, policy rules |
vmware-policy -- this skill |
Common Workflows
Query Recent Audit Activity
- 1. View last 20 audit entries: INLINECODE18
- Filter by skill: INLINECODE19
- Check denied operations: INLINECODE20
- View aggregate stats: INLINECODE21
Set Up Policy Rules for Production
- 1. Copy default rules: INLINECODE22
- Edit
~/.vmware/rules.yaml -- add deny rules for production:
deny:
- name: no-delete-in-prod
operations: ["delete_*", "cluster_delete"]
environments: ["production"]
reason: "Destructive operations blocked in production"
maintenance_window:
start: "22:00"
end: "06:00"
- 3. Rules hot-reload automatically -- no restart needed
- Verify:
vmware-audit log --status denied to see blocked operations
Export Audit Logs for Compliance
- 1. Export all logs as JSON: INLINECODE25
- Filter by skill: INLINECODE26
- Import into your SIEM or compliance tool
Usage Mode
| Scenario | Recommended | Why |
|---|
| Query audit logs | CLI | INLINECODE27 provides rich table output |
| Integrate into a skill |
Python API |
from vmware_policy import vmware_tool, sanitize |
| Automated compliance export |
CLI |
vmware-audit export --format json pipes to any tool |
CLI Quick Reference
CODEBLOCK2
Full CLI reference: see INLINECODE30
Python API
CODEBLOCK3
MCP Tools (0)
vmware-policy does not expose MCP tools. It is a Python library and CLI consumed by other VMware skills.
| Component | Type | Description |
|---|
| INLINECODE31 | Decorator | Wraps all 156+ MCP tools across 8 skills |
| INLINECODE32 |
Function | Prompt injection defense for API responses |
|
AuditEngine | Class | SQLite WAL audit logger with rotation |
|
PolicyEngine | Class | YAML rule evaluation with hot-reload |
|
vmware-audit | CLI | Typer CLI for querying audit trail |
Troubleshooting
"Cannot initialize audit DB" warning
The audit database directory
~/.vmware/ must be writable. Create it manually:
mkdir -p ~/.vmware && chmod 700 ~/.vmware.
Policy rules not taking effect
Rules are loaded from
~/.vmware/rules.yaml. Verify the file exists and contains valid YAML. The PolicyEngine hot-reloads on file change -- no restart needed.
Audit log growing too large
The AuditEngine automatically rotates at 100MB, keeping the 5 most recent archives. For manual cleanup:
ls ~/.vmware/audit.*.db to see archives.
"PolicyDenied" exception in skill
This means a deny rule in
~/.vmware/rules.yaml matched the operation. Check
vmware-audit log --status denied to see the rule name and reason. To temporarily bypass:
VMWARE_POLICY_DISABLED=1 (still logged as bypassed).
Decorator not detecting skill name
The
@vmware_tool decorator infers the skill name from the module path (e.g.,
vmware_aiops.ops.vm_lifecycle ->
aiops). If the module does not follow the
vmware_<skill> convention, the skill is logged as "unknown".
SQLite "database is locked" error
Multiple concurrent skill processes can write to the same audit.db via WAL mode. If locks persist beyond 5 seconds, check for zombie processes holding the database file.
Setup
CODEBLOCK4
vmware-policy is auto-installed as a dependency of all VMware skills. The ~/.vmware/ directory is created automatically on first audit write.
Full setup guide, security details, and integration instructions: see INLINECODE48
Security
- - Source Code: github.com/zw008/VMware-Policy
- Config File Contents:
~/.vmware/rules.yaml contains only rule definitions, no credentials - Webhook Data Scope: N/A -- vmware-policy does not send data externally
- TLS Verification: N/A -- vmware-policy does not make network connections
- Prompt Injection Protection:
sanitize() truncates to 500 chars and strips C0/C1 control characters - Least Privilege: Audit database is local-only (
~/.vmware/audit.db), no network exposure
License
MIT -- github.com/zw008/VMware-Policy
VMware Policy
统一的审计日志记录、策略执行和输入清理——这是整个VMware MCP技能系列的基础设施层。
基础设施依赖:所有8个VMware技能都依赖于vmware-policy。它会自动安装,并提供@vmware_tool装饰器、sanitize()函数以及共享的审计数据库。
技能家族:vmware-aiops(VM生命周期管理)、vmware-monitor(只读监控)、vmware-storage(iSCSI/vSAN)、vmware-vks(Tanzu Kubernetes)、vmware-nsx(NSX网络)、vmware-nsx-security(DFW/防火墙)、vmware-aria(指标/告警/容量)、vmware-avi(AVI/ALB/AKO)。
| vmware-pilot(工作流编排)
该技能的功能
| 类别 | 组件 | 数量 |
|---|
| 审计日志 | AuditEngine(SQLite WAL)、日志轮转、代理检测 | 3 |
| 策略引擎 |
拒绝规则、维护窗口、变更限制、热重载 | 4 |
|
清理 | sanitize()——提示注入防御、控制字符剥离 | 1 |
|
装饰器 | @vmware_tool——预检查 + 执行 + 后记录 + 元数据 | 1 |
|
CLI | vmware-audit log、vmware-audit export、vmware-audit stats | 3 |
快速安装
bash
uv tool install vmware-policy
vmware-audit stats # 验证安装
vmware-policy 会自动作为所有VMware技能的依赖项安装。仅当需要独立进行审计查询时才需要手动安装。
何时使用该技能
- - 查询所有VMware技能的统一审计追踪
- 查看被拒绝的操作和策略违规
- 检查审计统计信息(按技能、按状态、按时间范围)
- 将审计日志导出为JSON格式用于外部分析
- 配置拒绝规则、维护窗口或变更限制
- 将@vmware_tool装饰器集成到新的VMware技能中
该技能作为依赖项自动加载——您无需直接调用它。它在以下情况下激活:
- - 调用任何VMware技能工具函数时(通过@vmware_tool装饰器)
- 用户询问审计日志、被拒绝的操作或策略规则时
- 用户运行vmware-audit CLI命令时
相关技能——技能路由
| 用户意图 | 推荐技能 |
|---|
| VM生命周期、部署、客户机操作 | vmware-aiops(uv tool install vmware-aiops) |
| 只读监控、零风险 |
vmware-monitor(uv tool install vmware-monitor) |
| 存储:iSCSI、vSAN、数据存储 |
vmware-storage(uv tool install vmware-storage) |
| Tanzu Kubernetes(vSphere 8.x+) |
vmware-vks(uv tool install vmware-vks) |
| NSX网络:分段、网关、NAT |
vmware-nsx(uv tool install vmware-nsx-mgmt) |
| NSX安全:DFW规则、安全组 |
vmware-nsx-security(uv tool install vmware-nsx-security) |
| Aria Ops:指标、告警、容量 |
vmware-aria(uv tool install vmware-aria) |
| 负载均衡器、AVI、ALB、AKO、Ingress |
vmware-avi(uv tool install vmware-avi) |
| 带审批的多步骤工作流 |
vmware-pilot |
| 审计日志查询、策略规则 |
vmware-policy——本技能 |
常见工作流
查询近期审计活动
- 1. 查看最近20条审计条目:vmware-audit log --last 20
- 按技能筛选:vmware-audit log --skill vmware-nsx --last 50
- 检查被拒绝的操作:vmware-audit log --status denied --since 2026-03-28
- 查看汇总统计:vmware-audit stats --days 7
为生产环境设置策略规则
- 1. 复制默认规则:cp $(python -c import vmwarepolicy; print(vmwarepolicy.file.replace(init.py,rules_default.yaml))) ~/.vmware/rules.yaml
- 编辑~/.vmware/rules.yaml——为生产环境添加拒绝规则:
yaml
deny:
- name: no-delete-in-prod
operations: [delete
*, clusterdelete]
environments: [production]
reason: 生产环境中禁止破坏性操作
maintenance_window:
start: 22:00
end: 06:00
- 3. 规则自动热重载——无需重启
- 验证:vmware-audit log --status denied查看被阻止的操作
导出审计日志用于合规
- 1. 将所有日志导出为JSON:vmware-audit export --format json > audit-export.json
- 按技能筛选:vmware-audit export --skill vmware-aiops --since 2026-01-01
- 导入到您的SIEM或合规工具中
使用模式
| 场景 | 推荐方式 | 原因 |
|---|
| 查询审计日志 | CLI | vmware-audit提供丰富的表格输出 |
| 集成到技能中 |
Python API | from vmware
policy import vmwaretool, sanitize |
| 自动化合规导出 |
CLI | vmware-audit export --format json可管道传输到任何工具 |
CLI快速参考
bash
查看最近的审计条目
vmware-audit log --last 20
vmware-audit log --skill vmware-nsx --status denied
vmware-audit log --since 2026-03-28 --tool delete_segment
导出用于合规
vmware-audit export --format json > audit.json
vmware-audit export --skill vmware-aiops --since 2026-01-01
汇总统计
vmware-audit stats --days 7
vmware-audit stats --days 30
完整CLI参考:参见references/cli-reference.md
Python API
python
from vmwarepolicy import vmwaretool, sanitize
包装每个MCP工具函数
@vmware
tool(risklevel=high, sensitive_params=[password])
def delete_segment(name: str, env: str = ) -> dict:
...
在返回给LLM之前清理不受信任的API响应
clean
text = sanitize(apiresponse
text, maxlen=500)
MCP工具(0个)
vmware-policy不暴露MCP工具。它是一个被其他VMware技能使用的Python库和CLI。
| 组件 | 类型 | 描述 |
|---|
| @vmware_tool | 装饰器 | 包装8个技能中所有156+个MCP工具 |
| sanitize() |
函数 | API响应的提示注入防御 |
| AuditEngine | 类 | 带轮转功能的SQLite WAL审计日志记录器 |
| PolicyEngine | 类 | 带热重载功能的YAML规则评估引擎 |
| vmware-audit | CLI | 用于查询审计追踪的Typer CLI |
故障排除
无法初始化审计数据库警告
审计数据库目录~/.vmware/必须可写。手动创建:mkdir -p ~/.vmware && chmod 700 ~/.vmware。
策略规则未生效
规则从~/.vmware/rules.yaml加载。验证文件存在且包含有效的YAML。PolicyEngine在文件变更时自动热重载——无需重启。
审计日志增长过大
AuditEngine在达到100MB时自动轮转,保留最近5个归档文件。