安全

vmware-policy

试用

为 VMware MCP 技能家族提供统一的审计日志、策略执行与输入净化能力。

它能做什么

提供 @vmware_tool 装饰器、sanitize() 函数以及共享的 SQLite 审计数据库,被全部 8 个 VMware MCP 技能复用。附带 vmware-audit 命令行工具,可查询日志、导出 JSON、查看统计信息;并包含基于 YAML 的 PolicyEngine,支持 deny 规则、维护窗口与热重载。本技能不暴露 MCP 工具,而是作为基础设施层,由所有其他 VMware 技能自动依赖安装。

什么时候用它

  • 跨 VMware 技能查询统一审计轨迹
  • 查看被拒绝的操作与策略违规记录
  • 导出审计日志为 JSON 用于合规审查
  • 在 YAML 中配置 deny 规则与维护时间窗口

技能文档

VMware Policy

Disclaimer: This is a community-maintained open-source project and is not affiliated with, endorsed by, or sponsored by VMware, Inc. or Broadcom Inc. "VMware" and "vSphere" are trademarks of Broadcom. Source code is publicly auditable at github.com/vmware-skills/VMware-Policy under the MIT license.

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

CategoryComponentsCount
Audit LoggingAuditEngine (SQLite WAL), log rotation, agent detection3
Policy Enginedeny rules, maintenance windows, hot-reload3
Sanitizationsanitize() -- prompt injection defense, control char stripping1
Decorator@vmware_tool -- pre-check + execute + post-log + metadata1
CLIvmware-audit log, vmware-audit export, vmware-audit stats3

Quick Install

uv tool install vmware-policy
vmware-audit stats          # verify installation

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 or maintenance windows
  • 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
User IntentRecommended Skill
VM lifecycle, deployment, guest opsvmware-aiops (uv tool install vmware-aiops)
Read-only monitoring, zero riskvmware-monitor (uv tool install vmware-monitor)
Storage: iSCSI, vSAN, datastoresvmware-storage (uv tool install vmware-storage)
Tanzu Kubernetes (vSphere 8.x+)vmware-vks (uv tool install vmware-vks)
NSX networking: segments, gateways, NATvmware-nsx (uv tool install vmware-nsx-mgmt)
NSX security: DFW rules, security groupsvmware-nsx-security (uv tool install vmware-nsx-security)
Aria Ops: metrics, alerts, capacityvmware-aria (uv tool install vmware-aria)
Load balancer, AVI, ALB, AKO, Ingressvmware-avi (uv tool install vmware-avi)
Multi-step workflows with approvalvmware-pilot
Audit log query, policy rulesvmware-policy -- this skill

Common Workflows

Query Recent Audit Activity

  1. View last 20 audit entries: vmware-audit log --last 20
  2. Filter by skill: vmware-audit log --skill vmware-nsx --last 50
  3. Check denied operations: vmware-audit log --status denied --since 2026-03-28
  4. View aggregate stats: vmware-audit stats --days 7

Set Up Policy Rules for Production

  1. Copy default rules: cp $(python -c "import vmware_policy; print(vmware_policy.__file__.replace('__init__.py','rules_default.yaml'))") ~/.vmware/rules.yaml
  2. 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
  4. Verify: vmware-audit log --status denied to see blocked operations

Export Audit Logs for Compliance

  1. Export all logs as JSON: vmware-audit export --format json > audit-export.json
  2. Filter by skill: vmware-audit export --skill vmware-aiops --since 2026-01-01
  3. Import into your SIEM or compliance tool

Usage Mode

ScenarioRecommendedWhy
Query audit logsCLIvmware-audit provides rich table output
Integrate into a skillPython APIfrom vmware_policy import vmware_tool, sanitize
Automated compliance exportCLIvmware-audit export --format json pipes to any tool

CLI Quick Reference

# View recent audit entries
vmware-audit log --last 20
vmware-audit log --skill vmware-nsx --status denied
vmware-audit log --since 2026-03-28 --tool delete_segment

# Export for compliance
vmware-audit export --format json > audit.json
vmware-audit export --skill vmware-aiops --since 2026-01-01

# Aggregate statistics
vmware-audit stats --days 7
vmware-audit stats --days 30

Full CLI reference: see references/cli-reference.md

Python API

from vmware_policy import vmware_tool, sanitize

# Wrap every MCP tool function
@vmware_tool(risk_level="high", sensitive_params=["password"])
def delete_segment(name: str, env: str = "") -> dict:
    ...

# Sanitize untrusted API responses before returning to LLM
clean_text = sanitize(api_response_text, max_len=500)

MCP Tools (0)

vmware-policy does not expose MCP tools. It is a Python library and CLI consumed by other VMware skills.

ComponentTypeDescription
@vmware_toolDecoratorWraps all 156+ MCP tools across 8 skills
sanitize()FunctionPrompt injection defense for API responses
AuditEngineClassSQLite WAL audit logger with rotation
PolicyEngineClassYAML rule evaluation with hot-reload
vmware-auditCLITyper CLI for querying audit trail
detect_agent()FunctionInfers calling AI agent from env vars (see below)

Agent Detection (Transparency Note)

The detect_agent() function in audit.py checks the following environment variables to identify which AI agent is calling the tools. This is read-only inspection for audit logging purposes — no credentials are extracted or stored:

Env VarDetected AgentPurpose
CLAUDE_SESSION_ID or CLAUDE_CODEclaudeClaude Code session
OPENAI_API_KEY or CODEX_SESSIONcodexOpenAI Codex session
OLLAMA_HOSTlocalLocal Ollama model
DEERFLOW_SESSIONdeerflowDeerFlow session
(none matched)unknownUnrecognized agent

The detected agent name is stored in the agent column of ~/.vmware/audit.db for audit trail purposes only. No API keys or tokens are logged.

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_ 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

uv tool install vmware-policy
mkdir -p ~/.vmware

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 references/setup-guide.md

Security

  • Source Code: github.com/vmware-skills/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/vmware-skills/VMware-Policy

常见问题

这个技能暴露 MCP 工具吗?
不暴露。vmware-policy 是一个 Python 库与 CLI(vmware-audit),由其他 VMware 技能通过 @vmware_tool 装饰器调用。
如何安装?
它会作为全部 8 个 VMware 技能的依赖被自动安装。仅在需要独立查询审计日志时,才需要手动执行 `uv tool install vmware-policy`。
审计数据存储在哪里?
存储于本地 SQLite WAL 数据库 ~/.vmware/audit.db,按 100MB 自动滚动归档并保留最近 5 份。不向外部发送任何数据。

相关技能

针对 vSphere/ESXi/NSX 环境的合规扫描与基线比对,覆盖 CIS、STIG、等保 2.0 三级、PCI-DSS、IT-Grundschutz、NIS2。

33 次安装

为 VMware 多步操作设计审批流程、追踪状态、失败时自动回滚的统一编排入口。

23 次安装1 星标

Use this skill whenever the user is troubleshooting a VMware/vSphere problem — a reported error, an exception, a log dump, a slow or failed VM, a host that went sideways — and needs help locating the root cause. It is the diagnostic brain of the VMware family: it drives a systematic investigation, pulls the right signals from the other skills, correlates events into one timeline, ranks root-cause hypotheses, and tells you what to check next even when you don't know where to start. Always use this skill for "diagnose this VMware issue", "why is my VM slow", "troubleshoot this vSphere error", "what does this log mean", "help me figure out what broke" when the context is explicitly VMware/vSphere/ESXi/NSX. It is READ-ONLY: it never changes anything. Do NOT use it to execute fixes — single fixes go to vmware-aiops, multi-step gated remediation goes to vmware-pilot. Do NOT use it for routine inventory or health checks with no problem to solve — use vmware-monitor.

1 次安装

管理 vSphere 存储——数据存储、iSCSI 和 vSAN——通过 12 个 MCP 工具或 CLI。

53 次安装1 星标

通过 33 个 MCP 工具查询 VMware Aria Operations 的指标、告警、容量、异常与报告。

52 次安装

Use this skill whenever the user needs to search, aggregate, or investigate centralized logs in VMware VCF Operations for Logs (formerly Aria Operations for Logs / vRealize Log Insight) — the appliance that collects syslog from ESXi hosts, vCenter, and VMs. It is the log data source of the VMware family: full-text event search over a time window, aggregation with spike detection, field discovery, and alert queries. Always use this skill for "search the logs", "what did the host log", "find errors in Log Insight", "show me a log spike", "query vRealize Log Insight", "Aria Operations for Logs", "VCF Operations for Logs" when the context is explicitly VMware/vSphere/ESXi. It is strictly READ-ONLY — it never ingests, edits, or deletes anything. Do NOT use it for vCenter events/alarms (use vmware-monitor) or for performance metrics and anomalies (use vmware-aria). To correlate logs with events from other sources into one root-cause timeline, hand results to vmware-debug.

1 次安装