CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

osquery

$ osqueryi 基金会 低风险
osquery · 安全扫描与密钥管理 · Apache-2.0 OR GPL-2.0 · macos / linux / windows

osquery(osqueryi)将进程、监听套接字、内核扩展、用户、已装软件包与证书等操作系统状态暴露为 SQLite 虚拟表。传入 --json 与 SQL SELECT 查询即可让 Agent 获得严格只读、按字段裁剪的终端遥测数据,毫无修改风险。

FCRS-1.0 综合评分
94 /100
极佳 (Excellent)
中置信度 (源码/文档)
零摩擦安装命令
brew install osquery
CLI vs MCP 选型建议 仅 CLI 可用

osqueryi --json 通过 SQL 在毫秒级查询本地系统表并原生支持字段筛选,无需 MCP 中间层。

Agent 友好度体检单

✓ 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
✓ 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 24 / 25

支持单参数 SQL 执行、--json / --csv、SQL SELECT 字段过滤以及自描述的 osquery_registry / .schema 表。

  • Native --json and SQL column projection
  • Self-describing osquery_registry and PRAGMA table_info()
安全与权限边界 24 / 25

严格只读的虚拟 SQL 表,无法修改系统状态;注意未加限定的 file 表查询可能消耗较高 CPU/IO。

  • Read-only virtual table engine
安装与运行摩擦 14 / 15

可通过 brew install osquery 与 osquery.io 官方安装包在 macOS、Linux、Windows 部署。

  • Multi-OS native builds at osquery.io/downloads
能力覆盖与边际价值 14 / 15

用统一的类型化 SQL JSON 接口替代大量零散的 ps、lsof、netstat 文本解析。

  • Unified SQL over 250+ OS telemetry tables
维护与来源背书 9 / 10

由 Facebook 发起、现归属 Linux 基金会的开源项目,企业级采用度高。

  • Linux Foundation / osquery repository
文档与可验证性 9 / 10

osquery.io 与 ReadTheDocs 提供按操作系统与版本划分的可搜索 Schema 文档。

  • Schema reference at osquery.io/schema

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

无需凭据;直接读取本地操作系统 API 与 procfs/sysfs 表。

潜在副作用
只读查询
费用与配额提示

100% 免费、离线、开源(Apache-2.0 OR GPL-2.0)。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# osquery Agent Rules
- Always pass `--json` and a SQL query argument so `osqueryi` exits immediately instead of opening an interactive REPL.
- Use explicit `SELECT` columns and `LIMIT` clauses to avoid scanning huge `file` or `hash` tables unboundedly.

Agent 高频安全命令配方

只读查询(安全推荐)

以 JSON 查询正在监听的网络端口
osqueryi --json "SELECT lp.pid, p.name, lp.port, lp.address FROM listening_ports lp JOIN processes p USING (pid) WHERE lp.port > 0 LIMIT 25;"

在单条只读 SQL 中关联 listening_ports 与 processes 表并输出 JSON 行结果。

自省当前系统可用的 osquery 虚拟表
osqueryi --json "SELECT name FROM osquery_registry WHERE registry = 'table' AND active = 1 ORDER BY name;"

发现当前操作系统上已激活的虚拟表,便于 Agent 自描述查询。

核心优势

  • + 通过统一只读 SQL + --json 覆盖进程、套接字、用户、软件包与证书等系统信息。
  • + 自描述 Schema(PRAGMA table_info、osquery_registry)支持 Agent 动态发现字段。

注意事项与踩坑点

  • ! 不带查询参数调用 osqueryi 会进入交互式 REPL。
  • ! 部分表需要 root/sudo 才能看到完整视图(如其他用户的套接字),且无约束 file 查询较慢。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI