内容
# 姿势
[![Go CI][go-ci-svg]][go-ci-url]
[![Go Lint][go-lint-svg]][go-lint-url]
[![Go SAST][go-sast-svg]][go-sast-url]
[![Go 报告卡][goreport-svg]][goreport-url]
[![文档][docs-godoc-svg]][docs-godoc-url]
[![可视化][viz-svg]][viz-url]
[![许可证][license-svg]][license-url]
一款支持Model Context Protocol(MCP)服务器的跨平台安全姿势评估工具。Posture提供了macOS、Windows和Linux的统一安全检查,使AI助手能够查询硬件安全模块、启动安全、磁盘加密和生物识别能力。
## 功能
### 安全评估
- 🛡️ **平台安全芯片** - 安全飞地(macOS)/ TPM(Windows/Linux)检测和状态
- 🔐 **安全启动** - UEFI/Apple安全启动验证
- 💾 **磁盘加密** - FileVault(macOS),BitLocker(Windows),LUKS(Linux)
- 👆 **生物识别** - Touch ID,Face ID,Windows Hello,fprintd
- 📊 **安全摘要** - 统一的安全分数和建议
### 系统指标
- ⚡ **CPU使用率** - 总体和每核心监控
- 🧠 **内存使用率** - 总体,已用,空闲,可用内存
- 📋 **进程列表** - 运行中的进程和资源使用情况
### 输出格式
- 📄 **JSON** (默认)- 用于程序化使用的结构化数据
- 🗂️ **表格** - 带有ANSI颜色和UTF-8图标的丰富ASCII表格
## 安装
### 预编译二进制文件
从[发布页面](https://github.com/plexusone/posture/releases)下载适用于您平台的最新版本。
### 从源代码构建
需要Go 1.23或更高版本。
```bash
git clone https://github.com/plexusone/posture.git
cd posture
go build -o posture ./cmd/posture/
```
## 用法
Posture可以以三种方式使用:
1. **CLI** - 命令行工具,用于交互式使用
2. **MCP服务器** - 模型上下文协议服务器,用于AI助手
3. **Go模块** - Go应用程序中的编程访问
## CLI用法
```bash
# 显示带有分数的安全摘要
posture summary -f table
# 检查平台安全芯片(安全飞地/TPM)状态
posture security-chip -f table
# 检查安全启动状态
posture secureboot -f table
# 检查磁盘加密状态
posture encryption -f table
# 检查生物识别能力
posture biometrics -f table
# 系统指标
posture cpu -f table
posture memory -f table
posture processes -n 10 -f table
```
## MCP服务器用法
### Claude桌面配置
将以下内容添加到您的Claude桌面配置文件中:
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
"mcpServers": {
"posture": {
"command": "/path/to/posture",
"args": ["serve"]
}
}
}
```
### MCP工具
| 工具 | 描述 |
|------|-------------|
| `get_platform_security_chip` | 安全飞地(macOS)/ TPM(Windows/Linux)状态 |
| `get_secure_boot_status` | UEFI安全启动验证 |
| `get_encryption_status` | 磁盘加密(FileVault/BitLocker/LUKS) |
| `get_biometric_capabilities` | 生物识别身份验证状态 |
| `get_security_summary` | 统一安全姿势和分数 |
| `get_cpu_usage` | CPU使用率统计 |
| `get_memory` | 内存使用率统计 |
| `list_processes` | 运行中的进程列表 |
## Go模块用法
导入`inspector`包,以便对所有安全和系统指标进行编程访问。
### 安装
```bash
go get github.com/plexusone/posture
```
### 示例:安全摘要
```go
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/plexusone/posture/inspector"
)
func main() {
// 获取统一的安全摘要
summary, err := inspector.GetSecuritySummary()
if err != nil {
log.Fatal(err)
}
fmt.Printf("安全分数:%d/100\n", summary.OverallScore)
fmt.Printf("状态:%s\n", summary.OverallStatus)
// 输出为JSON
data, _ := json.MarshalIndent(summary, "", " ")
fmt.Println(string(data))
// 或使用内置表格格式化
fmt.Println(inspector.FormatSecuritySummaryTable(summary))
}
```
### 示例:单个检查
```go
package main
import (
"context"
"fmt"
"log"
"github.com/plexusone/posture/inspector"
)
func main() {
ctx := context.Background()
// 平台安全芯片(安全飞地/TPM)
if inspector.IsTPMSupported() {
tpm, err := inspector.GetTPMStatus()
if err == nil {
fmt.Printf("安全芯片:%s(启用:%v)\n", tpm.Type, tpm.Enabled)
}
}
// 安全启动
if inspector.IsSecureBootSupported() {
boot, err := inspector.GetSecureBootStatus()
if err == nil {
fmt.Printf("安全启动:%v(模式:%s)\n", boot.Enabled, boot.Mode)
}
}
// 磁盘加密
if inspector.IsEncryptionSupported() {
enc, err := inspector.GetEncryptionStatus()
if err == nil {
fmt.Printf("加密:%s(状态:%s)\n", enc.Type, enc.Status)
}
}
// 生物识别
if inspector.IsBiometricsSupported() {
bio, err := inspector.GetBiometricCapabilities()
if err == nil {
fmt.Printf("生物识别:%s(已注册:%v)\n",
bio.BiometryType, bio.TouchIDEnrolled || bio.FaceIDEnrolled)
}
}
// 系统指标
cpu, _ := inspector.GetCPUUsage(ctx)
fmt.Printf("CPU使用率:%.1f%%\n", cpu.OverallPercent)
mem, _ := inspector.GetMemory(ctx)
fmt.Printf("内存:%s / %s(%.1f%%)\n",
inspector.FormatBytes(mem.Used),
inspector.FormatBytes(mem.Total),
mem.UsedPercent)
}
```
### 可用函数
| 函数 | 描述 |
|----------|-------------|
| `GetSecuritySummary()` | 统一安全姿势和分数 |
| `GetTPMStatus()` | 平台安全芯片状态 |
| `GetSecureBootStatus()` | 安全启动配置 |
| `GetEncryptionStatus()` | 磁盘加密状态 |
| `GetBiometricCapabilities()` | 生物识别身份验证状态 |
| `GetCPUUsage(ctx)` | CPU使用率统计 |
| `GetMemory(ctx)` | 内存使用率统计 |
| `ListProcesses(ctx, limit)` | 运行中的进程列表 |
每个函数都有一个对应的`IsXXXSupported()`函数来检查平台可用性。
## 平台支持
| 功能 | macOS | Windows | Linux |
|---------|-------|---------|-------|
| 平台安全芯片 | ✅ 安全飞地 | ✅ TPM 1.2/2.0 | ✅ TPM 2.0 |
| 安全启动 | ✅ Apple安全启动 | ✅ UEFI安全启动 | ✅ UEFI安全启动 |
| 磁盘加密 | ✅ FileVault | ✅ BitLocker | ✅ LUKS/dm-crypt |
| 生物识别 | ✅ Touch ID/Face ID | ✅ Windows Hello | ✅ fprintd/Howdy |
| CPU/内存/进程 | ✅ | ✅ | ✅ |
## 示例输出
### 安全摘要(表格格式)
```
🛡️ 安全摘要
────────────────────────────────────────────────────────────
平台: 🍎 macOS
安全分数:75/100
██████████████████████████████░░░░░░░░░░
状态:✓ 良好
安全功能:
┌──────────────────────────┬──────────────┬────────────────────┐
│ 功能 │ 状态 │ 详情 │
├──────────────────────────┼──────────────┼────────────────────┤
│ 🛡️ 安全飞地 │ ✓ 已启用 │ secure_enclave │
│ 🔒 安全启动 │ ✓ 已启用 │ full │
│ 🔒 FileVault │ ✗ 已禁用 │ disabled │
│ 👆 生物识别 │ ✓ 已启用 │ touch_id │
└──────────────────────────┴──────────────┴────────────────────┘
⚠️ 建议:
──────────────────────────────────────────────────
1. 启用FileVault以保护静态数据
```
### 安全摘要(JSON格式)
```json
{
"platform": "darwin",
"overall_score": 75,
"overall_status": "good",
"tpm": {
"present": true,
"enabled": true,
"type": "secure_enclave"
},
"secure_boot": {
"enabled": true,
"mode": "full"
},
"encryption": {
"enabled": false,
"type": "filevault",
"status": "disabled"
},
"biometrics": {
"available": true,
"configured": true,
"type": "touch_id"
},
"recommendations": [
"启用FileVault以保护静态数据"
]
}
```
## 架构
```
┌─────────────────────────────────────────────────────────────┐
│ Claude桌面 │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ MCP客户端 │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
│ stdio(JSON-RPC)
▼
┌─────────────────────────────────────────────────────────────┐
│ Posture │
│ ┌──────────────────┐ ┌──────────────────────────────────┐ │
│ │ MCP服务器 │ │ 安全工具 │ │
│ │ │ │ 🛡️ get_platform_security_chip │ │
│ │ - 工具注册 │ │ 🔒 get_secure_boot_status │ │
│ │ - JSON-RPC │ │ 🔐 get_encryption_status │ │
│ │ - stdio │ │ 👆 get_biometric_capabilities │ │
│ │ │ │ 📊 get_security_summary │ │
│ └──────────────────┘ └──────────────────────────────────┘ │
│ │ │
│ ┌───────────────────────────┴────────────────────────────┐ │
│ │ 检查器 │ │
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
│ │ │ darwin │ │ windows │ │ linux │ │ common │ │ │
│ │ │(cgo) │ │ (WMI) │ │ (sysfs) │ │(gopsutil│ │ │
│ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
```
## 安全考虑
该工具的设计注重安全:
- **只读操作** - 不可能进行系统修改
- **不暴露秘密** - 不访问密钥链,密码或私钥
- **非侵入式检查** - 仅测试能力,绝不提取密钥
- **进程列表是信息性的** - 不能终止或修改进程
### 本工具不执行的操作
- 访问或导出任何加密密钥
- 读取密钥链项目或密码
- 修改系统设置
- 执行任意命令
- 访问文件内容
- 发出网络请求
## 为不同平台构建
```bash
# macOS(包括安全飞地)
GOOS=darwin GOARCH=arm64 go build -o posture-darwin-arm64 ./cmd/posture/
GOOS=darwin GOARCH=amd64 go build -o posture-darwin-amd64 ./cmd/posture/
# Linux(包括TPM,LUKS)
GOOS=linux GOARCH=amd64 go build -o posture-linux-amd64 ./cmd/posture/
GOOS=linux GOARCH=arm64 go build -o posture-linux-arm64 ./cmd/posture/
# Windows(包括TPM,BitLocker)
GOOS=windows GOARCH=amd64 go build -o posture-windows-amd64.exe ./cmd/posture/
```
注意:从其他平台交叉编译为macOS时,不会包含安全飞地支持,因为cgo依赖于此。
## 依赖
- [modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) - 官方MCP Go SDK
- [shirou/gopsutil/v4](https://github.com/shirou/gopsutil) - 跨平台系统指标
- [spf13/cobra](https://github.com/spf13/cobra) - CLI框架
## 相关项目
- [MCP规范](https://modelcontextprotocol.io/)
- [MCP Go SDK](https://github.com/modelcontextprotocol/go-sdk)
- [Claude桌面](https://claude.ai/download)
## 许可证
MIT许可证 - 有关详细信息,请参见[LICENSE](LICENSE)文件。
## 贡献
欢迎贡献!请随时提交拉取请求。
[go-ci-svg]: https://github.com/plexusone/posture/actions/workflows/go-ci.yaml/badge.svg?branch=main
[go-ci-url]: https://github.com/plexusone/posture/actions/workflows/go-ci.yaml
[go-lint-svg]: https://github.com/plexusone/posture/actions/workflows/go-lint.yaml/badge.svg?branch=main
[go-lint-url]: https://github.com/plexusone/posture/actions/workflows/go-lint.yaml
[go-sast-svg]: https://github.com/plexusone/posture/actions/workflows/go-sast-codeql.yaml/badge.svg?branch=main
[go-sast-url]: https://github.com/plexusone/posture/actions/workflows/go-sast-codeql.yaml
[goreport-svg]: https://goreportcard.com/badge/github.com/plexusone/posture
[goreport-url]: https://goreportcard.com/report/github.com/plexusone/posture
[docs-godoc-svg]: https://pkg.go.dev/badge/github.com/plexusone/posture
[docs-godoc-url]: https://pkg.go.dev/github.com/plexusone/posture
[viz-svg]: https://img.shields.io/badge/visualizaton-Go-blue.svg
[viz-url]: https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=plexusone%2Fposture
[loc-svg]: https://tokei.rs/b1/github/plexusone/posture
[repo-url]: https://github.com/plexusone/posture
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://github.com/plexusone/posture/blob/master/LICENSE
MCP 配置
以下是此 MCP Server 的配置信息,可直接复制到 Cursor 或其他 MCP 客户端中使用。
mcp.json
连接信息
猜你喜欢
暂无推荐服务器