fix(security): replace shell command execution with direct exec calls#1099
Merged
mhduiy merged 1 commit intolinuxdeepin:masterfrom May 11, 2026
Merged
fix(security): replace shell command execution with direct exec calls#1099mhduiy merged 1 commit intolinuxdeepin:masterfrom
mhduiy merged 1 commit intolinuxdeepin:masterfrom
Conversation
1. Remove doAction() helper in inputdevices1/utils.go and
bin/user-config/config_datas.go that passed commands through /bin/sh
2. Replace all exec.Command("/bin/sh", "-c", cmd) calls with
exec.Command(prog, args...) using proper argument lists
3. Fix command injection in checkProRunning() by validating serverName
with regex and using pgrep instead of shell piped ps|awk
4. Replace shell echo redirect with os.WriteFile in
setSupportAcpiDeviceEnable()
5. Convert lsblk invocation to use argument list instead of shell
Log: Eliminate command injection vectors by replacing shell command execution with direct exec.Command calls across multiple modules
fix(security): 替换 shell 命令执行为直接 exec 调用
1. 移除 inputdevices1/utils.go 和 bin/user-config/config_datas.go 中
通过 /bin/sh 传递命令的 doAction() 辅助函数
2. 将所有 exec.Command("/bin/sh", "-c", cmd) 调用替换为使用参数列表的
exec.Command(prog, args...)
3. 修复 checkProRunning() 中的命令注入漏洞,使用正则验证 serverName
并用 pgrep 替代 shell 管道 ps|awk
4. 将 setSupportAcpiDeviceEnable() 中的 shell echo 重定向替换为
os.WriteFile
5. 将 lsblk 调用改为使用参数列表而非 shell 执行
Log: 通过在多个模块中将 shell 命令执行替换为直接 exec.Command 调用,消除命令注入风险
PMS: TASK-389293
deepin pr auto review这份代码 diff 主要涉及对多个 Go 源文件的修改,核心改动在于移除了通过 以下是对语法逻辑、代码质量、代码性能和代码安全方面的详细审查意见: 1. 代码安全 - 显著提升审查意见: 这是本次改动最大的亮点,极大地提高了代码的安全性。
2. 代码质量 - 改进审查意见: 代码更加符合 Go 语言的惯用法,可读性和可维护性增强。
3. 代码性能 - 优化审查意见: 减少了系统资源消耗。
4. 语法逻辑 - 正确审查意见: 语法修改正确,逻辑保持一致。
5. 具体改进建议尽管整体改进很大,但仍有极少数细节可以进一步优化:
总结这是一次非常高质量的代码重构。主要目标是提升安全性(消除命令注入),同时顺带提升了性能和代码质量。改动符合 Go 语言的最佳实践,建议合并。 |
robertkill
approved these changes
May 9, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, robertkill The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log: Eliminate command injection vectors by replacing shell command execution with direct exec.Command calls across multiple modules
fix(security): 替换 shell 命令执行为直接 exec 调用
Log: 通过在多个模块中将 shell 命令执行替换为直接 exec.Command 调用,消除命令注入风险
PMS: TASK-389293