Skip to content

fix: fix safe build with debian/rules.#368

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-safeBuild
Jul 3, 2025
Merged

fix: fix safe build with debian/rules.#368
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-safeBuild

Conversation

@wjyrich
Copy link
Copy Markdown
Contributor

@wjyrich wjyrich commented Jul 3, 2025

as title.

Logs:

Summary by Sourcery

Move security hardening flags from CMake configuration into Debian packaging rules to ensure a safe build environment under Debian.

Enhancements:

  • Remove explicit -fstack-protector-all and linker security flags from CMakeLists.txt

Build:

  • Add security hardening flags in debian/rules for safe builds

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @wjyrich - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 3, 2025

Reviewer's Guide

This PR refactors the build configuration by removing hardcoded security compiler and linker flags from CMakeLists.txt and centralizing them in the Debian packaging rules (debian/rules) to ensure consistent safe-build behavior during package builds.

File-Level Changes

Change Details Files
Removed manual security compiler and linker flags from CMake build file
  • Deleted -fstack-protector-all from CMAKE_CXX_FLAGS
  • Deleted -fstack-protector-all from CMAKE_C_FLAGS
  • Deleted -z relro, -z now, -z noexecstack, -pie from CMAKE_EXE_LINKER_FLAGS
CMakeLists.txt
Moved hardening flags into Debian packaging script
  • Added stack-protector and RELRO/NOW/NoExecStack/PIE flags in debian/rules
  • Ensured safe-build options are applied at package build time rather than in source CMake
debian/rules

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

代码审查意见:

CMakeLists.txt 文件修改

  • 移除安全编译参数:移除了 CMAKE_CXX_FLAGSCMAKE_C_FLAGS 中添加的 -fstack-protector-all 参数。这可能会降低程序的安全性,建议确认是否有必要移除这些参数,或者考虑使用其他方式来增强安全性。

debian/rules 文件修改

  • 增加安全编译选项:在 DEB_BUILD_MAINT_OPTIONS 中增加了 hardening=+all,这是一个好的做法,因为它会启用多种安全增强选项。
  • 增加警告选项:通过 DEB_CFLAGS_MAINT_APPENDDEB_CXXFLAGS_MAINT_APPEND 添加了 -Wall 选项,这有助于发现潜在的问题。
  • 链接器选项:添加了 -Wl,--as-needed-Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-E 选项,这些选项有助于优化二进制文件并增强安全性。

代码质量

  • 注释:建议在移除安全编译参数时添加注释,说明为什么移除这些参数,以及是否有替代的安全措施。

代码性能

  • 链接器选项:添加的链接器选项有助于优化二进制文件的大小和性能,这是一个好的做法。

代码安全性

  • 安全编译参数:移除 -fstack-protector-all 参数可能会降低程序的安全性,建议重新评估是否需要这些参数。

总结

  • 确认移除 -fstack-protector-all 参数的原因,并考虑是否有替代的安全措施。
  • 在移除安全编译参数时添加注释,说明原因。
  • 保持其他安全编译选项和警告选项的添加,以增强代码质量和安全性。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23, wjyrich

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

@wjyrich
Copy link
Copy Markdown
Contributor Author

wjyrich commented Jul 3, 2025

/forcemerge

@deepin-bot
Copy link
Copy Markdown
Contributor

deepin-bot Bot commented Jul 3, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot Bot merged commit 5eb79bc into linuxdeepin:master Jul 3, 2025
15 of 17 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