Skip to content

fix: add build options for system security baseline#253

Merged
zhaohuiw42 merged 1 commit into
linuxdeepin:masterfrom
zhaohuiw42:master
Nov 5, 2025
Merged

fix: add build options for system security baseline#253
zhaohuiw42 merged 1 commit into
linuxdeepin:masterfrom
zhaohuiw42:master

Conversation

@zhaohuiw42

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

CLA Assistant Lite bot:
提交邮箱中包含我们的合作伙伴,但您似乎并非合作伙伴的成员或对接人,请联系相关对接人将您添加至组织之中,或由其重新发起 Pull Request。
The commit email domain belongs to one of our partners, but it seems you are not yet a member of the current organization, please contact the contact person to add you to the organization or let them submit the Pull Request.

You can retrigger this bot by commenting recheck in this Pull Request

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来对这个diff进行详细的代码审查:

  1. 安全编译选项改进:

在 debian/rules 中:

  • -D_FORTIFY_SOURCE=1 升级到 -D_FORTIFY_SOURCE=2,这提供了更强的缓冲区溢出保护
  • 添加了 -O2 优化级别,这有助于编译器进行更多的安全检查
  • -z lazy 改为 -z now,启用立即绑定,可以防止某些类型的攻击
  • 新增 -ftrapv 选项,可以在整数溢出时产生陷阱

这些改动显著提升了二进制文件的安全性,是很好的改进。

  1. Go构建选项增强:

在 debian/rules 中:

  • 扩展了 -extldflags 参数,添加了更多安全相关的链接器选项:
    • -Wl,-z,noexecstack:防止栈执行
    • -Wl,-z,relro:启用重定位只读保护
    • -Wl,-z,now:立即解析所有符号
  • 新增了 GOBUILD_CGO_FLAGS 环境变量,为CGO编译设置了安全选项
  1. Makefile构建流程改进:

在 makefile 中:

  • 所有 Go 构建命令都添加了 ${GOBUILD_CGO_FLAGS},确保 CGO 编译时使用相同的安全选项
  • 保持了原有的错误处理机制

改进建议:

  1. 考虑添加更多的编译器警告选项,比如:

    -Wformat -Wformat-security -Werror=format-security
    

    这可以帮助发现潜在的安全问题。

  2. 可以考虑添加 -fstack-clash-protection 选项(如果编译器支持),这可以提供额外的栈保护。

  3. 建议在 makefile 中添加对构建选项的验证,确保所有必要的安全选项都已正确设置。

  4. 考虑添加 -D_GLIBCXX_ASSERTIONS 选项(如果使用C++),这可以启用额外的安全检查。

  5. 对于 Go 代码,建议添加 -buildmode=pie 选项,确保生成位置无关的可执行文件。

总体来说,这些改动显著提升了构建过程的安全性,是一个很好的改进。建议可以考虑上述补充建议来进一步增强安全性。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: electricface, zhaohuiw42

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

@zhaohuiw42 zhaohuiw42 merged commit b65f284 into linuxdeepin:master Nov 5, 2025
14 of 16 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