已合并
[feat] add json validator #5068
sjtulxh创建于 26 天前
[feat] add json validator #5068
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 sjtulxh 的贡献)atomgit-bot
26 天前 评论:
26 天前 评论:
变更摘要
本 PR 主要新增资源清单 JSON 校验器,对 manifest 的基础字段、资源路径、编译选项、Kernel、常量、Object、Command、输出引用及占位符语法进行完整校验,并将资源目录字段由 base_dir 切换为 resource_path,在加载资源前执行校验。同时新增安全相对路径检查与相关单元测试,并优化了 CLI 的帮助输出和异常/失败时的日志提示。
主要改动
- 新增
resource_manifest_validator:新增resource_manifest_validator.h/.cpp,通过ValidateResourceManifest校验 manifest 的schema_version、resource_id、soc_version、kernels等基础字段,以及常量、对象、命令、编译选项、${resource}、${output}等占位符语法与输出引用一致性。 - 资源目录字段切换为
resource_path:collected_manifest_repository.cpp中的ReadBaseDir改为ReadResourcePath,在读取 manifest 时调用ValidateResourceManifest,并以resource_path替代原base_dir解析和加载资源目录。 - 新增安全相对路径检查:
file_utils.h/.cpp新增FileUtils::IsSafeRelativePath,用于拒绝绝对路径、路径穿越、反斜杠、./..组件、重复分隔符及嵌入 NUL 等非法路径格式。 - CLI 行为增强:
asc_compile_exporter.cpp新增IsHelpRequested和RunWithExceptionHandling,支持-h/--help输出用法到标准输出并以 0 退出,编译失败或捕获异常时向用户提示通过 plog 查看详细日志。 - 日志级别与函数签名调整:
file_utils.cpp将多处ASCENDLOGW调整为ASCENDLOGE,并将FileUtils::RemoveAll声明为noexcept,相应调整其错误日志输出方式。 - 补充单元测试:新增
test_resource_manifest_validator.cpp,并扩展test_asc_compile_exporter.cpp、test_asc_compile_exporter_unit.cpp、test_collected_manifest_repository.cpp、test_file_utils.cpp和test_support.h,覆盖校验器、CLI help、异常提示、路径安全及 repository 加载等场景。


不准确?
atomgit-bot
26 天前 评论:
26 天前 评论:
26 天前 添加了label:cann-cla/yes
CANN-robot
26 天前 评论:
26 天前 评论:
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/asc-devkit | ✅ 诸葛洵, XuebinYang (2/2) | ✅ 诸葛洵, XuebinYang (2/1) |
| tools/build | ✅ XuebinYang, 诸葛洵 (2/2) | ✅ XuebinYang (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
sjtulxh, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了154条消息 查看更多
zhugexun_sjtu
25 天前 评论:
25 天前 评论:
/lgtm
/approve


25 天前 添加了label:lgtm
XuebinYang
25 天前 评论:
25 天前 评论:
/approve


25 天前 添加了label:approved
25 天前 合入了pull request
[feat] add resource manifest validation
描述
新增资源清单 JSON 校验器,对 manifest 的基础字段、资源路径、编译选项、Kernel、常量、Object、Command、输出引用及占位符语法进行完整校验。
主要改动:
base_dir切换为resource_path,加载资源前执行 manifest 校验。file_utils.cpp中的ASCENDLOGW调整为ASCENDLOGE。asc_compile_exporter增加-h、--help选项。关联的Issue
无。
测试
asc_compile_exporter生产目标,构建成功。ascendc_ut_asc_compile_exporter单元测试目标,构建成功。resource_manifest_validator.cpp行覆盖率:100%(283/283)。resource_manifest_validator.cpp函数覆盖率:100%(20/20)。git diff --check检查通过。文档更新
无文档更新。
类型标签