Skip to content

Fix wiki content security

路志远请求将fix-wiki-cvs合并到main-jh

What does this MR do and why?

Issue: Wiki 页面未支持图片安全审核

What

当前我们的 Wiki 无法冻结违规图片,本 MR 修复此问题。

Why

  • Wiki 本质上是一个 Git 仓库,每次上传文件、修改文本,都会新增一个 Commit。
  • 当检测到图片违规时,GitLab 会存储图片地址和 它的 Commit sha 到数据库
  • 用户向 Wiki 中添加图片的操作是:将图片拖拽进输入框(自动触发上传,生成了 Commit1),之后点击保存按钮(生成了 Commit2)。GitLab 会将违规图片标记在 Commit1 上,而不是 Commit2
  • 用户访问 Wiki 时,内容取自最新的 Commit,即 Commit2。GitLab 认为 Commit2 不违规。所以图片被展示了出来。

How to fix

在判断 Wiki 图片是否违规时,不把 Commit 当做查询条件。图片的 Path 中已经有唯一标识的 Sha 了,所以只用 Path 查询是足够的。

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

对于违规图片:

Before After

How to set up and validate locally

bin/rspec jh/spec/controllers/projects/wikis_controller_spec.rb
路志远 编辑于

合并请求报告