DeltaScope 是一个离线优先的 PostgreSQL DDL审核工具,用于 PG 表结构变更审核。它审核 CREATE TABLE、ALTER TABLE、GRANT 等语句,覆盖表结构变更、权限分配、复合类型生命周期和扩展生命周期。无需连接数据库。
使用 --dialect postgresql 传入 PostgreSQL SQL 语句,DeltaScope 解析语句并评估所有适用规则。
$ deltascope audit --dialect postgresql \
--sql "GRANT ALL PRIVILEGES ON TABLE users TO analyst;"
Verdict: review
Statements: 1
Blockers: 0
Warnings: 1
Notices: 1
Statement 1: GRANT TABLE
- [notice] ddl.pg.grant.table_privilege.notice: granting privilege on table "users"
- [warning] ddl.pg.grant.table_privilege.all.warn: granting ALL PRIVILEGES is broader than needed
ddl.pg.grant.table_privilege.all.warn)ddl.pg.grant.table_privilege.notice)# 审核一个 PostgreSQL 迁移文件
deltascope audit \
--dialect postgresql \
--file ./migrations/20260409_add_column.sql \
--format github-actions \
--fail-on warning
支持的输出格式:json、github-actions、sarif、gitlab-codequality、text。
ddl.pg.grant.table_privilege.notice 对所有表权限授予发出提醒。ddl.pg.grant.table_privilege.all.warn 对 ALL PRIVILEGES 授予发出警告,因为 ALL 通常比实际需要的权限更宽泛。--dialect postgresql 或 --dialect mysql 切换方言。引擎、配置格式和 CI 集成在两种方言之间完全一致。