osquery
$ osqueryi 基金会 低风险osquery(osqueryi)将进程、监听套接字、内核扩展、用户、已装软件包与证书等操作系统状态暴露为 SQLite 虚拟表。传入 --json 与 SQL SELECT 查询即可让 Agent 获得严格只读、按字段裁剪的终端遥测数据,毫无修改风险。
brew install osquery osqueryi --json 通过 SQL 在毫秒级查询本地系统表并原生支持字段筛选,无需 MCP 中间层。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持单参数 SQL 执行、--json / --csv、SQL SELECT 字段过滤以及自描述的 osquery_registry / .schema 表。
- Native
--jsonand SQL column projection - Self-describing
osquery_registryandPRAGMA table_info()
严格只读的虚拟 SQL 表,无法修改系统状态;注意未加限定的 file 表查询可能消耗较高 CPU/IO。
- Read-only virtual table engine
可通过 brew install osquery 与 osquery.io 官方安装包在 macOS、Linux、Windows 部署。
- Multi-OS native builds at osquery.io/downloads
用统一的类型化 SQL JSON 接口替代大量零散的 ps、lsof、netstat 文本解析。
- Unified SQL over 250+ OS telemetry tables
由 Facebook 发起、现归属 Linux 基金会的开源项目,企业级采用度高。
- Linux Foundation / osquery repository
osquery.io 与 ReadTheDocs 提供按操作系统与版本划分的可搜索 Schema 文档。
- Schema reference at osquery.io/schema
安全边界、鉴权与放权指南
无需凭据;直接读取本地操作系统 API 与 procfs/sysfs 表。
100% 免费、离线、开源(Apache-2.0 OR GPL-2.0)。
# 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 高频安全命令配方
只读查询(安全推荐)
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 行结果。
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查询较慢。