Skip to content

v1.2.1

Choose a tag to compare

@github-actions github-actions released this 30 Apr 06:19
· 18 commits to main since this release

Patch release. Recommended for all users on v1.2.0 — fixes a high-severity import replay vulnerability and a 500 on the most common Grid::make(new Model()) import path.

Fixed

Import execute 端点存在重放写入风险(high)

dcat-api/import/execute 此前没有任何授权检查,签名 _import_config 一旦泄露/留存就成为可重放的写权限——离职/降权管理员只要 cookie 仍有效就能持续写库。

修复方案:

  • buildImporterConfig() 把 user_id / source 路由名 / expires_at 一并签入 payload
  • execute() 调用 guardExecute() 做三重校验:
    • expires_at 过期 → 419 拒绝
    • user_id 与当前登录用户不一致 → 403 拒绝
    • source 路由的 admin.permission 中间件参数 → 用 PermissionChecker 重跑权限检查
  • template 端点不写库,跳过 guard,让用户在签名过期时仍能下载模板

默认 Grid 导入因丢失 model 信息而 500(high)

最常见用法 Grid::make(new SomeModel()) 创建的 repository 是基类 EloquentRepository 的实例,model 信息存在实例 state 而非类名;之前实现只签了 get_class($repo),下次请求 app(EloquentRepository::class) 拿到空壳,createModel() 必触发 TypeError。

修复方案:

  • EloquentRepository 新增 eloquentClass() 访问器
  • buildImporterConfig() 检测到 EloquentRepository 实例时同时签 model 类名
  • buildRepository() 接受 modelClass 参数,对基类 EloquentRepository 走 new EloquentRepository($modelClass) 重建带 model 的 repo;校验 model 是 Eloquent\Model 子类,否则返回 null

Changed

  • 全面扁平化 dcat 阴影系统 — dcat 自家代码移除散落的硬编码 rgba 阴影,改走统一的 $shadow / $shadow-100/200 变量;_modern.scss 末尾新增 AdminLTE Shadow Flatten 区块,通过主题层覆盖 AdminLTE 残留装饰阴影(不动 AdminLTE 源码)。保留功能性 / 语义性 shadow:a11y focus ring、.elevation-1..5 工具类、PACE / nprogress glow、kbd inset shadow、固定列分隔阴影、$menu-shadow
  • 统一 .alert-* 视觉风格 — 5 个 alert 之前 shadow 透明度各不相同(0.16 / 0.12 / 0.09 / 无 / 无),改为全部纯色背景 + 文字色,无浮起阴影,与 .callout-light 扁平化整体方向一致

Compatibility

  • 签名 payload 新增 user_id / source / expires_at / model 字段,向前兼容——老客户端缓存的页面(升级前打开未刷新)签名不带这些字段,guardExecute 检测字段存在性才校验,最坏只是无防重放保护,等同升级前行为;用户刷新页面后立即获得三层保护
  • 没有改任何前端 JS 调用方式,ImportButton URL / 字段名不变

Verify

composer ci 全绿(Pint / Rector / PHPStan level 5 / 5027 tests),新增 7 个测试覆盖修复的所有路径。


Full Changelog: v1.2.0...v1.2.1