refactor(wacom): replace shell command with direct exec call#189
Open
mhduiy wants to merge 1 commit intolinuxdeepin:masterfrom
Open
refactor(wacom): replace shell command with direct exec call#189mhduiy wants to merge 1 commit intolinuxdeepin:masterfrom
mhduiy wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy 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 |
1. Replace `doAction(string)` with `doAction(args ...string)` to avoid shell injection risk
2. Refactor all Wacom set methods to pass arguments individually instead of using fmt.Sprintf to build shell commands
3. Remove `exec.Command("/bin/sh", "-c", cmd)` in favor of `exec.Command(cmdXSetWacom, args...)` for safer command execution
4. Sort imports and add strconv/errors usage for integer/string conversions
Log: Replace unsafe shell command construction with direct exec.Command calls in wacom module
refactor(wacom): 用直接 exec 调用替换 shell 命令拼接
1. 将 `doAction(string)` 重构为 `doAction(args ...string)` 以消除 shell 注入风险
2. 重构所有 Wacom set 方法,改为逐个传参而非使用 fmt.Sprintf 拼接 shell 命令
3. 移除 `exec.Command("/bin/sh", "-c", cmd)` 改用 `exec.Command(cmdXSetWacom, args...)` 执行命令
4. 调整 import 排序,添加 strconv/errors 用于整数/字符串转换
Log: 将 wacom 模块中不安全的 shell 命令拼接替换为直接 exec.Command 调用
pms: TASK-389293
deepin pr auto review这份代码变更主要是对 Wacom 设备控制命令执行方式的重大重构,从使用 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与建议这是一个非常优秀的重构,主要提升了代码的安全性和性能,同时也略微提高了可读性。 建议:
结论:该变更完全符合安全编码规范,建议合并。 |
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.
doAction(string)withdoAction(args ...string)to avoid shell injection riskexec.Command("/bin/sh", "-c", cmd)in favor ofexec.Command(cmdXSetWacom, args...)for safer command executionLog: Replace unsafe shell command construction with direct exec.Command calls in wacom module
refactor(wacom): 用直接 exec 调用替换 shell 命令拼接
doAction(string)重构为doAction(args ...string)以消除 shell 注入风险exec.Command("/bin/sh", "-c", cmd)改用exec.Command(cmdXSetWacom, args...)执行命令Log: 将 wacom 模块中不安全的 shell 命令拼接替换为直接 exec.Command 调用
Change-Id: Ia4978b3f2920dd8f005dc6f1cff45470d956bb65