已合并
fix command injection vulnerability #516
starchen_创建于 5 天前
fix command injection vulnerability #516
已合并
starchen_创建于 5 天前
starchen_成员
5 天前

描述

修复asys profiling/asys analyze/asys collect功能的shell命令注入风险

关联的Issue

关联Issue #186
关联Issue #187
关联Issue #188

测试

通过UT/ST/RDV测试

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 starchen_ 的贡献)
Sstarchen_成员
5 天前 创建了 pull request,commit 8d4e01e2
Sstarchen_成员
5 天前 关联了issue:【oam-tools】采集流程通过 cd 拼接输出目录执行命令
atomgit-bot
atomgit-bot
5 天前 评论:

变更摘要

该 PR 为安全修复(关联 Issue #186/#187/#188),针对 asysprofilinganalyzecollect 三个功能在拼接 shell 命令时存在的命令注入风险,通过引入 shlex.quote() 对命令中涉及路径/参数的变量进行转义处理,防止恶意输入被解释为 shell 命令。

主要改动

  • asys_analyze.py 命令注入修复:在 AsysAnalyze 构建 msaicerr 命令时,使用 shlex.quote() 包裹 self.pathoutput_pathasys_collector.output_root_path(转为字符串后)等路径参数,避免路径内容被当作 shell 命令执行。
  • asys_collect.py 命令注入修复:在 _device_file_exportrun_msnpureport 中,将 cd 命令的目标目录 export_dir_path 通过 shlex.quote() 转义,防止导出目录路径被注入恶意命令。
  • asys_profiling.py 命令注入修复:在 AsysProfiling 构建 msprof 命令时,使用 shlex.quote() 包裹 self.output_path,防止输出路径参数被注入 shell 命令。
likedislike
atomgit-bot
atomgit-bot
5 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
5 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
5 天前 评论:

CLA Signature Pass

starchen_, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robot
CANN-robot成员
5 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
For more, you also can visit HICANN.


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/oam-tools zhuliangying, fujun19 (2/2) zhuliangying (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robotCANN-robot成员
5 天前 将newstarzj,chenhao_1209,wulinyu,zhuliangying,yaoguangxiu,fujun19,jinyingqi,yuanjiang_设为评审人
CANN-robotCANN-robot成员
5 天前 将newstarzj,chenhao_1209,wulinyu,zhuliangying,yaoguangxiu,fujun19,jinyingqi,yuanjiang_设为审查人
Sstarchen_成员
5 天前 修改了pull request 的描述
starchen_成员
5 天前 评论:

compile

likedislike
Sstarchen_成员
5 天前 update merge request[project id: 8784133, iid: 516, commit_id: 17105aae7b8f4c99d1fda1afe37436f8ae2e572a] virtual merging success
CANN-robotCANN-robot成员
5 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
5 天前 评论:

流水线任务触发成功
任务链接 [5c81d18793cb4fffafc907bc0585eacd][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
cocheck_codestyle ✅ SUCCESS
precommit ✅ SUCCESS >>>>>
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
UT_Test_asys ✅ SUCCESS >>>>>
UT_Test_msaicerr ✅ SUCCESS >>>>>
UT_Test_msprof ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_A900 ✅ SUCCESS >>>>>

[2026-08-19 17:55:35]    CI执行结束

likedislike
CANN-robotCANN-robot成员
5 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
5 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
5 天前 添加了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
5 天前 评论:
流水线 PR-pipeline_cann_oam-tools#1717 [ commitID:65ab5159 ] 已完成
likedislike
starchen_成员
4 天前 评论:
likedislike
Sstarchen_成员
4 天前 修改了pull request 的描述
starchen_成员
4 天前 评论:
likedislike
fujun19成员
4 天前 评论:

/lgtm

likedislike
zhuliangying成员
4 天前 评论:
likedislike
starchen_成员
3 天前 评论:
likedislike
zhuliangying成员
3 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
3 天前 添加了label:lgtmapproved
CANN-robotCANN-robot成员
3 天前 合入了pull request