已合并
GetRandomChallenge retry after failed #331
GetRandomChallenge retry after failed #331
已合并
zfeixiang创建于 2月10日
zfeixiang
zfeixiang
2月10日

关联的issue:

修改描述(修改功能描述,规格变更说明):

测试用例(附上截图,不涉及不需要说明不涉及原因):

1、TDD:pass

2、XTS:NA

3、手工用例(自验证步骤/预期结果/实际结果):pass

兼容性上库自检:

  • 不涉及API功能发生变化
  • 不涉及改变回调函数或生命周期的触发时机或时序,或删除生命周期和回调函数
  • 不涉及参数的规格发生了变化,例如取值范围缩小等
  • 不涉及对外接口新增权限校验
  • 不涉及接口的使用约束规格收紧
  • 不涉及系统可创建的实例数量收紧
  • 不涉及修改了接口返回的数据
  • 未新增错误抛出,包括新增错误码、对已有的场景从不会抛错误码变成会抛出错误
  • 未修改已有的错误码,对于相同的输入原本抛出A错误码变成了抛出B错误码
  • 接口性能未出现明显劣化

安全编码自检:

  • 裸指针避免通过隐式转换构造为sptr
  • json对象在取值之前必须先判断类型,避免类型不匹配
  • 序列化时必须对传入的数组大小进行校验,避免出现超大数组
  • 避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型
  • 外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验
  • 指针变量、表示资源描述符的变量、bool变量必须赋初值
  • readParcelable获取的对象使用前需要判空
  • 分配和释放内存的函数需要成对出现
  • 申请内存后异常退出前需要及时进行内存释放
  • 内存申请前必须对内存大小进行合法性校验
  • 内存分配后必须判断是否成功
  • 禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰
  • 禁止打印内存地址
  • 整数之间运算时必须严格检查,确保不会出现溢出、反转、除0
  • 禁止对有符号整数进行位操作符运算
  • 循环次数如果收外部数据控制,需要检验其合法性
  • 必须检查安全函数的返回值,并进行正确处理

日志规范自检:

  • 【规则】高频代码的正常流程中禁止打印日志
  • 【规则】在基本不可能发生的点必须要打印日志
  • 【规则】事件记录的日志使用who do what 主谓宾的形式打印
  • 【规则】状态变化的日志打印使用state_name:s1->s2, reason:msg的形式打印
  • 【规则】参数值的日志打印使用name1=value1, name2=value2…的形式打印
likedislike
Pull Request已成功合入, 合并人@openharmony_ci
(感谢 zfeixiang 的贡献)
AsterNighT
AsterNighT
2月10日 评论:

AI检视任务后台执行中,稍候返回结果。

The AI Review task is being executed in the background and will return results shortly.

您可通过评论"list commands"来查询命令列表。
You can leave a "list commands" comment to get commands list.

likedislike
openharmony_ciopenharmony_ci成员
2月10日 添加了label:waiting_on_author
openharmony_ci
openharmony_ci成员
2月10日 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ci成员
2月10日 添加了label:dco检查成功
AsterNighT
AsterNighT
2月10日 评论:

⚠️ 🤖 AI 代码检视报告 ⚠️

总体评估: NEEDS_ATTENTION

问题统计:

  • 总问题数: 3
  • 严重问题: 0
  • 高危问题: 1

摘要:
本次PR为RAND_bytes增加了重试逻辑并改进了错误处理。但是,代码中使用了非固定位宽整型,并且引入了阻塞式睡眠,如果在共享线程(如IPC线程)中调用可能会影响性能。

📊 详细报告
查看完整的审查详情,包括具体的问题描述、建议和代码位置:
🔗 查看详细报告


此评论由 OpenHarmony Insight 代码审查系统自动生成

likedislike
AsterNighT
AsterNighT2月10日进行代码检视2
utils/src/cert_utils.cpp
已过期
@@ -188,3 +204,4 @@
188204}
189205 
190206bool CheckChallengeSize(uint32_t size)
AsterNighT
AsterNighT2月10日评论:

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟠 使用了非固定位宽整型变量

位置: L189-L191 | 严重程度: High

❓ 问题描述

代码中使用了 int 类型定义循环变量 i 和延时变量 delayMs。根据OpenHarmony编码规范,应使用固定位宽类型(如 int32_t)以确保跨平台一致性和避免潜在的溢出或截断问题。

💡 修复建议

修改建议:将 int 替换为 int32_t

189: + const int32_t MAX_RETRIES = 4;
190: + int32_t delayMs = 50; // 50ms
191: + for (int32_t i = 1; i <= MAX_RETRIES; i++) {


likedislike
System
系统消息系统
2月11日 评论:
likedislike
AsterNighT
AsterNighT2月10日进行代码检视1
utils/src/cert_utils.cpp
@@ -341,4 +358,4 @@
341358 }
342359 uint32_t certsCount = *reinterpret_cast<uint32_t *>(rawPtr);
343360 rawPtr += sizeof(uint32_t);
344361 if (certsCount == 0) {
AsterNighT
AsterNighT2月10日评论:

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟡 工具函数中存在阻塞式睡眠

位置: L196 | 严重程度: Medium

❓ 问题描述

GetRandomChallenge 函数中使用了 std::this_thread::sleep_for。如果该函数被IPC线程或主线程调用,最大350ms(50+100+200)的阻塞会导致线程挂起,可能影响系统响应速度或导致IPC调用超时。

💡 修复建议

修改建议:确认该函数仅在独立工作线程中调用。若可能运行在关键线程上,建议将重试逻辑改为异步执行或移除睡眠。

196: + // 确保不在IPC线程调用,否则需改为异步处理
197: + std::this_thread::sleep_for(std::chrono::milliseconds(delayMs));


likedislike
AsterNighT
AsterNighT2月10日进行代码检视1
utils/src/cert_utils.cpp
@@ -188,3 +204,4 @@
188204}
189205 
190206bool CheckChallengeSize(uint32_t size)
AsterNighT
AsterNighT2月10日评论:

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟢 std::make_unique 后的空指针检查无效

位置: L184-L186 | 严重程度: Low

❓ 问题描述

标准C++中 std::make_unique 在内存不足时会抛出 std::bad_alloc 异常,而不会返回 nullptr。因此 if (challenge == nullptr) 检查是无效代码(除非使用了特殊的no-throw分配器)。虽然在某些禁用异常的环境下可能保留,但通常建议移除或使用try-catch。

💡 修复建议

修改建议:若启用异常,建议移除该检查;若禁用异常,请确认分配器行为。此处保留检查可能掩盖逻辑问题。

184: if (challenge == nullptr) {
185: + LOG_ERROR("Failed to allocate ByteBuffer for challenge");
186: + return nullptr;
187: }


likedislike
zfeixiangzfeixiang
2月10日 关联了issue:[Bug]: RAND_bytes 失败未处理
zfeixiangzfeixiang
2月10日 强制推送  1 个提交:92178993-GetRandomChallenge retry after failed
openharmony_ci
openharmony_ci成员
2月10日 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
zfeixiangzfeixiang
2月10日 强制推送  1 个提交:2efa69ae-GetRandomChallenge retry after failed
openharmony_ci
openharmony_ci成员
2月10日 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
ren_ze_hua
ren_ze_hua成员2月11日进行代码检视2
utils/include/cs_hisysevent.h
已过期
@@ -38,3 +43,4 @@
3843inline void ReportInvalidCaller(const std::string &interfaceType, uint32_t tokenId)
3944{
4045 HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::CODE_SIGN, "CS_SA_INVALID_CALLER",
ren_ze_hua
ren_ze_hua2月11日评论:

按已有大数据,不同错误码上报

likedislike
System
系统消息系统
2月11日 评论:
likedislike
zfeixiangzfeixiang
2月11日 强制推送  1 个提交:31e9e831-GetRandomChallenge retry after failed
openharmony_ci
openharmony_ci成员
2月11日 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
zfeixiang
zfeixiang
2月11日 评论:

start build

likedislike
openharmony_ci
openharmony_ci成员
2月11日 评论:

首次触发
门禁构建开始,包含静态检查、代码编译和测试【dayu200-codearts编译, dayu200编译, dayu200测试, dayu200_tdd编译, part_compile测试, part_compile编译, master_inner_build编译】,预计在60分钟内完成,门禁结果会同步发送到注册邮箱。您可以通过如下链接跟踪门禁进展:http://dcp.openharmony.cn/workbench/cicd/detail/698bfa0964650f998bff46e5/runlist

likedislike
openharmony_ciopenharmony_ci成员
2月11日 添加了label:静态检查失败
openharmony_ci
openharmony_ci成员
2月11日 评论:

代码门禁未通过
您可以通过如下链接查看门禁报告:http://dcp.openharmony.cn/workbench/cicd/detail/698bfa0964650f998bff46e5/runlist

静态检查:

# check type result report
1 codeCheck noPass >>>

编译测试:
# Device build result package
1 dayu200 pending NA
2 dayu200_tdd pending NA
3 part_compile pending NA
4 master_inner_build pending NA
5 dayu200-codearts pending NA

likedislike
zfeixiangzfeixiang
2月11日 强制推送  1 个提交:45faceee-GetRandomChallenge retry after failed
openharmony_ciopenharmony_ci成员
2月11日 删除了label:静态检查失败
openharmony_ci
openharmony_ci成员
2月11日 评论:

代码有更新,重置PR验证状态

likedislike
openharmony_ci
openharmony_ci成员
2月11日 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
zfeixiang
zfeixiang
2月12日 评论:

start build

likedislike
openharmony_ci
openharmony_ci成员
2月12日 评论:

本地或库上代码有更新,全量重新构建,重置所有关联PR的验证状态
门禁构建开始,包含静态检查、代码编译和测试【dayu200_tdd编译, dayu200测试, master_inner_build编译, part_compile测试, dayu200编译, part_compile编译, dayu200-codearts编译】,预计在60分钟内完成,门禁结果会同步发送到注册邮箱。您可以通过如下链接跟踪门禁进展:http://dcp.openharmony.cn/workbench/cicd/detail/698db43164650f998b337450/runlist

likedislike
zfeixiangzfeixiang
2月12日 修改了pull request 的描述
openharmony_ciopenharmony_ci成员
2月12日 添加了label:编译成功
openharmony_ciopenharmony_ci成员
2月12日 添加了label:静态检查成功
openharmony_ciopenharmony_ci成员
2月12日 添加了label:冒烟测试成功
openharmony_ciopenharmony_ci成员
2月12日 通过测试
openharmony_ci
openharmony_ci成员
2月12日 评论:

代码门禁通过
您可以通过如下链接查看门禁报告:http://dcp.openharmony.cn/workbench/cicd/detail/698db43164650f998b337450/runlist

静态检查:

# check type result report
1 codeCheck pass >>>

编译测试:
# Device build result test result package
1 dayu200 success success >>>
2 dayu200_tdd success NA >>>
3 part_compile success success(IGNORE) >>>
4 master_inner_build success(IGNORE) NA >>>
5 dayu200-codearts failed(IGNORE)(skip build) NA >>>

likedislike
openharmony_ciopenharmony_ci成员
2月12日 删除了label:waiting_on_author
openharmony_ciopenharmony_ci成员
2月12日 添加了label:waiting_for_review
openharmony_ci
openharmony_ci成员
2月12日 评论:

您好,Committer @JerryH1011 @hehehe-li @LeonChan525 @zhu-sheng-le ,请分配检视人员检视该PR,可以通过命令"assign [@someone_id]"分配检视人员,也可以直接评论"assign"分配给自己进行检视。


Hello, Committer @JerryH1011 @hehehe-li @LeonChan525 @zhu-sheng-le . Please assign someone to review the PR. You can assign a reviewer by using the command "assign [@someone_id]", or you can comment "assign" to review the PR by yourself.

likedislike
JerryH1011JerryH1011成员
2月12日 通过审查
openharmony_ciopenharmony_ci成员
2月12日 关闭了关联的issue
openharmony_ciopenharmony_ci成员
2月12日 合入了pull request,合并节点 SHA:fe9239fee98228f2e03035160cb1147e0def4493
openharmony_ciopenharmony_ci成员
2月12日 删除了label:waiting_for_review
openharmony_ciopenharmony_ci成员
2月12日 添加了label:merged