Skip to content

Delete .github/workflows/call-synchronize-to-dtk6.yml#360

Merged
zccrs merged 1 commit intomasterfrom
asterwyx-patch-1
Jan 20, 2026
Merged

Delete .github/workflows/call-synchronize-to-dtk6.yml#360
zccrs merged 1 commit intomasterfrom
asterwyx-patch-1

Conversation

@asterwyx
Copy link
Contributor

No description provided.

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: asterwyx

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Synchronizing is no more needed.
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

代码审查报告:.github/workflows/call-synchronize-to-dtk6.yml

这份代码是一个 GitHub Actions 工作流定义文件,用于在 pull_request_target 事件触发时,调用另一个仓库 (linuxdeepin/dtk) 中的工作流,将代码同步到 linuxdeepin/dtk6gui

以下是对该文件(删除前状态)的详细审查意见:

1. 语法逻辑

  • 状态:基本正确。
  • 分析:YAML 语法结构符合 GitHub Actions 的规范。uses 关键字正确引用了外部仓库的工作流,secrets: inherit 正确配置了密钥传递,with 下的参数传递格式也符合规范。
  • 建议:逻辑上没有明显错误,能够实现预期的调用同步工作流的功能。

2. 代码质量

  • 状态:一般,存在潜在的安全风险。
  • 分析
    • 引用分支固定uses: ...@master。直接引用 master 分支意味着如果上游仓库的 master 分支发生变更(即使是恶意的),当前仓库执行该 Action 时也会自动运行变更后的代码。虽然 master 分支通常受保护,但最佳实践是引用特定的 Commit SHA 或 Tag,以确保构建的可复现性和稳定性。
    • 路径过滤paths-ignore 配置得比较细致,排除了打包相关的目录,这有助于减少不必要的构建触发,是好的做法。

3. 代码性能

  • 状态:良好。
  • 分析:作为一个调用型工作流,它本身不包含繁重的脚本,只是触发远程任务。paths-ignore 的设置有效避免了在仅修改打包文件时触发同步,节省了 CI 资源。

4. 代码安全 (重点)

  • 状态:存在严重的安全隐患
  • 分析
    • 事件触发风险 (pull_request_target):该工作流使用了 pull_request_target 事件。这个事件会在目标仓库(即当前被 PR 的仓库)的上下文中运行,并且拥有目标仓库的写入权限(secrets: inherit 继承了目标仓库的 Token)。
    • 代码注入风险:工作流中使用了 source_repo: ${{ github.event.pull_request.head.repo.full_name }}source_ref: ${{ github.event.pull_request.head.ref }}。这意味着被调用的下游工作流很可能会检出 PR 提交的代码。
    • 隐患:如果攻击者向该仓库提交一个恶意的 PR,虽然这个工作流文件本身没有直接运行 PR 中的代码,但它将 PR 的源信息传递给了具有高权限的下游工作流。如果下游工作流 (synchronize-to-dtk6.yml) 在处理过程中没有严格隔离环境(例如直接运行了脚本、或者使用了未经验证的代码),攻击者可以利用目标仓库的 GITHUB_TOKEN 窃取密钥或篡改代码库。
    • 删除操作:该文件被删除(deleted file mode 100644),这通常意味着维护者已经意识到了风险或不再需要此同步逻辑。从安全角度看,删除此文件是正确的决定,因为它消除了一个潜在的提权攻击向量。

改进建议

如果未来必须恢复类似的同步功能,建议采取以下改进措施:

  1. 固定 Action 版本
    不要使用 @master,而是使用具体的 Commit Hash 或 Release Tag。

    uses: linuxdeepin/dtk/.github/workflows/synchronize-to-dtk6.yml@v1.0.0 # 或具体的 commit hash
  2. 严格的权限控制 (如果恢复文件)

    • 不要轻易使用 secrets: inherit,除非绝对必要。如果只需要写入代码权限,显式设置 permissions 并限制范围。
    • 确保被调用的下游工作流 (synchronize-to-dtk6.yml) 在处理 source_ref 时,不会直接执行未受信任的代码。下游工作流应该只读取文件内容(如 diff),而不是运行脚本。
  3. 添加审查门槛
    对于使用 pull_request_target 的工作流,通常建议添加 if 条件,确保只有经过特定人员审查或来自特定仓库的 PR 才能触发。

    on:
      pull_request_target:
        types: [labeled]
    jobs:
      ...
        if: github.event.label.name == 'safe to test' # 示例:只有打上特定标签才运行
  4. 确认下游安全性
    必须审计 linuxdeepin/dtk 仓库中的 synchronize-to-dtk6.yml 文件,确保它能够安全处理不受信任的输入(即 PR 的代码),防止命令注入等攻击。

总结

该文件已被删除,这是一个积极的安全改进。原文件虽然语法正确,但在 pull_request_target 事件下结合 secrets: inherit 和动态源引用,构成了较高的安全风险。如果未来需要重新实现同步功能,务必遵循上述安全建议,特别是要固定引用版本并严格限制权限。

@zccrs
Copy link
Member

zccrs commented Jan 20, 2026

同步到gitee的这个失败了不影响这个提交,这个改动是github action的变化,本次未同步过去不要紧,直接合入了。

@zccrs zccrs merged commit 974533b into master Jan 20, 2026
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants