Atlas v1.4:数据库也能做 CVE 扫描,agent 不再直接写 migration
Atlas 是 Go 编写的 schema-as-code 工具,用 HCL/SQL 描述期望状态,由它生成并执行 migration。v1.4 于 2026-11-17 发布。
- 项目地址:https://github.com/ariga/atlas
- 发布说明:https://atlasgo.io/blog/2026/11/17/atlas-v1-4
- 文档:https://atlasgo.io
本次更新包括:数据库安全扫描、Atlas Agent Skills、测试框架 profiler、部署间 drift 检测、schema 仓库自托管存储、若干驱动改进,以及二进制下载域名迁移。
安装
curl -sSf https://atlasgo.sh | sh
brew install ariga/tap/atlas
docker pull arigaio/atlas
GitHub Actions 中使用 ariga/setup-atlas@v0(带 cloud-token)。
安全扫描:报出服务器与扩展的 CVE
atlas security scan 检查数据库服务器和已安装扩展的已知漏洞,可在 CLI、CI、Kubernetes 中运行。
atlas security scan \
--url "postgres://postgres:pass@localhost:5432/app?sslmode=disable" \
--url "clickhouse://default:pass@localhost:9000" \
--url "postgres://postgres:pass@localhost:5433/reporting?sslmode=disable"
输出节选:
Scanning 3 databases for security issues:
-- postgres://postgres:xxxxx@localhost:5432/app?sslmode=disable (postgres 18.6):
-- Extension "vector" version "0.8.5" is vulnerable to CVE-2026-103484 (HIGH): pgvector buffer overflow in IVFFlat index build. Upgrade extension "vector" to 0.8.7 or later
-- Extension "vector" version "0.8.5" is vulnerable to CVE-2026-18022 (HIGH): ... Upgrade to 0.8.6 or later
-- clickhouse://... (clickhouse 23.10.5.20):
-- Engine "clickhouse" version "23.10.5.20" is vulnerable to CVE-2024-22412 (ELEVATED): RBAC bypassed when query caching enabled. Upgrade to 23.12.6.19 or later
-- Engine "clickhouse" version "23.10.5.20" is vulnerable to CVE-2026-116366 (CRITICAL): Unauthenticated RCE. Upgrade to 26.3.62.3 or later
-- postgres:5433/reporting: querying system variables: dial tcp [::1]:5433: connect: connection refused
-- 1.061387208s
-- 1 database could not be scanned
-- 4 issues found: 1 critical, 2 high, 1 elevated
连不上的数据库不会被静默跳过:它计入结果,并让命令以失败退出,因为该库状态未知。
同一套漏洞检测也接入 lint,在合并前跑;另有 access check 标记影响面大的角色。引擎检测覆盖 PostgreSQL、MySQL、MariaDB、ClickHouse、SQL Server,PostgreSQL 还会检查已安装扩展。fail_on 控制哪个严重级别触发失败,notify 块可发 Slack。
定时执行的方式有几种:security/scan GitHub Action、K8s Operator 的 AtlasSecurityScan 资源(用 Compliant 条件作为部署门禁),以及汇总所有仓库与受监控数据库发现的 Security Dashboard。
安全扫描属于 Atlas Pro,且套餐需要包含 Security Graph,使用前需先 atlas login。文档见 security scanning guide。
Agent Skills:agent 改 desired state,Atlas 生成 plan
agent 改 schema 文件和改普通代码不一样:migration 需要考虑对象依赖顺序、要通过 lint 策略、同一变更应产出同一个 migration。所以 Atlas 的 agent skills 不教 agent 写 migration——agent 只改 desired state,由 Atlas 生成 plan,并且在 agent 报告完成之前,变更已经被 lint 和 test 过。
Claude Code:
claude plugin marketplace add ariga/atlas && claude plugin install atlas@ariga
然后执行 /atlas:atlas-onboard。
Codex / Cursor / Copilot:
npx skills add ariga/atlas -a codex -y
-a 也可换成 cursor 或 github-copilot,之后执行 $atlas-onboard。
安装内容包括:
atlas:inspect → plan → lint → test → apply 全流程atlas-onboard:引导式上手,从不改生产,首次部署由人执行- 各数据库 skill:PostgreSQL、MySQL、SQL Server、ClickHouse、Snowflake、Databricks、Redshift、Oracle、Spanner
atlas-operator:Kubernetesatlas-action:CI/CD
lint 对 drop column 默认失败,除非显式允许;skill 不允许 agent 在没有你同意的情况下跳过 lint 错误。也可以写自定义 lint 规则。
测试 profiler:在接近生产的数据上看锁与重写
这是 preview 功能,面向 Teams/Enterprise 的部分客户。profiling 目前支持 PostgreSQL、MySQL、MariaDB、SQL Server。
dataset 提供接近生产的测试行数:从 Amazon RDS 快照或 CSV 文件采样并脱敏,或者按 schema 生成。--profile 对测试跑过的每条语句做 profile(migration、query、function、procedure、trigger),报告持有的锁类型与时长、被重写的表、磁盘/日志/临时空间。
示例 migration migrations/20261104093012_add_orders_digest.sql:
ALTER TABLE orders ADD COLUMN digest text;
UPDATE orders SET digest = md5(note);
migrate.test.hcl:
dataset "synthetic" "orders" {
table "public.orders" { rows = 2000000 }
}
test "migrate" "20261104093012" {
migrate { to = "20261103101500" }
dataset { use = dataset.synthetic.orders }
migrate { to = "20261104093012" }
}
atlas migrate test --dev-url "docker://postgres/18/dev" --profile .
migrate#3 20261104093012 9.84s
rows public.orders 2,000,000 updated
read public.orders 2,000,000 rows, 1 sequential scan
size public.orders 185.3MB -> 432.0MB (+246.7MB)
log 721.3MB written, 721.3MB while the statements ran
! lock public.orders: takes AccessExclusiveLock for 9.842s, 9.806s of it after the statement, blocking reads and writes (20261104093012_add_orders_digest.sql:1)
以 ! 开头的行是 finding。这里指向第 1 行的 ALTER 而不是 UPDATE:9.842 秒里有 9.806 秒发生在语句执行完之后——PostgreSQL 持锁到事务结束,所以 UPDATE 填 200 万行期间,orders 的读写一直被阻塞。
同样的 flag 也可用于 schema test:
atlas schema test --dev-url "docker://postgres/18/dev" --url "file://schema.hcl" --profile .
dataset 细节。rds_snapshot 示例:
dataset "rds_snapshot" "prod" {
src = "s3://backups/exports/prod-2026-10-13/appdb?region=us-east-1"
exclude = ["analytics.events*"]
}
Atlas 用你的 AWS 凭证读取导出,按外键顺序加载表并保留主键;exclude 跳过 events 日志及其分区。
sampler 控制取行方式:head / tail 取首尾行,random 随机行,composite 按表指定。下面的例子给 events 表 1 万随机行、plans 全量、其它表每表首 100 行:
sampler "random" "large" { rows = 10000 }
sampler "head" "first" { rows = 100 }
sampler "composite" "prod" {
table { match = ["analytics.events"] use = sampler.random.large }
table { ... }
}
drift 检测:报告偏离 migration 的对象
atlas migrate drift --env prod
输出:
Drift Status: DRIFTED
Current Version: 20260423120000
Expected State: atlas://my-app (registry)
Pending Files: 0
Changes: 3 (1 extra, 1 missing, 1 modified)
Objects: 3 tables
Fingerprint: 28274a91e01d
后面会给出 diff(例如新增 nickname 列、新增 authors_name 索引)以及 "as if executed" 的 SQL。命令不修改数据库,发现 drift 时退出码为 1。
也支持一次跑多个租户环境、GitHub Action,以及 K8s Operator 的 AtlasDriftCheck 与 policy.drift。属于 Atlas Pro。
Schema 仓库:状态可以放在自己的存储里
env "prod" {
url = getenv("DATABASE_URL")
dev = "sqlite://dev?mode=memory"
schema {
src = "file://schema.sql"
repo { name = "app" url = getenv("ATLAS_REGISTRY_URL") }
}
}
repo.url 支持的协议:
s3://bucket/path?region=gs://bucket/pathazureblob://container/path?storage_account=oci://user:pass@ghcr.io/org/registry
OCI URL 里带凭证,应从环境变量或密钥库读取。
atlas schema push --env prod
输出:
Schema: app Atlas URL: atlas://app Registry URL: oci://ghcr.io/org/atlas-registry
plan / apply 的用法不变:
atlas schema plan --env prod --from atlas://app --name add-posts --auto-approve
atlas schema apply --env prod --to atlas://app --auto-approve
几点注意:这些命令仍需 atlas login;backup 可以与 url 并存,写入时同时复制一份到 backup,backup 失败不影响命令,url 读不到时回退到 backup;已经在 Atlas Cloud 里的 state/plan 不会自动复制到 url。
驱动改进
- Snowflake:governance policies
- SQL Server:linked servers 与 filegroups
- PostgreSQL 18:temporal keys
- Databricks:metric views
- Redshift:datashares
其他改动
- lint 现在把
drop table/drop column也标为 backward incompatible(BC103/BC104),此前只标 destructive(DS102/DS103)。 - 自 v1.3.5 起用 Go 1.26.10 构建,会拒绝由 eMudhra 中间证书签发的证书(该中间证书已泄露)。
二进制下载域名迁移
2026 年 12 月起,release.ariga.io 将重定向到 atlasbinaries.com。如果 CI 或脚本里对下载地址做了白名单或固定解析,需要提前放行新域名。